aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/mail/supercite.el362
1 files changed, 253 insertions, 109 deletions
diff --git a/lisp/mail/supercite.el b/lisp/mail/supercite.el
index 8babd369099..6980f3bf50e 100644
--- a/lisp/mail/supercite.el
+++ b/lisp/mail/supercite.el
@@ -1,11 +1,10 @@
1;;; supercite.el --- minor mode for citing mail and news replies 1;;; supercite.el --- minor mode for citing mail and news replies
2 2
3;; Copyright (C) 1993 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1997 Free Software Foundation, Inc.
4 4
5;; Author: 1993 Barry A. Warsaw, Century Computing, Inc. <bwarsaw@cen.com> 5;; Author: 1993 Barry A. Warsaw, Century Computing, Inc. <bwarsaw@cen.com>
6;; Maintainer: supercite-help@anthem.nlm.nih.gov 6;; Maintainer: supercite-help@anthem.nlm.nih.gov
7;; Created: February 1993 7;; Created: February 1993
8;; Version: 3.1
9;; Last Modified: 1993/09/22 18:58:46 8;; Last Modified: 1993/09/22 18:58:46
10;; Keywords: mail, news 9;; Keywords: mail, news
11 10
@@ -41,66 +40,133 @@
41;; start user configuration variables 40;; start user configuration variables
42;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 41;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
43 42
44(defvar sc-auto-fill-region-p t 43(defgroup supercite nil
45 "*If non-nil, automatically fill each paragraph after it has been cited.") 44 "Supercite package"
46 45 :prefix "sc-"
47(defvar sc-blank-lines-after-headers 1 46 :group 'mail
47 :group 'news)
48
49(defgroup supercite-frames nil
50 "Supercite (regi) frames"
51 :prefix "sc-"
52 :group 'supercite)
53
54(defgroup supercite-attr nil
55 "Supercite attributions"
56 :prefix "sc-"
57 :group 'supercite)
58
59(defgroup supercite-cite nil
60 "Supercite citings"
61 :prefix "sc-"
62 :group 'supercite)
63
64(defgroup supercite-hooks nil
65 "Hooking into supercite"
66 :prefix "sc-"
67 :group 'supercite)
68
69(defcustom sc-auto-fill-region-p t
70 "*If non-nil, automatically fill each paragraph after it has been cited."
71 :type 'boolean
72 :group 'supercite)
73
74(defcustom sc-blank-lines-after-headers 1
48 "*Number of blank lines to leave after mail headers have been nuked. 75 "*Number of blank lines to leave after mail headers have been nuked.
49Set to nil, to use whatever blank lines happen to occur naturally.") 76Set to nil, to use whatever blank lines happen to occur naturally."
77 :type '(choice (const :tag "leave" nil)
78 integer)
79 :group 'supercite)
80
81(defcustom sc-citation-leader " "
82 "*String comprising first part of a citation."
83 :type 'string
84 :group 'supercite-cite)
50 85
51(defvar sc-citation-leader " " 86(defcustom sc-citation-delimiter ">"
52 "*String comprising first part of a citation.")
53(defvar sc-citation-delimiter ">"
54 "*String comprising third part of a citation. 87 "*String comprising third part of a citation.
55This string is used in both nested and non-nested citations.") 88This string is used in both nested and non-nested citations."
56(defvar sc-citation-separator " " 89 :type 'string
57 "*String comprising fourth and last part of a citation.") 90 :group 'supercite-cite)
91
92(defcustom sc-citation-separator " "
93 "*String comprising fourth and last part of a citation."
94 :type 'string
95 :group 'supercite-cite)
58 96
59(defvar sc-citation-leader-regexp "[ \t]*" 97(defcustom sc-citation-leader-regexp "[ \t]*"
60 "*Regexp describing citation leader for a cited line. 98 "*Regexp describing citation leader for a cited line.
61This should NOT have a leading `^' character.") 99This should NOT have a leading `^' character."
100 :type 'regexp
101 :group 'supercite-cite)
62 102
63;; Nemacs and Mule users note: please see the texinfo manual for 103;; Nemacs and Mule users note: please see the texinfo manual for
64;; suggestions on setting these variables. 104;; suggestions on setting these variables.
65(defvar sc-citation-root-regexp "[-._a-zA-Z0-9]*" 105(defcustom sc-citation-root-regexp "[-._a-zA-Z0-9]*"
66 "*Regexp describing variable root part of a citation for a cited line. 106 "*Regexp describing variable root part of a citation for a cited line.
67This should NOT have a leading `^' character. See also 107This should NOT have a leading `^' character. See also
68`sc-citation-nonnested-root-regexp'.") 108`sc-citation-nonnested-root-regexp'."
69(defvar sc-citation-nonnested-root-regexp "[-._a-zA-Z0-9]+" 109 :type 'regexp
110 :group 'supercite-cite)
111
112(defcustom sc-citation-nonnested-root-regexp "[-._a-zA-Z0-9]+"
70 "*Regexp describing the variable root part of a nested citation. 113 "*Regexp describing the variable root part of a nested citation.
71This should NOT have a leading `^' character. This variable is 114This should NOT have a leading `^' character. This variable is
72related to `sc-citation-root-regexp' but whereas that variable 115related to `sc-citation-root-regexp' but whereas that variable
73describes both nested and non-nested citation roots, this variable 116describes both nested and non-nested citation roots, this variable
74describes only nested citation roots.") 117describes only nested citation roots."
75(defvar sc-citation-delimiter-regexp "[>]+" 118 :type 'regexp
119 :group 'supercite-cite)
120
121(defcustom sc-citation-delimiter-regexp "[>]+"
76 "*Regexp describing citation delimiter for a cited line. 122 "*Regexp describing citation delimiter for a cited line.
77This should NOT have a leading `^' character.") 123This should NOT have a leading `^' character."
78(defvar sc-citation-separator-regexp "[ \t]*" 124 :type 'regexp
125 :group 'supercite-cite)
126
127(defcustom sc-citation-separator-regexp "[ \t]*"
79 "*Regexp describing citation separator for a cited line. 128 "*Regexp describing citation separator for a cited line.
80This should NOT have a leading `^' character.") 129This should NOT have a leading `^' character."
130 :type 'regexp
131 :group 'supercite-cite)
81 132
82(defvar sc-cite-blank-lines-p nil 133(defcustom sc-cite-blank-lines-p nil
83 "*If non-nil, put a citation on blank lines.") 134 "*If non-nil, put a citation on blank lines."
135 :type 'boolean
136 :group 'supercite-cite)
84 137
85(defvar sc-cite-frame-alist '() 138(defcustom sc-cite-frame-alist '()
86 "*Alist for frame selection during citing. 139 "*Alist for frame selection during citing.
87Each element of this list has the following form: 140Each element of this list has the following form:
88
89 (INFOKEY ((REGEXP . FRAME) 141 (INFOKEY ((REGEXP . FRAME)
90 (REGEXP . FRAME) 142 (REGEXP . FRAME)
91 (...))) 143 (...)))
92 144
93Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular 145Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular
94expression to match against the INFOKEY's value. FRAME is a citation 146expression to match against the INFOKEY's value. FRAME is a citation
95frame, or a variable containing a citation frame.") 147frame, or a variable containing a citation frame."
96(defvar sc-uncite-frame-alist '() 148 :type '(repeat (list symbol (repeat (cons regexp
149 (choice (repeat (repeat sexp))
150 symbol)))))
151 :group 'supercite-frames)
152
153(defcustom sc-uncite-frame-alist '()
97 "*Alist for frame selection during unciting. 154 "*Alist for frame selection during unciting.
98See the variable `sc-cite-frame-alist' for details.") 155See the variable `sc-cite-frame-alist' for details."
99(defvar sc-recite-frame-alist '() 156 :type '(repeat (list symbol (repeat (cons regexp
157 (choice (repeat (repeat sexp))
158 symbol)))))
159 :group 'supercite-frames)
160
161(defcustom sc-recite-frame-alist '()
100 "*Alist for frame selection during reciting. 162 "*Alist for frame selection during reciting.
101See the variable `sc-cite-frame-alist' for details.") 163See the variable `sc-cite-frame-alist' for details."
164 :type '(repeat (list symbol (repeat (cons regexp
165 (choice (repeat (repeat sexp))
166 symbol)))))
167 :group 'supercite-frames)
102 168
103(defvar sc-default-cite-frame 169(defcustom sc-default-cite-frame
104 '(;; initialize fill state and temporary variables when entering 170 '(;; initialize fill state and temporary variables when entering
105 ;; frame. this makes things run much faster 171 ;; frame. this makes things run much faster
106 (begin (progn 172 (begin (progn
@@ -141,17 +207,21 @@ See the variable `sc-cite-frame-alist' for details.")
141 ;; be sure when we're done that we fill the last cited paragraph. 207 ;; be sure when we're done that we fill the last cited paragraph.
142 (end (sc-fill-if-different "")) 208 (end (sc-fill-if-different ""))
143 ) 209 )
144 "*Default REGI frame for citing a region.") 210 "*Default REGI frame for citing a region."
211 :type '(repeat (repeat sexp))
212 :group 'supercite-frames)
145 213
146(defvar sc-default-uncite-frame 214(defcustom sc-default-uncite-frame
147 '(;; do nothing on a blank line 215 '(;; do nothing on a blank line
148 ("^[ \t]*$" nil) 216 ("^[ \t]*$" nil)
149 ;; if the line is cited, uncite it 217 ;; if the line is cited, uncite it
150 ((sc-cite-regexp) (sc-uncite-line)) 218 ((sc-cite-regexp) (sc-uncite-line))
151 ) 219 )
152 "*Default REGI frame for unciting a region.") 220 "*Default REGI frame for unciting a region."
221 :type '(repeat (repeat sexp))
222 :group 'supercite-frames)
153 223
154(defvar sc-default-recite-frame 224(defcustom sc-default-recite-frame
155 '(;; initialize fill state when entering frame 225 '(;; initialize fill state when entering frame
156 (begin (sc-fill-if-different)) 226 (begin (sc-fill-if-different))
157 ;; do nothing on a blank line 227 ;; do nothing on a blank line
@@ -163,9 +233,11 @@ See the variable `sc-cite-frame-alist' for details.")
163 ;; be sure when we're done that we fill the last cited paragraph. 233 ;; be sure when we're done that we fill the last cited paragraph.
164 (end (sc-fill-if-different "")) 234 (end (sc-fill-if-different ""))
165 ) 235 )
166 "*Default REGI frame for reciting a region.") 236 "*Default REGI frame for reciting a region."
237 :type '(repeat (repeat sexp))
238 :group 'supercite-frames)
167 239
168(defvar sc-cite-region-limit t 240(defcustom sc-cite-region-limit t
169 "*This variable controls automatic citation of yanked text. 241 "*This variable controls automatic citation of yanked text.
170Legal values are: 242Legal values are:
171 243
@@ -180,42 +252,72 @@ nil -- do not cite the region at all
180The gathering of attribution information is not affected by the value 252The gathering of attribution information is not affected by the value
181of this variable. The number of lines in the region is calculated 253of this variable. The number of lines in the region is calculated
182*after* all mail headers are removed. This variable is only consulted 254*after* all mail headers are removed. This variable is only consulted
183during the initial citing via `sc-cite-original'.") 255during the initial citing via `sc-cite-original'."
184 256 :type '(choice (const :tag "always cite" t)
185(defvar sc-confirm-always-p t 257 (const :tag "do not cite" nil)
186 "*If non-nil, always confirm attribution string before citing text body.") 258 (integer :tag "citation threshold"))
187 259 :group 'supercite-cite)
188(defvar sc-default-attribution "Anon" 260
189 "*String used when author's attribution cannot be determined.") 261(defcustom sc-confirm-always-p t
190(defvar sc-default-author-name "Anonymous" 262 "*If non-nil, always confirm attribution string before citing text body."
191 "*String used when author's name cannot be determined.") 263 :type 'boolean
192 264 :group 'supercite-attr)
193(defvar sc-downcase-p nil 265
194 "*Non-nil means downcase the attribution and citation strings.") 266(defcustom sc-default-attribution "Anon"
195 267 "*String used when author's attribution cannot be determined."
196(defvar sc-electric-circular-p t 268 :type 'string
197 "*If non-nil, treat electric references as circular.") 269 :group 'supercite-attr)
198(defvar sc-electric-mode-hook nil 270(defcustom sc-default-author-name "Anonymous"
199 "*Hook for `sc-electric-mode' electric references mode.") 271 "*String used when author's name cannot be determined."
200(defvar sc-electric-references-p nil 272 :type 'string
201 "*Use electric references if non-nil.") 273 :group 'supercite-attr)
202 274(defcustom sc-downcase-p nil
203(defvar sc-fixup-whitespace-p nil 275 "*Non-nil means downcase the attribution and citation strings."
204 "*If non-nil, delete all leading white space before citing.") 276 :type 'boolean
205 277 :group 'supercite-attr
206(defvar sc-load-hook nil 278 :group 'supercite-cite)
207 "*Hook which gets run once after Supercite loads.") 279(defcustom sc-electric-circular-p t
208(defvar sc-pre-hook nil 280 "*If non-nil, treat electric references as circular."
209 "*Hook which gets run before each invocation of `sc-cite-original'.") 281 :type 'boolean
210(defvar sc-post-hook nil 282 :group 'supercite-attr)
211 "*Hook which gets run after each invocation of `sc-cite-original'.") 283
212 284(defcustom sc-electric-mode-hook nil
213(defvar sc-mail-warn-if-non-rfc822-p t 285 "*Hook for `sc-electric-mode' electric references mode."
214 "*Warn if mail headers don't conform to RFC822.") 286 :type 'hook
215(defvar sc-mumble "" 287 :group 'supercite-hooks)
216 "*Value returned by `sc-mail-field' if field isn't in mail headers.") 288(defcustom sc-electric-references-p nil
217 289 "*Use electric references if non-nil."
218(defvar sc-name-filter-alist 290 :type 'boolean
291 :group 'supercite)
292
293(defcustom sc-fixup-whitespace-p nil
294 "*If non-nil, delete all leading white space before citing."
295 :type 'boolean
296 :group 'supercite)
297
298(defcustom sc-load-hook nil
299 "*Hook which gets run once after Supercite loads."
300 :type 'hook
301 :group 'supercite-hooks)
302(defcustom sc-pre-hook nil
303 "*Hook which gets run before each invocation of `sc-cite-original'."
304 :type 'hook
305 :group 'supercite-hooks)
306(defcustom sc-post-hook nil
307 "*Hook which gets run after each invocation of `sc-cite-original'."
308 :type 'hook
309 :group 'supercite-hooks)
310
311(defcustom sc-mail-warn-if-non-rfc822-p t
312 "*Warn if mail headers don't conform to RFC822."
313 :type 'boolean
314 :group 'supercite-attr)
315(defcustom sc-mumble ""
316 "*Value returned by `sc-mail-field' if field isn't in mail headers."
317 :type 'string
318 :group 'supercite-attr)
319
320(defcustom sc-name-filter-alist
219 '(("^\\(Mr\\|Mrs\\|Ms\\|Dr\\)[.]?$" . 0) 321 '(("^\\(Mr\\|Mrs\\|Ms\\|Dr\\)[.]?$" . 0)
220 ("^\\(Jr\\|Sr\\)[.]?$" . last) 322 ("^\\(Jr\\|Sr\\)[.]?$" . last)
221 ("^ASTS$" . 0) 323 ("^ASTS$" . 0)
@@ -228,27 +330,37 @@ REGEXP is a regular expression which matches the name list component.
228Match is performed using `string-match'. POSITION is the position in 330Match is performed using `string-match'. POSITION is the position in
229the name list which can match the regular expression, starting at zero 331the name list which can match the regular expression, starting at zero
230for the first element. Use `last' to match the last element in the 332for the first element. Use `last' to match the last element in the
231list and `any' to match all elements.") 333list and `any' to match all elements."
334 :type '(repeat (cons regexp (choice (const last) (const any)
335 (integer :tag "position"))))
336 :group 'supercite-attr)
232 337
233(defvar sc-nested-citation-p nil 338(defcustom sc-nested-citation-p nil
234 "*Controls whether to use nested or non-nested citation style. 339 "*Controls whether to use nested or non-nested citation style.
235Non-nil uses nested citations, nil uses non-nested citations.") 340Non-nil uses nested citations, nil uses non-nested citations."
341 :type 'boolean
342 :group 'supercite)
236 343
237(defvar sc-nuke-mail-headers 'all 344(defcustom sc-nuke-mail-headers 'all
238 "*Controls mail header nuking. 345 "*Controls mail header nuking.
239Used in conjunction with `sc-nuke-mail-header-list'. Legal values are: 346Used in conjunction with `sc-nuke-mail-header-list'. Legal values are:
240 347
241`all' -- nuke all mail headers 348`all' -- nuke all mail headers
242`none' -- don't nuke any mail headers 349`none' -- don't nuke any mail headers
243`specified' -- nuke headers specified in `sc-nuke-mail-header-list' 350`specified' -- nuke headers specified in `sc-nuke-mail-header-list'
244`keep' -- keep headers specified in `sc-nuke-mail-header-list'") 351`keep' -- keep headers specified in `sc-nuke-mail-header-list'"
352 :type '(choice (const all) (const none)
353 (const specified) (const keep))
354 :group 'supercite)
245 355
246(defvar sc-nuke-mail-header-list nil 356(defcustom sc-nuke-mail-header-list nil
247 "*List of mail header regexps to remove or keep in body of reply. 357 "*List of mail header regexps to remove or keep in body of reply.
248This list contains regular expressions describing the mail headers to 358This list contains regular expressions describing the mail headers to
249keep or nuke, depending on the value of `sc-nuke-mail-headers'.") 359keep or nuke, depending on the value of `sc-nuke-mail-headers'."
360 :type '(repeat regexp)
361 :group 'supercite)
250 362
251(defvar sc-preferred-attribution-list 363(defcustom sc-preferred-attribution-list
252 '("sc-lastchoice" "x-attribution" "firstname" "initials" "lastname") 364 '("sc-lastchoice" "x-attribution" "firstname" "initials" "lastname")
253 "*Specifies what to use as the attribution string. 365 "*Specifies what to use as the attribution string.
254Supercite creates a list of possible attributions when it scans the 366Supercite creates a list of possible attributions when it scans the
@@ -286,9 +398,11 @@ in the attribution alist:
286Middle name indexes can be any positive integer greater than 0, 398Middle name indexes can be any positive integer greater than 0,
287although it is unlikely that many authors will supply more than one 399although it is unlikely that many authors will supply more than one
288middle name, if that many. The string of all middle names is 400middle name, if that many. The string of all middle names is
289associated with the key \"middlenames\".") 401associated with the key \"middlenames\"."
402 :type '(repeat string)
403 :group 'supercite-attr)
290 404
291(defvar sc-attrib-selection-list nil 405(defcustom sc-attrib-selection-list nil
292 "*An alist for selecting preferred attribution based on mail headers. 406 "*An alist for selecting preferred attribution based on mail headers.
293Each element of this list has the following form: 407Each element of this list has the following form:
294 408
@@ -303,28 +417,51 @@ selected by `sc-select-attribution'. If it is a list, it is `eval'd
303and the return value must be a string, which is used as the selected 417and the return value must be a string, which is used as the selected
304attribution. Note that the variable `sc-preferred-attribution-list' 418attribution. Note that the variable `sc-preferred-attribution-list'
305must contain an element of the string \"sc-consult\" for this variable 419must contain an element of the string \"sc-consult\" for this variable
306to be consulted during attribution selection.") 420to be consulted during attribution selection."
307 421 :type '(repeat (list symbol (repeat (cons regexp
308(defvar sc-attribs-preselect-hook nil 422 (choice (repeat (repeat sexp))
309 "*Hook to run before selecting an attribution.") 423 symbol)))))
310(defvar sc-attribs-postselect-hook nil 424 :group 'supercite-attr)
311 "*Hook to run after selecting an attribution, but before confirmation.") 425
312 426(defcustom sc-attribs-preselect-hook nil
313(defvar sc-pre-cite-hook nil 427 "*Hook to run before selecting an attribution."
314 "*Hook to run before citing a region of text.") 428 :type 'hook
315(defvar sc-pre-uncite-hook nil 429 :group 'supercite-attr
316 "*Hook to run before unciting a region of text.") 430 :group 'supercite-hooks)
317(defvar sc-pre-recite-hook nil 431(defcustom sc-attribs-postselect-hook nil
318 "*Hook to run before reciting a region of text.") 432 "*Hook to run after selecting an attribution, but before confirmation."
319 433 :type 'hook
320(defvar sc-preferred-header-style 4 434 :group 'supercite-attr
435 :group 'supercite-hooks)
436
437(defcustom sc-pre-cite-hook nil
438 "*Hook to run before citing a region of text."
439 :type 'hook
440 :group 'supercite-cite
441 :group 'supercite-hooks)
442(defcustom sc-pre-uncite-hook nil
443 "*Hook to run before unciting a region of text."
444 :type 'hook
445 :group 'supercite-cite
446 :group 'supercite-hooks)
447(defcustom sc-pre-recite-hook nil
448 "*Hook to run before reciting a region of text."
449 :type 'hook
450 :group 'supercite-cite
451 :group 'supercite-hooks)
452
453(defcustom sc-preferred-header-style 4
321 "*Index into `sc-rewrite-header-list' specifying preferred header style. 454 "*Index into `sc-rewrite-header-list' specifying preferred header style.
322Index zero accesses the first function in the list.") 455Index zero accesses the first function in the list."
456 :type 'integer
457 :group 'supercite)
323 458
324(defvar sc-reference-tag-string ">>>>> " 459(defcustom sc-reference-tag-string ">>>>> "
325 "*String used at the beginning of built-in reference headers.") 460 "*String used at the beginning of built-in reference headers."
461 :type 'string
462 :group 'supercite)
326 463
327(defvar sc-rewrite-header-list 464(defcustom sc-rewrite-header-list
328 '((sc-no-header) 465 '((sc-no-header)
329 (sc-header-on-said) 466 (sc-header-on-said)
330 (sc-header-inarticle-writes) 467 (sc-header-inarticle-writes)
@@ -337,17 +474,24 @@ Index zero accesses the first function in the list.")
337 "*List of reference header rewrite functions. 474 "*List of reference header rewrite functions.
338The variable `sc-preferred-header-style' controls which function in 475The variable `sc-preferred-header-style' controls which function in
339this list is chosen for automatic reference header insertions. 476this list is chosen for automatic reference header insertions.
340Electric reference mode will cycle through this list of functions.") 477Electric reference mode will cycle through this list of functions."
478 :type '(repeat sexp)
479 :group 'supercite)
341 480
342(defvar sc-titlecue-regexp "\\s +-+\\s +" 481(defcustom sc-titlecue-regexp "\\s +-+\\s +"
343 "*Regular expression describing the separator between names and titles. 482 "*Regular expression describing the separator between names and titles.
344Set to nil to treat entire field as a name.") 483Set to nil to treat entire field as a name."
484 :type '(choice (const :tag "entire field as name" nil)
485 regexp)
486 :group 'supercite-attr)
345 487
346(defvar sc-use-only-preference-p nil 488(defcustom sc-use-only-preference-p nil
347 "*Controls what happens when the preferred attribution cannot be found. 489 "*Controls what happens when the preferred attribution cannot be found.
348If non-nil, then `sc-default-attribution' will be used. If nil, then 490If non-nil, then `sc-default-attribution' will be used. If nil, then
349some secondary scheme will be employed to find a suitable attribution 491some secondary scheme will be employed to find a suitable attribution
350string.") 492string."
493 :type 'boolean
494 :group 'supercite-attr)
351 495
352;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 496;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
353;; end user configuration variables 497;; end user configuration variables