4527724902073fc662e0126fb8db5c7f8e2df21a
[gnus] / lisp / message.el
1 ;;; message.el --- composing mail and news messages
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; This mode provides mail-sending facilities from within Emacs.  It
27 ;; consists mainly of large chunks of code from the sendmail.el,
28 ;; gnus-msg.el and rnewspost.el files.
29
30 ;;; Code:
31
32 (eval-and-compile
33   (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34 (eval-when-compile
35   (require 'cl))
36
37 (require 'mailheader)
38 (require 'gmm-utils)
39 (require 'mail-utils)
40 ;; Only for the trivial macros mail-header-from, mail-header-date
41 ;; mail-header-references, mail-header-subject, mail-header-id
42 (eval-when-compile (require 'nnheader))
43 ;; This is apparently necessary even though things are autoloaded.
44 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
45 ;; require mailabbrev here.
46 (if (featurep 'xemacs)
47     (require 'mail-abbrevs)
48   (require 'mailabbrev))
49 (require 'mail-parse)
50 (require 'mml)
51 (require 'rfc822)
52
53 (autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/
54
55 (defvar gnus-message-group-art)
56 (defvar gnus-list-identifiers) ; gnus-sum is required where necessary
57 (defvar rmail-enable-mime-composing)
58
59 (defgroup message '((user-mail-address custom-variable)
60                     (user-full-name custom-variable))
61   "Mail and news message composing."
62   :link '(custom-manual "(message)Top")
63   :group 'mail
64   :group 'news)
65
66 (put 'user-mail-address 'custom-type 'string)
67 (put 'user-full-name 'custom-type 'string)
68
69 (defgroup message-various nil
70   "Various Message Variables."
71   :link '(custom-manual "(message)Various Message Variables")
72   :group 'message)
73
74 (defgroup message-buffers nil
75   "Message Buffers."
76   :link '(custom-manual "(message)Message Buffers")
77   :group 'message)
78
79 (defgroup message-sending nil
80   "Message Sending."
81   :link '(custom-manual "(message)Sending Variables")
82   :group 'message)
83
84 (defgroup message-interface nil
85   "Message Interface."
86   :link '(custom-manual "(message)Interface")
87   :group 'message)
88
89 (defgroup message-forwarding nil
90   "Message Forwarding."
91   :link '(custom-manual "(message)Forwarding")
92   :group 'message-interface)
93
94 (defgroup message-insertion nil
95   "Message Insertion."
96   :link '(custom-manual "(message)Insertion")
97   :group 'message)
98
99 (defgroup message-headers nil
100   "Message Headers."
101   :link '(custom-manual "(message)Message Headers")
102   :group 'message)
103
104 (defgroup message-news nil
105   "Composing News Messages."
106   :group 'message)
107
108 (defgroup message-mail nil
109   "Composing Mail Messages."
110   :group 'message)
111
112 (defgroup message-faces nil
113   "Faces used for message composing."
114   :group 'message
115   :group 'faces)
116
117 (defcustom message-directory "~/Mail/"
118   "*Directory from which all other mail file variables are derived."
119   :group 'message-various
120   :type 'directory)
121
122 (defcustom message-max-buffers 10
123   "*How many buffers to keep before starting to kill them off."
124   :group 'message-buffers
125   :type 'integer)
126
127 (defcustom message-send-rename-function nil
128   "Function called to rename the buffer after sending it."
129   :group 'message-buffers
130   :type '(choice function (const nil)))
131
132 (defcustom message-fcc-handler-function 'message-output
133   "*A function called to save outgoing articles.
134 This function will be called with the name of the file to store the
135 article in.  The default function is `message-output' which saves in Unix
136 mailbox format."
137   :type '(radio (function-item message-output)
138                 (function :tag "Other"))
139   :group 'message-sending)
140
141 (defcustom message-fcc-externalize-attachments nil
142   "If non-nil, attachments are included as external parts in Fcc copies."
143   :version "22.1"
144   :type 'boolean
145   :group 'message-sending)
146
147 (defcustom message-courtesy-message
148   "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
149   "*This is inserted at the start of a mailed copy of a posted message.
150 If the string contains the format spec \"%s\", the Newsgroups
151 the article has been posted to will be inserted there.
152 If this variable is nil, no such courtesy message will be added."
153   :group 'message-sending
154   :type '(radio string (const nil)))
155
156 (defcustom message-ignored-bounced-headers
157   "^\\(Received\\|Return-Path\\|Delivered-To\\):"
158   "*Regexp that matches headers to be removed in resent bounced mail."
159   :group 'message-interface
160   :type 'regexp)
161
162 (defcustom message-from-style 'default
163   "*Specifies how \"From\" headers look.
164
165 If nil, they contain just the return address like:
166         king@grassland.com
167 If `parens', they look like:
168         king@grassland.com (Elvis Parsley)
169 If `angles', they look like:
170         Elvis Parsley <king@grassland.com>
171
172 Otherwise, most addresses look like `angles', but they look like
173 `parens' if `angles' would need quoting and `parens' would not."
174   :version "23.2"
175   :type '(choice (const :tag "simple" nil)
176                  (const parens)
177                  (const angles)
178                  (const default))
179   :group 'message-headers)
180
181 (defcustom message-insert-canlock t
182   "Whether to insert a Cancel-Lock header in news postings."
183   :version "22.1"
184   :group 'message-headers
185   :type 'boolean)
186
187 (defcustom message-syntax-checks
188   (if message-insert-canlock '((sender . disabled)) nil)
189   ;; Guess this one shouldn't be easy to customize...
190   "*Controls what syntax checks should not be performed on outgoing posts.
191 To disable checking of long signatures, for instance, add
192  `(signature . disabled)' to this list.
193
194 Don't touch this variable unless you really know what you're doing.
195
196 Checks include `approved', `bogus-recipient', `continuation-headers',
197 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
198 `invisible-text', `long-header-lines', `long-lines', `message-id',
199 `multiple-headers', `new-text', `newsgroups', `quoting-style',
200 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
201 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
202 and `valid-newsgroups'."
203   :group 'message-news
204   :type '(repeat sexp))                 ; Fixme: improve this
205
206 (defcustom message-required-headers '((optional . References)
207                                       From)
208   "*Headers to be generated or prompted for when sending a message.
209 Also see `message-required-news-headers' and
210 `message-required-mail-headers'."
211   :version "22.1"
212   :group 'message-news
213   :group 'message-headers
214   :link '(custom-manual "(message)Message Headers")
215   :type '(repeat sexp))
216
217 (defcustom message-draft-headers '(References From Date)
218   "*Headers to be generated when saving a draft message."
219   :version "22.1"
220   :group 'message-news
221   :group 'message-headers
222   :link '(custom-manual "(message)Message Headers")
223   :type '(repeat sexp))
224
225 (defcustom message-required-news-headers
226   '(From Newsgroups Subject Date Message-ID
227          (optional . Organization)
228          (optional . User-Agent))
229   "*Headers to be generated or prompted for when posting an article.
230 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
231 Message-ID.  Organization, Lines, In-Reply-To, Expires, and
232 User-Agent are optional.  If you don't want message to insert some
233 header, remove it from this list."
234   :group 'message-news
235   :group 'message-headers
236   :link '(custom-manual "(message)Message Headers")
237   :type '(repeat sexp))
238
239 (defcustom message-required-mail-headers
240   '(From Subject Date (optional . In-Reply-To) Message-ID
241          (optional . User-Agent))
242   "*Headers to be generated or prompted for when mailing a message.
243 It is recommended that From, Date, To, Subject and Message-ID be
244 included.  Organization and User-Agent are optional."
245   :group 'message-mail
246   :group 'message-headers
247   :link '(custom-manual "(message)Message Headers")
248   :type '(repeat sexp))
249
250 (defcustom message-prune-recipient-rules nil
251   "Rules for how to prune the list of recipients when doing wide replies.
252 This is a list of regexps and regexp matches."
253   :group 'message-mail
254   :group 'message-headers
255   :link '(custom-manual "(message)Wide Reply")
256   :type '(repeat regexp))
257
258 (defcustom message-deletable-headers '(Message-ID Date Lines)
259   "Headers to be deleted if they already exist and were generated by message previously."
260   :group 'message-headers
261   :link '(custom-manual "(message)Message Headers")
262   :type 'sexp)
263
264 (defcustom message-ignored-news-headers
265   "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
266   "*Regexp of headers to be removed unconditionally before posting."
267   :group 'message-news
268   :group 'message-headers
269   :link '(custom-manual "(message)Message Headers")
270   :type '(repeat :value-to-internal (lambda (widget value)
271                                       (custom-split-regexp-maybe value))
272                  :match (lambda (widget value)
273                           (or (stringp value)
274                               (widget-editable-list-match widget value)))
275                  regexp))
276
277 (defcustom message-ignored-mail-headers
278   "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
279   "*Regexp of headers to be removed unconditionally before mailing."
280   :group 'message-mail
281   :group 'message-headers
282   :link '(custom-manual "(message)Mail Headers")
283   :type 'regexp)
284
285 (defcustom message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|^X-Trace:\\|^X-ID:\\|^X-Complaints-To:\\|Return-Path:\\|^Supersedes:\\|^NNTP-Posting-Date:\\|^X-Trace:\\|^X-Complaints-To:\\|^Cancel-Lock:\\|^Cancel-Key:\\|^X-Hashcash:\\|^X-Payment:\\|^Approved:"
286   "*Header lines matching this regexp will be deleted before posting.
287 It's best to delete old Path and Date headers before posting to avoid
288 any confusion."
289   :group 'message-interface
290   :link '(custom-manual "(message)Superseding")
291   :type '(repeat :value-to-internal (lambda (widget value)
292                                       (custom-split-regexp-maybe value))
293                  :match (lambda (widget value)
294                           (or (stringp value)
295                               (widget-editable-list-match widget value)))
296                  regexp))
297
298 (defcustom message-subject-re-regexp
299   "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
300   "*Regexp matching \"Re: \" in the subject line."
301   :group 'message-various
302   :link '(custom-manual "(message)Message Headers")
303   :type 'regexp)
304
305 ;;; Start of variables adopted from `message-utils.el'.
306
307 (defcustom message-subject-trailing-was-query 'ask
308   "*What to do with trailing \"(was: <old subject>)\" in subject lines.
309 If nil, leave the subject unchanged.  If it is the symbol `ask', query
310 the user what do do.  In this case, the subject is matched against
311 `message-subject-trailing-was-ask-regexp'.  If
312 `message-subject-trailing-was-query' is t, always strip the trailing
313 old subject.  In this case, `message-subject-trailing-was-regexp' is
314 used."
315   :version "22.1"
316   :type '(choice (const :tag "never" nil)
317                  (const :tag "always strip" t)
318                  (const ask))
319   :link '(custom-manual "(message)Message Headers")
320   :group 'message-various)
321
322 (defcustom message-subject-trailing-was-ask-regexp
323   "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
324   "*Regexp matching \"(was: <old subject>)\" in the subject line.
325
326 The function `message-strip-subject-trailing-was' uses this regexp if
327 `message-subject-trailing-was-query' is set to the symbol `ask'.  If
328 the variable is t instead of `ask', use
329 `message-subject-trailing-was-regexp' instead.
330
331 It is okay to create some false positives here, as the user is asked."
332   :version "22.1"
333   :group 'message-various
334   :link '(custom-manual "(message)Message Headers")
335   :type 'regexp)
336
337 (defcustom message-subject-trailing-was-regexp
338   "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
339   "*Regexp matching \"(was: <old subject>)\" in the subject line.
340
341 If `message-subject-trailing-was-query' is set to t, the subject is
342 matched against `message-subject-trailing-was-regexp' in
343 `message-strip-subject-trailing-was'.  You should use a regexp creating very
344 few false positives here."
345   :version "22.1"
346   :group 'message-various
347   :link '(custom-manual "(message)Message Headers")
348   :type 'regexp)
349
350 ;;; marking inserted text
351
352 (defcustom message-mark-insert-begin
353   "--8<---------------cut here---------------start------------->8---\n"
354   "How to mark the beginning of some inserted text."
355   :version "22.1"
356   :type 'string
357   :link '(custom-manual "(message)Insertion Variables")
358   :group 'message-various)
359
360 (defcustom message-mark-insert-end
361   "--8<---------------cut here---------------end--------------->8---\n"
362   "How to mark the end of some inserted text."
363   :version "22.1"
364   :type 'string
365   :link '(custom-manual "(message)Insertion Variables")
366   :group 'message-various)
367
368 (defcustom message-archive-header "X-No-Archive: Yes\n"
369   "Header to insert when you don't want your article to be archived.
370 Archives \(such as groups.google.com\) respect this header."
371   :version "22.1"
372   :type 'string
373   :link '(custom-manual "(message)Header Commands")
374   :group 'message-various)
375
376 (defcustom message-archive-note
377   "X-No-Archive: Yes - save http://groups.google.com/"
378   "Note to insert why you wouldn't want this posting archived.
379 If nil, don't insert any text in the body."
380   :version "22.1"
381   :type '(radio string (const nil))
382   :link '(custom-manual "(message)Header Commands")
383   :group 'message-various)
384
385 ;;; Crossposts and Followups
386 ;; inspired by JoH-followup-to by Jochem Huhman <joh  at gmx.de>
387 ;; new suggestions by R. Weikusat <rw at another.de>
388
389 (defvar message-cross-post-old-target nil
390   "Old target for cross-posts or follow-ups.")
391 (make-variable-buffer-local 'message-cross-post-old-target)
392
393 (defcustom message-cross-post-default t
394   "When non-nil `message-cross-post-followup-to' will perform a crosspost.
395 If nil, `message-cross-post-followup-to' will only do a followup.  Note that
396 you can explicitly override this setting by calling
397 `message-cross-post-followup-to' with a prefix."
398   :version "22.1"
399   :type 'boolean
400   :group 'message-various)
401
402 (defcustom message-cross-post-note "Crosspost & Followup-To: "
403   "Note to insert before signature to notify of cross-post and follow-up."
404   :version "22.1"
405   :type 'string
406   :group 'message-various)
407
408 (defcustom message-followup-to-note "Followup-To: "
409   "Note to insert before signature to notify of follow-up only."
410   :version "22.1"
411   :type 'string
412   :group 'message-various)
413
414 (defcustom message-cross-post-note-function 'message-cross-post-insert-note
415   "Function to use to insert note about Crosspost or Followup-To.
416 The function will be called with four arguments.  The function should not only
417 insert a note, but also ensure old notes are deleted.  See the documentation
418 for `message-cross-post-insert-note'."
419   :version "22.1"
420   :type 'function
421   :group 'message-various)
422
423 ;;; End of variables adopted from `message-utils.el'.
424
425 (defcustom message-signature-separator "^-- $"
426   "Regexp matching the signature separator.
427 This variable is used to strip off the signature from quoted text
428 when `message-cite-function' is
429 `message-cite-original-without-signature'.  Most useful values
430 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
431 whitespace)."
432   :type '(choice (const :tag "strict" "^-- $")
433                  (const :tag "loose" "^-- *$")
434                  regexp)
435   :version "22.3" ;; Gnus 5.10.12 (changed default)
436   :link '(custom-manual "(message)Various Message Variables")
437   :group 'message-various)
438
439 (defcustom message-elide-ellipsis "\n[...]\n\n"
440   "*The string which is inserted for elided text."
441   :type 'string
442   :link '(custom-manual "(message)Various Commands")
443   :group 'message-various)
444
445 (defcustom message-interactive t
446   "Non-nil means when sending a message wait for and display errors.
447 A value of nil means let mailer mail back a message to report errors."
448   :version "23.2"
449   :group 'message-sending
450   :group 'message-mail
451   :link '(custom-manual "(message)Sending Variables")
452   :type 'boolean)
453
454 (defcustom message-confirm-send nil
455   "When non-nil, ask for confirmation when sending a message."
456   :group 'message-sending
457   :group 'message-mail
458   :version "23.1" ;; No Gnus
459   :link '(custom-manual "(message)Sending Variables")
460   :type 'boolean)
461
462 (defcustom message-generate-new-buffers 'unique
463   "*Say whether to create a new message buffer to compose a message.
464 Valid values include:
465
466 nil
467   Generate the buffer name in the Message way (e.g., *mail*, *news*,
468   *mail to whom*, *news on group*, etc.) and continue editing in the
469   existing buffer of that name.  If there is no such buffer, it will
470   be newly created.
471
472 `unique' or t
473   Create the new buffer with the name generated in the Message way.
474
475 `unsent'
476   Similar to `unique' but the buffer name begins with \"*unsent \".
477
478 `standard'
479   Similar to nil but the buffer name is simpler like *mail message*.
480
481 function
482   If this is a function, call that function with three parameters:
483   The type, the To address and the group name (any of these may be nil).
484   The function should return the new buffer name."
485   :group 'message-buffers
486   :link '(custom-manual "(message)Message Buffers")
487   :type '(choice (const nil)
488                  (sexp :tag "unique" :format "unique\n" :value unique
489                        :match (lambda (widget value) (memq value '(unique t))))
490                  (const unsent)
491                  (const standard)
492                  (function :format "\n    %{%t%}: %v")))
493
494 (defcustom message-kill-buffer-on-exit nil
495   "*Non-nil means that the message buffer will be killed after sending a message."
496   :group 'message-buffers
497   :link '(custom-manual "(message)Message Buffers")
498   :type 'boolean)
499
500 (defcustom message-kill-buffer-query t
501   "*Non-nil means that killing a modified message buffer has to be confirmed.
502 This is used by `message-kill-buffer'."
503   :version "23.1" ;; No Gnus
504   :group 'message-buffers
505   :type 'boolean)
506
507 (defvar gnus-local-organization)
508 (defcustom message-user-organization
509   (or (and (boundp 'gnus-local-organization)
510            (stringp gnus-local-organization)
511            gnus-local-organization)
512       (getenv "ORGANIZATION")
513       t)
514   "*String to be used as an Organization header.
515 If t, use `message-user-organization-file'."
516   :group 'message-headers
517   :type '(choice string
518                  (const :tag "consult file" t)))
519
520 (defcustom message-user-organization-file
521   (let (orgfile)
522     (dolist (f (list "/etc/organization"
523                      "/etc/news/organization"
524                      "/usr/lib/news/organization"))
525       (when (file-readable-p f)
526         (setq orgfile f)))
527     orgfile)
528   "*Local news organization file."
529   :type 'file
530   :link '(custom-manual "(message)News Headers")
531   :group 'message-headers)
532
533 (defcustom message-make-forward-subject-function
534   #'message-forward-subject-name-subject
535   "*List of functions called to generate subject headers for forwarded messages.
536 The subject generated by the previous function is passed into each
537 successive function.
538
539 The provided functions are:
540
541 * `message-forward-subject-author-subject' Source of article (author or
542       newsgroup), in brackets followed by the subject
543 * `message-forward-subject-name-subject' Source of article (name of author
544       or newsgroup), in brackets followed by the subject
545 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
546       to it."
547   :group 'message-forwarding
548   :link '(custom-manual "(message)Forwarding")
549   :type '(radio (function-item message-forward-subject-author-subject)
550                 (function-item message-forward-subject-fwd)
551                 (function-item message-forward-subject-name-subject)
552                 (repeat :tag "List of functions" function)))
553
554 (defcustom message-forward-as-mime t
555   "*Non-nil means forward messages as an inline/rfc822 MIME section.
556 Otherwise, directly inline the old message in the forwarded message."
557   :version "21.1"
558   :group 'message-forwarding
559   :link '(custom-manual "(message)Forwarding")
560   :type 'boolean)
561
562 (defcustom message-forward-show-mml 'best
563   "*Non-nil means show forwarded messages as MML (decoded from MIME).
564 Otherwise, forwarded messages are unchanged.
565 Can also be the symbol `best' to indicate that MML should be
566 used, except when it is a bad idea to use MML.  One example where
567 it is a bad idea is when forwarding a signed or encrypted
568 message, because converting MIME to MML would invalidate the
569 digital signature."
570   :version "21.1"
571   :group 'message-forwarding
572   :type '(choice (const :tag "use MML" t)
573                  (const :tag "don't use MML " nil)
574                  (const :tag "use MML when appropriate" best)))
575
576 (defcustom message-forward-before-signature t
577   "*Non-nil means put forwarded message before signature, else after."
578   :group 'message-forwarding
579   :type 'boolean)
580
581 (defcustom message-wash-forwarded-subjects nil
582   "*Non-nil means try to remove as much cruft as possible from the subject.
583 Done before generating the new subject of a forward."
584   :group 'message-forwarding
585   :link '(custom-manual "(message)Forwarding")
586   :type 'boolean)
587
588 (defcustom message-ignored-resent-headers
589   ;; `Delivered-To' needs to be removed because some mailers use it to
590   ;; detect loops, so if you resend a message to an address that ultimately
591   ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
592   ;; case you may be removed from the list on the grounds that mail to you
593   ;; bounced with a "mailing loop" error).
594   "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
595   "*All headers that match this regexp will be deleted when resending a message."
596   :group 'message-interface
597   :link '(custom-manual "(message)Resending")
598   :type '(repeat :value-to-internal (lambda (widget value)
599                                       (custom-split-regexp-maybe value))
600                  :match (lambda (widget value)
601                           (or (stringp value)
602                               (widget-editable-list-match widget value)))
603                  regexp))
604
605 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
606   "*All headers that match this regexp will be deleted when forwarding a message."
607   :version "21.1"
608   :group 'message-forwarding
609   :type '(repeat :value-to-internal (lambda (widget value)
610                                       (custom-split-regexp-maybe value))
611                  :match (lambda (widget value)
612                           (or (stringp value)
613                               (widget-editable-list-match widget value)))
614                  regexp))
615
616 (defcustom message-ignored-cited-headers "."
617   "*Delete these headers from the messages you yank."
618   :group 'message-insertion
619   :link '(custom-manual "(message)Insertion Variables")
620   :type 'regexp)
621
622 (defcustom message-cite-prefix-regexp
623   (if (string-match "[[:digit:]]" "1")
624       ;; Support POSIX?  XEmacs 21.5.27 doesn't.
625       "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|}]\\)+"
626     ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
627     (let (non-word-constituents)
628       (with-syntax-table text-mode-syntax-table
629         (setq non-word-constituents
630               (concat
631                (if (string-match "\\w" "_")  "" "_")
632                (if (string-match "\\w" ".")  "" "."))))
633       (if (equal non-word-constituents "")
634           "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}]\\)+"
635         (concat "\\([ \t]*\\(\\w\\|["
636                 non-word-constituents
637                 "]\\)+>+\\|[ \t]*[]>|}]\\)+"))))
638   "*Regexp matching the longest possible citation prefix on a line."
639   :version "23.2"
640   :group 'message-insertion
641   :link '(custom-manual "(message)Insertion Variables")
642   :type 'regexp
643   :set (lambda (symbol value)
644          (prog1
645              (custom-set-default symbol value)
646            (if (boundp 'gnus-message-cite-prefix-regexp)
647                (setq gnus-message-cite-prefix-regexp
648                      (concat "^\\(?:" value "\\)"))))))
649
650 (defcustom message-cancel-message "I am canceling my own article.\n"
651   "Message to be inserted in the cancel message."
652   :group 'message-interface
653   :link '(custom-manual "(message)Canceling News")
654   :type 'string)
655
656 (defun message-send-mail-function ()
657   "Return suitable value for the variable `message-send-mail-function'."
658   (cond ((and (require 'sendmail)
659               (boundp 'sendmail-program)
660               sendmail-program
661               (executable-find sendmail-program))
662          'message-send-mail-with-sendmail)
663         ((and (locate-library "smtpmail")
664               (boundp 'smtpmail-default-smtp-server)
665               smtpmail-default-smtp-server)
666          'message-smtpmail-send-it)
667         ((locate-library "mailclient")
668          'message-send-mail-with-mailclient)
669         (t
670          (error "Don't know how to send mail.  Please customize `message-send-mail-function'"))))
671
672 ;; Useful to set in site-init.el
673 (defcustom message-send-mail-function
674   (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it)
675         ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it)
676         ((eq send-mail-function 'mailclient-send-it)
677          'message-send-mail-with-mailclient)
678         (t (message-send-mail-function)))
679   "Function to call to send the current buffer as mail.
680 The headers should be delimited by a line whose contents match the
681 variable `mail-header-separator'.
682
683 Valid values include `message-send-mail-with-sendmail'
684 `message-send-mail-with-mh', `message-send-mail-with-qmail',
685 `message-smtpmail-send-it', `smtpmail-send-it',
686 `feedmail-send-it' and `message-send-mail-with-mailclient'.  The
687 default is system dependent and determined by the function
688 `message-send-mail-function'.
689
690 See also `send-mail-function'."
691   :type '(radio (function-item message-send-mail-with-sendmail)
692                 (function-item message-send-mail-with-mh)
693                 (function-item message-send-mail-with-qmail)
694                 (function-item message-smtpmail-send-it)
695                 (function-item smtpmail-send-it)
696                 (function-item feedmail-send-it)
697                 (function-item message-send-mail-with-mailclient
698                                :tag "Use Mailclient package")
699                 (function :tag "Other"))
700   :group 'message-sending
701   :version "23.2"
702   :initialize 'custom-initialize-default
703   :link '(custom-manual "(message)Mail Variables")
704   :group 'message-mail)
705
706 (defcustom message-send-news-function 'message-send-news
707   "Function to call to send the current buffer as news.
708 The headers should be delimited by a line whose contents match the
709 variable `mail-header-separator'."
710   :group 'message-sending
711   :group 'message-news
712   :link '(custom-manual "(message)News Variables")
713   :type 'function)
714
715 (defcustom message-reply-to-function nil
716   "If non-nil, function that should return a list of headers.
717 This function should pick out addresses from the To, Cc, and From headers
718 and respond with new To and Cc headers."
719   :group 'message-interface
720   :link '(custom-manual "(message)Reply")
721   :type '(choice function (const nil)))
722
723 (defcustom message-wide-reply-to-function nil
724   "If non-nil, function that should return a list of headers.
725 This function should pick out addresses from the To, Cc, and From headers
726 and respond with new To and Cc headers."
727   :group 'message-interface
728   :link '(custom-manual "(message)Wide Reply")
729   :type '(choice function (const nil)))
730
731 (defcustom message-followup-to-function nil
732   "If non-nil, function that should return a list of headers.
733 This function should pick out addresses from the To, Cc, and From headers
734 and respond with new To and Cc headers."
735   :group 'message-interface
736   :link '(custom-manual "(message)Followup")
737   :type '(choice function (const nil)))
738
739 (defcustom message-extra-wide-headers nil
740   "If non-nil, a list of additional address headers.
741 These are used when composing a wide reply."
742   :group 'message-sending
743   :type '(repeat string))
744
745 (defcustom message-use-followup-to 'ask
746   "*Specifies what to do with Followup-To header.
747 If nil, always ignore the header.  If it is t, use its value, but
748 query before using the \"poster\" value.  If it is the symbol `ask',
749 always query the user whether to use the value.  If it is the symbol
750 `use', always use the value."
751   :group 'message-interface
752   :link '(custom-manual "(message)Followup")
753   :type '(choice (const :tag "ignore" nil)
754                  (const :tag "use & query" t)
755                  (const use)
756                  (const ask)))
757
758 (defcustom message-use-mail-followup-to 'use
759   "*Specifies what to do with Mail-Followup-To header.
760 If nil, always ignore the header.  If it is the symbol `ask', always
761 query the user whether to use the value.  If it is the symbol `use',
762 always use the value."
763   :version "22.1"
764   :group 'message-interface
765   :link '(custom-manual "(message)Mailing Lists")
766   :type '(choice (const :tag "ignore" nil)
767                  (const use)
768                  (const ask)))
769
770 (defcustom message-subscribed-address-functions nil
771   "*Specifies functions for determining list subscription.
772 If nil, do not attempt to determine list subscription with functions.
773 If non-nil, this variable contains a list of functions which return
774 regular expressions to match lists.  These functions can be used in
775 conjunction with `message-subscribed-regexps' and
776 `message-subscribed-addresses'."
777   :version "22.1"
778   :group 'message-interface
779   :link '(custom-manual "(message)Mailing Lists")
780   :type '(repeat sexp))
781
782 (defcustom message-subscribed-address-file nil
783   "*A file containing addresses the user is subscribed to.
784 If nil, do not look at any files to determine list subscriptions.  If
785 non-nil, each line of this file should be a mailing list address."
786   :version "22.1"
787   :group 'message-interface
788   :link '(custom-manual "(message)Mailing Lists")
789   :type '(radio file (const nil)))
790
791 (defcustom message-subscribed-addresses nil
792   "*Specifies a list of addresses the user is subscribed to.
793 If nil, do not use any predefined list subscriptions.  This list of
794 addresses can be used in conjunction with
795 `message-subscribed-address-functions' and `message-subscribed-regexps'."
796   :version "22.1"
797   :group 'message-interface
798   :link '(custom-manual "(message)Mailing Lists")
799   :type '(repeat string))
800
801 (defcustom message-subscribed-regexps nil
802   "*Specifies a list of addresses the user is subscribed to.
803 If nil, do not use any predefined list subscriptions.  This list of
804 regular expressions can be used in conjunction with
805 `message-subscribed-address-functions' and `message-subscribed-addresses'."
806   :version "22.1"
807   :group 'message-interface
808   :link '(custom-manual "(message)Mailing Lists")
809   :type '(repeat regexp))
810
811 (defcustom message-allow-no-recipients 'ask
812   "Specifies what to do when there are no recipients other than Gcc/Fcc.
813 If it is the symbol `always', the posting is allowed.  If it is the
814 symbol `never', the posting is not allowed.  If it is the symbol
815 `ask', you are prompted."
816   :version "22.1"
817   :group 'message-interface
818   :link '(custom-manual "(message)Message Headers")
819   :type '(choice (const always)
820                  (const never)
821                  (const ask)))
822
823 (defcustom message-sendmail-f-is-evil nil
824   "*Non-nil means don't add \"-f username\" to the sendmail command line.
825 Doing so would be even more evil than leaving it out."