(message-cite-prefix-regexp): Revert my last edit.
[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   :version "24.1"
254   :group 'message-mail
255   :group 'message-headers
256   :link '(custom-manual "(message)Wide Reply")
257   :type '(repeat regexp))
258
259 (defcustom message-deletable-headers '(Message-ID Date Lines)
260   "Headers to be deleted if they already exist and were generated by message previously."
261   :group 'message-headers
262   :link '(custom-manual "(message)Message Headers")
263   :type 'sexp)
264
265 (defcustom message-ignored-news-headers
266   "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
267   "*Regexp of headers to be removed unconditionally before posting."
268   :group 'message-news
269   :group 'message-headers
270   :link '(custom-manual "(message)Message Headers")
271   :type '(repeat :value-to-internal (lambda (widget value)
272                                       (custom-split-regexp-maybe value))
273                  :match (lambda (widget value)
274                           (or (stringp value)
275                               (widget-editable-list-match widget value)))
276                  regexp))
277
278 (defcustom message-ignored-mail-headers
279   "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
280   "*Regexp of headers to be removed unconditionally before mailing."
281   :group 'message-mail
282   :group 'message-headers
283   :link '(custom-manual "(message)Mail Headers")
284   :type 'regexp)
285
286 (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:"
287   "*Header lines matching this regexp will be deleted before posting.
288 It's best to delete old Path and Date headers before posting to avoid
289 any confusion."
290   :group 'message-interface
291   :link '(custom-manual "(message)Superseding")
292   :type '(repeat :value-to-internal (lambda (widget value)
293                                       (custom-split-regexp-maybe value))
294                  :match (lambda (widget value)
295                           (or (stringp value)
296                               (widget-editable-list-match widget value)))
297                  regexp))
298
299 (defcustom message-subject-re-regexp
300   "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
301   "*Regexp matching \"Re: \" in the subject line."
302   :group 'message-various
303   :link '(custom-manual "(message)Message Headers")
304   :type 'regexp)
305
306 ;;; Start of variables adopted from `message-utils.el'.
307
308 (defcustom message-subject-trailing-was-query 'ask
309   "*What to do with trailing \"(was: <old subject>)\" in subject lines.
310 If nil, leave the subject unchanged.  If it is the symbol `ask', query
311 the user what do do.  In this case, the subject is matched against
312 `message-subject-trailing-was-ask-regexp'.  If
313 `message-subject-trailing-was-query' is t, always strip the trailing
314 old subject.  In this case, `message-subject-trailing-was-regexp' is
315 used."
316   :version "22.1"
317   :type '(choice (const :tag "never" nil)
318                  (const :tag "always strip" t)
319                  (const ask))
320   :link '(custom-manual "(message)Message Headers")
321   :group 'message-various)
322
323 (defcustom message-subject-trailing-was-ask-regexp
324   "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
325   "*Regexp matching \"(was: <old subject>)\" in the subject line.
326
327 The function `message-strip-subject-trailing-was' uses this regexp if
328 `message-subject-trailing-was-query' is set to the symbol `ask'.  If
329 the variable is t instead of `ask', use
330 `message-subject-trailing-was-regexp' instead.
331
332 It is okay to create some false positives here, as the user is asked."
333   :version "22.1"
334   :group 'message-various
335   :link '(custom-manual "(message)Message Headers")
336   :type 'regexp)
337
338 (defcustom message-subject-trailing-was-regexp
339   "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
340   "*Regexp matching \"(was: <old subject>)\" in the subject line.
341
342 If `message-subject-trailing-was-query' is set to t, the subject is
343 matched against `message-subject-trailing-was-regexp' in
344 `message-strip-subject-trailing-was'.  You should use a regexp creating very
345 few false positives here."
346   :version "22.1"
347   :group 'message-various
348   :link '(custom-manual "(message)Message Headers")
349   :type 'regexp)
350
351 ;;; marking inserted text
352
353 (defcustom message-mark-insert-begin
354   "--8<---------------cut here---------------start------------->8---\n"
355   "How to mark the beginning of some inserted text."
356   :version "22.1"
357   :type 'string
358   :link '(custom-manual "(message)Insertion Variables")
359   :group 'message-various)
360
361 (defcustom message-mark-insert-end
362   "--8<---------------cut here---------------end--------------->8---\n"
363   "How to mark the end of some inserted text."
364   :version "22.1"
365   :type 'string
366   :link '(custom-manual "(message)Insertion Variables")
367   :group 'message-various)
368
369 (defcustom message-archive-header "X-No-Archive: Yes\n"
370   "Header to insert when you don't want your article to be archived.
371 Archives \(such as groups.google.com\) respect this header."
372   :version "22.1"
373   :type 'string
374   :link '(custom-manual "(message)Header Commands")
375   :group 'message-various)
376
377 (defcustom message-archive-note
378   "X-No-Archive: Yes - save http://groups.google.com/"
379   "Note to insert why you wouldn't want this posting archived.
380 If nil, don't insert any text in the body."
381   :version "22.1"
382   :type '(radio string (const nil))
383   :link '(custom-manual "(message)Header Commands")
384   :group 'message-various)
385
386 ;;; Crossposts and Followups
387 ;; inspired by JoH-followup-to by Jochem Huhman <joh  at gmx.de>
388 ;; new suggestions by R. Weikusat <rw at another.de>
389
390 (defvar message-cross-post-old-target nil
391   "Old target for cross-posts or follow-ups.")
392 (make-variable-buffer-local 'message-cross-post-old-target)
393
394 (defcustom message-cross-post-default t
395   "When non-nil `message-cross-post-followup-to' will perform a crosspost.
396 If nil, `message-cross-post-followup-to' will only do a followup.  Note that
397 you can explicitly override this setting by calling
398 `message-cross-post-followup-to' with a prefix."
399   :version "22.1"
400   :type 'boolean
401   :group 'message-various)
402
403 (defcustom message-cross-post-note "Crosspost & Followup-To: "
404   "Note to insert before signature to notify of cross-post and follow-up."
405   :version "22.1"
406   :type 'string
407   :group 'message-various)
408
409 (defcustom message-followup-to-note "Followup-To: "
410   "Note to insert before signature to notify of follow-up only."
411   :version "22.1"
412   :type 'string
413   :group 'message-various)
414
415 (defcustom message-cross-post-note-function 'message-cross-post-insert-note
416   "Function to use to insert note about Crosspost or Followup-To.
417 The function will be called with four arguments.  The function should not only
418 insert a note, but also ensure old notes are deleted.  See the documentation
419 for `message-cross-post-insert-note'."
420   :version "22.1"
421   :type 'function
422   :group 'message-various)
423
424 ;;; End of variables adopted from `message-utils.el'.
425
426 (defcustom message-signature-separator "^-- $"
427   "Regexp matching the signature separator.
428 This variable is used to strip off the signature from quoted text
429 when `message-cite-function' is
430 `message-cite-original-without-signature'.  Most useful values
431 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
432 whitespace)."
433   :type '(choice (const :tag "strict" "^-- $")
434                  (const :tag "loose" "^-- *$")
435                  regexp)
436   :version "22.3" ;; Gnus 5.10.12 (changed default)
437   :link '(custom-manual "(message)Various Message Variables")
438   :group 'message-various)
439
440 (defcustom message-elide-ellipsis "\n[...]\n\n"
441   "*The string which is inserted for elided text."
442   :type 'string
443   :link '(custom-manual "(message)Various Commands")
444   :group 'message-various)
445
446 (defcustom message-interactive t
447   "Non-nil means when sending a message wait for and display errors.
448 A value of nil means let mailer mail back a message to report errors."
449   :version "23.2"
450   :group 'message-sending
451   :group 'message-mail
452   :link '(custom-manual "(message)Sending Variables")
453   :type 'boolean)
454
455 (defcustom message-confirm-send nil
456   "When non-nil, ask for confirmation when sending a message."
457   :group 'message-sending
458   :group 'message-mail
459   :version "23.1" ;; No Gnus
460   :link '(custom-manual "(message)Sending Variables")
461   :type 'boolean)
462
463 (defcustom message-generate-new-buffers 'unsent
464   "*Say whether to create a new message buffer to compose a message.
465 Valid values include:
466
467 nil
468   Generate the buffer name in the Message way (e.g., *mail*, *news*,
469   *mail to whom*, *news on group*, etc.) and continue editing in the
470   existing buffer of that name.  If there is no such buffer, it will
471   be newly created.
472
473 `unique' or t
474   Create the new buffer with the name generated in the Message way.
475
476 `unsent'
477   Similar to `unique' but the buffer name begins with \"*unsent \".
478
479 `standard'
480   Similar to nil but the buffer name is simpler like *mail message*.
481
482 function
483   If this is a function, call that function with three parameters:
484   The type, the To address and the group name (any of these may be nil).
485   The function should return the new buffer name."
486   :version "24.1"
487   :group 'message-buffers
488   :link '(custom-manual "(message)Message Buffers")
489   :type '(choice (const nil)
490                  (sexp :tag "unique" :format "unique\n" :value unique
491                        :match (lambda (widget value) (memq value '(unique t))))
492                  (const unsent)
493                  (const standard)
494                  (function :format "\n    %{%t%}: %v")))
495
496 (defcustom message-kill-buffer-on-exit nil
497   "*Non-nil means that the message buffer will be killed after sending a message."
498   :group 'message-buffers
499   :link '(custom-manual "(message)Message Buffers")
500   :type 'boolean)
501
502 (defcustom message-kill-buffer-query t
503   "*Non-nil means that killing a modified message buffer has to be confirmed.
504 This is used by `message-kill-buffer'."
505   :version "23.1" ;; No Gnus
506   :group 'message-buffers
507   :type 'boolean)
508
509 (defvar gnus-local-organization)
510 (defcustom message-user-organization
511   (or (and (boundp 'gnus-local-organization)
512            (stringp gnus-local-organization)
513            gnus-local-organization)
514       (getenv "ORGANIZATION")
515       t)
516   "*String to be used as an Organization header.
517 If t, use `message-user-organization-file'."
518   :group 'message-headers
519   :type '(choice string
520                  (const :tag "consult file" t)))
521
522 (defcustom message-user-organization-file
523   (let (orgfile)
524     (dolist (f (list "/etc/organization"
525                      "/etc/news/organization"
526                      "/usr/lib/news/organization"))
527       (when (file-readable-p f)
528         (setq orgfile f)))
529     orgfile)
530   "*Local news organization file."
531   :type 'file
532   :link '(custom-manual "(message)News Headers")
533   :group 'message-headers)
534
535 (defcustom message-make-forward-subject-function
536   #'message-forward-subject-name-subject
537   "*List of functions called to generate subject headers for forwarded messages.
538 The subject generated by the previous function is passed into each
539 successive function.
540
541 The provided functions are:
542
543 * `message-forward-subject-author-subject' Source of article (author or
544       newsgroup), in brackets followed by the subject
545 * `message-forward-subject-name-subject' Source of article (name of author
546       or newsgroup), in brackets followed by the subject
547 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
548       to it."
549   :group 'message-forwarding
550   :link '(custom-manual "(message)Forwarding")
551   :type '(radio (function-item message-forward-subject-author-subject)
552                 (function-item message-forward-subject-fwd)
553                 (function-item message-forward-subject-name-subject)
554                 (repeat :tag "List of functions" function)))
555
556 (defcustom message-forward-as-mime t
557   "*Non-nil means forward messages as an inline/rfc822 MIME section.
558 Otherwise, directly inline the old message in the forwarded message."
559   :version "21.1"
560   :group 'message-forwarding
561   :link '(custom-manual "(message)Forwarding")
562   :type 'boolean)
563
564 (defcustom message-forward-show-mml 'best
565   "*Non-nil means show forwarded messages as MML (decoded from MIME).
566 Otherwise, forwarded messages are unchanged.
567 Can also be the symbol `best' to indicate that MML should be
568 used, except when it is a bad idea to use MML.  One example where
569 it is a bad idea is when forwarding a signed or encrypted
570 message, because converting MIME to MML would invalidate the
571 digital signature."
572   :version "21.1"
573   :group 'message-forwarding
574   :type '(choice (const :tag "use MML" t)
575                  (const :tag "don't use MML " nil)
576                  (const :tag "use MML when appropriate" best)))
577
578 (defcustom message-forward-before-signature t
579   "*Non-nil means put forwarded message before signature, else after."
580   :group 'message-forwarding
581   :type 'boolean)
582
583 (defcustom message-wash-forwarded-subjects nil
584   "*Non-nil means try to remove as much cruft as possible from the subject.
585 Done before generating the new subject of a forward."
586   :group 'message-forwarding
587   :link '(custom-manual "(message)Forwarding")
588   :type 'boolean)
589
590 (defcustom message-ignored-resent-headers
591   ;; `Delivered-To' needs to be removed because some mailers use it to
592   ;; detect loops, so if you resend a message to an address that ultimately
593   ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
594   ;; case you may be removed from the list on the grounds that mail to you
595   ;; bounced with a "mailing loop" error).
596   "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
597   "*All headers that match this regexp will be deleted when resending a message."
598   :group 'message-interface
599   :link '(custom-manual "(message)Resending")
600   :type '(repeat :value-to-internal (lambda (widget value)
601                                       (custom-split-regexp-maybe value))
602                  :match (lambda (widget value)
603                           (or (stringp value)
604                               (widget-editable-list-match widget value)))
605                  regexp))
606
607 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
608   "*All headers that match this regexp will be deleted when forwarding a message."
609   :version "21.1"
610   :group 'message-forwarding
611   :type '(repeat :value-to-internal (lambda (widget value)
612                                       (custom-split-regexp-maybe value))
613                  :match (lambda (widget value)
614                           (or (stringp value)
615                               (widget-editable-list-match widget value)))
616                  regexp))
617
618 (defcustom message-ignored-cited-headers "."
619   "*Delete these headers from the messages you yank."
620   :group 'message-insertion
621   :link '(custom-manual "(message)Insertion Variables")
622   :type 'regexp)
623
624 (defcustom message-cite-prefix-regexp
625   ;; Default to the value of `mail-citation-prefix-regexp' if available.
626   ;; Note: as for XEmacs 21.4 and 21.5, it is unavailable unless sendmail.el
627   ;; is loaded.
628   (cond ((boundp 'mail-citation-prefix-regexp)
629          mail-citation-prefix-regexp)
630         ((string-match "[[:digit:]]" "1")
631          ;; Support POSIX?  XEmacs 21.5.27 doesn't.
632          "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|}]\\)+")
633         (t
634          ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
635          (let (non-word-constituents)
636            (with-syntax-table text-mode-syntax-table
637              (setq non-word-constituents
638                    (concat
639                     (if (string-match "\\w" "_")  "" "_")
640                     (if (string-match "\\w" ".")  "" "."))))
641            (if (equal non-word-constituents "")
642                "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}]\\)+"
643              (concat "\\([ \t]*\\(\\w\\|["
644                      non-word-constituents
645                      "]\\)+>+\\|[ \t]*[]>|}]\\)+")))))
646   "*Regexp matching the longest possible citation prefix on a line."
647   :version "24.1"
648   :group 'message-insertion
649   :link '(custom-manual "(message)Insertion Variables")
650   :type 'regexp
651   :set (lambda (symbol value)
652          (prog1
653              (custom-set-default symbol value)
654            (if (boundp 'gnus-message-cite-prefix-regexp)
655                (setq gnus-message-cite-prefix-regexp
656                      (concat "^\\(?:" value "\\)"))))))
657
658 (defcustom message-cancel-message "I am canceling my own article.\n"
659   "Message to be inserted in the cancel message."
660   :group 'message-interface
661   :link '(custom-manual "(message)Canceling News")
662   :type 'string)
663
664 (defun message-send-mail-function ()
665   "Return suitable value for the variable `message-send-mail-function'."
666   (cond ((and (require 'sendmail)
667               (boundp 'sendmail-program)
668               sendmail-program
669               (executable-find sendmail-program))
670          'message-send-mail-with-sendmail)
671         ((and (locate-library "smtpmail")
672               (boundp 'smtpmail-default-smtp-server)
673               smtpmail-default-smtp-server)
674          'message-smtpmail-send-it)
675         ((locate-library "mailclient")
676          'message-send-mail-with-mailclient)
677         (t
678          (error "Don't know how to send mail.  Please customize `message-send-mail-function'"))))
679
680 ;; Useful to set in site-init.el
681 (defcustom message-send-mail-function
682   (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it)
683         ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it)
684         ((eq send-mail-function 'mailclient-send-it)
685          'message-send-mail-with-mailclient)
686         (t (message-send-mail-function)))
687   "Function to call to send the current buffer as mail.
688 The headers should be delimited by a line whose contents match the
689 variable `mail-header-separator'.
690
691 Valid values include `message-send-mail-with-sendmail'
692 `message-send-mail-with-mh', `message-send-mail-with-qmail',
693 `message-smtpmail-send-it', `smtpmail-send-it',
694 `feedmail-send-it' and `message-send-mail-with-mailclient'.  The
695 default is system dependent and determined by the function
696 `message-send-mail-function'.
697
698 See also `send-mail-function'."
699   :type '(radio (function-item message-send-mail-with-sendmail)
700                 (function-item message-send-mail-with-mh)
701                 (function-item message-send-mail-with-qmail)
702                 (function-item message-smtpmail-send-it)
703                 (function-item smtpmail-send-it)
704                 (function-item feedmail-send-it)
705                 (function-item message-send-mail-with-mailclient
706                                :tag "Use Mailclient package")
707                 (function :tag "Other"))
708   :group 'message-sending
709   :version "23.2"
710   :initialize 'custom-initialize-default
711   :link '(custom-manual "(message)Mail Variables")
712   :group 'message-mail)
713
714 (defcustom message-send-news-function 'message-send-news
715   "Function to call to send the current buffer as news.
716 The headers should be delimited by a line whose contents match the
717 variable `mail-header-separator'."
718   :group 'message-sending
719   :group 'message-news
720   :link '(custom-manual "(message)News Variables")
721   :type 'function)
722
723 (defcustom message-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)Reply")
729   :type '(choice function (const nil)))
730
731 (defcustom message-wide-reply-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)Wide Reply")
737   :type '(choice function (const nil)))
738
739 (defcustom message-followup-to-function nil
740   "If non-nil, function that should return a list of headers.
741 This function should pick out addresses from the To, Cc, and From headers
742 and respond with new To and Cc headers."
743   :group 'message-interface
744   :link '(custom-manual "(message)Followup")
745   :type '(choice function (const nil)))
746
747 (defcustom message-extra-wide-headers nil
748   "If non-nil, a list of additional address headers.
749 These are used when composing a wide reply."
750   :group 'message-sending
751   :type '(repeat string))
752
753 (defcustom message-use-followup-to 'ask
754   "*Specifies what to do with Followup-To header.
755 If nil, always ignore the header.  If it is t, use its value, but
756 query before using the \"poster\" value.  If it is the symbol `ask',
757 always query the user whether to use the value.  If it is the symbol
758 `use', always use the value."
759   :group 'message-interface
760   :link '(custom-manual "(message)Followup")
761   :type '(choice (const :tag "ignore" nil)
762                  (const :tag "use & query" t)
763                  (const use)
764                  (const ask)))
765
766 (defcustom message-use-mail-followup-to 'use
767   "*Specifies what to do with Mail-Followup-To header.
768 If nil, always ignore the header.  If it is the symbol `ask', always
769 query the user whether to use the value.  If it is the symbol `use',
770 always use the value."
771   :version "22.1"
772   :group 'message-interface
773   :link '(custom-manual "(message)Mailing Lists")
774   :type '(choice (const :tag "ignore" nil)
775                  (const use)
776                  (const ask)))
777
778 (defcustom message-subscribed-address-functions nil
779   "*Specifies functions for determining list subscription.
780 If nil, do not attempt to determine list subscription with functions.
781 If non-nil, this variable contains a list of functions which return
782 regular expressions to match lists.  These functions can be used in
783 conjunction with `message-subscribed-regexps' and
784 `message-subscribed-addresses'."
785   :version "22.1"
786   :group 'message-interface
787   :link '(custom-manual "(message)Mailing Lists")
788   :type '(repeat sexp))
789
790 (defcustom message-subscribed-address-file nil
791   "*A file containing addresses the user is subscribed to.
792 If nil, do not look at any files to determine list subscriptions.  If
793 non-nil, each line of this file should be a mailing list address."
794   :version "22.1"
795   :group 'message-interface
796   :link '(custom-manual "(message)Mailing Lists")
797   :type '(radio file (const nil)))
798
799 (defcustom message-subscribed-addresses nil
800   "*Specifies a list of addresses the user is subscribed to.
801 If nil, do not use any predefined list subscriptions.  This list of
802 addresses can be used in conjunction with
803 `message-subscribed-address-functions' and `message-subscribed-regexps'."
804   :version "22.1"
805   :group 'message-interface
806   :link '(custom-manual "(message)Mailing Lists")
807   :type '(repeat string))
808
809 (defcustom message-subscribed-regexps nil
810   "*Specifies a list of addresses the user is subscribed to.
811 If nil, do not use any predefined list subscriptions.  This list of
812 regular expressions can be used in conjunction with
813 `message-subscribed-address-functions' and `message-subscribed-addresses'."
814   :version "22.1"
815   :group 'message-interface
816   :link '(custom-manual "(message)Mailing Lists")
817   :type '(repeat regexp))
818
819 (defcustom message-allow-no-recipients 'ask
820   "Specifies what to do when there are no recipients other than Gcc/Fcc.
821 If it is the symbol `always', the posting is allowed.  If it is the
822 symbol `never', the posting is not allowed.  If it is the symbol
823 `ask', you are prompted."
824   :version "22.1"
825   :group 'message-interface
826   :link '(custom-manual "(message)Message Headers")
827   :type '(choice (const always)
828                  (const never)
829                  (const ask)))
830
831 (defcustom message-sendmail-f-is-evil nil
832   "*Non-nil means don't add \"-f username\" to the sendmail command line.
833 Doing so would be even more evil than leaving it out."
834   :group 'message-sending
835   :link '(custom-manual "(message)Mail Variables")
836   :type 'boolean)
837
838 (defcustom message-sendmail-envelope-from nil
839   "*Envelope-from when sending mail with sendmail.
840 If this is nil, use `user-mail-address'.  If it is the symbol
841 `header', use the From: header of the message."
842   :version "23.2"
843   :type '(choice (string :tag "From name")
844                  (const :tag "Use From: header from message" header)
845                  (const :tag "Use `user-mail-address'" nil))
846   :link '(custom-manual "(message)Mail Variables")
847   :group 'message-sending)
848
849 (defcustom message-sendmail-extra-arguments nil
850   "Additional arguments to `sendmail-program'."
851   ;; E.g. '("-a" "account") for msmtp
852   :version "23.1" ;; No Gnus
853   :type '(repeat string)
854   ;; :link '(custom-manual "(message)Mail Variables")
855   :group 'message-sending)
856
857 ;; qmail-related stuff
858 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
859   "Location of the qmail-inject program."
860   :group 'message-sending
861   :link '(custom-manual "(message)Mail Variables")
862   :type 'file)
863
864 (defcustom message-qmail-inject-args nil
865   "Arguments passed to qmail-inject programs.
866 This should be a list of strings, one string for each argument.
867 It may also be a function.
868
869 For e.g., if you wish to set the envelope sender address so that bounces
870 go to the right place or to deal with listserv's usage of that address, you
871 might set this variable to '(\"-f\" \"you@some.where\")."
872   :group 'message-sending
873   :link '(custom-manual "(message)Mail Variables")
874   :type '(choice (function)
875                  (repeat string)))
876
877 (defvar gnus-post-method)
878 (defvar gnus-select-method)
879 (defcustom message-post-method
880   (cond ((and (boundp 'gnus-post-method)
881               (listp gnus-post-method)
882               gnus-post-method)
883          gnus-post-method)
884         ((boundp 'gnus-select-method)
885          gnus-select-method)
886         (t '(nnspool "")))
887   "*Method used to post news.
888 Note that when posting from inside Gnus, for instance, this
889 variable isn't used."
890   :group 'message-news
891   :group 'message-sending
892   ;; This should be the `gnus-select-method' widget, but that might
893   ;; create a dependence to `gnus.el'.
894   :type 'sexp)
895
896 ;; FIXME: This should be a temporary workaround until someone implements a
897 ;; proper solution.  If a crash happens while replying, the auto-save file
898 ;; will *not* have a `References:' header if `message-generate-headers-first'
899 ;; is nil.  See: http://article.gmane.org/gmane.emacs.gnus.general/51138
900 (defcustom message-generate-headers-first '(references)
901   "Which headers should be generated before starting to compose a message.
902 If t, generate all required headers.  This can also be a list of headers to
903 generate.  The variables `message-required-news-headers' and
904 `message-required-mail-headers' specify which headers to generate.
905
906 Note that the variable `message-deletable-headers' specifies headers which
907 are to be deleted and then re-generated before sending, so this variable
908 will not have a visible effect for those headers."
909   :group 'message-headers
910   :link '(custom-manual "(message)Message Headers")
911   :type '(choice (const :tag "None" nil)
912                  (const :tag "References" '(references))
913                  (const :tag "All" t)
914                  (repeat (sexp :tag "Header"))))
915
916 (defcustom message-fill-column 72
917   "Column beyond which automatic line-wrapping should happen.
918 Local value for message buffers.  If non-nil, also turn on
919 auto-fill in message buffers."
920   :group 'message-various
921   ;; :link '(custom-manual "(message)Message Headers")
922   :type '(choice (const :tag "Don't turn on auto fill" nil)
923                  (integer)))
924
925 (defcustom message-setup-hook nil
926   "Normal hook, run each time a new outgoing message is initialized.
927 The function `message-setup' runs this hook."
928   :group 'message-various
929   :link '(custom-manual "(message)Various Message Variables")
930   :type 'hook)
931
932 (defcustom message-cancel-hook nil
933   "Hook run when cancelling articles."
934   :group 'message-various
935   :link '(custom-manual "(message)Various Message Variables")
936   :type 'hook)
937
938 (defcustom message-signature-setup-hook nil
939   "Normal hook, run each time a new outgoing message is initialized.
940 It is run after the headers have been inserted and before
941 the signature is inserted."
942   :group 'message-various
943   :link '(custom-manual "(message)Various Message Variables")
944   :type 'hook)
945
946 (defcustom message-mode-hook nil
947   "Hook run in message mode buffers."
948   :group 'message-various
949   :type 'hook)
950
951 (defcustom message-header-hook nil
952   "Hook run in a message mode buffer narrowed to the headers."
953   :group 'message-various
954   :type 'hook)
955
956 (defcustom message-header-setup-hook nil
957   "Hook called narrowed to the headers when setting up a message buffer."
958   :group 'message-various
959   :link '(custom-manual "(message)Various Message Variables")
960   :type 'hook)
961
962 (defcustom message-minibuffer-local-map
963   (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
964     (set-keymap-parent map minibuffer-local-map)
965     map)
966   "Keymap for `message-read-from-minibuffer'."
967   :version "22.1"
968   :group 'message-various)
969
970 (defcustom message-citation-line-function 'message-insert-citation-line
971   "*Function called to insert the \"Whomever writes:\" line.
972
973 Predefined functions include `message-insert-citation-line' and
974 `message-insert-formatted-citation-line' (see the variable
975 `message-citation-line-format').
976
977 Note that Gnus provides a feature where the reader can click on
978 `writes:' to hide the cited text.  If you change this line too much,
979 people who read your message will have to change their Gnus
980 configuration.  See the variable `gnus-cite-attribution-suffix'."
981   :type '(choice
982           (function-item :tag "plain" message-insert-citation-line)
983           (function-item :tag "formatted" message-insert-formatted-citation-line)
984           (function :tag "Other"))
985   :link '(custom-manual "(message)Insertion Variables")
986   :group 'message-insertion)
987
988 (defcustom message-citation-line-format "On %a, %b %d %Y, %N wrote:\n"
989   "Format of the \"Whomever writes:\" line.
990
991 The string is formatted using `format-spec'.  The following
992 constructs are replaced:
993
994   %f   The full From, e.g. \"John Doe <john.doe@example.invalid>\".
995   %n   The mail address, e.g. \"john.doe@example.invalid\".
996   %N   The real name if present, e.g.: \"John Doe\", else fall
997        back to the mail address.
998   %F   The first name if present, e.g.: \"John\".
999   %L   The last name if present, e.g.: \"Doe\".
1000
1001 All other format specifiers are passed to `format-time-string'
1002 which is called using the date from the article your replying to.
1003 Extracting the first (%F) and last name (%L) is done
1004 heuristically, so you should always check it yourself.
1005
1006 Please also read the note in the documentation of
1007 `message-citation-line-function'."
1008   :type '(choice (const :tag "Plain" "%f writes:")
1009                  (const :tag "Include date" "On %a, %b %d %Y, %n wrote:")
1010                  string)
1011   :link '(custom-manual "(message)Insertion Variables")
1012   :version "23.1" ;; No Gnus
1013   :group 'message-insertion)
1014
1015 (defcustom message-yank-prefix "> "
1016   "*Prefix inserted on the lines of yanked messages.
1017 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1018 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
1019   :version "23.2"
1020   :type 'string
1021   :link '(custom-manual "(message)Insertion Variables")
1022   :group 'message-insertion)
1023
1024 (defcustom message-yank-cited-prefix ">"
1025   "*Prefix inserted on cited lines of yanked messages.
1026 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1027 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1028   :version "22.1"
1029   :type 'string
1030   :link '(custom-manual "(message)Insertion Variables")
1031   :group 'message-insertion)
1032
1033 (defcustom message-yank-empty-prefix ">"
1034   "*Prefix inserted on empty lines of yanked messages.
1035 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1036   :version "22.1"
1037   :type 'string
1038   :link '(custom-manual "(message)Insertion Variables")
1039   :group 'message-insertion)
1040
1041 (defcustom message-indentation-spaces 3
1042   "*Number of spaces to insert at the beginning of each cited line.
1043 Used by `message-yank-original' via `message-yank-cite'."
1044   :version "23.2"
1045   :group 'message-insertion
1046   :link '(custom-manual "(message)Insertion Variables")
1047   :type 'integer)
1048
1049 (defcustom message-cite-function 'message-cite-original-without-signature
1050   "*Function for citing an original message.
1051 Predefined functions include `message-cite-original' and
1052 `message-cite-original-without-signature'.
1053 Note that these functions use `mail-citation-hook' if that is non-nil."
1054   :type '(radio (function-item message-cite-original)
1055                 (function-item message-cite-original-without-signature)
1056                 (function-item sc-cite-original)
1057                 (function :tag "Other"))
1058   :link '(custom-manual "(message)Insertion Variables")
1059   :version "22.3" ;; Gnus 5.10.12 (changed default)
1060   :group 'message-insertion)
1061
1062 (defcustom message-indent-citation-function 'message-indent-citation
1063   "*Function for modifying a citation just inserted in the mail buffer.
1064 This can also be a list of functions.  Each function can find the
1065 citation between (point) and (mark t).  And each function should leave
1066 point and mark around the citation text as modified."
1067   :type 'function
1068   :link '(custom-manual "(message)Insertion Variables")
1069   :group 'message-insertion)
1070
1071 (defcustom message-signature t
1072   "*String to be inserted at the end of the message buffer.
1073 If t, the `message-signature-file' file will be inserted instead.
1074 If a function, the result from the function will be used instead.
1075 If a form, the result from the form will be used instead."
1076   :version "23.2"
1077   :type 'sexp
1078   :link '(custom-manual "(message)Insertion Variables")
1079   :group 'message-insertion)
1080
1081 (defcustom message-signature-file "~/.signature"
1082   "*Name of file containing the text inserted at end of message buffer.
1083 Ignored if the named file doesn't exist.
1084 If nil, don't insert a signature.
1085 If a path is specified, the value of `message-signature-directory' is ignored,
1086 even if set."
1087   :version "23.2"
1088   :type '(choice file (const :tags "None" nil))
1089   :link '(custom-manual "(message)Insertion Variables")
1090   :group 'message-insertion)
1091
1092 (defcustom message-signature-directory nil
1093   "*Name of directory containing signature files.
1094 Comes in handy if you have many such files, handled via posting styles for
1095 instance.
1096 If nil, `message-signature-file' is expected to specify the directory if
1097 needed."
1098   :type '(choice string (const :tags "None" nil))
1099   :link '(custom-manual "(message)Insertion Variables")
1100   :group 'message-insertion)
1101
1102 (defcustom message-signature-insert-empty-line t
1103   "*If non-nil, insert an empty line before the signature separator."
1104   :version "22.1"
1105   :type 'boolean
1106   :link '(custom-manual "(message)Insertion Variables")
1107   :group 'message-insertion)
1108
1109 (defcustom message-distribution-function nil
1110   "*Function called to return a Distribution header."
1111   :group 'message-news
1112   :group 'message-headers
1113   :link '(custom-manual "(message)News Headers")
1114   :type '(choice function (const nil)))
1115
1116 (defcustom message-expires 14
1117   "Number of days before your article expires."
1118   :group 'message-news
1119   :group 'message-headers
1120   :link '(custom-manual "(message)News Headers")
1121   :type 'integer)
1122
1123 (defcustom message-user-path nil
1124   "If nil, use the NNTP server name in the Path header.
1125 If stringp, use this; if non-nil, use no host name (user name only)."
1126   :group 'message-news
1127   :group 'message-headers
1128   :link '(custom-manual "(message)News Headers")
1129   :type '(choice (const :tag "nntp" nil)
1130                  (string :tag "name")
1131                  (sexp :tag "none" :format "%t" t)))
1132
1133 ;; This can be the name of a buffer, or a cons cell (FUNCTION . ARGS)
1134 ;; for yanking the original buffer.
1135 (defvar message-reply-buffer nil)
1136 (defvar message-reply-headers nil
1137   "The headers of the current replied article.
1138 It is a vector of the following headers:
1139 \[number subject from date id references chars lines xref extra].")
1140 (defvar message-newsreader nil)
1141 (defvar message-mailer nil)
1142 (defvar message-sent-message-via nil)
1143 (defvar message-checksum nil)
1144 (defvar message-send-actions nil
1145   "A list of actions to be performed upon successful sending of a message.")
1146 (defvar message-exit-actions nil
1147   "A list of actions to be performed upon exiting after sending a message.")
1148 (defvar message-kill-actions nil
1149   "A list of actions to be performed before killing a message buffer.")
1150 (defvar message-postpone-actions nil
1151   "A list of actions to be performed after postponing a message.")
1152
1153 (define-widget 'message-header-lines 'text
1154   "All header lines must be LFD terminated."
1155   :format "%{%t%}:%n%v"
1156   :valid-regexp "^\\'"
1157   :error "All header lines must be newline terminated")
1158
1159 (defcustom message-default-headers ""
1160   "*A string containing header lines to be inserted in outgoing messages.
1161 It is inserted before you edit the message, so you can edit or delete
1162 these lines."
1163   :version "23.2"
1164   :group 'message-headers
1165   :link '(custom-manual "(message)Message Headers")
1166   :type 'message-header-lines)
1167
1168 (defcustom message-default-mail-headers
1169   ;; Ease the transition from mail-mode to message-mode.  See bugs#4431, 5555.
1170   (concat (if (and (boundp 'mail-default-reply-to)
1171                    (stringp mail-default-reply-to))
1172               (format "Reply-to: %s\n" mail-default-reply-to))
1173           (if (and (boundp 'mail-self-blind)
1174                    mail-self-blind)
1175               (format "BCC: %s\n" user-mail-address))
1176           (if (and (boundp 'mail-archive-file-name)
1177                    (stringp mail-archive-file-name))
1178               (format "FCC: %s\n" mail-archive-file-name))
1179           ;; Use the value of `mail-default-headers' if available.
1180           ;; Note: as for Emacs 21, XEmacs 21.4 and 21.5, it is
1181           ;; unavailable unless sendmail.el is loaded.
1182           (if (boundp 'mail-default-headers)
1183               mail-default-headers))
1184   "*A string of header lines to be inserted in outgoing mails."
1185   :version "23.2"
1186   :group 'message-headers
1187   :group 'message-mail
1188   :link '(custom-manual "(message)Mail Headers")
1189   :type 'message-header-lines)
1190
1191 (defcustom message-default-news-headers ""
1192   "*A string of header lines to be inserted in outgoing news articles."
1193   :group 'message-headers
1194   :group 'message-news
1195   :link '(custom-manual "(message)News Headers")
1196   :type 'message-header-lines)
1197
1198 ;; Note: could use /usr/ucb/mail instead of sendmail;
1199 ;; options -t, and -v if not interactive.
1200 (defcustom message-mailer-swallows-blank-line
1201   (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1202                          system-configuration)
1203            (file-readable-p "/etc/sendmail.cf")
1204            (let ((buffer (get-buffer-create " *temp*")))
1205              (unwind-protect
1206                  (with-current-buffer buffer
1207                    (insert-file-contents "/etc/sendmail.cf")
1208                    (goto-char (point-min))
1209                    (let ((case-fold-search nil))
1210                      (re-search-forward "^OR\\>" nil t)))
1211                (kill-buffer buffer))))
1212       ;; According to RFC822, "The field-name must be composed of printable
1213       ;; ASCII characters (i. e., characters that have decimal values between
1214       ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1215       ;; space, or colon.
1216       '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1217   "*Set this non-nil if the system's mailer runs the header and body together.
1218 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1219 The value should be an expression to test whether the problem will
1220 actually occur."
1221   :group 'message-sending
1222   :link '(custom-manual "(message)Mail Variables")
1223   :type 'sexp)
1224
1225 ;;;###autoload
1226 (define-mail-user-agent 'message-user-agent
1227   'message-mail 'message-send-and-exit
1228   'message-kill-buffer 'message-send-hook)
1229
1230 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1231   "If non-nil, delete the deletable headers before feeding to mh.")
1232
1233 (defvar message-send-method-alist
1234   '((news message-news-p message-send-via-news)
1235     (mail message-mail-p message-send-via-mail))
1236   "Alist of ways to send outgoing messages.
1237 Each element has the form
1238
1239   \(TYPE PREDICATE FUNCTION)
1240
1241 where TYPE is a symbol that names the method; PREDICATE is a function
1242 called without any parameters to determine whether the message is
1243 a message of type TYPE; and FUNCTION is a function to be called if
1244 PREDICATE returns non-nil.  FUNCTION is called with one parameter --
1245 the prefix.")
1246
1247 (defcustom message-mail-alias-type 'abbrev
1248   "*What alias expansion type to use in Message buffers.
1249 The default is `abbrev', which uses mailabbrev.  `ecomplete' uses
1250 an electric completion mode.  nil switches mail aliases off.
1251 This can also be a list of values."
1252   :group 'message
1253   :link '(custom-manual "(message)Mail Aliases")
1254   :type '(choice (const :tag "Use Mailabbrev" abbrev)
1255                  (const :tag "Use ecomplete" ecomplete)
1256                  (const :tag "No expansion" nil)))
1257
1258 (defcustom message-self-insert-commands '(self-insert-command)
1259   "List of `self-insert-command's used to trigger ecomplete.
1260 When one of those commands is invoked to enter a character in To or Cc
1261 header, ecomplete will suggest the candidates of recipients (see also
1262 `message-mail-alias-type').  If you use some tool to enter non-ASCII
1263 text and it replaces `self-insert-command' with the other command, e.g.
1264 `egg-self-insert-command', you may want to add it to this list."
1265   :group 'message-various
1266   :type '(repeat function))
1267
1268 (defcustom message-auto-save-directory
1269   (file-name-as-directory (expand-file-name "drafts" message-directory))
1270   "*Directory where Message auto-saves buffers if Gnus isn't running.
1271 If nil, Message won't auto-save."
1272   :group 'message-buffers
1273   :link '(custom-manual "(message)Various Message Variables")
1274   :type '(choice directory (const :tag "Don't auto-save" nil)))
1275
1276 (defcustom message-default-charset
1277   (and (not (mm-multibyte-p)) 'iso-8859-1)
1278   "Default charset used in non-MULE Emacsen.
1279 If nil, you might be asked to input the charset."
1280   :version "21.1"
1281   :group 'message
1282   :link '(custom-manual "(message)Various Message Variables")
1283   :type 'symbol)
1284
1285 (defcustom message-dont-reply-to-names
1286   (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1287   "*Addresses to prune when doing wide replies.
1288 This can be a regexp or a list of regexps.  Also, a value of nil means
1289 exclude your own user name only."
1290   :version "21.1"
1291   :group 'message
1292   :link '(custom-manual "(message)Wide Reply")
1293   :type '(choice (const :tag "Yourself" nil)
1294                  regexp
1295                  (repeat :tag "Regexp List" regexp)))
1296
1297 (defsubst message-dont-reply-to-names ()
1298   (gmm-regexp-concat message-dont-reply-to-names))
1299
1300 (defvar message-shoot-gnksa-feet nil
1301   "*A list of GNKSA feet you are allowed to shoot.
1302 Gnus gives you all the opportunity you could possibly want for
1303 shooting yourself in the foot.  Also, Gnus allows you to shoot the
1304 feet of Good Net-Keeping Seal of Approval.  The following are foot
1305 candidates:
1306 `empty-article'     Allow you to post an empty article;
1307 `quoted-text-only'  Allow you to post quoted text only;
1308 `multiple-copies'   Allow you to post multiple copies;
1309 `cancel-messages'   Allow you to cancel or supersede messages from
1310                     your other email addresses.")
1311
1312 (defsubst message-gnksa-enable-p (feature)
1313   (or (not (listp message-shoot-gnksa-feet))
1314       (memq feature message-shoot-gnksa-feet)))
1315
1316 (defcustom message-hidden-headers '("^References:" "^Face:" "^X-Face:"
1317                                     "^X-Draft-From:")
1318   "Regexp of headers to be hidden when composing new messages.
1319 This can also be a list of regexps to match headers.  Or a list
1320 starting with `not' and followed by regexps."
1321   :version "22.1"
1322   :group 'message
1323   :link '(custom-manual "(message)Message Headers")
1324   :type '(choice
1325           :format "%{%t%}: %[Value Type%] %v"
1326           (regexp :menu-tag "regexp" :format "regexp\n%t: %v")
1327           (repeat :menu-tag "(regexp ...)" :format "(regexp ...)\n%v%i"
1328                   (regexp :format "%t: %v"))
1329           (cons :menu-tag "(not regexp ...)" :format "(not regexp ...)\n%v"
1330                 (const not)
1331                 (repeat :format "%v%i"
1332                         (regexp :format "%t: %v")))))
1333
1334 (defcustom message-cite-articles-with-x-no-archive t
1335   "If non-nil, cite text from articles that has X-No-Archive set."
1336   :group 'message
1337   :type 'boolean)
1338
1339 ;;; Internal variables.
1340 ;;; Well, not really internal.
1341
1342 (defvar message-mode-syntax-table
1343   (let ((table (copy-syntax-table text-mode-syntax-table)))
1344     (modify-syntax-entry ?% ". " table)
1345     (modify-syntax-entry ?> ". " table)
1346     (modify-syntax-entry ?< ". " table)
1347     table)
1348   "Syntax table used while in Message mode.")
1349
1350 (defface message-header-to
1351   '((((class color)
1352       (background dark))
1353      (:foreground "DarkOliveGreen1" :bold t))
1354     (((class color)
1355       (background light))
1356      (:foreground "MidnightBlue" :bold t))
1357     (t
1358      (:bold t :italic t)))
1359   "Face used for displaying From headers."
1360   :group 'message-faces)
1361 ;; backward-compatibility alias
1362 (put 'message-header-to-face 'face-alias 'message-header-to)
1363 (put 'message-header-to-face 'obsolete-face "22.1")
1364
1365 (defface message-header-cc
1366   '((((class color)
1367       (background dark))
1368      (:foreground "chartreuse1" :bold t))
1369     (((class color)
1370       (background light))
1371      (:foreground "MidnightBlue"))
1372     (t
1373      (:bold t)))
1374   "Face used for displaying Cc headers."
1375   :group 'message-faces)
1376 ;; backward-compatibility alias
1377 (put 'message-header-cc-face 'face-alias 'message-header-cc)
1378 (put 'message-header-cc-face 'obsolete-face "22.1")
1379
1380 (defface message-header-subject
1381   '((((class color)
1382       (background dark))
1383      (:foreground "OliveDrab1"))
1384     (((class color)
1385       (background light))
1386      (:foreground "navy blue" :bold t))
1387     (t
1388      (:bold t)))
1389   "Face used for displaying subject headers."
1390   :group 'message-faces)
1391 ;; backward-compatibility alias
1392 (put 'message-header-subject-face 'face-alias 'message-header-subject)
1393 (put 'message-header-subject-face 'obsolete-face "22.1")
1394
1395 (defface message-header-newsgroups
1396   '((((class color)
1397       (background dark))
1398      (:foreground "yellow" :bold t :italic t))
1399     (((class color)
1400       (background light))
1401      (:foreground "blue4" :bold t :italic t))
1402     (t
1403      (:bold t :italic t)))
1404   "Face used for displaying newsgroups headers."
1405   :group 'message-faces)
1406 ;; backward-compatibility alias
1407 (put 'message-header-newsgroups-face 'face-alias 'message-header-newsgroups)
1408 (put 'message-header-newsgroups-face 'obsolete-face "22.1")
1409
1410 (defface message-header-other
1411   '((((class color)
1412       (background dark))
1413      (:foreground "VioletRed1"))
1414     (((class color)
1415       (background light))
1416      (:foreground "steel blue"))
1417     (t
1418      (:bold t :italic t)))
1419   "Face used for displaying newsgroups headers."
1420   :group 'message-faces)
1421 ;; backward-compatibility alias
1422 (put 'message-header-other-face 'face-alias 'message-header-other)
1423 (put 'message-header-other-face 'obsolete-face "22.1")
1424
1425 (defface message-header-name
1426   '((((class color)
1427       (background dark))
1428      (:foreground "green"))
1429     (((class color)
1430       (background light))
1431      (:foreground "cornflower blue"))
1432     (t
1433      (:bold t)))
1434   "Face used for displaying header names."
1435   :group 'message-faces)
1436 ;; backward-compatibility alias
1437 (put 'message-header-name-face 'face-alias 'message-header-name)
1438 (put 'message-header-name-face 'obsolete-face "22.1")
1439
1440 (defface message-header-xheader
1441   '((((class color)
1442       (background dark))
1443      (:foreground "DeepSkyBlue1"))
1444     (((class color)
1445       (background light))
1446      (:foreground "blue"))
1447     (t
1448      (:bold t)))
1449   "Face used for displaying X-Header headers."
1450   :group 'message-faces)
1451 ;; backward-compatibility alias
1452 (put 'message-header-xheader-face 'face-alias 'message-header-xheader)
1453 (put 'message-header-xheader-face 'obsolete-face "22.1")
1454
1455 (defface message-separator
1456   '((((class color)
1457       (background dark))
1458      (:foreground "LightSkyBlue1"))
1459     (((class color)
1460       (background light))
1461      (:foreground "brown"))
1462     (t
1463      (:bold t)))
1464   "Face used for displaying the separator."
1465   :group 'message-faces)
1466 ;; backward-compatibility alias
1467 (put 'message-separator-face 'face-alias 'message-separator)
1468 (put 'message-separator-face 'obsolete-face "22.1")
1469
1470 (defface message-cited-text
1471   '((((class color)
1472       (background dark))
1473      (:foreground "LightPink1"))
1474     (((class color)
1475       (background light))
1476      (:foreground "red"))
1477     (t
1478      (:bold t)))
1479   "Face used for displaying cited text names."
1480   :group 'message-faces)
1481 ;; backward-compatibility alias
1482 (put 'message-cited-text-face 'face-alias 'message-cited-text)
1483 (put 'message-cited-text-face 'obsolete-face "22.1")
1484
1485 (defface message-mml
1486   '((((class color)
1487       (background dark))
1488      (:foreground "MediumSpringGreen"))
1489     (((class color)
1490       (background light))
1491      (:foreground "ForestGreen"))
1492     (t
1493      (:bold t)))
1494   "Face used for displaying MML."
1495   :group 'message-faces)
1496 ;; backward-compatibility alias
1497 (put 'message-mml-face 'face-alias 'message-mml)
1498 (put 'message-mml-face 'obsolete-face "22.1")
1499
1500 (defun message-font-lock-make-header-matcher (regexp)
1501   (let ((form
1502          `(lambda (limit)
1503             (let ((start (point)))
1504               (save-restriction
1505                 (widen)
1506                 (goto-char (point-min))
1507                 (if (re-search-forward
1508                      (concat "^" (regexp-quote mail-header-separator) "$")
1509                      nil t)
1510                     (setq limit (min limit (match-beginning 0))))
1511                 (goto-char start))
1512               (and (< start limit)
1513                    (re-search-forward ,regexp limit t))))))
1514     (if (featurep 'bytecomp)
1515         (byte-compile form)
1516       form)))
1517
1518 (defvar message-font-lock-keywords
1519   (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1520     `((,(message-font-lock-make-header-matcher
1521          (concat "^\\([Tt]o:\\)" content))
1522        (1 'message-header-name)
1523        (2 'message-header-to nil t))
1524       (,(message-font-lock-make-header-matcher
1525          (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1526        (1 'message-header-name)
1527        (2 'message-header-cc nil t))
1528       (,(message-font-lock-make-header-matcher
1529          (concat "^\\([Ss]ubject:\\)" content))
1530        (1 'message-header-name)
1531        (2 'message-header-subject nil t))
1532       (,(message-font-lock-make-header-matcher
1533          (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content))
1534        (1 'message-header-name)
1535        (2 'message-header-newsgroups nil t))
1536       (,(message-font-lock-make-header-matcher
1537          (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content))
1538        (1 'message-header-name)
1539        (2 'message-header-xheader))
1540       (,(message-font-lock-make-header-matcher
1541          (concat "^\\([A-Z][^: \n\t]+:\\)" content))
1542        (1 'message-header-name)
1543        (2 'message-header-other nil t))
1544       ,@(if (and mail-header-separator
1545                  (not (equal mail-header-separator "")))
1546             `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
1547                1 'message-separator))
1548           nil)
1549       ((lambda (limit)
1550          (re-search-forward (concat "^\\("
1551                                     message-cite-prefix-regexp
1552                                     "\\).*")
1553                             limit t))
1554        (0 'message-cited-text))
1555       ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1556        (0 'message-mml))))
1557   "Additional expressions to highlight in Message mode.")
1558
1559
1560 ;; XEmacs does it like this.  For Emacs, we have to set the
1561 ;; `font-lock-defaults' buffer-local variable.
1562 (put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
1563
1564 (defvar message-face-alist
1565   '((bold . message-bold-region)
1566     (underline . underline-region)
1567     (default . (lambda (b e)
1568                  (message-unbold-region b e)
1569                  (ununderline-region b e))))
1570   "Alist of mail and news faces for facemenu.
1571 The cdr of each entry is a function for applying the face to a region.")
1572
1573 (defcustom message-send-hook nil
1574   "Hook run before sending messages.
1575 This hook is run quite early when sending."
1576   :group 'message-various
1577   :options '(ispell-message)
1578   :link '(custom-manual "(message)Various Message Variables")
1579   :type 'hook)
1580
1581 (defcustom message-send-mail-hook nil
1582   "Hook run before sending mail messages.
1583 This hook is run very late -- just before the message is sent as
1584 mail."
1585   :group 'message-various
1586   :link '(custom-manual "(message)Various Message Variables")
1587   :type 'hook)
1588
1589 (defcustom message-send-news-hook nil
1590   "Hook run before sending news messages.
1591 This hook is run very late -- just before the message is sent as
1592 news."
1593   :group 'message-various
1594   :link '(custom-manual "(message)Various Message Variables")
1595   :type 'hook)
1596
1597 (defcustom message-sent-hook nil
1598   "Hook run after sending messages."
1599   :group 'message-various
1600   :type 'hook)
1601
1602 (defvar message-send-coding-system 'binary
1603   "Coding system to encode outgoing mail.")
1604
1605 (defvar message-draft-coding-system
1606   mm-auto-save-coding-system
1607   "*Coding system to compose mail.
1608 If you'd like to make it possible to share draft files between XEmacs
1609 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1610 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1611
1612 (defcustom message-send-mail-partially-limit nil
1613   "The limitation of messages sent as message/partial.
1614 The lower bound of message size in characters, beyond which the message
1615 should be sent in several parts.  If it is nil, the size is unlimited."
1616   :version "24.1"
1617   :group 'message-buffers
1618   :link '(custom-manual "(message)Mail Variables")
1619   :type '(choice (const :tag "unlimited" nil)
1620                  (integer 1000000)))
1621
1622 (defcustom message-alternative-emails nil
1623   "*Regexp matching alternative email addresses.
1624 The first address in the To, Cc or From headers of the original
1625 article matching this variable is used as the From field of
1626 outgoing messages.
1627
1628 This variable has precedence over posting styles and anything that runs
1629 off `message-setup-hook'."
1630   :group 'message-headers
1631   :link '(custom-manual "(message)Message Headers")
1632   :type '(choice (const :tag "Always use primary" nil)
1633                  regexp))
1634
1635 (defcustom message-hierarchical-addresses nil
1636   "A list of hierarchical mail address definitions.
1637
1638 Inside each entry, the first address is the \"top\" address, and
1639 subsequent addresses are subaddresses; this is used to indicate that
1640 mail sent to the first address will automatically be delivered to the
1641 subaddresses.  So if the first address appears in the recipient list
1642 for a message, the subaddresses will be removed (if present) before
1643 the mail is sent.  All addresses in this structure should be
1644 downcased."
1645   :version "22.1"
1646   :group 'message-headers
1647   :type '(repeat (repeat string)))
1648
1649 (defcustom message-mail-user-agent nil
1650   "Like `mail-user-agent'.
1651 Except if it is nil, use Gnus native MUA; if it is t, use
1652 `mail-user-agent'."
1653   :version "22.1"
1654   :type '(radio (const :tag "Gnus native"
1655                        :format "%t\n"
1656                        nil)
1657                 (const :tag "`mail-user-agent'"
1658                        :format "%t\n"
1659                        t)
1660                 (function-item :tag "Default Emacs mail"
1661                                :format "%t\n"
1662                                sendmail-user-agent)
1663                 (function-item :tag "Emacs interface to MH"
1664                                :format "%t\n"
1665                                mh-e-user-agent)
1666                 (function :tag "Other"))
1667   :version "21.1"
1668   :group 'message)
1669
1670 (defcustom message-wide-reply-confirm-recipients nil
1671   "Whether to confirm a wide reply to multiple email recipients.
1672 If this variable is nil, don't ask whether to reply to all recipients.
1673 If this variable is non-nil, pose the question \"Reply to all
1674 recipients?\" before a wide reply to multiple recipients.  If the user
1675 answers yes, reply to all recipients as usual.  If the user answers
1676 no, only reply back to the author."
1677   :version "22.1"
1678   :group 'message-headers
1679   :link '(custom-manual "(message)Wide Reply")
1680   :type 'boolean)
1681
1682 (defcustom message-user-fqdn nil
1683   "*Domain part of Message-Ids."
1684   :version "22.1"
1685   :group 'message-headers
1686   :link '(custom-manual "(message)News Headers")
1687   :type '(radio (const :format "%v  " nil)
1688                 (string :format "FQDN: %v")))
1689
1690 (defcustom message-use-idna (and (condition-case nil (require 'idna)
1691                                    (file-error))
1692                                  (mm-coding-system-p 'utf-8)
1693                                  (executable-find idna-program)
1694                                  (string= (idna-to-ascii "räksmörgås")
1695                                           "xn--rksmrgs-5wao1o")
1696                                  t)
1697   "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1698 GNU Libidn, and in particular the elisp package \"idna.el\" and
1699 the external program \"idn\", must be installed for this
1700 functionality to work."
1701   :version "22.1"
1702   :group 'message-headers
1703   :link '(custom-manual "(message)IDNA")
1704   :type '(choice (const :tag "Ask" ask)
1705                  (const :tag "Never" nil)
1706                  (const :tag "Always" t)))
1707
1708 (defcustom message-generate-hashcash (if (executable-find "hashcash") 'opportunistic)
1709   "*Whether to generate X-Hashcash: headers.
1710 If t, always generate hashcash headers.  If `opportunistic',
1711 only generate hashcash headers if it can be done without the user
1712 waiting (i.e., only asynchronously).
1713
1714 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1715   :version "24.1"
1716   :group 'message-headers
1717   :link '(custom-manual "(message)Mail Headers")
1718   :type '(choice (const :tag "Always" t)
1719                  (const :tag "Never" nil)
1720                  (const :tag "Opportunistic" opportunistic)))
1721
1722 ;;; Internal variables.
1723
1724 (defvar message-sending-message "Sending...")
1725 (defvar message-buffer-list nil)
1726 (defvar message-this-is-news nil)
1727 (defvar message-this-is-mail nil)
1728 (defvar message-draft-article nil)
1729 (defvar message-mime-part nil)
1730 (defvar message-posting-charset nil)
1731 (defvar message-inserted-headers nil)
1732 (defvar message-inhibit-ecomplete nil)
1733
1734 ;; Byte-compiler warning
1735 (defvar gnus-active-hashtb)
1736 (defvar gnus-read-active-file)
1737
1738 ;;; Regexp matching the delimiter of messages in UNIX mail format
1739 ;;; (UNIX From lines), minus the initial ^.  It should be a copy
1740 ;;; of rmail.el's rmail-unix-mail-delimiter.
1741 (defvar message-unix-mail-delimiter
1742   (let ((time-zone-regexp
1743          (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1744                  "\\|[-+]?[0-9][0-9][0-9][0-9]"
1745                  "\\|"
1746                  "\\) *")))
1747     (concat
1748      "From "
1749
1750      ;; Many things can happen to an RFC 822 mailbox before it is put into
1751      ;; a `From' line.  The leading phrase can be stripped, e.g.
1752      ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'.  The <> can be stripped, e.g.
1753      ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'.  Everything starting with a CRLF
1754      ;; can be removed, e.g.
1755      ;;         From: joe@y.z (Joe      K
1756      ;;                 User)
1757      ;; can yield `From joe@y.z (Joe    K Fri Mar 22 08:11:15 1996', and
1758      ;;         From: Joe User
1759      ;;                 <joe@y.z>
1760      ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1761      ;; The mailbox can be removed or be replaced by white space, e.g.
1762      ;;         From: "Joe User"{space}{tab}
1763      ;;                 <joe@y.z>
1764      ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1765      ;; where {space} and {tab} represent the Ascii space and tab characters.
1766      ;; We want to match the results of any of these manglings.
1767      ;; The following regexp rejects names whose first characters are
1768      ;; obviously bogus, but after that anything goes.
1769      "\\([^\0-\b\n-\r\^?].*\\)?"
1770
1771      ;; The time the message was sent.
1772      "\\([^\0-\r \^?]+\\) +"            ; day of the week
1773      "\\([^\0-\r \^?]+\\) +"            ; month
1774      "\\([0-3]?[0-9]\\) +"              ; day of month
1775      "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1776
1777      ;; Perhaps a time zone, specified by an abbreviation, or by a
1778      ;; numeric offset.
1779      time-zone-regexp
1780
1781      ;; The year.
1782      " \\([0-9][0-9]+\\) *"