1 ;;; message.el --- composing mail and news messages
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: mail, news
8 ;; This file is part of GNU Emacs.
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 2, or (at your option)
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This mode provides mail-sending facilities from within Emacs. It
28 ;; consists mainly of large chunks of code from the sendmail.el,
29 ;; gnus-msg.el and rnewspost.el files.
35 (defvar gnus-message-group-art)
36 (defvar gnus-list-identifiers)) ; gnus-sum is required where necessary
40 ;; This is apparently necessary even though things are autoloaded.
41 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
42 ;; require mailabbrev here.
43 (if (featurep 'xemacs)
44 (require 'mail-abbrevs)
45 (require 'mailabbrev))
50 (defgroup message '((user-mail-address custom-variable)
51 (user-full-name custom-variable))
52 "Mail and news message composing."
53 :link '(custom-manual "(message)Top")
57 (put 'user-mail-address 'custom-type 'string)
58 (put 'user-full-name 'custom-type 'string)
60 (defgroup message-various nil
61 "Various Message Variables"
62 :link '(custom-manual "(message)Various Message Variables")
65 (defgroup message-buffers nil
67 :link '(custom-manual "(message)Message Buffers")
70 (defgroup message-sending nil
72 :link '(custom-manual "(message)Sending Variables")
75 (defgroup message-interface nil
77 :link '(custom-manual "(message)Interface")
80 (defgroup message-forwarding nil
82 :link '(custom-manual "(message)Forwarding")
83 :group 'message-interface)
85 (defgroup message-insertion nil
87 :link '(custom-manual "(message)Insertion")
90 (defgroup message-headers nil
92 :link '(custom-manual "(message)Message Headers")
95 (defgroup message-news nil
96 "Composing News Messages"
99 (defgroup message-mail nil
100 "Composing Mail Messages"
103 (defgroup message-faces nil
104 "Faces used for message composing."
108 (defcustom message-directory "~/Mail/"
109 "*Directory from which all other mail file variables are derived."
110 :group 'message-various
113 (defcustom message-max-buffers 10
114 "*How many buffers to keep before starting to kill them off."
115 :group 'message-buffers
118 (defcustom message-send-rename-function nil
119 "Function called to rename the buffer after sending it."
120 :group 'message-buffers
121 :type '(choice function (const nil)))
123 (defcustom message-fcc-handler-function 'message-output
124 "*A function called to save outgoing articles.
125 This function will be called with the name of the file to store the
126 article in. The default function is `message-output' which saves in Unix
128 :type '(radio (function-item message-output)
129 (function :tag "Other"))
130 :group 'message-sending)
132 (defcustom message-fcc-externalize-attachments nil
133 "If non-nil, attachments are included as external parts in Fcc copies."
135 :group 'message-sending)
137 (defcustom message-courtesy-message
138 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
139 "*This is inserted at the start of a mailed copy of a posted message.
140 If the string contains the format spec \"%s\", the Newsgroups
141 the article has been posted to will be inserted there.
142 If this variable is nil, no such courtesy message will be added."
143 :group 'message-sending
144 :type '(radio (string :format "%t: %v\n" :size 0) (const nil)))
146 (defcustom message-ignored-bounced-headers
147 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
148 "*Regexp that matches headers to be removed in resent bounced mail."
149 :group 'message-interface
153 (defcustom message-from-style 'default
154 "*Specifies how \"From\" headers look.
156 If nil, they contain just the return address like:
158 If `parens', they look like:
159 king@grassland.com (Elvis Parsley)
160 If `angles', they look like:
161 Elvis Parsley <king@grassland.com>
163 Otherwise, most addresses look like `angles', but they look like
164 `parens' if `angles' would need quoting and `parens' would not."
165 :type '(choice (const :tag "simple" nil)
169 :group 'message-headers)
171 (defcustom message-insert-canlock t
172 "Whether to insert a Cancel-Lock header in news postings."
174 :group 'message-headers
177 (defcustom message-syntax-checks
178 (if message-insert-canlock '((sender . disabled)) nil)
179 ;; Guess this one shouldn't be easy to customize...
180 "*Controls what syntax checks should not be performed on outgoing posts.
181 To disable checking of long signatures, for instance, add
182 `(signature . disabled)' to this list.
184 Don't touch this variable unless you really know what you're doing.
186 Checks include `subject-cmsg', `multiple-headers', `sendsys',
187 `message-id', `from', `long-lines', `control-chars', `size',
188 `new-text', `quoting-style', `redirected-followup', `signature',
189 `approved', `sender', `empty', `empty-headers', `message-id', `from',
190 `subject', `shorten-followup-to', `existing-newsgroups',
191 `buffer-file-name', `unchanged', `newsgroups', `reply-to',
192 `continuation-headers', `long-header-lines', `invisible-text' and
195 :type '(repeat sexp)) ; Fixme: improve this
197 (defcustom message-required-headers '((optional . References)
199 "*Headers to be generated or prompted for when sending a message.
200 Also see `message-required-news-headers' and
201 `message-required-mail-headers'."
203 :group 'message-headers
204 :link '(custom-manual "(message)Message Headers")
205 :type '(repeat sexp))
207 (defcustom message-draft-headers '(References From)
208 "*Headers to be generated when saving a draft message."
210 :group 'message-headers
211 :link '(custom-manual "(message)Message Headers")
212 :type '(repeat sexp))
214 (defcustom message-required-news-headers
215 '(From Newsgroups Subject Date Message-ID
216 (optional . Organization)
217 (optional . User-Agent))
218 "*Headers to be generated or prompted for when posting an article.
219 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
220 Message-ID. Organization, Lines, In-Reply-To, Expires, and
221 User-Agent are optional. If don't you want message to insert some
222 header, remove it from this list."
224 :group 'message-headers
225 :link '(custom-manual "(message)Message Headers")
226 :type '(repeat sexp))
228 (defcustom message-required-mail-headers
229 '(From Subject Date (optional . In-Reply-To) Message-ID
230 (optional . User-Agent))
231 "*Headers to be generated or prompted for when mailing a message.
232 It is recommended that From, Date, To, Subject and Message-ID be
233 included. Organization and User-Agent are optional."
235 :group 'message-headers
236 :link '(custom-manual "(message)Message Headers")
237 :type '(repeat sexp))
239 (defcustom message-deletable-headers '(Message-ID Date Lines)
240 "Headers to be deleted if they already exist and were generated by message previously."
241 :group 'message-headers
242 :link '(custom-manual "(message)Message Headers")
245 (defcustom message-ignored-news-headers
246 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
247 "*Regexp of headers to be removed unconditionally before posting."
249 :group 'message-headers
250 :link '(custom-manual "(message)Message Headers")
253 (defcustom message-ignored-mail-headers
254 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
255 "*Regexp of headers to be removed unconditionally before mailing."
257 :group 'message-headers
258 :link '(custom-manual "(message)Mail Headers")
261 (defcustom message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|^X-Trace:\\|^X-Complaints-To:\\|Return-Path:\\|^Supersedes:\\|^NNTP-Posting-Date:\\|^X-Trace:\\|^X-Complaints-To:\\|^Cancel-Lock:\\|^Cancel-Key:\\|^X-Hashcash:\\|^X-Payment:"
262 "*Header lines matching this regexp will be deleted before posting.
263 It's best to delete old Path and Date headers before posting to avoid
265 :group 'message-interface
266 :link '(custom-manual "(message)Superseding")
269 (defcustom message-subject-re-regexp
270 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
271 "*Regexp matching \"Re: \" in the subject line."
272 :group 'message-various
273 :link '(custom-manual "(message)Message Headers")
276 ;;; Start of variables adopted from `message-utils.el'.
278 (defcustom message-subject-trailing-was-query 'ask
279 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
280 If nil, leave the subject unchanged. If it is the symbol `ask', query
281 the user what do do. In this case, the subject is matched against
282 `message-subject-trailing-was-ask-regexp'. If
283 `message-subject-trailing-was-query' is t, always strip the trailing
284 old subject. In this case, `message-subject-trailing-was-regexp' is
286 :type '(choice (const :tag "never" nil)
287 (const :tag "always strip" t)
289 :link '(custom-manual "(message)Message Headers")
290 :group 'message-various)
292 (defcustom message-subject-trailing-was-ask-regexp
293 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
294 "*Regexp matching \"(was: <old subject>)\" in the subject line.
296 The function `message-strip-subject-trailing-was' uses this regexp if
297 `message-subject-trailing-was-query' is set to the symbol `ask'. If
298 the variable is t instead of `ask', use
299 `message-subject-trailing-was-regexp' instead.
301 It is okay to create some false positives here, as the user is asked."
302 :group 'message-various
303 :link '(custom-manual "(message)Message Headers")
306 (defcustom message-subject-trailing-was-regexp
307 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
308 "*Regexp matching \"(was: <old subject>)\" in the subject line.
310 If `message-subject-trailing-was-query' is set to t, the subject is
311 matched against `message-subject-trailing-was-regexp' in
312 `message-strip-subject-trailing-was'. You should use a regexp creating very
313 few false positives here."
314 :group 'message-various
315 :link '(custom-manual "(message)Message Headers")
318 ;; Fixme: Why are all these things autoloaded?
320 ;;; marking inserted text
323 (defcustom message-mark-insert-begin
324 "--8<---------------cut here---------------start------------->8---\n"
325 "How to mark the beginning of some inserted text."
327 :link '(custom-manual "(message)Insertion Variables")
328 :group 'message-various)
331 (defcustom message-mark-insert-end
332 "--8<---------------cut here---------------end--------------->8---\n"
333 "How to mark the end of some inserted text."
335 :link '(custom-manual "(message)Insertion Variables")
336 :group 'message-various)
339 (defcustom message-archive-header
340 "X-No-Archive: Yes\n"
341 "Header to insert when you don't want your article to be archived.
342 Archives \(such as groups.google.com\) respect this header."
344 :link '(custom-manual "(message)Header Commands")
345 :group 'message-various)
348 (defcustom message-archive-note
349 "X-No-Archive: Yes - save http://groups.google.com/"
350 "Note to insert why you wouldn't want this posting archived.
351 If nil, don't insert any text in the body."
352 :type '(radio (string :format "%t: %v\n" :size 0)
354 :link '(custom-manual "(message)Header Commands")
355 :group 'message-various)
357 ;;; Crossposts and Followups
358 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
359 ;; new suggestions by R. Weikusat <rw at another.de>
361 (defvar message-cross-post-old-target nil
362 "Old target for cross-posts or follow-ups.")
363 (make-variable-buffer-local 'message-cross-post-old-target)
366 (defcustom message-cross-post-default t
367 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
368 If nil, `message-cross-post-followup-to' will only do a followup. Note that
369 you can explicitly override this setting by calling
370 `message-cross-post-followup-to' with a prefix."
372 :group 'message-various)
375 (defcustom message-cross-post-note
376 "Crosspost & Followup-To: "
377 "Note to insert before signature to notify of cross-post and follow-up."
379 :group 'message-various)
382 (defcustom message-followup-to-note
384 "Note to insert before signature to notify of follow-up only."
386 :group 'message-various)
389 (defcustom message-cross-post-note-function
390 'message-cross-post-insert-note
391 "Function to use to insert note about Crosspost or Followup-To.
392 The function will be called with four arguments. The function should not only
393 insert a note, but also ensure old notes are deleted. See the documentation
394 for `message-cross-post-insert-note'."
396 :group 'message-various)
398 ;;; End of variables adopted from `message-utils.el'.
401 (defcustom message-signature-separator "^-- *$"
402 "Regexp matching the signature separator."
404 :link '(custom-manual "(message)Various Message Variables")
405 :group 'message-various)
407 (defcustom message-elide-ellipsis "\n[...]\n\n"
408 "*The string which is inserted for elided text."
410 :link '(custom-manual "(message)Various Commands")
411 :group 'message-various)
413 (defcustom message-interactive t
414 "Non-nil means when sending a message wait for and display errors.
415 nil means let mailer mail back a message to report errors."
416 :group 'message-sending
418 :link '(custom-manual "(message)Sending Variables")
421 (defcustom message-generate-new-buffers 'unique
422 "*Non-nil means create a new message buffer whenever `message-setup' is called.
423 If this is a function, call that function with three parameters: The type,
424 the to address and the group name. (Any of these may be nil.) The function
425 should return the new buffer name."
426 :group 'message-buffers
427 :link '(custom-manual "(message)Message Buffers")
428 :type '(choice (const :tag "off" nil)
429 (const :tag "unique" unique)
430 (const :tag "unsent" unsent)
433 (defcustom message-kill-buffer-on-exit nil
434 "*Non-nil means that the message buffer will be killed after sending a message."
435 :group 'message-buffers
436 :link '(custom-manual "(message)Message Buffers")
440 (defvar gnus-local-organization))
441 (defcustom message-user-organization
442 (or (and (boundp 'gnus-local-organization)
443 (stringp gnus-local-organization)
444 gnus-local-organization)
445 (getenv "ORGANIZATION")
447 "*String to be used as an Organization header.
448 If t, use `message-user-organization-file'."
449 :group 'message-headers
450 :type '(choice string
451 (const :tag "consult file" t)))
454 (defcustom message-user-organization-file "/usr/lib/news/organization"
455 "*Local news organization file."
457 :link '(custom-manual "(message)News Headers")
458 :group 'message-headers)
460 (defcustom message-make-forward-subject-function
461 #'message-forward-subject-name-subject
462 "*List of functions called to generate subject headers for forwarded messages.
463 The subject generated by the previous function is passed into each
466 The provided functions are:
468 * `message-forward-subject-author-subject' Source of article (author or
469 newsgroup), in brackets followed by the subject
470 * `message-forward-subject-name-subject' Source of article (name of author
471 or newsgroup), in brackets followed by the subject
472 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
474 :group 'message-forwarding
475 :link '(custom-manual "(message)Forwarding")
476 :type '(radio (function-item message-forward-subject-author-subject)
477 (function-item message-forward-subject-fwd)
478 (function-item message-forward-subject-name-subject)
479 (repeat :tag "List of functions" function)))
481 (defcustom message-forward-as-mime t
482 "*Non-nil means forward messages as an inline/rfc822 MIME section.
483 Otherwise, directly inline the old message in the forwarded message."
485 :group 'message-forwarding
486 :link '(custom-manual "(message)Forwarding")
489 (defcustom message-forward-show-mml 'best
490 "*Non-nil means show forwarded messages as MML (decoded from MIME).
491 Otherwise, forwarded messages are unchanged.
492 Can also be the symbol `best' to indicate that MML should be
493 used, except when it is a bad idea to use MML. One example where
494 it is a bad idea is when forwarding a signed or encrypted
495 message, because converting MIME to MML would invalidate the
498 :group 'message-forwarding
499 :type '(choice (const :tag "use MML" t)
500 (const :tag "don't use MML " nil)
501 (const :tag "use MML when appropriate" best)))
503 (defcustom message-forward-before-signature t
504 "*Non-nil means put forwarded message before signature, else after."
505 :group 'message-forwarding
508 (defcustom message-wash-forwarded-subjects nil
509 "*Non-nil means try to remove as much cruft as possible from the subject.
510 Done before generating the new subject of a forward."
511 :group 'message-forwarding
512 :link '(custom-manual "(message)Forwarding")
515 (defcustom message-ignored-resent-headers "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From "
516 "*All headers that match this regexp will be deleted when resending a message."
517 :group 'message-interface
518 :link '(custom-manual "(message)Resending")
521 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
522 "*All headers that match this regexp will be deleted when forwarding a message."
524 :group 'message-forwarding
525 :type '(choice (const :tag "None" nil)
528 (defcustom message-ignored-cited-headers "."
529 "*Delete these headers from the messages you yank."
530 :group 'message-insertion
531 :link '(custom-manual "(message)Insertion Variables")
534 (defcustom message-cite-prefix-regexp
535 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
536 "\\([ \t]*[-_.[:word:]]+>+\\|[ \t]*[]>|}+]\\)+"
537 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
538 (let (non-word-constituents)
539 (with-syntax-table text-mode-syntax-table
540 (setq non-word-constituents
542 (if (string-match "\\w" "-") "" "-")
543 (if (string-match "\\w" "_") "" "_")
544 (if (string-match "\\w" ".") "" "."))))
545 (if (equal non-word-constituents "")
546 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}+]\\)+"
547 (concat "\\([ \t]*\\(\\w\\|["
548 non-word-constituents
549 "]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
550 "*Regexp matching the longest possible citation prefix on a line."
551 :group 'message-insertion
552 :link '(custom-manual "(message)Insertion Variables")
555 (defcustom message-cancel-message "I am canceling my own article.\n"
556 "Message to be inserted in the cancel message."
557 :group 'message-interface
558 :link '(custom-manual "(message)Canceling News")
561 ;; Useful to set in site-init.el
563 (defcustom message-send-mail-function 'message-send-mail-with-sendmail
564 "Function to call to send the current buffer as mail.
565 The headers should be delimited by a line whose contents match the
566 variable `mail-header-separator'.
568 Valid values include `message-send-mail-with-sendmail' (the default),
569 `message-send-mail-with-mh', `message-send-mail-with-qmail',
570 `message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
572 See also `send-mail-function'."
573 :type '(radio (function-item message-send-mail-with-sendmail)
574 (function-item message-send-mail-with-mh)
575 (function-item message-send-mail-with-qmail)
576 (function-item message-smtpmail-send-it)
577 (function-item smtpmail-send-it)
578 (function-item feedmail-send-it)
579 (function :tag "Other"))
580 :group 'message-sending
581 :link '(custom-manual "(message)Mail Variables")
582 :group 'message-mail)
584 (defcustom message-send-news-function 'message-send-news
585 "Function to call to send the current buffer as news.
586 The headers should be delimited by a line whose contents match the
587 variable `mail-header-separator'."
588 :group 'message-sending
590 :link '(custom-manual "(message)News Variables")
593 (defcustom message-reply-to-function nil
594 "If non-nil, function that should return a list of headers.
595 This function should pick out addresses from the To, Cc, and From headers
596 and respond with new To and Cc headers."
597 :group 'message-interface
598 :link '(custom-manual "(message)Reply")
599 :type '(choice function (const nil)))
601 (defcustom message-wide-reply-to-function nil
602 "If non-nil, function that should return a list of headers.
603 This function should pick out addresses from the To, Cc, and From headers
604 and respond with new To and Cc headers."
605 :group 'message-interface
606 :link '(custom-manual "(message)Wide Reply")
607 :type '(choice function (const nil)))
609 (defcustom message-followup-to-function nil
610 "If non-nil, function that should return a list of headers.
611 This function should pick out addresses from the To, Cc, and From headers
612 and respond with new To and Cc headers."
613 :group 'message-interface
614 :link '(custom-manual "(message)Followup")
615 :type '(choice function (const nil)))
617 (defcustom message-use-followup-to 'ask
618 "*Specifies what to do with Followup-To header.
619 If nil, always ignore the header. If it is t, use its value, but
620 query before using the \"poster\" value. If it is the symbol `ask',
621 always query the user whether to use the value. If it is the symbol
622 `use', always use the value."
623 :group 'message-interface
624 :link '(custom-manual "(message)Followup")
625 :type '(choice (const :tag "ignore" nil)
626 (const :tag "use & query" t)
630 (defcustom message-use-mail-followup-to 'use
631 "*Specifies what to do with Mail-Followup-To header.
632 If nil, always ignore the header. If it is the symbol `ask', always
633 query the user whether to use the value. If it is the symbol `use',
634 always use the value."
635 :group 'message-interface
636 :link '(custom-manual "(message)Mailing Lists")
637 :type '(choice (const :tag "ignore" nil)
641 (defcustom message-subscribed-address-functions nil
642 "*Specifies functions for determining list subscription.
643 If nil, do not attempt to determine list subscription with functions.
644 If non-nil, this variable contains a list of functions which return
645 regular expressions to match lists. These functions can be used in
646 conjunction with `message-subscribed-regexps' and
647 `message-subscribed-addresses'."
648 :group 'message-interface
649 :link '(custom-manual "(message)Mailing Lists")
650 :type '(repeat sexp))
652 (defcustom message-subscribed-address-file nil
653 "*A file containing addresses the user is subscribed to.
654 If nil, do not look at any files to determine list subscriptions. If
655 non-nil, each line of this file should be a mailing list address."
656 :group 'message-interface
657 :link '(custom-manual "(message)Mailing Lists")
658 :type '(radio (file :format "%t: %v\n" :size 0)
661 (defcustom message-subscribed-addresses nil
662 "*Specifies a list of addresses the user is subscribed to.
663 If nil, do not use any predefined list subscriptions. This list of
664 addresses can be used in conjunction with
665 `message-subscribed-address-functions' and `message-subscribed-regexps'."
666 :group 'message-interface
667 :link '(custom-manual "(message)Mailing Lists")
668 :type '(repeat string))
670 (defcustom message-subscribed-regexps nil
671 "*Specifies a list of addresses the user is subscribed to.
672 If nil, do not use any predefined list subscriptions. This list of
673 regular expressions can be used in conjunction with
674 `message-subscribed-address-functions' and `message-subscribed-addresses'."
675 :group 'message-interface
676 :link '(custom-manual "(message)Mailing Lists")
677 :type '(repeat regexp))
679 (defcustom message-allow-no-recipients 'ask
680 "Specifies what to do when there are no recipients other than Gcc/Fcc.
681 If it is the symbol `always', the posting is allowed. If it is the
682 symbol `never', the posting is not allowed. If it is the symbol
683 `ask', you are prompted."
684 :group 'message-interface
685 :link '(custom-manual "(message)Message Headers")
686 :type '(choice (const always)
690 (defcustom message-sendmail-f-is-evil nil
691 "*Non-nil means don't add \"-f username\" to the sendmail command line.
692 Doing so would be even more evil than leaving it out."
693 :group 'message-sending
694 :link '(custom-manual "(message)Mail Variables")
697 (defcustom message-sendmail-envelope-from nil
698 "*Envelope-from when sending mail with sendmail.
699 If this is nil, use `user-mail-address'. If it is the symbol
700 `header', use the From: header of the message."
701 :type '(choice (string :tag "From name")
702 (const :tag "Use From: header from message" header)
703 (const :tag "Use `user-mail-address'" nil))
704 :link '(custom-manual "(message)Mail Variables")
705 :group 'message-sending)
707 ;; qmail-related stuff
708 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
709 "Location of the qmail-inject program."
710 :group 'message-sending
711 :link '(custom-manual "(message)Mail Variables")
714 (defcustom message-qmail-inject-args nil
715 "Arguments passed to qmail-inject programs.
716 This should be a list of strings, one string for each argument. It
717 may also be a function.
719 For e.g., if you wish to set the envelope sender address so that bounces
720 go to the right place or to deal with listserv's usage of that address, you
721 might set this variable to '(\"-f\" \"you@some.where\")."
722 :group 'message-sending
723 :link '(custom-manual "(message)Mail Variables")
724 :type '(choice (function)
727 (defvar message-cater-to-broken-inn t
728 "Non-nil means Gnus should not fold the `References' header.
729 Folding `References' makes ancient versions of INN create incorrect
733 (defvar gnus-post-method)
734 (defvar gnus-select-method))
735 (defcustom message-post-method
736 (cond ((and (boundp 'gnus-post-method)
737 (listp gnus-post-method)
740 ((boundp 'gnus-select-method)
743 "*Method used to post news.
744 Note that when posting from inside Gnus, for instance, this
745 variable isn't used."
747 :group 'message-sending
748 ;; This should be the `gnus-select-method' widget, but that might
749 ;; create a dependence to `gnus.el'.
752 ;; FIXME: This should be a temporary workaround until someone implements a
753 ;; proper solution. If a crash happens while replying, the auto-save file
754 ;; will *not* have a `References:' header if `message-generate-headers-first'
755 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
756 (defcustom message-generate-headers-first '(references)
757 "Which headers should be generated before starting to compose a message.
758 If t, generate all required headers. This can also be a list of headers to
759 generate. The variables `message-required-news-headers' and
760 `message-required-mail-headers' specify which headers to generate.
762 Note that the variable `message-deletable-headers' specifies headers which
763 are to be deleted and then re-generated before sending, so this variable
764 will not have a visible effect for those headers."
765 :group 'message-headers
766 :link '(custom-manual "(message)Message Headers")
767 :type '(choice (const :tag "None" nil)
768 (const :tag "References" '(references))
770 (repeat (sexp :tag "Header"))))
772 (defcustom message-setup-hook nil
773 "Normal hook, run each time a new outgoing message is initialized.
774 The function `message-setup' runs this hook."
775 :group 'message-various
776 :link '(custom-manual "(message)Various Message Variables")
779 (defcustom message-cancel-hook nil
780 "Hook run when cancelling articles."
781 :group 'message-various
782 :link '(custom-manual "(message)Various Message Variables")
785 (defcustom message-signature-setup-hook nil
786 "Normal hook, run each time a new outgoing message is initialized.
787 It is run after the headers have been inserted and before
788 the signature is inserted."
789 :group 'message-various
790 :link '(custom-manual "(message)Various Message Variables")
793 (defcustom message-mode-hook nil
794 "Hook run in message mode buffers."
795 :group 'message-various
798 (defcustom message-header-hook nil
799 "Hook run in a message mode buffer narrowed to the headers."
800 :group 'message-various
803 (defcustom message-header-setup-hook nil
804 "Hook called narrowed to the headers when setting up a message buffer."
805 :group 'message-various
806 :link '(custom-manual "(message)Various Message Variables")
809 (defcustom message-minibuffer-local-map
810 (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
811 (set-keymap-parent map minibuffer-local-map)
813 "Keymap for `message-read-from-minibuffer'.")
816 (defcustom message-citation-line-function 'message-insert-citation-line
817 "*Function called to insert the \"Whomever writes:\" line.
819 Note that Gnus provides a feature where the reader can click on
820 `writes:' to hide the cited text. If you change this line too much,
821 people who read your message will have to change their Gnus
822 configuration. See the variable `gnus-cite-attribution-suffix'."
824 :link '(custom-manual "(message)Insertion Variables")
825 :group 'message-insertion)
828 (defcustom message-yank-prefix "> "
829 "*Prefix inserted on the lines of yanked messages.
830 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
831 See also `message-yank-cited-prefix'."
833 :link '(custom-manual "(message)Insertion Variables")
834 :group 'message-insertion)
836 (defcustom message-yank-cited-prefix ">"
837 "*Prefix inserted on cited or empty lines of yanked messages.
838 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
839 See also `message-yank-prefix'."
841 :link '(custom-manual "(message)Insertion Variables")
842 :group 'message-insertion)
844 (defcustom message-indentation-spaces 3
845 "*Number of spaces to insert at the beginning of each cited line.
846 Used by `message-yank-original' via `message-yank-cite'."
847 :group 'message-insertion
848 :link '(custom-manual "(message)Insertion Variables")
852 (defcustom message-cite-function 'message-cite-original
853 "*Function for citing an original message.
854 Predefined functions include `message-cite-original' and
855 `message-cite-original-without-signature'.
856 Note that `message-cite-original' uses `mail-citation-hook' if that is non-nil."
857 :type '(radio (function-item message-cite-original)
858 (function-item message-cite-original-without-signature)
859 (function-item sc-cite-original)
860 (function :tag "Other"))
861 :link '(custom-manual "(message)Insertion Variables")
862 :group 'message-insertion)
865 (defcustom message-indent-citation-function 'message-indent-citation
866 "*Function for modifying a citation just inserted in the mail buffer.
867 This can also be a list of functions. Each function can find the
868 citation between (point) and (mark t). And each function should leave
869 point and mark around the citation text as modified."
871 :link '(custom-manual "(message)Insertion Variables")
872 :group 'message-insertion)
875 (defcustom message-signature t
876 "*String to be inserted at the end of the message buffer.
877 If t, the `message-signature-file' file will be inserted instead.
878 If a function, the result from the function will be used instead.
879 If a form, the result from the form will be used instead."
881 :link '(custom-manual "(message)Insertion Variables")
882 :group 'message-insertion)
885 (defcustom message-signature-file "~/.signature"
886 "*Name of file containing the text inserted at end of message buffer.
887 Ignored if the named file doesn't exist.
888 If nil, don't insert a signature."
889 :type '(choice file (const :tags "None" nil))
890 :link '(custom-manual "(message)Insertion Variables")
891 :group 'message-insertion)
894 (defcustom message-signature-insert-empty-line t
895 "*If non-nil, insert an empty line before the signature separator."
897 :link '(custom-manual "(message)Insertion Variables")
898 :group 'message-insertion)
900 (defcustom message-distribution-function nil
901 "*Function called to return a Distribution header."
903 :group 'message-headers
904 :link '(custom-manual "(message)News Headers")
905 :type '(choice function (const nil)))
907 (defcustom message-expires 14
908 "Number of days before your article expires."
910 :group 'message-headers
911 :link '(custom-manual "(message)News Headers")
914 (defcustom message-user-path nil
915 "If nil, use the NNTP server name in the Path header.
916 If stringp, use this; if non-nil, use no host name (user name only)."
918 :group 'message-headers
919 :link '(custom-manual "(message)News Headers")
920 :type '(choice (const :tag "nntp" nil)
922 (sexp :tag "none" :format "%t" t)))
924 (defvar message-reply-buffer nil)
925 (defvar message-reply-headers nil
926 "The headers of the current replied article.
927 It is a vector of the following headers:
928 \[number subject from date id references chars lines xref extra].")
929 (defvar message-newsreader nil)
930 (defvar message-mailer nil)
931 (defvar message-sent-message-via nil)
932 (defvar message-checksum nil)
933 (defvar message-send-actions nil
934 "A list of actions to be performed upon successful sending of a message.")
935 (defvar message-exit-actions nil
936 "A list of actions to be performed upon exiting after sending a message.")
937 (defvar message-kill-actions nil
938 "A list of actions to be performed before killing a message buffer.")
939 (defvar message-postpone-actions nil
940 "A list of actions to be performed after postponing a message.")
942 (define-widget 'message-header-lines 'text
943 "All header lines must be LFD terminated."
944 :format "%{%t%}:%n%v"
946 :error "All header lines must be newline terminated")
948 (defcustom message-default-headers ""
949 "*A string containing header lines to be inserted in outgoing messages.
950 It is inserted before you edit the message, so you can edit or delete
952 :group 'message-headers
953 :link '(custom-manual "(message)Message Headers")
954 :type 'message-header-lines)
956 (defcustom message-default-mail-headers ""
957 "*A string of header lines to be inserted in outgoing mails."
958 :group 'message-headers
960 :link '(custom-manual "(message)Mail Headers")
961 :type 'message-header-lines)
963 (defcustom message-default-news-headers ""
964 "*A string of header lines to be inserted in outgoing news articles."
965 :group 'message-headers
967 :link '(custom-manual "(message)News Headers")
968 :type 'message-header-lines)
970 ;; Note: could use /usr/ucb/mail instead of sendmail;
971 ;; options -t, and -v if not interactive.
972 (defcustom message-mailer-swallows-blank-line
973 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
974 system-configuration)
975 (file-readable-p "/etc/sendmail.cf")
976 (let ((buffer (get-buffer-create " *temp*")))
980 (insert-file-contents "/etc/sendmail.cf")
981 (goto-char (point-min))
982 (let ((case-fold-search nil))
983 (re-search-forward "^OR\\>" nil t)))
984 (kill-buffer buffer))))
985 ;; According to RFC822, "The field-name must be composed of printable
986 ;; ASCII characters (i. e., characters that have decimal values between
987 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
989 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
990 "*Set this non-nil if the system's mailer runs the header and body together.
991 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
992 The value should be an expression to test whether the problem will
994 :group 'message-sending
995 :link '(custom-manual "(message)Mail Variables")
999 (define-mail-user-agent 'message-user-agent
1000 'message-mail 'message-send-and-exit
1001 'message-kill-buffer 'message-send-hook)
1003 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1004 "If non-nil, delete the deletable headers before feeding to mh.")
1006 (defvar message-send-method-alist
1007 '((news message-news-p message-send-via-news)
1008 (mail message-mail-p message-send-via-mail))
1009 "Alist of ways to send outgoing messages.
1010 Each element has the form
1012 \(TYPE PREDICATE FUNCTION)
1014 where TYPE is a symbol that names the method; PREDICATE is a function
1015 called without any parameters to determine whether the message is
1016 a message of type TYPE; and FUNCTION is a function to be called if
1017 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1020 (defcustom message-mail-alias-type 'abbrev
1021 "*What alias expansion type to use in Message buffers.
1022 The default is `abbrev', which uses mailabbrev. nil switches
1025 :link '(custom-manual "(message)Mail Aliases")
1026 :type '(choice (const :tag "Use Mailabbrev" abbrev)
1027 (const :tag "No expansion" nil)))
1029 (defcustom message-auto-save-directory
1030 (file-name-as-directory (nnheader-concat message-directory "drafts"))
1031 "*Directory where Message auto-saves buffers if Gnus isn't running.
1032 If nil, Message won't auto-save."
1033 :group 'message-buffers
1034 :link '(custom-manual "(message)Various Message Variables")
1035 :type '(choice directory (const :tag "Don't auto-save" nil)))
1037 (defcustom message-default-charset
1038 (and (not (mm-multibyte-p)) 'iso-8859-1)
1039 "Default charset used in non-MULE Emacsen.
1040 If nil, you might be asked to input the charset."
1043 :link '(custom-manual "(message)Various Message Variables")
1046 (defcustom message-dont-reply-to-names
1047 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1048 "*A regexp specifying addresses to prune when doing wide replies.
1049 A value of nil means exclude your own user name only."
1052 :link '(custom-manual "(message)Wide Reply")
1053 :type '(choice (const :tag "Yourself" nil)
1056 (defvar message-shoot-gnksa-feet nil
1057 "*A list of GNKSA feet you are allowed to shoot.
1058 Gnus gives you all the opportunity you could possibly want for
1059 shooting yourself in the foot. Also, Gnus allows you to shoot the
1060 feet of Good Net-Keeping Seal of Approval. The following are foot
1062 `empty-article' Allow you to post an empty article;
1063 `quoted-text-only' Allow you to post quoted text only;
1064 `multiple-copies' Allow you to post multiple copies;
1065 `cancel-messages' Allow you to cancel or supersede messages from
1066 your other email addresses.")
1068 (defsubst message-gnksa-enable-p (feature)
1069 (or (not (listp message-shoot-gnksa-feet))
1070 (memq feature message-shoot-gnksa-feet)))
1072 (defcustom message-hidden-headers nil
1073 "Regexp of headers to be hidden when composing new messages.
1074 This can also be a list of regexps to match headers. Or a list
1075 starting with `not' and followed by regexps."
1077 :link '(custom-manual "(message)Message Headers")
1078 :type '(repeat regexp))
1080 ;;; Internal variables.
1081 ;;; Well, not really internal.
1083 (defvar message-mode-syntax-table
1084 (let ((table (copy-syntax-table text-mode-syntax-table)))
1085 (modify-syntax-entry ?% ". " table)
1086 (modify-syntax-entry ?> ". " table)
1087 (modify-syntax-entry ?< ". " table)
1089 "Syntax table used while in Message mode.")
1091 (defface message-header-to-face
1094 (:foreground "green2" :bold t))
1097 (:foreground "MidnightBlue" :bold t))
1099 (:bold t :italic t)))
1100 "Face used for displaying From headers."
1101 :group 'message-faces)
1103 (defface message-header-cc-face
1106 (:foreground "green4" :bold t))
1109 (:foreground "MidnightBlue"))
1112 "Face used for displaying Cc headers."
1113 :group 'message-faces)
1115 (defface message-header-subject-face
1118 (:foreground "green3"))
1121 (:foreground "navy blue" :bold t))
1124 "Face used for displaying subject headers."
1125 :group 'message-faces)
1127 (defface message-header-newsgroups-face
1130 (:foreground "yellow" :bold t :italic t))
1133 (:foreground "blue4" :bold t :italic t))
1135 (:bold t :italic t)))
1136 "Face used for displaying newsgroups headers."
1137 :group 'message-faces)
1139 (defface message-header-other-face
1142 (:foreground "#b00000"))
1145 (:foreground "steel blue"))
1147 (:bold t :italic t)))
1148 "Face used for displaying newsgroups headers."
1149 :group 'message-faces)
1151 (defface message-header-name-face
1154 (:foreground "DarkGreen"))
1157 (:foreground "cornflower blue"))
1160 "Face used for displaying header names."
1161 :group 'message-faces)
1163 (defface message-header-xheader-face
1166 (:foreground "blue"))
1169 (:foreground "blue"))
1172 "Face used for displaying X-Header headers."
1173 :group 'message-faces)
1175 (defface message-separator-face
1178 (:foreground "blue3"))
1181 (:foreground "brown"))
1184 "Face used for displaying the separator."
1185 :group 'message-faces)
1187 (defface message-cited-text-face
1190 (:foreground "red"))
1193 (:foreground "red"))
1196 "Face used for displaying cited text names."
1197 :group 'message-faces)
1199 (defface message-mml-face
1202 (:foreground "ForestGreen"))
1205 (:foreground "ForestGreen"))
1208 "Face used for displaying MML."
1209 :group 'message-faces)
1211 (defun message-font-lock-make-header-matcher (regexp)
1214 (let ((start (point)))
1217 (goto-char (point-min))
1218 (if (re-search-forward
1219 (concat "^" (regexp-quote mail-header-separator) "$")
1221 (setq limit (min limit (match-beginning 0))))
1223 (and (< start limit)
1224 (re-search-forward ,regexp limit t))))))
1225 (if (featurep 'bytecomp)
1229 (defvar message-font-lock-keywords
1230 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1231 `((,(message-font-lock-make-header-matcher
1232 (concat "^\\([Tt]o:\\)" content))
1233 (1 'message-header-name-face)
1234 (2 'message-header-to-face nil t))
1235 (,(message-font-lock-make-header-matcher
1236 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1237 (1 'message-header-name-face)
1238 (2 'message-header-cc-face nil t))
1239 (,(message-font-lock-make-header-matcher
1240 (concat "^\\([Ss]ubject:\\)" content))
1241 (1 'message-header-name-face)
1242 (2 'message-header-subject-face nil t))
1243 (,(message-font-lock-make-header-matcher
1244 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content))
1245 (1 'message-header-name-face)
1246 (2 'message-header-newsgroups-face nil t))
1247 (,(message-font-lock-make-header-matcher
1248 (concat "^\\([A-Z][^: \n\t]+:\\)" content))
1249 (1 'message-header-name-face)
1250 (2 'message-header-other-face nil t))
1251 (,(message-font-lock-make-header-matcher
1252 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content))
1253 (1 'message-header-name-face)
1254 (2 'message-header-name-face))
1255 ,@(if (and mail-header-separator
1256 (not (equal mail-header-separator "")))
1257 `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
1258 1 'message-separator-face))
1261 (re-search-forward (concat "^\\("
1262 message-cite-prefix-regexp
1265 (0 'message-cited-text-face))
1266 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1267 (0 'message-mml-face))))
1268 "Additional expressions to highlight in Message mode.")
1271 ;; XEmacs does it like this. For Emacs, we have to set the
1272 ;; `font-lock-defaults' buffer-local variable.
1273 (put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
1275 (defvar message-face-alist
1276 '((bold . bold-region)
1277 (underline . underline-region)
1278 (default . (lambda (b e)
1280 (ununderline-region b e))))
1281 "Alist of mail and news faces for facemenu.
1282 The cdr of each entry is a function for applying the face to a region.")
1284 (defcustom message-send-hook nil
1285 "Hook run before sending messages.
1286 This hook is run quite early when sending."
1287 :group 'message-various
1288 :options '(ispell-message)
1289 :link '(custom-manual "(message)Various Message Variables")
1292 (defcustom message-send-mail-hook nil
1293 "Hook run before sending mail messages.
1294 This hook is run very late -- just before the message is sent as
1296 :group 'message-various
1297 :link '(custom-manual "(message)Various Message Variables")
1300 (defcustom message-send-news-hook nil
1301 "Hook run before sending news messages.
1302 This hook is run very late -- just before the message is sent as
1304 :group 'message-various
1305 :link '(custom-manual "(message)Various Message Variables")
1308 (defcustom message-sent-hook nil
1309 "Hook run after sending messages."
1310 :group 'message-various
1313 (defvar message-send-coding-system 'binary
1314 "Coding system to encode outgoing mail.")
1316 (defvar message-draft-coding-system
1317 mm-auto-save-coding-system
1318 "*Coding system to compose mail.
1319 If you'd like to make it possible to share draft files between XEmacs
1320 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1321 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1323 (defcustom message-send-mail-partially-limit 1000000
1324 "The limitation of messages sent as message/partial.
1325 The lower bound of message size in characters, beyond which the message
1326 should be sent in several parts. If it is nil, the size is unlimited."
1328 :group 'message-buffers
1329 :link '(custom-manual "(message)Mail Variables")
1330 :type '(choice (const :tag "unlimited" nil)
1333 (defcustom message-alternative-emails nil
1334 "A regexp to match the alternative email addresses.
1335 The first matched address (not primary one) is used in the From field."
1336 :group 'message-headers
1337 :link '(custom-manual "(message)Message Headers")
1338 :type '(choice (const :tag "Always use primary" nil)
1341 (defcustom message-hierarchical-addresses nil
1342 "A list of hierarchical mail address definitions.
1344 Inside each entry, the first address is the \"top\" address, and
1345 subsequent addresses are subaddresses; this is used to indicate that
1346 mail sent to the first address will automatically be delivered to the
1347 subaddresses. So if the first address appears in the recipient list
1348 for a message, the subaddresses will be removed (if present) before
1349 the mail is sent. All addresses in this structure should be
1351 :group 'message-headers
1352 :type '(repeat (repeat string)))
1354 (defcustom message-mail-user-agent nil
1355 "Like `mail-user-agent'.
1356 Except if it is nil, use Gnus native MUA; if it is t, use
1358 :type '(radio (const :tag "Gnus native"