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
41 ;; This is apparently necessary even though things are autoloaded.
42 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
43 ;; require mailabbrev here.
44 (if (featurep 'xemacs)
45 (require 'mail-abbrevs)
46 (require 'mailabbrev))
51 (defgroup message '((user-mail-address custom-variable)
52 (user-full-name custom-variable))
53 "Mail and news message composing."
54 :link '(custom-manual "(message)Top")
58 (put 'user-mail-address 'custom-type 'string)
59 (put 'user-full-name 'custom-type 'string)
61 (defgroup message-various nil
62 "Various Message Variables"
63 :link '(custom-manual "(message)Various Message Variables")
66 (defgroup message-buffers nil
68 :link '(custom-manual "(message)Message Buffers")
71 (defgroup message-sending nil
73 :link '(custom-manual "(message)Sending Variables")
76 (defgroup message-interface nil
78 :link '(custom-manual "(message)Interface")
81 (defgroup message-forwarding nil
83 :link '(custom-manual "(message)Forwarding")
84 :group 'message-interface)
86 (defgroup message-insertion nil
88 :link '(custom-manual "(message)Insertion")
91 (defgroup message-headers nil
93 :link '(custom-manual "(message)Message Headers")
96 (defgroup message-news nil
97 "Composing News Messages"
100 (defgroup message-mail nil
101 "Composing Mail Messages"
104 (defgroup message-faces nil
105 "Faces used for message composing."
109 (defcustom message-directory "~/Mail/"
110 "*Directory from which all other mail file variables are derived."
111 :group 'message-various
114 (defcustom message-max-buffers 10
115 "*How many buffers to keep before starting to kill them off."
116 :group 'message-buffers
119 (defcustom message-send-rename-function nil
120 "Function called to rename the buffer after sending it."
121 :group 'message-buffers
122 :type '(choice function (const nil)))
124 (defcustom message-fcc-handler-function 'message-output
125 "*A function called to save outgoing articles.
126 This function will be called with the name of the file to store the
127 article in. The default function is `message-output' which saves in Unix
129 :type '(radio (function-item message-output)
130 (function :tag "Other"))
131 :group 'message-sending)
133 (defcustom message-fcc-externalize-attachments nil
134 "If non-nil, attachments are included as external parts in Fcc copies."
137 :group 'message-sending)
139 (defcustom message-courtesy-message
140 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
141 "*This is inserted at the start of a mailed copy of a posted message.
142 If the string contains the format spec \"%s\", the Newsgroups
143 the article has been posted to will be inserted there.
144 If this variable is nil, no such courtesy message will be added."
145 :group 'message-sending
146 :type '(radio (string :format "%t: %v\n" :size 0) (const nil)))
148 (defcustom message-ignored-bounced-headers
149 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
150 "*Regexp that matches headers to be removed in resent bounced mail."
151 :group 'message-interface
155 (defcustom message-from-style 'default
156 "*Specifies how \"From\" headers look.
158 If nil, they contain just the return address like:
160 If `parens', they look like:
161 king@grassland.com (Elvis Parsley)
162 If `angles', they look like:
163 Elvis Parsley <king@grassland.com>
165 Otherwise, most addresses look like `angles', but they look like
166 `parens' if `angles' would need quoting and `parens' would not."
167 :type '(choice (const :tag "simple" nil)
171 :group 'message-headers)
173 (defcustom message-insert-canlock t
174 "Whether to insert a Cancel-Lock header in news postings."
176 :group 'message-headers
179 (defcustom message-syntax-checks
180 (if message-insert-canlock '((sender . disabled)) nil)
181 ;; Guess this one shouldn't be easy to customize...
182 "*Controls what syntax checks should not be performed on outgoing posts.
183 To disable checking of long signatures, for instance, add
184 `(signature . disabled)' to this list.
186 Don't touch this variable unless you really know what you're doing.
188 Checks include `subject-cmsg', `multiple-headers', `sendsys',
189 `message-id', `from', `long-lines', `control-chars', `size',
190 `new-text', `quoting-style', `redirected-followup', `signature',
191 `approved', `sender', `empty', `empty-headers', `message-id', `from',
192 `subject', `shorten-followup-to', `existing-newsgroups',
193 `buffer-file-name', `unchanged', `newsgroups', `reply-to',
194 `continuation-headers', `long-header-lines', `invisible-text' and
197 :type '(repeat sexp)) ; Fixme: improve this
199 (defcustom message-required-headers '((optional . References)
201 "*Headers to be generated or prompted for when sending a message.
202 Also see `message-required-news-headers' and
203 `message-required-mail-headers'."
206 :group 'message-headers
207 :link '(custom-manual "(message)Message Headers")
208 :type '(repeat sexp))
210 (defcustom message-draft-headers '(References From)
211 "*Headers to be generated when saving a draft message."
214 :group 'message-headers
215 :link '(custom-manual "(message)Message Headers")
216 :type '(repeat sexp))
218 (defcustom message-required-news-headers
219 '(From Newsgroups Subject Date Message-ID
220 (optional . Organization)
221 (optional . User-Agent))
222 "*Headers to be generated or prompted for when posting an article.
223 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
224 Message-ID. Organization, Lines, In-Reply-To, Expires, and
225 User-Agent are optional. If don't you want message to insert some
226 header, remove it from this list."
228 :group 'message-headers
229 :link '(custom-manual "(message)Message Headers")
230 :type '(repeat sexp))
232 (defcustom message-required-mail-headers
233 '(From Subject Date (optional . In-Reply-To) Message-ID
234 (optional . User-Agent))
235 "*Headers to be generated or prompted for when mailing a message.
236 It is recommended that From, Date, To, Subject and Message-ID be
237 included. Organization and User-Agent are optional."
239 :group 'message-headers
240 :link '(custom-manual "(message)Message Headers")
241 :type '(repeat sexp))
243 (defcustom message-deletable-headers '(Message-ID Date Lines)
244 "Headers to be deleted if they already exist and were generated by message previously."
245 :group 'message-headers
246 :link '(custom-manual "(message)Message Headers")
249 (defcustom message-ignored-news-headers
250 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
251 "*Regexp of headers to be removed unconditionally before posting."
253 :group 'message-headers
254 :link '(custom-manual "(message)Message Headers")
255 :type '(repeat :value-to-internal (lambda (widget value)
256 (custom-split-regexp-maybe value))
257 :match (lambda (widget value)
259 (widget-editable-list-match widget value)))
262 (defcustom message-ignored-mail-headers
263 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
264 "*Regexp of headers to be removed unconditionally before mailing."
266 :group 'message-headers
267 :link '(custom-manual "(message)Mail Headers")
270 (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:\\|^Approved:"
271 "*Header lines matching this regexp will be deleted before posting.
272 It's best to delete old Path and Date headers before posting to avoid
274 :group 'message-interface
275 :link '(custom-manual "(message)Superseding")
276 :type '(repeat :value-to-internal (lambda (widget value)
277 (custom-split-regexp-maybe value))
278 :match (lambda (widget value)
280 (widget-editable-list-match widget value)))
283 (defcustom message-subject-re-regexp
284 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
285 "*Regexp matching \"Re: \" in the subject line."
286 :group 'message-various
287 :link '(custom-manual "(message)Message Headers")
290 ;;; Start of variables adopted from `message-utils.el'.
292 (defcustom message-subject-trailing-was-query 'ask
293 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
294 If nil, leave the subject unchanged. If it is the symbol `ask', query
295 the user what do do. In this case, the subject is matched against
296 `message-subject-trailing-was-ask-regexp'. If
297 `message-subject-trailing-was-query' is t, always strip the trailing
298 old subject. In this case, `message-subject-trailing-was-regexp' is
301 :type '(choice (const :tag "never" nil)
302 (const :tag "always strip" t)
304 :link '(custom-manual "(message)Message Headers")
305 :group 'message-various)
307 (defcustom message-subject-trailing-was-ask-regexp
308 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
309 "*Regexp matching \"(was: <old subject>)\" in the subject line.
311 The function `message-strip-subject-trailing-was' uses this regexp if
312 `message-subject-trailing-was-query' is set to the symbol `ask'. If
313 the variable is t instead of `ask', use
314 `message-subject-trailing-was-regexp' instead.
316 It is okay to create some false positives here, as the user is asked."
318 :group 'message-various
319 :link '(custom-manual "(message)Message Headers")
322 (defcustom message-subject-trailing-was-regexp
323 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
324 "*Regexp matching \"(was: <old subject>)\" in the subject line.
326 If `message-subject-trailing-was-query' is set to t, the subject is
327 matched against `message-subject-trailing-was-regexp' in
328 `message-strip-subject-trailing-was'. You should use a regexp creating very
329 few false positives here."
331 :group 'message-various
332 :link '(custom-manual "(message)Message Headers")
335 ;; Fixme: Why are all these things autoloaded?
337 ;;; marking inserted text
340 (defcustom message-mark-insert-begin
341 "--8<---------------cut here---------------start------------->8---\n"
342 "How to mark the beginning of some inserted text."
345 :link '(custom-manual "(message)Insertion Variables")
346 :group 'message-various)
349 (defcustom message-mark-insert-end
350 "--8<---------------cut here---------------end--------------->8---\n"
351 "How to mark the end of some inserted text."
354 :link '(custom-manual "(message)Insertion Variables")
355 :group 'message-various)
358 (defcustom message-archive-header
359 "X-No-Archive: Yes\n"
360 "Header to insert when you don't want your article to be archived.
361 Archives \(such as groups.google.com\) respect this header."
364 :link '(custom-manual "(message)Header Commands")
365 :group 'message-various)
368 (defcustom message-archive-note
369 "X-No-Archive: Yes - save http://groups.google.com/"
370 "Note to insert why you wouldn't want this posting archived.
371 If nil, don't insert any text in the body."
373 :type '(radio (string :format "%t: %v\n" :size 0)
375 :link '(custom-manual "(message)Header Commands")
376 :group 'message-various)
378 ;;; Crossposts and Followups
379 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
380 ;; new suggestions by R. Weikusat <rw at another.de>
382 (defvar message-cross-post-old-target nil
383 "Old target for cross-posts or follow-ups.")
384 (make-variable-buffer-local 'message-cross-post-old-target)
387 (defcustom message-cross-post-default t
388 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
389 If nil, `message-cross-post-followup-to' will only do a followup. Note that
390 you can explicitly override this setting by calling
391 `message-cross-post-followup-to' with a prefix."
394 :group 'message-various)
397 (defcustom message-cross-post-note
398 "Crosspost & Followup-To: "
399 "Note to insert before signature to notify of cross-post and follow-up."
402 :group 'message-various)
405 (defcustom message-followup-to-note
407 "Note to insert before signature to notify of follow-up only."
410 :group 'message-various)
413 (defcustom message-cross-post-note-function
414 'message-cross-post-insert-note
415 "Function to use to insert note about Crosspost or Followup-To.
416 The function will be called with four arguments. The function should not only
417 insert a note, but also ensure old notes are deleted. See the documentation
418 for `message-cross-post-insert-note'."
421 :group 'message-various)
423 ;;; End of variables adopted from `message-utils.el'.
426 (defcustom message-signature-separator "^-- *$"
427 "Regexp matching the signature separator."
429 :link '(custom-manual "(message)Various Message Variables")
430 :group 'message-various)
432 (defcustom message-elide-ellipsis "\n[...]\n\n"
433 "*The string which is inserted for elided text."
435 :link '(custom-manual "(message)Various Commands")
436 :group 'message-various)
438 (defcustom message-interactive t
439 "Non-nil means when sending a message wait for and display errors.
440 nil means let mailer mail back a message to report errors."
441 :group 'message-sending
443 :link '(custom-manual "(message)Sending Variables")
446 (defcustom message-generate-new-buffers 'unique
447 "*Non-nil means create a new message buffer whenever `message-setup' is called.
448 If this is a function, call that function with three parameters: The type,
449 the to address and the group name. (Any of these may be nil.) The function
450 should return the new buffer name."
451 :group 'message-buffers
452 :link '(custom-manual "(message)Message Buffers")
453 :type '(choice (const :tag "off" nil)
454 (const :tag "unique" unique)
455 (const :tag "unsent" unsent)
458 (defcustom message-kill-buffer-on-exit nil
459 "*Non-nil means that the message buffer will be killed after sending a message."
460 :group 'message-buffers
461 :link '(custom-manual "(message)Message Buffers")
465 (defvar gnus-local-organization))
466 (defcustom message-user-organization
467 (or (and (boundp 'gnus-local-organization)
468 (stringp gnus-local-organization)
469 gnus-local-organization)
470 (getenv "ORGANIZATION")
472 "*String to be used as an Organization header.
473 If t, use `message-user-organization-file'."
474 :group 'message-headers
475 :type '(choice string
476 (const :tag "consult file" t)))
479 (defcustom message-user-organization-file "/usr/lib/news/organization"
480 "*Local news organization file."
482 :link '(custom-manual "(message)News Headers")
483 :group 'message-headers)
485 (defcustom message-make-forward-subject-function
486 #'message-forward-subject-name-subject
487 "*List of functions called to generate subject headers for forwarded messages.
488 The subject generated by the previous function is passed into each
491 The provided functions are:
493 * `message-forward-subject-author-subject' Source of article (author or
494 newsgroup), in brackets followed by the subject
495 * `message-forward-subject-name-subject' Source of article (name of author
496 or newsgroup), in brackets followed by the subject
497 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
499 :group 'message-forwarding
500 :link '(custom-manual "(message)Forwarding")
501 :type '(radio (function-item message-forward-subject-author-subject)
502 (function-item message-forward-subject-fwd)
503 (function-item message-forward-subject-name-subject)
504 (repeat :tag "List of functions" function)))
506 (defcustom message-forward-as-mime t
507 "*Non-nil means forward messages as an inline/rfc822 MIME section.
508 Otherwise, directly inline the old message in the forwarded message."
510 :group 'message-forwarding
511 :link '(custom-manual "(message)Forwarding")
514 (defcustom message-forward-show-mml 'best
515 "*Non-nil means show forwarded messages as MML (decoded from MIME).
516 Otherwise, forwarded messages are unchanged.
517 Can also be the symbol `best' to indicate that MML should be
518 used, except when it is a bad idea to use MML. One example where
519 it is a bad idea is when forwarding a signed or encrypted
520 message, because converting MIME to MML would invalidate the
523 :group 'message-forwarding
524 :type '(choice (const :tag "use MML" t)
525 (const :tag "don't use MML " nil)
526 (const :tag "use MML when appropriate" best)))
528 (defcustom message-forward-before-signature t
529 "*Non-nil means put forwarded message before signature, else after."
530 :group 'message-forwarding
533 (defcustom message-wash-forwarded-subjects nil
534 "*Non-nil means try to remove as much cruft as possible from the subject.
535 Done before generating the new subject of a forward."
536 :group 'message-forwarding
537 :link '(custom-manual "(message)Forwarding")
540 (defcustom message-ignored-resent-headers "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From "
541 "*All headers that match this regexp will be deleted when resending a message."
542 :group 'message-interface
543 :link '(custom-manual "(message)Resending")
544 :type '(repeat :value-to-internal (lambda (widget value)
545 (custom-split-regexp-maybe value))
546 :match (lambda (widget value)
548 (widget-editable-list-match widget value)))
551 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
552 "*All headers that match this regexp will be deleted when forwarding a message."
554 :group 'message-forwarding
555 :type '(repeat :value-to-internal (lambda (widget value)
556 (custom-split-regexp-maybe value))
557 :match (lambda (widget value)
559 (widget-editable-list-match widget value)))
562 (defcustom message-ignored-cited-headers "."
563 "*Delete these headers from the messages you yank."
564 :group 'message-insertion
565 :link '(custom-manual "(message)Insertion Variables")
568 (defcustom message-cite-prefix-regexp
569 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
570 "\\([ \t]*[-_.[:word:]]+>+\\|[ \t]*[]>|}+]\\)+"
571 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
572 (let (non-word-constituents)
573 (with-syntax-table text-mode-syntax-table
574 (setq non-word-constituents
576 (if (string-match "\\w" "-") "" "-")
577 (if (string-match "\\w" "_") "" "_")
578 (if (string-match "\\w" ".") "" "."))))
579 (if (equal non-word-constituents "")
580 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}+]\\)+"
581 (concat "\\([ \t]*\\(\\w\\|["
582 non-word-constituents
583 "]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
584 "*Regexp matching the longest possible citation prefix on a line."
586 :group 'message-insertion
587 :link '(custom-manual "(message)Insertion Variables")
590 (defcustom message-cancel-message "I am canceling my own article.\n"
591 "Message to be inserted in the cancel message."
592 :group 'message-interface
593 :link '(custom-manual "(message)Canceling News")
596 ;; Useful to set in site-init.el
598 (defcustom message-send-mail-function 'message-send-mail-with-sendmail
599 "Function to call to send the current buffer as mail.
600 The headers should be delimited by a line whose contents match the
601 variable `mail-header-separator'.
603 Valid values include `message-send-mail-with-sendmail' (the default),
604 `message-send-mail-with-mh', `message-send-mail-with-qmail',
605 `message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
607 See also `send-mail-function'."
608 :type '(radio (function-item message-send-mail-with-sendmail)
609 (function-item message-send-mail-with-mh)
610 (function-item message-send-mail-with-qmail)
611 (function-item message-smtpmail-send-it)
612 (function-item smtpmail-send-it)
613 (function-item feedmail-send-it)
614 (function :tag "Other"))
615 :group 'message-sending
616 :link '(custom-manual "(message)Mail Variables")
617 :group 'message-mail)
619 (defcustom message-send-news-function 'message-send-news
620 "Function to call to send the current buffer as news.
621 The headers should be delimited by a line whose contents match the
622 variable `mail-header-separator'."
623 :group 'message-sending
625 :link '(custom-manual "(message)News Variables")
628 (defcustom message-reply-to-function nil
629 "If non-nil, function that should return a list of headers.
630 This function should pick out addresses from the To, Cc, and From headers
631 and respond with new To and Cc headers."
632 :group 'message-interface
633 :link '(custom-manual "(message)Reply")
634 :type '(choice function (const nil)))
636 (defcustom message-wide-reply-to-function nil
637 "If non-nil, function that should return a list of headers.
638 This function should pick out addresses from the To, Cc, and From headers
639 and respond with new To and Cc headers."
640 :group 'message-interface
641 :link '(custom-manual "(message)Wide Reply")
642 :type '(choice function (const nil)))
644 (defcustom message-followup-to-function nil
645 "If non-nil, function that should return a list of headers.
646 This function should pick out addresses from the To, Cc, and From headers
647 and respond with new To and Cc headers."
648 :group 'message-interface
649 :link '(custom-manual "(message)Followup")
650 :type '(choice function (const nil)))
652 (defcustom message-use-followup-to 'ask
653 "*Specifies what to do with Followup-To header.
654 If nil, always ignore the header. If it is t, use its value, but
655 query before using the \"poster\" value. If it is the symbol `ask',
656 always query the user whether to use the value. If it is the symbol
657 `use', always use the value."
658 :group 'message-interface
659 :link '(custom-manual "(message)Followup")
660 :type '(choice (const :tag "ignore" nil)
661 (const :tag "use & query" t)
665 (defcustom message-use-mail-followup-to 'use
666 "*Specifies what to do with Mail-Followup-To header.
667 If nil, always ignore the header. If it is the symbol `ask', always
668 query the user whether to use the value. If it is the symbol `use',
669 always use the value."
671 :group 'message-interface
672 :link '(custom-manual "(message)Mailing Lists")
673 :type '(choice (const :tag "ignore" nil)
677 (defcustom message-subscribed-address-functions nil
678 "*Specifies functions for determining list subscription.
679 If nil, do not attempt to determine list subscription with functions.
680 If non-nil, this variable contains a list of functions which return
681 regular expressions to match lists. These functions can be used in
682 conjunction with `message-subscribed-regexps' and
683 `message-subscribed-addresses'."
685 :group 'message-interface
686 :link '(custom-manual "(message)Mailing Lists")
687 :type '(repeat sexp))
689 (defcustom message-subscribed-address-file nil
690 "*A file containing addresses the user is subscribed to.
691 If nil, do not look at any files to determine list subscriptions. If
692 non-nil, each line of this file should be a mailing list address."
694 :group 'message-interface
695 :link '(custom-manual "(message)Mailing Lists")
696 :type '(radio (file :format "%t: %v\n" :size 0)
699 (defcustom message-subscribed-addresses nil
700 "*Specifies a list of addresses the user is subscribed to.
701 If nil, do not use any predefined list subscriptions. This list of
702 addresses can be used in conjunction with
703 `message-subscribed-address-functions' and `message-subscribed-regexps'."
705 :group 'message-interface
706 :link '(custom-manual "(message)Mailing Lists")
707 :type '(repeat string))
709 (defcustom message-subscribed-regexps nil
710 "*Specifies a list of addresses the user is subscribed to.
711 If nil, do not use any predefined list subscriptions. This list of
712 regular expressions can be used in conjunction with
713 `message-subscribed-address-functions' and `message-subscribed-addresses'."
715 :group 'message-interface
716 :link '(custom-manual "(message)Mailing Lists")
717 :type '(repeat regexp))
719 (defcustom message-allow-no-recipients 'ask
720 "Specifies what to do when there are no recipients other than Gcc/Fcc.
721 If it is the symbol `always', the posting is allowed. If it is the
722 symbol `never', the posting is not allowed. If it is the symbol
723 `ask', you are prompted."
725 :group 'message-interface
726 :link '(custom-manual "(message)Message Headers")
727 :type '(choice (const always)
731 (defcustom message-sendmail-f-is-evil nil
732 "*Non-nil means don't add \"-f username\" to the sendmail command line.
733 Doing so would be even more evil than leaving it out."
734 :group 'message-sending
735 :link '(custom-manual "(message)Mail Variables")
738 (defcustom message-sendmail-envelope-from nil
739 "*Envelope-from when sending mail with sendmail.
740 If this is nil, use `user-mail-address'. If it is the symbol
741 `header', use the From: header of the message."
743 :type '(choice (string :tag "From name")
744 (const :tag "Use From: header from message" header)
745 (const :tag "Use `user-mail-address'" nil))
746 :link '(custom-manual "(message)Mail Variables")
747 :group 'message-sending)
749 ;; qmail-related stuff
750 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
751 "Location of the qmail-inject program."
752 :group 'message-sending
753 :link '(custom-manual "(message)Mail Variables")
756 (defcustom message-qmail-inject-args nil
757 "Arguments passed to qmail-inject programs.
758 This should be a list of strings, one string for each argument. It
759 may also be a function.
761 For e.g., if you wish to set the envelope sender address so that bounces
762 go to the right place or to deal with listserv's usage of that address, you
763 might set this variable to '(\"-f\" \"you@some.where\")."
764 :group 'message-sending
765 :link '(custom-manual "(message)Mail Variables")
766 :type '(choice (function)
770 (defvar gnus-post-method)
771 (defvar gnus-select-method))
772 (defcustom message-post-method
773 (cond ((and (boundp 'gnus-post-method)
774 (listp gnus-post-method)
777 ((boundp 'gnus-select-method)
780 "*Method used to post news.
781 Note that when posting from inside Gnus, for instance, this
782 variable isn't used."
784 :group 'message-sending
785 ;; This should be the `gnus-select-method' widget, but that might
786 ;; create a dependence to `gnus.el'.
789 ;; FIXME: This should be a temporary workaround until someone implements a
790 ;; proper solution. If a crash happens while replying, the auto-save file
791 ;; will *not* have a `References:' header if `message-generate-headers-first'
792 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
793 (defcustom message-generate-headers-first '(references)
794 "Which headers should be generated before starting to compose a message.
795 If t, generate all required headers. This can also be a list of headers to
796 generate. The variables `message-required-news-headers' and
797 `message-required-mail-headers' specify which headers to generate.
799 Note that the variable `message-deletable-headers' specifies headers which
800 are to be deleted and then re-generated before sending, so this variable
801 will not have a visible effect for those headers."
802 :group 'message-headers
803 :link '(custom-manual "(message)Message Headers")
804 :type '(choice (const :tag "None" nil)
805 (const :tag "References" '(references))
807 (repeat (sexp :tag "Header"))))
809 (defcustom message-setup-hook nil
810 "Normal hook, run each time a new outgoing message is initialized.
811 The function `message-setup' runs this hook."
812 :group 'message-various
813 :link '(custom-manual "(message)Various Message Variables")
816 (defcustom message-cancel-hook nil
817 "Hook run when cancelling articles."
818 :group 'message-various
819 :link '(custom-manual "(message)Various Message Variables")
822 (defcustom message-signature-setup-hook nil
823 "Normal hook, run each time a new outgoing message is initialized.
824 It is run after the headers have been inserted and before
825 the signature is inserted."
826 :group 'message-various
827 :link '(custom-manual "(message)Various Message Variables")
830 (defcustom message-mode-hook nil
831 "Hook run in message mode buffers."
832 :group 'message-various
835 (defcustom message-header-hook nil
836 "Hook run in a message mode buffer narrowed to the headers."
837 :group 'message-various
840 (defcustom message-header-setup-hook nil
841 "Hook called narrowed to the headers when setting up a message buffer."
842 :group 'message-various
843 :link '(custom-manual "(message)Various Message Variables")
846 (defcustom message-minibuffer-local-map
847 (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
848 (set-keymap-parent map minibuffer-local-map)
850 "Keymap for `message-read-from-minibuffer'."
854 (defcustom message-citation-line-function 'message-insert-citation-line
855 "*Function called to insert the \"Whomever writes:\" line.
857 Note that Gnus provides a feature where the reader can click on
858 `writes:' to hide the cited text. If you change this line too much,
859 people who read your message will have to change their Gnus
860 configuration. See the variable `gnus-cite-attribution-suffix'."
862 :link '(custom-manual "(message)Insertion Variables")
863 :group 'message-insertion)
866 (defcustom message-yank-prefix "> "
867 "*Prefix inserted on the lines of yanked messages.
868 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
869 See also `message-yank-cited-prefix'."
871 :link '(custom-manual "(message)Insertion Variables")
872 :group 'message-insertion)
874 (defcustom message-yank-cited-prefix ">"
875 "*Prefix inserted on cited or empty lines of yanked messages.
876 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
877 See also `message-yank-prefix'."
880 :link '(custom-manual "(message)Insertion Variables")
881 :group 'message-insertion)
883 (defcustom message-indentation-spaces 3
884 "*Number of spaces to insert at the beginning of each cited line.
885 Used by `message-yank-original' via `message-yank-cite'."
886 :group 'message-insertion
887 :link '(custom-manual "(message)Insertion Variables")
891 (defcustom message-cite-function 'message-cite-original
892 "*Function for citing an original message.
893 Predefined functions include `message-cite-original' and
894 `message-cite-original-without-signature'.
895 Note that `message-cite-original' uses `mail-citation-hook' if that is non-nil."
896 :type '(radio (function-item message-cite-original)
897 (function-item message-cite-original-without-signature)
898 (function-item sc-cite-original)
899 (function :tag "Other"))
900 :link '(custom-manual "(message)Insertion Variables")
901 :group 'message-insertion)
904 (defcustom message-indent-citation-function 'message-indent-citation
905 "*Function for modifying a citation just inserted in the mail buffer.
906 This can also be a list of functions. Each function can find the
907 citation between (point) and (mark t). And each function should leave
908 point and mark around the citation text as modified."
910 :link '(custom-manual "(message)Insertion Variables")
911 :group 'message-insertion)
914 (defcustom message-signature t
915 "*String to be inserted at the end of the message buffer.
916 If t, the `message-signature-file' file will be inserted instead.
917 If a function, the result from the function will be used instead.
918 If a form, the result from the form will be used instead."
920 :link '(custom-manual "(message)Insertion Variables")
921 :group 'message-insertion)
924 (defcustom message-signature-file "~/.signature"
925 "*Name of file containing the text inserted at end of message buffer.
926 Ignored if the named file doesn't exist.
927 If nil, don't insert a signature."
928 :type '(choice file (const :tags "None" nil))
929 :link '(custom-manual "(message)Insertion Variables")
930 :group 'message-insertion)
933 (defcustom message-signature-insert-empty-line t
934 "*If non-nil, insert an empty line before the signature separator."
937 :link '(custom-manual "(message)Insertion Variables")
938 :group 'message-insertion)
940 (defcustom message-distribution-function nil
941 "*Function called to return a Distribution header."
943 :group 'message-headers
944 :link '(custom-manual "(message)News Headers")
945 :type '(choice function (const nil)))
947 (defcustom message-expires 14
948 "Number of days before your article expires."
950 :group 'message-headers
951 :link '(custom-manual "(message)News Headers")
954 (defcustom message-user-path nil
955 "If nil, use the NNTP server name in the Path header.
956 If stringp, use this; if non-nil, use no host name (user name only)."
958 :group 'message-headers
959 :link '(custom-manual "(message)News Headers")
960 :type '(choice (const :tag "nntp" nil)
962 (sexp :tag "none" :format "%t" t)))
964 (defvar message-reply-buffer nil)
965 (defvar message-reply-headers nil
966 "The headers of the current replied article.
967 It is a vector of the following headers:
968 \[number subject from date id references chars lines xref extra].")
969 (defvar message-newsreader nil)
970 (defvar message-mailer nil)
971 (defvar message-sent-message-via nil)
972 (defvar message-checksum nil)
973 (defvar message-send-actions nil
974 "A list of actions to be performed upon successful sending of a message.")
975 (defvar message-exit-actions nil
976 "A list of actions to be performed upon exiting after sending a message.")
977 (defvar message-kill-actions nil
978 "A list of actions to be performed before killing a message buffer.")
979 (defvar message-postpone-actions nil
980 "A list of actions to be performed after postponing a message.")
982 (define-widget 'message-header-lines 'text
983 "All header lines must be LFD terminated."
984 :format "%{%t%}:%n%v"
986 :error "All header lines must be newline terminated")
988 (defcustom message-default-headers ""
989 "*A string containing header lines to be inserted in outgoing messages.
990 It is inserted before you edit the message, so you can edit or delete
992 :group 'message-headers
993 :link '(custom-manual "(message)Message Headers")
994 :type 'message-header-lines)
996 (defcustom message-default-mail-headers ""
997 "*A string of header lines to be inserted in outgoing mails."
998 :group 'message-headers
1000 :link '(custom-manual "(message)Mail Headers")
1001 :type 'message-header-lines)
1003 (defcustom message-default-news-headers ""
1004 "*A string of header lines to be inserted in outgoing news articles."
1005 :group 'message-headers
1006 :group 'message-news
1007 :link '(custom-manual "(message)News Headers")
1008 :type 'message-header-lines)
1010 ;; Note: could use /usr/ucb/mail instead of sendmail;
1011 ;; options -t, and -v if not interactive.
1012 (defcustom message-mailer-swallows-blank-line
1013 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1014 system-configuration)
1015 (file-readable-p "/etc/sendmail.cf")
1016 (let ((buffer (get-buffer-create " *temp*")))
1020 (insert-file-contents "/etc/sendmail.cf")
1021 (goto-char (point-min))
1022 (let ((case-fold-search nil))
1023 (re-search-forward "^OR\\>" nil t)))
1024 (kill-buffer buffer))))
1025 ;; According to RFC822, "The field-name must be composed of printable
1026 ;; ASCII characters (i. e., characters that have decimal values between
1027 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1029 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1030 "*Set this non-nil if the system's mailer runs the header and body together.
1031 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1032 The value should be an expression to test whether the problem will
1034 :group 'message-sending
1035 :link '(custom-manual "(message)Mail Variables")
1039 (define-mail-user-agent 'message-user-agent
1040 'message-mail 'message-send-and-exit
1041 'message-kill-buffer 'message-send-hook)
1043 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1044 "If non-nil, delete the deletable headers before feeding to mh.")
1046 (defvar message-send-method-alist
1047 '((news message-news-p message-send-via-news)
1048 (mail message-mail-p message-send-via-mail))
1049 "Alist of ways to send outgoing messages.
1050 Each element has the form
1052 \(TYPE PREDICATE FUNCTION)
1054 where TYPE is a symbol that names the method; PREDICATE is a function
1055 called without any parameters to determine whether the message is
1056 a message of type TYPE; and FUNCTION is a function to be called if
1057 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1060 (defcustom message-mail-alias-type 'abbrev
1061 "*What alias expansion type to use in Message buffers.
1062 The default is `abbrev', which uses mailabbrev. nil switches
1065 :link '(custom-manual "(message)Mail Aliases")
1066 :type '(choice (const :tag "Use Mailabbrev" abbrev)
1067 (const :tag "No expansion" nil)))
1069 (defcustom message-auto-save-directory
1070 (file-name-as-directory (nnheader-concat message-directory "drafts"))
1071 "*Directory where Message auto-saves buffers if Gnus isn't running.
1072 If nil, Message won't auto-save."
1073 :group 'message-buffers
1074 :link '(custom-manual "(message)Various Message Variables")
1075 :type '(choice directory (const :tag "Don't auto-save" nil)))
1077 (defcustom message-default-charset
1078 (and (not (mm-multibyte-p)) 'iso-8859-1)
1079 "Default charset used in non-MULE Emacsen.
1080 If nil, you might be asked to input the charset."
1083 :link '(custom-manual "(message)Various Message Variables")
1086 (defcustom message-dont-reply-to-names
1087 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1088 "*A regexp specifying addresses to prune when doing wide replies.
1089 A value of nil means exclude your own user name only."
1092 :link '(custom-manual "(message)Wide Reply")
1093 :type '(choice (const :tag "Yourself" nil)
1096 (defvar message-shoot-gnksa-feet nil
1097 "*A list of GNKSA feet you are allowed to shoot.
1098 Gnus gives you all the opportunity you could possibly want for
1099 shooting yourself in the foot. Also, Gnus allows you to shoot the
1100 feet of Good Net-Keeping Seal of Approval. The following are foot
1102 `empty-article' Allow you to post an empty article;
1103 `quoted-text-only' Allow you to post quoted text only;
1104 `multiple-copies' Allow you to post multiple copies;
1105 `cancel-messages' Allow you to cancel or supersede messages from
1106 your other email addresses.")
1108 (defsubst message-gnksa-enable-p (feature)
1109 (or (not (listp message-shoot-gnksa-feet))
1110 (memq feature message-shoot-gnksa-feet)))
1112 (defcustom message-hidden-headers nil
1113 "Regexp of headers to be hidden when composing new messages.
1114 This can also be a list of regexps to match headers. Or a list
1115 starting with `not' and followed by regexps."
1118 :link '(custom-manual "(message)Message Headers")
1119 :type '(repeat regexp))
1121 (defcustom message-cite-articles-with-x-no-archive t
1122 "If non-nil, cite text from articles that has X-No-Archive set."
1126 ;;; Internal variables.
1127 ;;; Well, not really internal.
1129 (defvar message-mode-syntax-table
1130 (let ((table (copy-syntax-table text-mode-syntax-table)))
1131 (modify-syntax-entry ?% ". " table)
1132 (modify-syntax-entry ?> ". " table)
1133 (modify-syntax-entry ?< ". " table)
1135 "Syntax table used while in Message mode.")
1137 (defface message-header-to-face
1140 (:foreground "green2" :bold t))
1143 (:foreground "MidnightBlue" :bold t))
1145 (:bold t :italic t)))
1146 "Face used for displaying From headers."
1147 :group 'message-faces)
1149 (defface message-header-cc-face
1152 (:foreground "green4" :bold t))
1155 (:foreground "MidnightBlue"))
1158 "Face used for displaying Cc headers."
1159 :group 'message-faces)
1161 (defface message-header-subject-face
1164 (:foreground "green3"))
1167 (:foreground "navy blue" :bold t))
1170 "Face used for displaying subject headers."
1171 :group 'message-faces)
1173 (defface message-header-newsgroups-face
1176 (:foreground "yellow" :bold t :italic t))
1179 (:foreground "blue4" :bold t :italic t))
1181 (:bold t :italic t)))
1182 "Face used for displaying newsgroups headers."
1183 :group 'message-faces)
1185 (defface message-header-other-face
1188 (:foreground "#b00000"))
1191 (:foreground "steel blue"))
1193 (:bold t :italic t)))
1194 "Face used for displaying newsgroups headers."
1195 :group 'message-faces)
1197 (defface message-header-name-face
1200 (:foreground "DarkGreen"))
1203 (:foreground "cornflower blue"))
1206 "Face used for displaying header names."
1207 :group 'message-faces)
1209 (defface message-header-xheader-face
1212 (:foreground "blue"))
1215 (:foreground "blue"))
1218 "Face used for displaying X-Header headers."
1219 :group 'message-faces)
1221 (defface message-separator-face
1224 (:foreground "blue3"))
1227 (:foreground "brown"))
1230 "Face used for displaying the separator."
1231 :group 'message-faces)
1233 (defface message-cited-text-face
1236 (:foreground "red"))
1239 (:foreground "red"))
1242 "Face used for displaying cited text names."
1243 :group 'message-faces)
1245 (defface message-mml-face
1248 (:foreground "ForestGreen"))
1251 (:foreground "ForestGreen"))
1254 "Face used for displaying MML."
1255 :group 'message-faces)
1257 (defun message-font-lock-make-header-matcher (regexp)
1260 (let ((start (point)))
1263 (goto-char (point-min))
1264 (if (re-search-forward
1265 (concat "^" (regexp-quote mail-header-separator) "$")
1267 (setq limit (min limit (match-beginning 0))))
1269 (and (< start limit)
1270 (re-search-forward ,regexp limit t))))))
1271 (if (featurep 'bytecomp)
1275 (defvar message-font-lock-keywords
1276 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1277 `((,(message-font-lock-make-header-matcher
1278 (concat "^\\([Tt]o:\\)" content))
1279 (1 'message-header-name-face)
1280 (2 'message-header-to-face nil t))
1281 (,(message-font-lock-make-header-matcher
1282 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1283 (1 'message-header-name-face)
1284 (2 'message-header-cc-face nil t))
1285 (,(message-font-lock-make-header-matcher
1286 (concat "^\\([Ss]ubject:\\)" content))
1287 (1 'message-header-name-face)
1288 (2 'message-header-subject-face nil t))