aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-08-16 19:10:48 +0000
committerDave Love2000-08-16 19:10:48 +0000
commit329d7667c81baa9a718d102d892df9e96d4df908 (patch)
tree8332423fc606fd1e42971da315284cf8f52f4961
parente8951be0ff59590180b045d0bd37fe8d1c2451f7 (diff)
downloademacs-329d7667c81baa9a718d102d892df9e96d4df908.tar.gz
emacs-329d7667c81baa9a718d102d892df9e96d4df908.zip
(fortune) <defgroup>: Add :version.
(fortune-append): Fix error message. (fortune-from-region): Doc fix.
-rw-r--r--lisp/play/fortune.el43
1 files changed, 22 insertions, 21 deletions
diff --git a/lisp/play/fortune.el b/lisp/play/fortune.el
index 1166c5f6592..c3e94eaaa37 100644
--- a/lisp/play/fortune.el
+++ b/lisp/play/fortune.el
@@ -46,7 +46,7 @@
46;; it into message-mode: 46;; it into message-mode:
47;; (add-hook 'message-setup-hook 47;; (add-hook 'message-setup-hook
48;; '(lambda () 48;; '(lambda ()
49;; (fortune-to-signature))) 49;; (fortune-to-signature)))
50;; This time no fortune-file is specified, so fortune-to-signature would use 50;; This time no fortune-file is specified, so fortune-to-signature would use
51;; the default-file as specified by fortune-file. 51;; the default-file as specified by fortune-file.
52 52
@@ -54,7 +54,7 @@
54;;(add-hook 'gnus-article-mode-hook 54;;(add-hook 'gnus-article-mode-hook
55;; '(lambda () 55;; '(lambda ()
56;; (define-key gnus-article-mode-map "i" 'fortune-from-region))) 56;; (define-key gnus-article-mode-map "i" 'fortune-from-region)))
57;; which allows marking a region and then pressing "i" so that the marked 57;; which allows marking a region and then pressing "i" so that the marked
58;; region will be automatically added to my favourite fortune-file. 58;; region will be automatically added to my favourite fortune-file.
59 59
60;;; Code: 60;;; Code:
@@ -63,21 +63,22 @@
63;;; Customizable Settings 63;;; Customizable Settings
64(defgroup fortune nil 64(defgroup fortune nil
65 "Settings for fortune." 65 "Settings for fortune."
66 :version "21.1"
66 :group 'games) 67 :group 'games)
67(defgroup fortune-signature nil 68(defgroup fortune-signature nil
68 "Settings for use of fortune for signatures." 69 "Settings for use of fortune for signatures."
69 :group 'fortune 70 :group 'fortune
70 :group 'mail) 71 :group 'mail)
71 72
72(defcustom fortune-dir "~/docs/ascii/misc/fortunes/" 73(defcustom fortune-dir "~/docs/ascii/misc/fortunes/"
73 "*The directory to look in for local fortune cookies files." 74 "*The directory to look in for local fortune cookies files."
74 :group 'fortune) 75 :group 'fortune)
75(defcustom fortune-file 76(defcustom fortune-file
76 (expand-file-name "usenet" fortune-dir) 77 (expand-file-name "usenet" fortune-dir)
77 "*The file in which local fortune cookies will be stored." 78 "*The file in which local fortune cookies will be stored."
78 :group 'fortune) 79 :group 'fortune)
79(defcustom fortune-database-extension ".dat" 80(defcustom fortune-database-extension ".dat"
80 "The extension of the corresponding fortune database. 81 "The extension of the corresponding fortune database.
81Normally you won't have a reason to change it." 82Normally you won't have a reason to change it."
82 :group 'fortune) 83 :group 'fortune)
83(defcustom fortune-program "fortune" 84(defcustom fortune-program "fortune"
@@ -123,19 +124,19 @@ No need to add an `in'."
123 124
124;; not customizable settings 125;; not customizable settings
125(defvar fortune-buffer-name "*fortune*") 126(defvar fortune-buffer-name "*fortune*")
126(defconst fortune-end-sep "\n%\n") 127(defconst fortune-end-sep "\n%\n")
127 128
128 129
129;;; ************** 130;;; **************
130;;; Inserting a new fortune 131;;; Inserting a new fortune
131(defun fortune-append (string &optional interactive file) 132(defun fortune-append (string &optional interactive file)
132 "Appends STRING to the fortune FILE. 133 "Appends STRING to the fortune FILE.
133 134
134If INTERACTIVE is non-nil, don't compile the fortune file afterwards." 135If INTERACTIVE is non-nil, don't compile the fortune file afterwards."
135 (setq file (expand-file-name 136 (setq file (expand-file-name
136 (substitute-in-file-name (or file fortune-file)))) 137 (substitute-in-file-name (or file fortune-file))))
137 (if (file-directory-p file) 138 (if (file-directory-p file)
138 (error "Cannot append fortune to directory %s." file)) 139 (error "Cannot append fortune to directory %s" file))
139 (if interactive ; switch to file and return buffer 140 (if interactive ; switch to file and return buffer
140 (find-file-other-frame file) 141 (find-file-other-frame file)
141 (find-file-noselect file)) 142 (find-file-noselect file))
@@ -154,7 +155,7 @@ If INTERACTIVE is non-nil, don't compile the fortune file afterwards."
154 155
155(defun fortune-ask-file () 156(defun fortune-ask-file ()
156 "Asks the user for a file-name." 157 "Asks the user for a file-name."
157 (expand-file-name 158 (expand-file-name
158 (read-file-name 159 (read-file-name
159 "Fortune file to use: " 160 "Fortune file to use: "
160 fortune-dir nil nil ""))) 161 fortune-dir nil nil "")))
@@ -172,11 +173,11 @@ read the file name to use. Otherwise use the value of `fortune-file'."
172 173
173;;; ###autoload 174;;; ###autoload
174(defun fortune-from-region (beg end file) 175(defun fortune-from-region (beg end file)
175 "Appends the current region to a local fortune-like data file. 176 "Append the current region to a local fortune-like data file.
176 177
177Interactively, if called with a prefix argument, 178Interactively, if called with a prefix argument,
178read the file name to use. Otherwise use the value of `fortune-file'." 179read the file name to use. Otherwise use the value of `fortune-file'."
179 (interactive 180 (interactive
180 (list (region-beginning) (region-end) 181 (list (region-beginning) (region-end)
181 (if current-prefix-arg (fortune-ask-file)))) 182 (if current-prefix-arg (fortune-ask-file))))
182 (let ((string (buffer-substring beg end)) 183 (let ((string (buffer-substring beg end))
@@ -184,12 +185,12 @@ read the file name to use. Otherwise use the value of `fortune-file'."
184 ;; try to determine author ... 185 ;; try to determine author ...
185 (save-excursion 186 (save-excursion
186 (goto-char (point-min)) 187 (goto-char (point-min))
187 (setq help-point 188 (setq help-point
188 (search-forward-regexp 189 (search-forward-regexp
189 "^From: \\(.*\\)$" 190 "^From: \\(.*\\)$"
190 (point-max) t)) 191 (point-max) t))
191 (if help-point 192 (if help-point
192 (setq author (buffer-substring (match-beginning 1) help-point)) 193 (setq author (buffer-substring (match-beginning 1) help-point))
193 (setq author "An unknown author"))) 194 (setq author "An unknown author")))
194 ;; ... and newsgroup 195 ;; ... and newsgroup
195 (save-excursion 196 (save-excursion
@@ -198,7 +199,7 @@ read the file name to use. Otherwise use the value of `fortune-file'."
198 (search-forward-regexp 199 (search-forward-regexp
199 "^Newsgroups: \\(.*\\)$" 200 "^Newsgroups: \\(.*\\)$"
200 (point-max) t)) 201 (point-max) t))
201 (if help-point 202 (if help-point
202 (setq newsgroup (buffer-substring (match-beginning 1) help-point)) 203 (setq newsgroup (buffer-substring (match-beginning 1) help-point))
203 (setq newsgroup (if (or (eql major-mode 'gnus-article-mode) 204 (setq newsgroup (if (or (eql major-mode 'gnus-article-mode)
204 (eql major-mode 'vm-mode) 205 (eql major-mode 'vm-mode)
@@ -222,20 +223,20 @@ read the file name to use. Otherwise use the value of `fortune-file'."
222 223
223If called with a prefix asks for the FILE to compile, otherwise uses 224If called with a prefix asks for the FILE to compile, otherwise uses
224the value of `fortune-file'. This currently cannot handle directories." 225the value of `fortune-file'. This currently cannot handle directories."
225 (interactive 226 (interactive
226 (list 227 (list
227 (if current-prefix-arg 228 (if current-prefix-arg
228 (fortune-ask-file) 229 (fortune-ask-file)
229 fortune-file))) 230 fortune-file)))
230 (let* ((fortune-file (expand-file-name (substitute-in-file-name file))) 231 (let* ((fortune-file (expand-file-name (substitute-in-file-name file)))
231 (fortune-dat (expand-file-name 232 (fortune-dat (expand-file-name
232 (substitute-in-file-name 233 (substitute-in-file-name
233 (concat fortune-file fortune-database-extension))))) 234 (concat fortune-file fortune-database-extension)))))
234 (cond ((file-exists-p fortune-file) 235 (cond ((file-exists-p fortune-file)
235 (if (file-exists-p fortune-dat) 236 (if (file-exists-p fortune-dat)
236 (cond ((file-newer-than-file-p fortune-file fortune-dat) 237 (cond ((file-newer-than-file-p fortune-file fortune-dat)
237 (message "Compiling new fortune database %s" fortune-dat) 238 (message "Compiling new fortune database %s" fortune-dat)
238 (shell-command 239 (shell-command
239 (concat fortune-strfile fortune-strfile-options 240 (concat fortune-strfile fortune-strfile-options
240 " " fortune-file fortune-quiet-strfile-options)))))) 241 " " fortune-file fortune-quiet-strfile-options))))))
241 (t (error "Can't compile fortune file %s" fortune-file))))) 242 (t (error "Can't compile fortune file %s" fortune-file)))))
@@ -251,7 +252,7 @@ If called with a prefix asks for the FILE to choose the fortune from,
251otherwise uses the value of `fortune-file'. If you want to have fortune 252otherwise uses the value of `fortune-file'. If you want to have fortune
252choose from a set of files in a directory, call interactively with prefix 253choose from a set of files in a directory, call interactively with prefix
253and choose the directory as the fortune-file." 254and choose the directory as the fortune-file."
254 (interactive 255 (interactive
255 (list 256 (list
256 (if current-prefix-arg 257 (if current-prefix-arg
257 (fortune-ask-file) 258 (fortune-ask-file)
@@ -300,7 +301,7 @@ If called with a prefix asks for the FILE to choose the fortune from,
300otherwise uses the value of `fortune-file'. If you want to have fortune 301otherwise uses the value of `fortune-file'. If you want to have fortune
301choose from a set of files in a directory, call interactively with prefix 302choose from a set of files in a directory, call interactively with prefix
302and choose the directory as the fortune-file." 303and choose the directory as the fortune-file."
303 (interactive 304 (interactive
304 (list 305 (list
305 (if current-prefix-arg 306 (if current-prefix-arg
306 (fortune-ask-file) 307 (fortune-ask-file)