Fixes to improve auth-source prompting and don't default user name to anything.
[gnus] / lisp / message.el
1 ;;; message.el --- composing mail and news messages
2
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: mail, news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;; This mode provides mail-sending facilities from within Emacs.  It
26 ;; consists mainly of large chunks of code from the sendmail.el,
27 ;; gnus-msg.el and rnewspost.el files.
28
29 ;;; Code:
30
31 ;; For Emacs <22.2 and XEmacs.
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-cite-style nil
133   "The overall style to be used when yanking cited text.
134 Values are either `traditional' (cited text first),
135 `top-post' (cited text at the bottom), or nil (don't override the
136 individual message variables)."
137   :version "24.1"
138   :group 'message-various
139   :type '(choice (const :tag "None" :value nil)
140                  (const :tag "Traditional" :value traditional)
141                  (const :tag "Top-post" :value top-post)))
142
143 (defcustom message-fcc-handler-function 'message-output
144   "*A function called to save outgoing articles.
145 This function will be called with the name of the file to store the
146 article in.  The default function is `message-output' which saves in Unix
147 mailbox format."
148   :type '(radio (function-item message-output)
149                 (function :tag "Other"))
150   :group 'message-sending)
151
152 (defcustom message-fcc-externalize-attachments nil
153   "If non-nil, attachments are included as external parts in Fcc copies."
154   :version "22.1"
155   :type 'boolean
156   :group 'message-sending)
157
158 (defcustom message-courtesy-message
159   "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
160   "*This is inserted at the start of a mailed copy of a posted message.
161 If the string contains the format spec \"%s\", the Newsgroups
162 the article has been posted to will be inserted there.
163 If this variable is nil, no such courtesy message will be added."
164   :group 'message-sending
165   :type '(radio string (const nil)))
166
167 (defcustom message-ignored-bounced-headers
168   "^\\(Received\\|Return-Path\\|Delivered-To\\):"
169   "*Regexp that matches headers to be removed in resent bounced mail."
170   :group 'message-interface
171   :type 'regexp)
172
173 (defcustom message-from-style 'default
174   ;; In Emacs 24.1 this defaults to the value of `mail-from-style'
175   ;; that defaults to:
176   ;; `angles' in Emacs 22.1~23.1, XEmacs 21.4, 21.5, and SXEmacs 22.1;
177   ;; `system-default' in Emacs 23.2, and 24.1
178   "Specifies how \"From\" headers look.
179
180 If nil, they contain just the return address like:
181         king@grassland.com
182 If `parens', they look like:
183         king@grassland.com (Elvis Parsley)
184 If `angles', they look like:
185         Elvis Parsley <king@grassland.com>
186
187 Otherwise, most addresses look like `angles', but they look like
188 `parens' if `angles' would need quoting and `parens' would not."
189   :version "23.2"
190   :type '(choice (const :tag "simple" nil)
191                  (const parens)
192                  (const angles)
193                  (const default))
194   :group 'message-headers)
195
196 (defcustom message-insert-canlock t
197   "Whether to insert a Cancel-Lock header in news postings."
198   :version "22.1"
199   :group 'message-headers
200   :type 'boolean)
201
202 (defcustom message-syntax-checks
203   (if message-insert-canlock '((sender . disabled)) nil)
204   ;; Guess this one shouldn't be easy to customize...
205   "*Controls what syntax checks should not be performed on outgoing posts.
206 To disable checking of long signatures, for instance, add
207  `(signature . disabled)' to this list.
208
209 Don't touch this variable unless you really know what you're doing.
210
211 Checks include `approved', `bogus-recipient', `continuation-headers',
212 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
213 `invisible-text', `long-header-lines', `long-lines', `message-id',
214 `multiple-headers', `new-text', `newsgroups', `quoting-style',
215 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
216 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
217 and `valid-newsgroups'."
218   :group 'message-news
219   :type '(repeat sexp))                 ; Fixme: improve this
220
221 (defcustom message-required-headers '((optional . References)
222                                       From)
223   "*Headers to be generated or prompted for when sending a message.
224 Also see `message-required-news-headers' and
225 `message-required-mail-headers'."
226   :version "22.1"
227   :group 'message-news
228   :group 'message-headers
229   :link '(custom-manual "(message)Message Headers")
230   :type '(repeat sexp))
231
232 (defcustom message-draft-headers '(References From Date)
233   "*Headers to be generated when saving a draft message."
234   :version "22.1"
235   :group 'message-news
236   :group 'message-headers
237   :link '(custom-manual "(message)Message Headers")
238   :type '(repeat sexp))
239
240 (defcustom message-required-news-headers
241   '(From Newsgroups Subject Date Message-ID
242          (optional . Organization)
243          (optional . User-Agent))
244   "*Headers to be generated or prompted for when posting an article.
245 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
246 Message-ID.  Organization, Lines, In-Reply-To, Expires, and
247 User-Agent are optional.  If you don't want message to insert some
248 header, remove it from this list."
249   :group 'message-news
250   :group 'message-headers
251   :link '(custom-manual "(message)Message Headers")
252   :type '(repeat sexp))
253
254 (defcustom message-required-mail-headers
255   '(From Subject Date (optional . In-Reply-To) Message-ID
256          (optional . User-Agent))
257   "*Headers to be generated or prompted for when mailing a message.
258 It is recommended that From, Date, To, Subject and Message-ID be
259 included.  Organization and User-Agent are optional."
260   :group 'message-mail
261   :group 'message-headers
262   :link '(custom-manual "(message)Message Headers")
263   :type '(repeat sexp))
264
265 (defcustom message-prune-recipient-rules nil
266   "Rules for how to prune the list of recipients when doing wide replies.
267 This is a list of regexps and regexp matches."
268   :version "24.1"
269   :group 'message-mail
270   :group 'message-headers
271   :link '(custom-manual "(message)Wide Reply")
272   :type '(repeat regexp))
273
274 (defcustom message-deletable-headers '(Message-ID Date Lines)
275   "Headers to be deleted if they already exist and were generated by message previously."
276   :group 'message-headers
277   :link '(custom-manual "(message)Message Headers")
278   :type 'sexp)
279
280 (defcustom message-ignored-news-headers
281   "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
282   "*Regexp of headers to be removed unconditionally before posting."
283   :group 'message-news
284   :group 'message-headers
285   :link '(custom-manual "(message)Message Headers")
286   :type '(repeat :value-to-internal (lambda (widget value)
287                                       (custom-split-regexp-maybe value))
288                  :match (lambda (widget value)
289                           (or (stringp value)
290                               (widget-editable-list-match widget value)))
291                  regexp))
292
293 (defcustom message-ignored-mail-headers
294   "^\\([GF]cc\\|Resent-Fcc\\|Xref\\|X-Draft-From\\|X-Gnus-Agent-Meta-Information\\):"
295   "*Regexp of headers to be removed unconditionally before mailing."
296   :group 'message-mail
297   :group 'message-headers
298   :link '(custom-manual "(message)Mail Headers")
299   :type 'regexp)
300
301 (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:\\|^Injection-Date:\\|^Injection-Info:"
302   "*Header lines matching this regexp will be deleted before posting.
303 It's best to delete old Path and Date headers before posting to avoid
304 any confusion."
305   :group 'message-interface
306   :link '(custom-manual "(message)Superseding")
307   :type '(repeat :value-to-internal (lambda (widget value)
308                                       (custom-split-regexp-maybe value))
309                  :match (lambda (widget value)
310                           (or (stringp value)
311                               (widget-editable-list-match widget value)))
312                  regexp))
313
314 (defcustom message-subject-re-regexp
315   "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
316   "*Regexp matching \"Re: \" in the subject line."
317   :group 'message-various
318   :link '(custom-manual "(message)Message Headers")
319   :type 'regexp)
320
321 ;;; Start of variables adopted from `message-utils.el'.
322
323 (defcustom message-subject-trailing-was-query t
324   "*What to do with trailing \"(was: <old subject>)\" in subject lines.
325 If nil, leave the subject unchanged.  If it is the symbol `ask', query
326 the user what do do.  In this case, the subject is matched against
327 `message-subject-trailing-was-ask-regexp'.  If
328 `message-subject-trailing-was-query' is t, always strip the trailing
329 old subject.  In this case, `message-subject-trailing-was-regexp' is
330 used."
331   :version "24.1"
332   :type '(choice (const :tag "never" nil)
333                  (const :tag "always strip" t)
334                  (const ask))
335   :link '(custom-manual "(message)Message Headers")
336   :group 'message-various)
337
338 (defcustom message-subject-trailing-was-ask-regexp
339   "[ \t]*\\([[(]+[Ww][Aa][Ss]:?[ \t]*.*[])]+\\)"
340   "*Regexp matching \"(was: <old subject>)\" in the subject line.
341
342 The function `message-strip-subject-trailing-was' uses this regexp if
343 `message-subject-trailing-was-query' is set to the symbol `ask'.  If
344 the variable is t instead of `ask', use
345 `message-subject-trailing-was-regexp' instead.
346
347 It is okay to create some false positives here, as the user is asked."
348   :version "22.1"
349   :group 'message-various
350   :link '(custom-manual "(message)Message Headers")
351   :type 'regexp)
352
353 (defcustom message-subject-trailing-was-regexp
354   "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
355   "*Regexp matching \"(was: <old subject>)\" in the subject line.
356
357 If `message-subject-trailing-was-query' is set to t, the subject is
358 matched against `message-subject-trailing-was-regexp' in
359 `message-strip-subject-trailing-was'.  You should use a regexp creating very
360 few false positives here."
361   :version "22.1"
362   :group 'message-various
363   :link '(custom-manual "(message)Message Headers")
364   :type 'regexp)
365
366 ;;; marking inserted text
367
368 (defcustom message-mark-insert-begin
369   "--8<---------------cut here---------------start------------->8---\n"
370   "How to mark the beginning of some inserted text."
371   :version "22.1"
372   :type 'string
373   :link '(custom-manual "(message)Insertion Variables")
374   :group 'message-various)
375
376 (defcustom message-mark-insert-end
377   "--8<---------------cut here---------------end--------------->8---\n"
378   "How to mark the end of some inserted text."
379   :version "22.1"
380   :type 'string
381   :link '(custom-manual "(message)Insertion Variables")
382   :group 'message-various)
383
384 (defcustom message-archive-header "X-No-Archive: Yes\n"
385   "Header to insert when you don't want your article to be archived.
386 Archives \(such as groups.google.com\) respect this header."
387   :version "22.1"
388   :type 'string
389   :link '(custom-manual "(message)Header Commands")
390   :group 'message-various)
391
392 (defcustom message-archive-note
393   "X-No-Archive: Yes - save http://groups.google.com/"
394   "Note to insert why you wouldn't want this posting archived.
395 If nil, don't insert any text in the body."
396   :version "22.1"
397   :type '(radio string (const nil))
398   :link '(custom-manual "(message)Header Commands")
399   :group 'message-various)
400
401 ;;; Crossposts and Followups
402 ;; inspired by JoH-followup-to by Jochem Huhman <joh  at gmx.de>
403 ;; new suggestions by R. Weikusat <rw at another.de>
404
405 (defvar message-cross-post-old-target nil
406   "Old target for cross-posts or follow-ups.")
407 (make-variable-buffer-local 'message-cross-post-old-target)
408
409 (defcustom message-cross-post-default t
410   "When non-nil `message-cross-post-followup-to' will perform a crosspost.
411 If nil, `message-cross-post-followup-to' will only do a followup.  Note that
412 you can explicitly override this setting by calling
413 `message-cross-post-followup-to' with a prefix."
414   :version "22.1"
415   :type 'boolean
416   :group 'message-various)
417
418 (defcustom message-cross-post-note "Crosspost & Followup-To: "
419   "Note to insert before signature to notify of cross-post and follow-up."
420   :version "22.1"
421   :type 'string
422   :group 'message-various)
423
424 (defcustom message-followup-to-note "Followup-To: "
425   "Note to insert before signature to notify of follow-up only."
426   :version "22.1"
427   :type 'string
428   :group 'message-various)
429
430 (defcustom message-cross-post-note-function 'message-cross-post-insert-note
431   "Function to use to insert note about Crosspost or Followup-To.
432 The function will be called with four arguments.  The function should not only
433 insert a note, but also ensure old notes are deleted.  See the documentation
434 for `message-cross-post-insert-note'."
435   :version "22.1"
436   :type 'function
437   :group 'message-various)
438
439 ;;; End of variables adopted from `message-utils.el'.
440
441 (defcustom message-signature-separator "^-- $"
442   "Regexp matching the signature separator.
443 This variable is used to strip off the signature from quoted text
444 when `message-cite-function' is
445 `message-cite-original-without-signature'.  Most useful values
446 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
447 whitespace)."
448   :type '(choice (const :tag "strict" "^-- $")
449                  (const :tag "loose" "^-- *$")
450                  regexp)
451   :version "22.3" ;; Gnus 5.10.12 (changed default)
452   :link '(custom-manual "(message)Various Message Variables")
453   :group 'message-various)
454
455 (defcustom message-elide-ellipsis "\n[...]\n\n"
456   "*The string which is inserted for elided text."
457   :type 'string
458   :link '(custom-manual "(message)Various Commands")
459   :group 'message-various)
460
461 (defcustom message-interactive t
462   ;; In Emacs 24.1 this defaults to the value of `mail-interactive'
463   ;; that defaults to:
464   ;; `nil' in Emacs 22.1~22.3, XEmacs 21.4, 21.5, and SXEmacs 22.1;
465   ;; `t' in Emacs 23.1~24.1
466   "Non-nil means when sending a message wait for and display errors.
467 A value of nil means let mailer mail back a message to report errors."
468   :version "23.2"
469   :group 'message-sending
470   :group 'message-mail
471   :link '(custom-manual "(message)Sending Variables")
472   :type 'boolean)
473
474 (defcustom message-confirm-send nil
475   "When non-nil, ask for confirmation when sending a message."
476   :group 'message-sending
477   :group 'message-mail
478   :version "23.1" ;; No Gnus
479   :link '(custom-manual "(message)Sending Variables")
480   :type 'boolean)
481
482 (defcustom message-generate-new-buffers 'unsent
483   "*Say whether to create a new message buffer to compose a message.
484 Valid values include:
485
486 nil
487   Generate the buffer name in the Message way (e.g., *mail*, *news*,
488   *mail to whom*, *news on group*, etc.) and continue editing in the
489   existing buffer of that name.  If there is no such buffer, it will
490   be newly created.
491
492 `unique' or t
493   Create the new buffer with the name generated in the Message way.
494
495 `unsent'
496   Similar to `unique' but the buffer name begins with \"*unsent \".
497
498 `standard'
499   Similar to nil but the buffer name is simpler like *mail message*.
500
501 function
502   If this is a function, call that function with three parameters:
503   The type, the To address and the group name (any of these may be nil).
504   The function should return the new buffer name."
505   :version "24.1"
506   :group 'message-buffers
507   :link '(custom-manual "(message)Message Buffers")
508   :type '(choice (const nil)
509                  (sexp :tag "unique" :format "unique\n" :value unique
510                        :match (lambda (widget value) (memq value '(unique t))))
511                  (const unsent)
512                  (const standard)
513                  (function :format "\n    %{%t%}: %v")))
514
515 (defcustom message-kill-buffer-on-exit nil
516   "*Non-nil means that the message buffer will be killed after sending a message."
517   :group 'message-buffers
518   :link '(custom-manual "(message)Message Buffers")
519   :type 'boolean)
520
521 (defcustom message-kill-buffer-query t
522   "*Non-nil means that killing a modified message buffer has to be confirmed.
523 This is used by `message-kill-buffer'."
524   :version "23.1" ;; No Gnus
525   :group 'message-buffers
526   :type 'boolean)
527
528 (defcustom message-user-organization
529   (or (getenv "ORGANIZATION") t)
530   "String to be used as an Organization header.
531 If t, use `message-user-organization-file'."
532   :group 'message-headers
533   :type '(choice string
534                  (const :tag "consult file" t)))
535
536 (defcustom message-user-organization-file
537   (let (orgfile)
538     (dolist (f (list "/etc/organization"
539                      "/etc/news/organization"
540                      "/usr/lib/news/organization"))
541       (when (file-readable-p f)
542         (setq orgfile f)))
543     orgfile)
544   "*Local news organization file."
545   :type 'file
546   :link '(custom-manual "(message)News Headers")
547   :group 'message-headers)
548
549 (defcustom message-make-forward-subject-function
550   #'message-forward-subject-name-subject
551   "*List of functions called to generate subject headers for forwarded messages.
552 The subject generated by the previous function is passed into each
553 successive function.
554
555 The provided functions are:
556
557 * `message-forward-subject-author-subject' Source of article (author or
558       newsgroup), in brackets followed by the subject
559 * `message-forward-subject-name-subject' Source of article (name of author
560       or newsgroup), in brackets followed by the subject
561 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
562       to it."
563   :group 'message-forwarding
564   :link '(custom-manual "(message)Forwarding")
565   :type '(radio (function-item message-forward-subject-author-subject)
566                 (function-item message-forward-subject-fwd)
567                 (function-item message-forward-subject-name-subject)
568                 (repeat :tag "List of functions" function)))
569
570 (defcustom message-forward-as-mime t
571   "*Non-nil means forward messages as an inline/rfc822 MIME section.
572 Otherwise, directly inline the old message in the forwarded message."
573   :version "21.1"
574   :group 'message-forwarding
575   :link '(custom-manual "(message)Forwarding")
576   :type 'boolean)
577
578 (defcustom message-forward-show-mml 'best
579   "*Non-nil means show forwarded messages as MML (decoded from MIME).
580 Otherwise, forwarded messages are unchanged.
581 Can also be the symbol `best' to indicate that MML should be
582 used, except when it is a bad idea to use MML.  One example where
583 it is a bad idea is when forwarding a signed or encrypted
584 message, because converting MIME to MML would invalidate the
585 digital signature."
586   :version "21.1"
587   :group 'message-forwarding
588   :type '(choice (const :tag "use MML" t)
589                  (const :tag "don't use MML " nil)
590                  (const :tag "use MML when appropriate" best)))
591
592 (defcustom message-forward-before-signature t
593   "*Non-nil means put forwarded message before signature, else after."
594   :group 'message-forwarding
595   :type 'boolean)
596
597 (defcustom message-wash-forwarded-subjects nil
598   "*Non-nil means try to remove as much cruft as possible from the subject.
599 Done before generating the new subject of a forward."
600   :group 'message-forwarding
601   :link '(custom-manual "(message)Forwarding")
602   :type 'boolean)
603
604 (defcustom message-ignored-resent-headers
605   ;; `Delivered-To' needs to be removed because some mailers use it to
606   ;; detect loops, so if you resend a message to an address that ultimately
607   ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
608   ;; case you may be removed from the list on the grounds that mail to you
609   ;; bounced with a "mailing loop" error).
610   "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
611   "*All headers that match this regexp will be deleted when resending a message."
612   :group 'message-interface
613   :link '(custom-manual "(message)Resending")
614   :type '(repeat :value-to-internal (lambda (widget value)
615                                       (custom-split-regexp-maybe value))
616                  :match (lambda (widget value)
617                           (or (stringp value)
618                               (widget-editable-list-match widget value)))
619                  regexp))
620
621 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
622   "*All headers that match this regexp will be deleted when forwarding a message."
623   :version "21.1"
624   :group 'message-forwarding
625   :type '(repeat :value-to-internal (lambda (widget value)
626                                       (custom-split-regexp-maybe value))
627                  :match (lambda (widget value)
628                           (or (stringp value)
629                               (widget-editable-list-match widget value)))
630                  regexp))
631
632 (defcustom message-ignored-cited-headers "."
633   "*Delete these headers from the messages you yank."
634   :group 'message-insertion
635   :link '(custom-manual "(message)Insertion Variables")
636   :type 'regexp)
637
638 (defcustom message-cite-prefix-regexp
639   ;; In Emacs 24.1 this defaults to the value of
640   ;; `mail-citation-prefix-regexp'; the default value varies according
641   ;; to the Emacs version.  In XEmacs 21.4 and 21.5, sendmail.el
642   ;; provides it.
643   (if (string-match "[[:digit:]]" "1")
644       ;; Support POSIX?  XEmacs 21.5.27 doesn't.
645       "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|]\\)+"
646     ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
647     (let (non-word-constituents)
648       (with-syntax-table text-mode-syntax-table
649         (setq non-word-constituents
650               (concat
651                (if (string-match "\\w" "_")  "" "_")
652                (if (string-match "\\w" ".")  "" "."))))
653       (if (equal non-word-constituents "")
654           "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|]\\)+"
655         (concat "\\([ \t]*\\(\\w\\|["
656                 non-word-constituents
657                 "]\\)+>+\\|[ \t]*[]>|]\\)+"))))
658   "*Regexp matching the longest possible citation prefix on a line."
659   :version "24.1"
660   :group 'message-insertion
661   :link '(custom-manual "(message)Insertion Variables")
662   :type 'regexp
663   :set (lambda (symbol value)
664          (prog1
665              (custom-set-default symbol value)
666            (if (boundp 'gnus-message-cite-prefix-regexp)
667                (setq gnus-message-cite-prefix-regexp
668                      (concat "^\\(?:" value "\\)"))))))
669
670 (defcustom message-cancel-message "I am canceling my own article.\n"
671   "Message to be inserted in the cancel message."
672   :group 'message-interface
673   :link '(custom-manual "(message)Canceling News")
674   :type 'string)
675
676 (defun message-send-mail-function ()
677   "Return suitable value for the variable `message-send-mail-function'."
678   (cond ((and (require 'sendmail)
679               (boundp 'sendmail-program)
680               sendmail-program
681               (executable-find sendmail-program))
682          'message-send-mail-with-sendmail)
683         ((and (locate-library "smtpmail")
684               (boundp 'smtpmail-default-smtp-server)
685               smtpmail-default-smtp-server)
686          'message-smtpmail-send-it)
687         ((locate-library "mailclient")
688          'message-send-mail-with-mailclient)
689         (t
690          (error "Don't know how to send mail.  Please customize `message-send-mail-function'"))))
691
692 ;; Useful to set in site-init.el
693 (defcustom message-send-mail-function
694   (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it)
695         ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it)
696         ((eq send-mail-function 'mailclient-send-it)
697          'message-send-mail-with-mailclient)
698         (t (message-send-mail-function)))
699   "Function to call to send the current buffer as mail.
700 The headers should be delimited by a line whose contents match the
701 variable `mail-header-separator'.
702
703 Valid values include `message-send-mail-with-sendmail'
704 `message-send-mail-with-mh', `message-send-mail-with-qmail',
705 `message-smtpmail-send-it', `smtpmail-send-it',
706 `feedmail-send-it' and `message-send-mail-with-mailclient'.  The
707 default is system dependent and determined by the function
708 `message-send-mail-function'.
709
710 See also `send-mail-function'."
711   :type '(radio (function-item message-send-mail-with-sendmail)
712                 (function-item message-send-mail-with-mh)
713                 (function-item message-send-mail-with-qmail)
714                 (function-item message-smtpmail-send-it)
715                 (function-item smtpmail-send-it)
716                 (function-item feedmail-send-it)
717                 (function-item message-send-mail-with-mailclient
718                                :tag "Use Mailclient package")
719                 (function :tag "Other"))
720   :group 'message-sending
721   :version "23.2"
722   :initialize 'custom-initialize-default
723   :link '(custom-manual "(message)Mail Variables")
724   :group 'message-mail)
725
726 (defcustom message-send-news-function 'message-send-news
727   "Function to call to send the current buffer as news.
728 The headers should be delimited by a line whose contents match the
729 variable `mail-header-separator'."
730   :group 'message-sending
731   :group 'message-news
732   :link '(custom-manual "(message)News Variables")
733   :type 'function)
734
735 (defcustom message-reply-to-function nil
736   "If non-nil, function that should return a list of headers.
737 This function should pick out addresses from the To, Cc, and From headers
738 and respond with new To and Cc headers."
739   :group 'message-interface
740   :link '(custom-manual "(message)Reply")
741   :type '(choice function (const nil)))
742
743 (defcustom message-wide-reply-to-function nil
744   "If non-nil, function that should return a list of headers.
745 This function should pick out addresses from the To, Cc, and From headers
746 and respond with new To and Cc headers."
747   :group 'message-interface
748   :link '(custom-manual "(message)Wide Reply")
749   :type '(choice function (const nil)))
750
751 (defcustom message-followup-to-function nil
752   "If non-nil, function that should return a list of headers.
753 This function should pick out addresses from the To, Cc, and From headers
754 and respond with new To and Cc headers."
755   :group 'message-interface
756   :link '(custom-manual "(message)Followup")
757   :type '(choice function (const nil)))
758
759 (defcustom message-extra-wide-headers nil
760   "If non-nil, a list of additional address headers.
761 These are used when composing a wide reply."
762   :group 'message-sending
763   :type '(repeat string))
764
765 (defcustom message-use-followup-to 'ask
766   "*Specifies what to do with Followup-To header.
767 If nil, always ignore the header.  If it is t, use its value, but
768 query before using the \"poster\" value.  If it is the symbol `ask',
769 always query the user whether to use the value.  If it is the symbol
770 `use', always use the value."
771   :group 'message-interface
772   :link '(custom-manual "(message)Followup")
773   :type '(choice (const :tag "ignore" nil)
774                  (const :tag "use & query" t)
775                  (const use)
776                  (const ask)))
777
778 (defcustom message-use-mail-followup-to 'use
779   "*Specifies what to do with Mail-Followup-To header.
780 If nil, always ignore the header.  If it is the symbol `ask', always
781 query the user whether to use the value.  If it is the symbol `use',
782 always use the value."
783   :version "22.1"
784   :group 'message-interface
785   :link '(custom-manual "(message)Mailing Lists")
786   :type '(choice (const :tag "ignore" nil)
787                  (const use)
788                  (const ask)))
789
790 (defcustom message-subscribed-address-functions nil
791   "*Specifies functions for determining list subscription.
792 If nil, do not attempt to determine list subscription with functions.
793 If non-nil, this variable contains a list of functions which return
794 regular expressions to match lists.  These functions can be used in
795 conjunction with `message-subscribed-regexps' and
796 `message-subscribed-addresses'."
797   :version "22.1"
798   :group 'message-interface
799   :link '(custom-manual "(message)Mailing Lists")
800   :type '(repeat sexp))
801
802 (defcustom message-subscribed-address-file nil
803   "*A file containing addresses the user is subscribed to.
804 If nil, do not look at any files to determine list subscriptions.  If
805 non-nil, each line of this file should be a mailing list address."
806   :version "22.1"
807   :group 'message-interface
808   :link '(custom-manual "(message)Mailing Lists")
809   :type '(radio file (const nil)))
810
811 (defcustom message-subscribed-addresses nil
812   "*Specifies a list of addresses the user is subscribed to.
813 If nil, do not use any predefined list subscriptions.  This list of
814 addresses can be used in conjunction with
815 `message-subscribed-address-functions' and `message-subscribed-regexps'."
816   :version "22.1"
817   :group 'message-interface
818   :link '(custom-manual "(message)Mailing Lists")
819   :type '(repeat string))
820
821 (defcustom message-subscribed-regexps nil
822   "*Specifies a list of addresses the user is subscribed to.
823 If nil, do not use any predefined list subscriptions.  This list of
824 regular expressions can be used in conjunction with
825 `message-subscribed-address-functions' and `message-subscribed-addresses'."
826   :version "22.1"
827   :group 'message-interface
828   :link '(custom-manual "(message)Mailing Lists")
829   :type '(repeat regexp))
830
831 (defcustom message-allow-no-recipients 'ask
832   "Specifies what to do when there are no recipients other than Gcc/Fcc.
833 If it is the symbol `always', the posting is allowed.  If it is the
834 symbol `never', the posting is not allowed.  If it is the symbol
835 `ask', you are prompted."
836   :version "22.1"
837   :group 'message-interface
838   :link '(custom-manual "(message)Message Headers")
839   :type '(choice (const always)
840                  (const never)
841                  (const ask)))
842
843 (defcustom message-sendmail-f-is-evil nil
844   "*Non-nil means don't add \"-f username\" to the sendmail command line.
845 Doing so would be even more evil than leaving it out."
846   :group 'message-sending
847   :link '(custom-manual "(message)Mail Variables")
848   :type 'boolean)
849
850 (defcustom message-sendmail-envelope-from nil
851   ;; In Emacs 24.1 this defaults to the value of `mail-envelope-from'
852   ;; if it is available, or defaults to nil.  sendmail.el provides it;
853   ;; the default value is nil in all (X)Emacsen that Gnus supports.
854   "*Envelope-from when sending mail with sendmail.
855 If this is nil, use `user-mail-address'.  If it is the symbol
856 `header', use the From: header of the message."
857   :version "23.2"
858   :type '(choice (string :tag "From name")
859                  (const :tag "Use From: header from message" header)
860                  (const :tag "Use `user-mail-address'" nil))
861   :link '(custom-manual "(message)Mail Variables")
862   :group 'message-sending)
863
864 (defcustom message-sendmail-extra-arguments nil
865   "Additional arguments to `sendmail-program'."
866   ;; E.g. '("-a" "account") for msmtp
867   :version "23.1" ;; No Gnus
868   :type '(repeat string)
869   ;; :link '(custom-manual "(message)Mail Variables")
870   :group 'message-sending)
871
872 ;; qmail-related stuff
873 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
874   "Location of the qmail-inject program."
875   :group 'message-sending
876   :link '(custom-manual "(message)Mail Variables")
877   :type 'file)
878
879 (defcustom message-qmail-inject-args nil
880   "Arguments passed to qmail-inject programs.
881 This should be a list of strings, one string for each argument.
882 It may also be a function.
883
884 For e.g., if you wish to set the envelope sender address so that bounces
885 go to the right place or to deal with listserv's usage of that address, you
886 might set this variable to '(\"-f\" \"you@some.where\")."
887   :group 'message-sending
888   :link '(custom-manual "(message)Mail Variables")
889   :type '(choice (function)
890                  (repeat string)))
891
892 (defvar gnus-post-method)
893 (defvar gnus-select-method)
894 (defcustom message-post-method
895   (cond ((and (boundp 'gnus-post-method)
896               (listp gnus-post-method)
897               gnus-post-method)
898          gnus-post-method)
899         ((boundp 'gnus-select-method)
900          gnus-select-method)
901         (t '(nnspool "")))
902   "*Method used to post news.
903 Note that when posting from inside Gnus, for instance, this
904 variable isn't used."
905   :group 'message-news
906   :group 'message-sending
907   ;; This should be the `gnus-select-method' widget, but that might
908   ;; create a dependence to `gnus.el'.
909   :type 'sexp)
910
911 (defcustom message-generate-headers-first nil
912   "Which headers should be generated before starting to compose a message.
913 If t, generate all required headers.  This can also be a list of headers to
914 generate.  The variables `message-required-news-headers' and
915 `message-required-mail-headers' specify which headers to generate.
916
917 Note that the variable `message-deletable-headers' specifies headers which
918 are to be deleted and then re-generated before sending, so this variable
919 will not have a visible effect for those headers."
920   :group 'message-headers
921   :link '(custom-manual "(message)Message Headers")
922   :type '(choice (const :tag "None" nil)
923                  (const :tag "All" t)
924                  (repeat (sexp :tag "Header"))))
925
926 (defcustom message-fill-column 72
927   "Column beyond which automatic line-wrapping should happen.
928 Local value for message buffers.  If non-nil, also turn on
929 auto-fill in message buffers."
930   :group 'message-various
931   ;; :link '(custom-manual "(message)Message Headers")
932   :type '(choice (const :tag "Don't turn on auto fill" nil)
933                  (integer)))
934
935 (defcustom message-setup-hook nil
936   "Normal hook, run each time a new outgoing message is initialized.
937 The function `message-setup' runs this hook."
938   :group 'message-various
939   :link '(custom-manual "(message)Various Message Variables")
940   :type 'hook)
941
942 (defcustom message-cancel-hook nil
943   "Hook run&nb