• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/play/

Lines Matching +defs:add +defs:name +defs:to +defs:file

1 ;;; fortune.el --- use fortune to create signatures
9 ;; This file is part of GNU Emacs.
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; This utility allows you to automatically cut regions to a fortune
28 ;; file. In case that the region stems from an article buffer (mail or
29 ;; news), it will try to automatically determine the author of the
30 ;; fortune. It will also allow you to compile your fortune-database
31 ;; as well as providing a function to extract a fortune for use as your
34 ;; Use prefix arguments to specify different fortune databases.
38 ;; Please check the customize settings -- you will at least have to
39 ;; modify the values of `fortune-dir' and `fortune-file'.
42 ;;(message "Making new signature: %s" (fortune-to-signature "~/fortunes/"))
44 ;; Note that the call to fortune-to-signature specifies a directory in which
47 ;; If you like to get a new signature for every message, you can also hook
49 ;; (add-hook 'message-setup-hook 'fortune-to-signature)
50 ;; This time no fortune-file is specified, so fortune-to-signature would use
51 ;; the default-file as specified by fortune-file.
54 ;;(add-hook 'gnus-article-mode-hook
58 ;; region will be automatically added to my favourite fortune-file.
75 "*The directory to look in for local fortune cookies files."
78 (defcustom fortune-file
79 (expand-file-name "usenet" fortune-dir)
80 "*The file in which local fortune cookies will be stored."
81 :type 'file
85 Normally you won't have a reason to change it."
89 "Program to select a fortune cookie."
93 "Options to pass to the fortune program (a string)."
97 "Program to compute a new fortune database."
101 "Options to pass to the strfile program (a string)."
105 "Text added to the command for running `strfile'.
107 Set this to \"\" if you would like to see the output."
113 If nil, you must invoke `fortune-compile' manually to do that."
117 "Prefix to put before the author name of a fortunate."
125 "String to use to characterize that the fortune comes from an e-mail.
126 No need to add an `in'."
130 "*Some text to insert before the fortune cookie, in a mail signature."
134 "*Some text to insert after the fortune cookie, in a mail signature."
140 (defvar fortune-buffer-name "*fortune*")
146 (defun fortune-append (string &optional interactive file)
147 "Appends STRING to the fortune FILE.
149 If INTERACTIVE is non-nil, don't compile the fortune file afterwards."
150 (setq file (expand-file-name
151 (substitute-in-file-name (or file fortune-file))))
152 (if (file-directory-p file)
153 (error "Cannot append fortune to directory %s" file))
154 (if interactive ; switch to file and return buffer
155 (find-file-other-frame file)
156 (find-file-noselect file))
157 (let ((fortune-buffer (get-file-buffer file)))
168 (fortune-compile file)))))
170 (defun fortune-ask-file ()
171 "Asks the user for a file-name."
172 (expand-file-name
173 (read-file-name
174 "Fortune file to use: "
178 (defun fortune-add-fortune (string file)
179 "Add STRING to a fortune file FILE.
182 read the file name to use. Otherwise use the value of `fortune-file'."
185 (if current-prefix-arg (fortune-ask-file))))
186 (fortune-append string t file))
189 (defun fortune-from-region (beg end file)
190 "Append the current region to a local fortune-like data file.
193 read the file name to use. Otherwise use the value of `fortune-file'."
196 (if current-prefix-arg (fortune-ask-file))))
199 ;; try to determine author ...
224 ;; append entry to end of fortune file, and display result
229 (fortune-append string t file)))
235 (defun fortune-compile (&optional file)
236 "Compile fortune file.
238 If called with a prefix asks for the FILE to compile, otherwise uses
239 the value of `fortune-file'. This currently cannot handle directories."
243 (fortune-ask-file)
244 fortune-file)))
245 (let* ((fortune-file (expand-file-name (substitute-in-file-name file)))
246 (fortune-dat (expand-file-name
247 (substitute-in-file-name
248 (concat fortune-file fortune-database-extension)))))
249 (cond ((file-exists-p fortune-file)
250 (if (file-exists-p fortune-dat)
251 (cond ((file-newer-than-file-p fortune-file fortune-dat)
255 " " fortune-file fortune-quiet-strfile-options))))))
256 (t (error "Can't compile fortune file %s" fortune-file)))))
262 (defun fortune-to-signature (&optional file)
265 If called with a prefix asks for the FILE to choose the fortune from,
266 otherwise uses the value of `fortune-file'. If you want to have fortune
268 and choose the directory as the fortune-file."
272 (fortune-ask-file)
273 fortune-file)))
275 (fortune-in-buffer t file)
276 (set-buffer fortune-buffer-name)
286 (defun fortune-in-buffer (interactive &optional file)
290 when supplied, specifies the file to choose the fortune from."
291 (let ((fortune-buffer (or (get-buffer fortune-buffer-name)
292 (generate-new-buffer fortune-buffer-name)))
293 (fort-file (expand-file-name
294 (substitute-in-file-name
295 (or file fortune-file)))))
302 (fortune-compile fort-file))
305 fortune-program ;; programm to call
307 (concat fortune-program-options fort-file)))))
311 (defun fortune (&optional file)
314 If called with a prefix asks for the FILE to choose the fortune from,
315 otherwise uses the value of `fortune-file'. If you want to have fortune
317 and choose the directory as the fortune-file."
321 (fortune-ask-file)
322 fortune-file)))
323 (fortune-in-buffer t file)
324 (switch-to-buffer (get-buffer fortune-buffer-name))