1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This mode provides mail-sending facilities from within Emacs. It
27 ;; consists mainly of large chunks of code from the sendmail.el,
28 ;; gnus-msg.el and rnewspost.el files.
33 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
42 ;; This is apparently necessary even though things are autoloaded.
43 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
44 ;; require mailabbrev here.
45 (if (featurep 'xemacs)
46 (require 'mail-abbrevs)
47 (require 'mailabbrev))
53 (autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/
55 (defvar gnus-message-group-art)
56 (defvar gnus-list-identifiers) ; gnus-sum is required where necessary
57 (defvar rmail-enable-mime-composing)
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")
66 (put 'user-mail-address 'custom-type 'string)
67 (put 'user-full-name 'custom-type 'string)
69 (defgroup message-various nil
70 "Various Message Variables."
71 :link '(custom-manual "(message)Various Message Variables")
74 (defgroup message-buffers nil
76 :link '(custom-manual "(message)Message Buffers")
79 (defgroup message-sending nil
81 :link '(custom-manual "(message)Sending Variables")
84 (defgroup message-interface nil
86 :link '(custom-manual "(message)Interface")
89 (defgroup message-forwarding nil
91 :link '(custom-manual "(message)Forwarding")
92 :group 'message-interface)
94 (defgroup message-insertion nil
96 :link '(custom-manual "(message)Insertion")
99 (defgroup message-headers nil
101 :link '(custom-manual "(message)Message Headers")
104 (defgroup message-news nil
105 "Composing News Messages."
108 (defgroup message-mail nil
109 "Composing Mail Messages."
112 (defgroup message-faces nil
113 "Faces used for message composing."
117 (defcustom message-directory "~/Mail/"
118 "*Directory from which all other mail file variables are derived."
119 :group 'message-various
122 (defcustom message-max-buffers 10
123 "*How many buffers to keep before starting to kill them off."
124 :group 'message-buffers
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)))
132 (defcustom message-fcc-handler-function 'message-output
133 "*A function called to save outgoing articles.
134 This function will be called with the name of the file to store the
135 article in. The default function is `message-output' which saves in Unix
137 :type '(radio (function-item message-output)
138 (function :tag "Other"))
139 :group 'message-sending)
141 (defcustom message-fcc-externalize-attachments nil
142 "If non-nil, attachments are included as external parts in Fcc copies."
145 :group 'message-sending)
147 (defcustom message-courtesy-message
148 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
149 "*This is inserted at the start of a mailed copy of a posted message.
150 If the string contains the format spec \"%s\", the Newsgroups
151 the article has been posted to will be inserted there.
152 If this variable is nil, no such courtesy message will be added."
153 :group 'message-sending
154 :type '(radio string (const nil)))
156 (defcustom message-ignored-bounced-headers
157 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
158 "*Regexp that matches headers to be removed in resent bounced mail."
159 :group 'message-interface
162 (defcustom message-from-style 'default
163 "*Specifies how \"From\" headers look.
165 If nil, they contain just the return address like:
167 If `parens', they look like:
168 king@grassland.com (Elvis Parsley)
169 If `angles', they look like:
170 Elvis Parsley <king@grassland.com>
172 Otherwise, most addresses look like `angles', but they look like
173 `parens' if `angles' would need quoting and `parens' would not."
174 :type '(choice (const :tag "simple" nil)
178 :group 'message-headers)
180 (defcustom message-insert-canlock t
181 "Whether to insert a Cancel-Lock header in news postings."
183 :group 'message-headers
186 (defcustom message-syntax-checks
187 (if message-insert-canlock '((sender . disabled)) nil)
188 ;; Guess this one shouldn't be easy to customize...
189 "*Controls what syntax checks should not be performed on outgoing posts.
190 To disable checking of long signatures, for instance, add
191 `(signature . disabled)' to this list.
193 Don't touch this variable unless you really know what you're doing.
195 Checks include `approved', `bogus-recipient', `continuation-headers',
196 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
197 `invisible-text', `long-header-lines', `long-lines', `message-id',
198 `multiple-headers', `new-text', `newsgroups', `quoting-style',
199 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
200 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
201 and `valid-newsgroups'."
203 :type '(repeat sexp)) ; Fixme: improve this
205 (defcustom message-required-headers '((optional . References)
207 "*Headers to be generated or prompted for when sending a message.
208 Also see `message-required-news-headers' and
209 `message-required-mail-headers'."
212 :group 'message-headers
213 :link '(custom-manual "(message)Message Headers")
214 :type '(repeat sexp))
216 (defcustom message-draft-headers '(References From Date)
217 "*Headers to be generated when saving a draft message."
220 :group 'message-headers
221 :link '(custom-manual "(message)Message Headers")
222 :type '(repeat sexp))
224 (defcustom message-required-news-headers
225 '(From Newsgroups Subject Date Message-ID
226 (optional . Organization)
227 (optional . User-Agent))
228 "*Headers to be generated or prompted for when posting an article.
229 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
230 Message-ID. Organization, Lines, In-Reply-To, Expires, and
231 User-Agent are optional. If you don't want message to insert some
232 header, remove it from this list."
234 :group 'message-headers
235 :link '(custom-manual "(message)Message Headers")
236 :type '(repeat sexp))
238 (defcustom message-required-mail-headers
239 '(From Subject Date (optional . In-Reply-To) Message-ID
240 (optional . User-Agent))
241 "*Headers to be generated or prompted for when mailing a message.
242 It is recommended that From, Date, To, Subject and Message-ID be
243 included. Organization and User-Agent are optional."
245 :group 'message-headers
246 :link '(custom-manual "(message)Message Headers")
247 :type '(repeat sexp))
249 (defcustom message-deletable-headers '(Message-ID Date Lines)
250 "Headers to be deleted if they already exist and were generated by message previously."
251 :group 'message-headers
252 :link '(custom-manual "(message)Message Headers")
255 (defcustom message-ignored-news-headers
256 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
257 "*Regexp of headers to be removed unconditionally before posting."
259 :group 'message-headers
260 :link '(custom-manual "(message)Message Headers")
261 :type '(repeat :value-to-internal (lambda (widget value)
262 (custom-split-regexp-maybe value))
263 :match (lambda (widget value)
265 (widget-editable-list-match widget value)))
268 (defcustom message-ignored-mail-headers
269 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
270 "*Regexp of headers to be removed unconditionally before mailing."
272 :group 'message-headers
273 :link '(custom-manual "(message)Mail Headers")
276 (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:"
277 "*Header lines matching this regexp will be deleted before posting.
278 It's best to delete old Path and Date headers before posting to avoid
280 :group 'message-interface
281 :link '(custom-manual "(message)Superseding")
282 :type '(repeat :value-to-internal (lambda (widget value)
283 (custom-split-regexp-maybe value))
284 :match (lambda (widget value)
286 (widget-editable-list-match widget value)))
289 (defcustom message-subject-re-regexp
290 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
291 "*Regexp matching \"Re: \" in the subject line."
292 :group 'message-various
293 :link '(custom-manual "(message)Message Headers")
296 ;;; Start of variables adopted from `message-utils.el'.
298 (defcustom message-subject-trailing-was-query 'ask
299 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
300 If nil, leave the subject unchanged. If it is the symbol `ask', query
301 the user what do do. In this case, the subject is matched against
302 `message-subject-trailing-was-ask-regexp'. If
303 `message-subject-trailing-was-query' is t, always strip the trailing
304 old subject. In this case, `message-subject-trailing-was-regexp' is
307 :type '(choice (const :tag "never" nil)
308 (const :tag "always strip" t)
310 :link '(custom-manual "(message)Message Headers")
311 :group 'message-various)
313 (defcustom message-subject-trailing-was-ask-regexp
314 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
315 "*Regexp matching \"(was: <old subject>)\" in the subject line.
317 The function `message-strip-subject-trailing-was' uses this regexp if
318 `message-subject-trailing-was-query' is set to the symbol `ask'. If
319 the variable is t instead of `ask', use
320 `message-subject-trailing-was-regexp' instead.
322 It is okay to create some false positives here, as the user is asked."
324 :group 'message-various
325 :link '(custom-manual "(message)Message Headers")
328 (defcustom message-subject-trailing-was-regexp
329 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
330 "*Regexp matching \"(was: <old subject>)\" in the subject line.
332 If `message-subject-trailing-was-query' is set to t, the subject is
333 matched against `message-subject-trailing-was-regexp' in
334 `message-strip-subject-trailing-was'. You should use a regexp creating very
335 few false positives here."
337 :group 'message-various
338 :link '(custom-manual "(message)Message Headers")
341 ;;; marking inserted text
343 (defcustom message-mark-insert-begin
344 "--8<---------------cut here---------------start------------->8---\n"
345 "How to mark the beginning of some inserted text."
348 :link '(custom-manual "(message)Insertion Variables")
349 :group 'message-various)
351 (defcustom message-mark-insert-end
352 "--8<---------------cut here---------------end--------------->8---\n"
353 "How to mark the end of some inserted text."
356 :link '(custom-manual "(message)Insertion Variables")
357 :group 'message-various)
359 (defcustom message-archive-header "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)
367 (defcustom message-archive-note
368 "X-No-Archive: Yes - save http://groups.google.com/"
369 "Note to insert why you wouldn't want this posting archived.
370 If nil, don't insert any text in the body."
372 :type '(radio string (const nil))
373 :link '(custom-manual "(message)Header Commands")
374 :group 'message-various)
376 ;;; Crossposts and Followups
377 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
378 ;; new suggestions by R. Weikusat <rw at another.de>
380 (defvar message-cross-post-old-target nil
381 "Old target for cross-posts or follow-ups.")
382 (make-variable-buffer-local 'message-cross-post-old-target)
384 (defcustom message-cross-post-default t
385 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
386 If nil, `message-cross-post-followup-to' will only do a followup. Note that
387 you can explicitly override this setting by calling
388 `message-cross-post-followup-to' with a prefix."
391 :group 'message-various)
393 (defcustom message-cross-post-note "Crosspost & Followup-To: "
394 "Note to insert before signature to notify of cross-post and follow-up."
397 :group 'message-various)
399 (defcustom message-followup-to-note "Followup-To: "
400 "Note to insert before signature to notify of follow-up only."
403 :group 'message-various)
405 (defcustom message-cross-post-note-function 'message-cross-post-insert-note
406 "Function to use to insert note about Crosspost or Followup-To.
407 The function will be called with four arguments. The function should not only
408 insert a note, but also ensure old notes are deleted. See the documentation
409 for `message-cross-post-insert-note'."
412 :group 'message-various)
414 ;;; End of variables adopted from `message-utils.el'.
416 (defcustom message-signature-separator "^-- $"
417 "Regexp matching the signature separator.
418 This variable is used to strip off the signature from quoted text
419 when `message-cite-function' is
420 `message-cite-original-without-signature'. Most useful values
421 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
423 :type '(choice (const :tag "strict" "^-- $")
424 (const :tag "loose" "^-- *$")
426 :version "22.3" ;; Gnus 5.10.12 (changed default)
427 :link '(custom-manual "(message)Various Message Variables")
428 :group 'message-various)
430 (defcustom message-elide-ellipsis "\n[...]\n\n"
431 "*The string which is inserted for elided text."
433 :link '(custom-manual "(message)Various Commands")
434 :group 'message-various)
436 (defcustom message-interactive t
437 "Non-nil means when sending a message wait for and display errors.
438 nil means let mailer mail back a message to report errors."
439 :group 'message-sending
441 :link '(custom-manual "(message)Sending Variables")
444 (defcustom message-confirm-send nil
445 "When non-nil, ask for confirmation when sending a message."
446 :group 'message-sending
448 :version "23.1" ;; No Gnus
449 :link '(custom-manual "(message)Sending Variables")
452 (defcustom message-generate-new-buffers 'unique
453 "*Say whether to create a new message buffer to compose a message.
454 Valid values include:
457 Generate the buffer name in the Message way (e.g., *mail*, *news*,
458 *mail to whom*, *news on group*, etc.) and continue editing in the
459 existing buffer of that name. If there is no such buffer, it will
463 Create the new buffer with the name generated in the Message way.
466 Similar to `unique' but the buffer name begins with \"*unsent \".
469 Similar to nil but the buffer name is simpler like *mail message*.
472 If this is a function, call that function with three parameters:
473 The type, the To address and the group name (any of these may be nil).
474 The function should return the new buffer name."
475 :group 'message-buffers
476 :link '(custom-manual "(message)Message Buffers")
477 :type '(choice (const nil)
478 (sexp :tag "unique" :format "unique\n" :value unique
479 :match (lambda (widget value) (memq value '(unique t))))
482 (function :format "\n %{%t%}: %v")))
484 (defcustom message-kill-buffer-on-exit nil
485 "*Non-nil means that the message buffer will be killed after sending a message."
486 :group 'message-buffers
487 :link '(custom-manual "(message)Message Buffers")
490 (defcustom message-kill-buffer-query t
491 "*Non-nil means that killing a modified message buffer has to be confirmed.
492 This is used by `message-kill-buffer'."
493 :version "23.1" ;; No Gnus
494 :group 'message-buffers
497 (defvar gnus-local-organization)
498 (defcustom message-user-organization
499 (or (and (boundp 'gnus-local-organization)
500 (stringp gnus-local-organization)
501 gnus-local-organization)
502 (getenv "ORGANIZATION")
504 "*String to be used as an Organization header.
505 If t, use `message-user-organization-file'."
506 :group 'message-headers
507 :type '(choice string
508 (const :tag "consult file" t)))
510 (defcustom message-user-organization-file
512 (dolist (f (list "/etc/organization"
513 "/etc/news/organization"
514 "/usr/lib/news/organization"))
515 (when (file-readable-p f)
518 "*Local news organization file."
520 :link '(custom-manual "(message)News Headers")
521 :group 'message-headers)
523 (defcustom message-make-forward-subject-function
524 #'message-forward-subject-name-subject
525 "*List of functions called to generate subject headers for forwarded messages.
526 The subject generated by the previous function is passed into each
529 The provided functions are:
531 * `message-forward-subject-author-subject' Source of article (author or
532 newsgroup), in brackets followed by the subject
533 * `message-forward-subject-name-subject' Source of article (name of author
534 or newsgroup), in brackets followed by the subject
535 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
537 :group 'message-forwarding
538 :link '(custom-manual "(message)Forwarding")
539 :type '(radio (function-item message-forward-subject-author-subject)
540 (function-item message-forward-subject-fwd)
541 (function-item message-forward-subject-name-subject)
542 (repeat :tag "List of functions" function)))
544 (defcustom message-forward-as-mime t
545 "*Non-nil means forward messages as an inline/rfc822 MIME section.
546 Otherwise, directly inline the old message in the forwarded message."
548 :group 'message-forwarding
549 :link '(custom-manual "(message)Forwarding")
552 (defcustom message-forward-show-mml 'best
553 "*Non-nil means show forwarded messages as MML (decoded from MIME).
554 Otherwise, forwarded messages are unchanged.
555 Can also be the symbol `best' to indicate that MML should be
556 used, except when it is a bad idea to use MML. One example where
557 it is a bad idea is when forwarding a signed or encrypted
558 message, because converting MIME to MML would invalidate the
561 :group 'message-forwarding
562 :type '(choice (const :tag "use MML" t)
563 (const :tag "don't use MML " nil)
564 (const :tag "use MML when appropriate" best)))
566 (defcustom message-forward-before-signature t
567 "*Non-nil means put forwarded message before signature, else after."
568 :group 'message-forwarding
571 (defcustom message-wash-forwarded-subjects nil
572 "*Non-nil means try to remove as much cruft as possible from the subject.
573 Done before generating the new subject of a forward."
574 :group 'message-forwarding
575 :link '(custom-manual "(message)Forwarding")
578 (defcustom message-ignored-resent-headers
579 ;; `Delivered-To' needs to be removed because some mailers use it to
580 ;; detect loops, so if you resend a message to an address that ultimately
581 ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
582 ;; case you may be removed from the list on the grounds that mail to you
583 ;; bounced with a "mailing loop" error).
584 "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
585 "*All headers that match this regexp will be deleted when resending a message."
586 :group 'message-interface
587 :link '(custom-manual "(message)Resending")
588 :type '(repeat :value-to-internal (lambda (widget value)
589 (custom-split-regexp-maybe value))
590 :match (lambda (widget value)
592 (widget-editable-list-match widget value)))
595 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
596 "*All headers that match this regexp will be deleted when forwarding a message."
598 :group 'message-forwarding
599 :type '(repeat :value-to-internal (lambda (widget value)
600 (custom-split-regexp-maybe value))
601 :match (lambda (widget value)
603 (widget-editable-list-match widget value)))
606 (defcustom message-ignored-cited-headers "."
607 "*Delete these headers from the messages you yank."
608 :group 'message-insertion
609 :link '(custom-manual "(message)Insertion Variables")
612 (defcustom message-cite-prefix-regexp
613 (if (string-match "[[:digit:]]" "1")
614 ;; Support POSIX? XEmacs 21.5.27 doesn't.
615 "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|}]\\)+"
616 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
617 (let (non-word-constituents)
618 (with-syntax-table text-mode-syntax-table
619 (setq non-word-constituents
621 (if (string-match "\\w" "_") "" "_")
622 (if (string-match "\\w" ".") "" "."))))
623 (if (equal non-word-constituents "")
624 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}]\\)+"
625 (concat "\\([ \t]*\\(\\w\\|["
626 non-word-constituents
627 "]\\)+>+\\|[ \t]*[]>|}]\\)+"))))
628 "*Regexp matching the longest possible citation prefix on a line."
630 :group 'message-insertion
631 :link '(custom-manual "(message)Insertion Variables")
633 :set (lambda (symbol value)
635 (custom-set-default symbol value)
636 (if (boundp 'gnus-message-cite-prefix-regexp)
637 (setq gnus-message-cite-prefix-regexp
638 (concat "^\\(?:" value "\\)"))))))
640 (defcustom message-cancel-message "I am canceling my own article.\n"
641 "Message to be inserted in the cancel message."
642 :group 'message-interface
643 :link '(custom-manual "(message)Canceling News")
646 (defvar smtpmail-default-smtp-server)
648 (defun message-send-mail-function ()
649 "Return suitable value for the variable `message-send-mail-function'."
650 (cond ((and (require 'sendmail)
651 (boundp 'sendmail-program)
653 (executable-find sendmail-program))
654 'message-send-mail-with-sendmail)
655 ((and (locate-library "smtpmail")
657 smtpmail-default-smtp-server)
658 'message-smtpmail-send-it)
659 ((locate-library "mailclient")
660 'message-send-mail-with-mailclient)
663 (error "Don't know how to send mail. Please customize `message-send-mail-function'")))))
665 ;; Useful to set in site-init.el
666 (defcustom message-send-mail-function (message-send-mail-function)
667 "Function to call to send the current buffer as mail.
668 The headers should be delimited by a line whose contents match the
669 variable `mail-header-separator'.
671 Valid values include `message-send-mail-with-sendmail'
672 `message-send-mail-with-mh', `message-send-mail-with-qmail',
673 `message-smtpmail-send-it', `smtpmail-send-it',
674 `feedmail-send-it' and `message-send-mail-with-mailclient'. The
675 default is system dependent and determined by the function
676 `message-send-mail-function'.
678 See also `send-mail-function'."
679 :type '(radio (function-item message-send-mail-with-sendmail)
680 (function-item message-send-mail-with-mh)
681 (function-item message-send-mail-with-qmail)
682 (function-item message-smtpmail-send-it)
683 (function-item smtpmail-send-it)
684 (function-item feedmail-send-it)
685 (function-item message-send-mail-with-mailclient
686 :tag "Use Mailclient package")
687 (function :tag "Other"))
688 :group 'message-sending
689 :version "23.1" ;; No Gnus
690 :initialize 'custom-initialize-default
691 :link '(custom-manual "(message)Mail Variables")
692 :group 'message-mail)
694 (defcustom message-send-news-function 'message-send-news
695 "Function to call to send the current buffer as news.
696 The headers should be delimited by a line whose contents match the
697 variable `mail-header-separator'."
698 :group 'message-sending
700 :link '(custom-manual "(message)News Variables")
703 (defcustom message-reply-to-function nil
704 "If non-nil, function that should return a list of headers.
705 This function should pick out addresses from the To, Cc, and From headers
706 and respond with new To and Cc headers."
707 :group 'message-interface
708 :link '(custom-manual "(message)Reply")
709 :type '(choice function (const nil)))
711 (defcustom message-wide-reply-to-function nil
712 "If non-nil, function that should return a list of headers.
713 This function should pick out addresses from the To, Cc, and From headers
714 and respond with new To and Cc headers."
715 :group 'message-interface
716 :link '(custom-manual "(message)Wide Reply")
717 :type '(choice function (const nil)))
719 (defcustom message-followup-to-function nil
720 "If non-nil, function that should return a list of headers.
721 This function should pick out addresses from the To, Cc, and From headers
722 and respond with new To and Cc headers."
723 :group 'message-interface
724 :link '(custom-manual "(message)Followup")
725 :type '(choice function (const nil)))
727 (defcustom message-extra-wide-headers nil
728 "If non-nil, a list of additional address headers.
729 These are used when composing a wide reply."
730 :group 'message-sending
731 :type '(repeat string))
733 (defcustom message-use-followup-to 'ask
734 "*Specifies what to do with Followup-To header.
735 If nil, always ignore the header. If it is t, use its value, but
736 query before using the \"poster\" value. If it is the symbol `ask',
737 always query the user whether to use the value. If it is the symbol
738 `use', always use the value."
739 :group 'message-interface
740 :link '(custom-manual "(message)Followup")
741 :type '(choice (const :tag "ignore" nil)
742 (const :tag "use & query" t)
746 (defcustom message-use-mail-followup-to 'use
747 "*Specifies what to do with Mail-Followup-To header.
748 If nil, always ignore the header. If it is the symbol `ask', always
749 query the user whether to use the value. If it is the symbol `use',
750 always use the value."
752 :group 'message-interface
753 :link '(custom-manual "(message)Mailing Lists")
754 :type '(choice (const :tag "ignore" nil)
758 (defcustom message-subscribed-address-functions nil
759 "*Specifies functions for determining list subscription.
760 If nil, do not attempt to determine list subscription with functions.
761 If non-nil, this variable contains a list of functions which return
762 regular expressions to match lists. These functions can be used in
763 conjunction with `message-subscribed-regexps' and
764 `message-subscribed-addresses'."
766 :group 'message-interface
767 :link '(custom-manual "(message)Mailing Lists")
768 :type '(repeat sexp))
770 (defcustom message-subscribed-address-file nil
771 "*A file containing addresses the user is subscribed to.
772 If nil, do not look at any files to determine list subscriptions. If
773 non-nil, each line of this file should be a mailing list address."
775 :group 'message-interface
776 :link '(custom-manual "(message)Mailing Lists")
777 :type '(radio file (const nil)))
779 (defcustom message-subscribed-addresses nil
780 "*Specifies a list of addresses the user is subscribed to.
781 If nil, do not use any predefined list subscriptions. This list of
782 addresses can be used in conjunction with
783 `message-subscribed-address-functions' and `message-subscribed-regexps'."
785 :group 'message-interface
786 :link '(custom-manual "(message)Mailing Lists")
787 :type '(repeat string))
789 (defcustom message-subscribed-regexps nil
790 "*Specifies a list of addresses the user is subscribed to.
791 If nil, do not use any predefined list subscriptions. This list of
792 regular expressions can be used in conjunction with
793 `message-subscribed-address-functions' and `message-subscribed-addresses'."
795 :group 'message-interface
796 :link '(custom-manual "(message)Mailing Lists")
797 :type '(repeat regexp))
799 (defcustom message-allow-no-recipients 'ask
800 "Specifies what to do when there are no recipients other than Gcc/Fcc.
801 If it is the symbol `always', the posting is allowed. If it is the
802 symbol `never', the posting is not allowed. If it is the symbol
803 `ask', you are prompted."
805 :group 'message-interface
806 :link '(custom-manual "(message)Message Headers")
807 :type '(choice (const always)
811 (defcustom message-sendmail-f-is-evil nil
812 "*Non-nil means don't add \"-f username\" to the sendmail command line.
813 Doing so would be even more evil than leaving it out."
814 :group 'message-sending
815 :link '(custom-manual "(message)Mail Variables")
818 (defcustom message-sendmail-envelope-from nil
819 "*Envelope-from when sending mail with sendmail.
820 If this is nil, use `user-mail-address'. If it is the symbol
821 `header', use the From: header of the message."
823 :type '(choice (string :tag "From name")
824 (const :tag "Use From: header from message" header)
825 (const :tag "Use `user-mail-address'" nil))
826 :link '(custom-manual "(message)Mail Variables")
827 :group 'message-sending)
829 (defcustom message-sendmail-extra-arguments nil
830 "Additional arguments to `sendmail-program'."
831 ;; E.g. '("-a" "account") for msmtp
832 :version "23.1" ;; No Gnus
833 :type '(repeat string)
834 ;; :link '(custom-manual "(message)Mail Variables")
835 :group 'message-sending)
837 ;; qmail-related stuff
838 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
839 "Location of the qmail-inject program."
840 :group 'message-sending
841 :link '(custom-manual "(message)Mail Variables")
844 (defcustom message-qmail-inject-args nil
845 "Arguments passed to qmail-inject programs.
846 This should be a list of strings, one string for each argument. It
847 may also be a function.
849 For e.g., if you wish to set the envelope sender address so that bounces
850 go to the right place or to deal with listserv's usage of that address, you
851 might set this variable to '(\"-f\" \"you@some.where\")."
852 :group 'message-sending
853 :link '(custom-manual "(message)Mail Variables")
854 :type '(choice (function)
857 (defvar gnus-post-method)
858 (defvar gnus-select-method)
859 (defcustom message-post-method
860 (cond ((and (boundp 'gnus-post-method)
861 (listp gnus-post-method)
864 ((boundp 'gnus-select-method)
867 "*Method used to post news.
868 Note that when posting from inside Gnus, for instance, this
869 variable isn't used."
871 :group 'message-sending
872 ;; This should be the `gnus-select-method' widget, but that might
873 ;; create a dependence to `gnus.el'.
876 ;; FIXME: This should be a temporary workaround until someone implements a
877 ;; proper solution. If a crash happens while replying, the auto-save file
878 ;; will *not* have a `References:' header if `message-generate-headers-first'
879 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
880 (defcustom message-generate-headers-first '(references)
881 "Which headers should be generated before starting to compose a message.
882 If t, generate all required headers. This can also be a list of headers to
883 generate. The variables `message-required-news-headers' and
884 `message-required-mail-headers' specify which headers to generate.
886 Note that the variable `message-deletable-headers' specifies headers which
887 are to be deleted and then re-generated before sending, so this variable
888 will not have a visible effect for those headers."
889 :group 'message-headers
890 :link '(custom-manual "(message)Message Headers")
891 :type '(choice (const :tag "None" nil)
892 (const :tag "References" '(references))
894 (repeat (sexp :tag "Header"))))
896 (defcustom message-fill-column 72
897 "Column beyond which automatic line-wrapping should happen.
898 Local value for message buffers. If non-nil, also turn on
899 auto-fill in message buffers."
900 :group 'message-various
901 ;; :link '(custom-manual "(message)Message Headers")
902 :type '(choice (const :tag "Don't turn on auto fill" nil)
905 (defcustom message-setup-hook nil
906 "Normal hook, run each time a new outgoing message is initialized.
907 The function `message-setup' runs this hook."
908 :group 'message-various
909 :link '(custom-manual "(message)Various Message Variables")
912 (defcustom message-cancel-hook nil
913 "Hook run when cancelling articles."
914 :group 'message-various
915 :link '(custom-manual "(message)Various Message Variables")
918 (defcustom message-signature-setup-hook nil
919 "Normal hook, run each time a new outgoing message is initialized.
920 It is run after the headers have been inserted and before
921 the signature is inserted."
922 :group 'message-various
923 :link '(custom-manual "(message)Various Message Variables")
926 (defcustom message-mode-hook nil
927 "Hook run in message mode buffers."
928 :group 'message-various
931 (defcustom message-header-hook nil
932 "Hook run in a message mode buffer narrowed to the headers."
933 :group 'message-various
936 (defcustom message-header-setup-hook nil
937 "Hook called narrowed to the headers when setting up a message buffer."
938 :group 'message-various
939 :link '(custom-manual "(message)Various Message Variables")
942 (defcustom message-minibuffer-local-map
943 (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
944 (set-keymap-parent map minibuffer-local-map)
946 "Keymap for `message-read-from-minibuffer'."
948 :group 'message-various)
950 (defcustom message-citation-line-function 'message-insert-citation-line
951 "*Function called to insert the \"Whomever writes:\" line.
953 Predefined functions include `message-insert-citation-line' and
954 `message-insert-formatted-citation-line' (see the variable
955 `message-citation-line-format').
957 Note that Gnus provides a feature where the reader can click on
958 `writes:' to hide the cited text. If you change this line too much,
959 people who read your message will have to change their Gnus
960 configuration. See the variable `gnus-cite-attribution-suffix'."
962 (function-item :tag "plain" message-insert-citation-line)
963 (function-item :tag "formatted" message-insert-formatted-citation-line)
964 (function :tag "Other"))
965 :link '(custom-manual "(message)Insertion Variables")
966 :group 'message-insertion)
968 (defcustom message-citation-line-format "On %a, %b %d %Y, %N wrote:\n"
969 "Format of the \"Whomever writes:\" line.
971 The string is formatted using `format-spec'. The following
972 constructs are replaced:
974 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
975 %n The mail address, e.g. \"john.doe@example.invalid\".
976 %N The real name if present, e.g.: \"John Doe\", else fall
977 back to the mail address.
978 %F The first name if present, e.g.: \"John\".
979 %L The last name if present, e.g.: \"Doe\".
981 All other format specifiers are passed to `format-time-string'
982 which is called using the date from the article your replying to.
983 Extracting the first (%F) and last name (%L) is done
984 heuristically, so you should always check it yourself.
986 Please also read the note in the documentation of
987 `message-citation-line-function'."
988 :type '(choice (const :tag "Plain" "%f writes:")
989 (const :tag "Include date" "On %a, %b %d %Y, %n wrote:")
991 :link '(custom-manual "(message)Insertion Variables")
992 :version "23.1" ;; No Gnus
993 :group 'message-insertion)
995 (defcustom message-yank-prefix "> "
996 "*Prefix inserted on the lines of yanked messages.
997 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
998 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
1000 :link '(custom-manual "(message)Insertion Variables")
1001 :group 'message-insertion)
1003 (defcustom message-yank-cited-prefix ">"
1004 "*Prefix inserted on cited lines of yanked messages.
1005 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1006 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1009 :link '(custom-manual "(message)Insertion Variables")
1010 :group 'message-insertion)
1012 (defcustom message-yank-empty-prefix ">"
1013 "*Prefix inserted on empty lines of yanked messages.
1014 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1017 :link '(custom-manual "(message)Insertion Variables")
1018 :group 'message-insertion)
1020 (defcustom message-indentation-spaces 3
1021 "*Number of spaces to insert at the beginning of each cited line.
1022 Used by `message-yank-original' via `message-yank-cite'."
1023 :group 'message-insertion
1024 :link '(custom-manual "(message)Insertion Variables")
1027 (defcustom message-cite-function 'message-cite-original-without-signature
1028 "*Function for citing an original message.
1029 Predefined functions include `message-cite-original' and
1030 `message-cite-original-without-signature'.
1031 Note that these functions use `mail-citation-hook' if that is non-nil."
1032 :type '(radio (function-item message-cite-original)
1033 (function-item message-cite-original-without-signature)
1034 (function-item sc-cite-original)
1035 (function :tag "Other"))
1036 :link '(custom-manual "(message)Insertion Variables")
1037 :version "22.3" ;; Gnus 5.10.12 (changed default)
1038 :group 'message-insertion)
1040 (defcustom message-indent-citation-function 'message-indent-citation
1041 "*Function for modifying a citation just inserted in the mail buffer.
1042 This can also be a list of functions. Each function can find the
1043 citation between (point) and (mark t). And each function should leave
1044 point and mark around the citation text as modified."
1046 :link '(custom-manual "(message)Insertion Variables")
1047 :group 'message-insertion)
1049 (defcustom message-signature t
1050 "*String to be inserted at the end of the message buffer.
1051 If t, the `message-signature-file' file will be inserted instead.
1052 If a function, the result from the function will be used instead.
1053 If a form, the result from the form will be used instead."
1055 :link '(custom-manual "(message)Insertion Variables")
1056 :group 'message-insertion)
1058 (defcustom message-signature-file "~/.signature"
1059 "*Name of file containing the text inserted at end of message buffer.
1060 Ignored if the named file doesn't exist.
1061 If nil, don't insert a signature.
1062 If a path is specified, the value of `message-signature-directory' is ignored,
1064 :type '(choice file (const :tags "None" nil))
1065 :link '(custom-manual "(message)Insertion Variables")
1066 :group 'message-insertion)
1068 (defcustom message-signature-directory nil
1069 "*Name of directory containing signature files.
1070 Comes in handy if you have many such files, handled via posting styles for
1072 If nil, `message-signature-file' is expected to specify the directory if
1074 :type '(choice string (const :tags "None" nil))
1075 :link '(custom-manual "(message)Insertion Variables")
1076 :group 'message-insertion)
1078 (defcustom message-signature-insert-empty-line t
1079 "*If non-nil, insert an empty line before the signature separator."
1082 :link '(custom-manual "(message)Insertion Variables")
1083 :group 'message-insertion)
1085 (defcustom message-distribution-function nil
1086 "*Function called to return a Distribution header."
1087 :group 'message-news
1088 :group 'message-headers
1089 :link '(custom-manual "(message)News Headers")
1090 :type '(choice function (const nil)))
1092 (defcustom message-expires 14
1093 "Number of days before your article expires."
1094 :group 'message-news
1095 :group 'message-headers
1096 :link '(custom-manual "(message)News Headers")
1099 (defcustom message-user-path nil
1100 "If nil, use the NNTP server name in the Path header.
1101 If stringp, use this; if non-nil, use no host name (user name only)."
1102 :group 'message-news
1103 :group 'message-headers
1104 :link '(custom-manual "(message)News Headers")
1105 :type '(choice (const :tag "nntp" nil)
1106 (string :tag "name")
1107 (sexp :tag "none" :format "%t" t)))
1109 (defvar message-reply-buffer nil)
1110 (defvar message-reply-headers nil
1111 "The headers of the current replied article.
1112 It is a vector of the following headers:
1113 \[number subject from date id references chars lines xref extra].")
1114 (defvar message-newsreader nil)
1115 (defvar message-mailer nil)
1116 (defvar message-sent-message-via nil)
1117 (defvar message-checksum nil)
1118 (defvar message-send-actions nil
1119 "A list of actions to be performed upon successful sending of a message.")
1120 (defvar message-exit-actions nil
1121 "A list of actions to be performed upon exiting after sending a message.")
1122 (defvar message-kill-actions nil
1123 "A list of actions to be performed before killing a message buffer.")
1124 (defvar message-postpone-actions nil
1125 "A list of actions to be performed after postponing a message.")
1127 (define-widget 'message-header-lines 'text
1128 "All header lines must be LFD terminated."
1129 :format "%{%t%}:%n%v"
1130 :valid-regexp "^\\'"
1131 :error "All header lines must be newline terminated")
1133 (defcustom message-default-headers ""
1134 "*A string containing header lines to be inserted in outgoing messages.
1135 It is inserted before you edit the message, so you can edit or delete
1137 :group 'message-headers
1138 :link '(custom-manual "(message)Message Headers")
1139 :type 'message-header-lines)
1141 (defcustom message-default-mail-headers ""
1142 "*A string of header lines to be inserted in outgoing mails."
1143 :group 'message-headers
1144 :group 'message-mail
1145 :link '(custom-manual "(message)Mail Headers")
1146 :type 'message-header-lines)
1148 (defcustom message-default-news-headers ""
1149 "*A string of header lines to be inserted in outgoing news articles."
1150 :group 'message-headers
1151 :group 'message-news
1152 :link '(custom-manual "(message)News Headers")
1153 :type 'message-header-lines)
1155 ;; Note: could use /usr/ucb/mail instead of sendmail;
1156 ;; options -t, and -v if not interactive.
1157 (defcustom message-mailer-swallows-blank-line
1158 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1159 system-configuration)
1160 (file-readable-p "/etc/sendmail.cf")
1161 (let ((buffer (get-buffer-create " *temp*")))
1163 (with-current-buffer buffer
1164 (insert-file-contents "/etc/sendmail.cf")
1165 (goto-char (point-min))
1166 (let ((case-fold-search nil))
1167 (re-search-forward "^OR\\>" nil t)))
1168 (kill-buffer buffer))))
1169 ;; According to RFC822, "The field-name must be composed of printable
1170 ;; ASCII characters (i. e., characters that have decimal values between
1171 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1173 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1174 "*Set this non-nil if the system's mailer runs the header and body together.
1175 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1176 The value should be an expression to test whether the problem will
1178 :group 'message-sending
1179 :link '(custom-manual "(message)Mail Variables")
1183 (define-mail-user-agent 'message-user-agent
1184 'message-mail 'message-send-and-exit
1185 'message-kill-buffer 'message-send-hook)
1187 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1188 "If non-nil, delete the deletable headers before feeding to mh.")
1190 (defvar message-send-method-alist
1191 '((news message-news-p message-send-via-news)
1192 (mail message-mail-p message-send-via-mail))
1193 "Alist of ways to send outgoing messages.
1194 Each element has the form
1196 \(TYPE PREDICATE FUNCTION)
1198 where TYPE is a symbol that names the method; PREDICATE is a function
1199 called without any parameters to determine whether the message is
1200 a message of type TYPE; and FUNCTION is a function to be called if
1201 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1204 (defcustom message-mail-alias-type 'abbrev
1205 "*What alias expansion type to use in Message buffers.
1206 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1207 an electric completion mode. nil switches mail aliases off.
1208 This can also be a list of values."
1210 :link '(custom-manual "(message)Mail Aliases")
1211 :type '(choice (const :tag "Use Mailabbrev" abbrev)
1212 (const :tag "Use ecomplete" ecomplete)
1213 (const :tag "No expansion" nil)))
1215 (defcustom message-self-insert-commands '(self-insert-command)
1216 "List of `self-insert-command's used to trigger ecomplete.
1217 When one of those commands is invoked to enter a character in To or Cc
1218 header, ecomplete will suggest the candidates of recipients (see also
1219 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1220 text and it replaces `self-insert-command' with the other command, e.g.
1221 `egg-self-insert-command', you may want to add it to this list."
1222 :group 'message-various
1223 :type '(repeat function))
1225 (defcustom message-auto-save-directory
1226 (file-name-as-directory (nnheader-concat message-directory "drafts"))
1227 "*Directory where Message auto-saves buffers if Gnus isn't running.
1228 If nil, Message won't auto-save."
1229 :group 'message-buffers
1230 :link '(custom-manual "(message)Various Message Variables")
1231 :type '(choice directory (const :tag "Don't auto-save" nil)))
1233 (defcustom message-default-charset
1234 (and (not (mm-multibyte-p)) 'iso-8859-1)
1235 "Default charset used in non-MULE Emacsen.
1236 If nil, you might be asked to input the charset."
1239 :link '(custom-manual "(message)Various Message Variables")
1242 (defcustom message-dont-reply-to-names
1243 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1244 "*Addresses to prune when doing wide replies.
1245 This can be a regexp or a list of regexps. Also, a value of nil means
1246 exclude your own user name only."
1249 :link '(custom-manual "(message)Wide Reply")
1250 :type '(choice (const :tag "Yourself" nil)
1252 (repeat :tag "Regexp List" regexp)))
1254 (defsubst message-dont-reply-to-names ()
1255 (gmm-regexp-concat message-dont-reply-to-names))
1257 (defvar message-shoot-gnksa-feet nil
1258 "*A list of GNKSA feet you are allowed to shoot.
1259 Gnus gives you all the opportunity you could possibly want for
1260 shooting yourself in the foot. Also, Gnus allows you to shoot the
1261 feet of Good Net-Keeping Seal of Approval. The following are foot
1263 `empty-article' Allow you to post an empty article;
1264 `quoted-text-only' Allow you to post quoted text only;
1265 `multiple-copies' Allow you to post multiple copies;
1266 `cancel-messages' Allow you to cancel or supersede messages from
1267 your other email addresses.")
1269 (defsubst message-gnksa-enable-p (feature)
1270 (or (not (listp message-shoot-gnksa-feet))
1271 (memq feature message-shoot-gnksa-feet)))
1273 (defcustom message-hidden-headers '("^References:" "^Face:" "^X-Face:"
1275 "Regexp of headers to be hidden when composing new messages.
1276 This can also be a list of regexps to match headers. Or a list
1277 starting with `not' and followed by regexps."
1280 :link '(custom-manual "(message)Message Headers")
1282 :format "%{%t%}: %[Value Type%] %v"
1283 (regexp :menu-tag "regexp" :format "regexp\n%t: %v")
1284 (repeat :menu-tag "(regexp ...)" :format "(regexp ...)\n%v%i"
1285 (regexp :format "%t: %v"))
1286 (cons :menu-tag "(not regexp ...)" :format "(not regexp ...)\n%v"
1288 (repeat :format "%v%i"
1289 (regexp :format "%t: %v")))))
1291 (defcustom message-cite-articles-with-x-no-archive t
1292 "If non-nil, cite text from articles that has X-No-Archive set."
1296 ;;; Internal variables.
1297 ;;; Well, not really internal.
1299 (defvar message-mode-syntax-table
1300 (let ((table (copy-syntax-table text-mode-syntax-table)))
1301 (modify-syntax-entry ?% ". " table)
1302 (modify-syntax-entry ?> ". " table)
1303 (modify-syntax-entry ?< ". " table)
1305 "Syntax table used while in Message mode.")
1307 (defface message-header-to
1310 (:foreground "DarkOliveGreen1" :bold t))
1313 (:foreground "MidnightBlue" :bold t))
1315 (:bold t :italic t)))
1316 "Face used for displaying From headers."
1317 :group 'message-faces)
1318 ;; backward-compatibility alias
1319 (put 'message-header-to-face 'face-alias 'message-header-to)
1321 (defface message-header-cc
1324 (:foreground "chartreuse1" :bold t))
1327 (:foreground "MidnightBlue"))
1330 "Face used for displaying Cc headers."
1331 :group 'message-faces)
1332 ;; backward-compatibility alias
1333 (put 'message-header-cc-face 'face-alias 'message-header-cc)
1335 (defface message-header-subject
1338 (:foreground "OliveDrab1"))
1341 (:foreground "navy blue" :bold t))
1344 "Face used for displaying subject headers."
1345 :group 'message-faces)
1346 ;; backward-compatibility alias
1347 (put 'message-header-subject-face 'face-alias 'message-header-subject)
1349 (defface message-header-newsgroups
1352 (:foreground "yellow" :bold t :italic t))
1355 (:foreground "blue4" :bold t :italic t))
1357 (:bold t :italic t)))
1358 "Face used for displaying newsgroups headers."
1359 :group 'message-faces)
1360 ;; backward-compatibility alias
1361 (put 'message-header-newsgroups-face 'face-alias 'message-header-newsgroups)
1363 (defface message-header-other
1366 (:foreground "VioletRed1"))
1369 (:foreground "steel blue"))
1371 (:bold t :italic t)))
1372 "Face used for displaying newsgroups headers."
1373 :group 'message-faces)
1374 ;; backward-compatibility alias
1375 (put 'message-header-other-face 'face-alias 'message-header-other)
1377 (defface message-header-name
1380 (:foreground "green"))
1383 (:foreground "cornflower blue"))
1386 "Face used for displaying header names."
1387 :group 'message-faces)
1388 ;; backward-compatibility alias
1389 (put 'message-header-name-face 'face-alias 'message-header-name)
1391 (defface message-header-xheader
1394 (:foreground "DeepSkyBlue1"))
1397 (:foreground "blue"))
1400 "Face used for displaying X-Header headers."
1401 :group 'message-faces)
1402 ;; backward-compatibility alias
1403 (put 'message-header-xheader-face 'face-alias 'message-header-xheader)
1405 (defface message-separator
1408 (:foreground "LightSkyBlue1"))
1411 (:foreground "brown"))
1414 "Face used for displaying the separator."
1415 :group 'message-faces)
1416 ;; backward-compatibility alias
1417 (put 'message-separator-face 'face-alias 'message-separator)
1419 (defface message-cited-text
1422 (:foreground "LightPink1"))
1425 (:foreground "red"))
1428 "Face used for displaying cited text names."
1429 :group 'message-faces)
1430 ;; backward-compatibility alias
1431 (put 'message-cited-text-face 'face-alias 'message-cited-text)
1433 (defface message-mml
1436 (:foreground "MediumSpringGreen"))
1439 (:foreground "ForestGreen"))
1442 "Face used for displaying MML."
1443 :group 'message-faces)
1444 ;; backward-compatibility alias
1445 (put 'message-mml-face 'face-alias 'message-mml)
1447 (defun message-font-lock-make-header-matcher (regexp)
1450 (let ((start (point)))
1453 (goto-char (point-min))
1454 (if (re-search-forward
1455 (concat "^" (regexp-quote mail-header-separator) "$")
1457 (setq limit (min limit (match-beginning 0))))
1459 (and (< start limit)
1460 (re-search-forward ,regexp limit t))))))
1461 (if (featurep 'bytecomp)
1465 (defvar message-font-lock-keywords
1466 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1467 `((,(message-font-lock-make-header-matcher
1468 (concat "^\\([Tt]o:\\)" content))
1469 (1 'message-header-name)
1470 (2 'message-header-to nil t))
1471 (,(message-font-lock-make-header-matcher
1472 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1473 (1 'message-header-name)
1474 (2 'message-header-cc nil t))
1475 (,(message-font-lock-make-header-matcher
1476 (concat "^\\([Ss]ubject:\\)" content))
1477 (1 'message-header-name)
1478 (2 'message-header-subject nil t))
1479 (,(message-font-lock-make-header-matcher
1480 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content))
1481 (1 'message-header-name)
1482 (2 'message-header-newsgroups nil t))
1483 (,(message-font-lock-make-header-matcher
1484 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content))
1485 (1 'message-header-name)
1486 (2 'message-header-xheader))
1487 (,(message-font-lock-make-header-matcher
1488 (concat "^\\([A-Z][^: \n\t]+:\\)" content))
1489 (1 'message-header-name)
1490 (2 'message-header-other nil t))
1491 ,@(if (and mail-header-separator
1492 (not (equal mail-header-separator "")))
1493 `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
1494 1 'message-separator))
1497 (re-search-forward (concat "^\\("
1498 message-cite-prefix-regexp
1501 (0 'message-cited-text))
1502 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1504 "Additional expressions to highlight in Message mode.")
1507 ;; XEmacs does it like this. For Emacs, we have to set the
1508 ;; `font-lock-defaults' buffer-local variable.
1509 (put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
1511 (defvar message-face-alist
1512 '((bold . message-bold-region)
1513 (underline . underline-region)
1514 (default . (lambda (b e)
1515 (message-unbold-region b e)
1516 (ununderline-region b e))))
1517 "Alist of mail and news faces for facemenu.
1518 The cdr of each entry is a function for applying the face to a region.")
1520 (defcustom message-send-hook nil
1521 "Hook run before sending messages.
1522 This hook is run quite early when sending."
1523 :group 'message-various
1524 :options '(ispell-message)
1525 :link '(custom-manual "(message)Various Message Variables")
1528 (defcustom message-send-mail-hook nil
1529 "Hook run before sending mail messages.
1530 This hook is run very late -- just before the message is sent as
1532 :group 'message-various
1533 :link '(custom-manual "(message)Various Message Variables")
1536 (defcustom message-send-news-hook nil
1537 "Hook run before sending news messages.
1538 This hook is run very late -- just before the message is sent as
1540 :group 'message-various
1541 :link '(custom-manual "(message)Various Message Variables")
1544 (defcustom message-sent-hook nil
1545 "Hook run after sending messages."
1546 :group 'message-various
1549 (defvar message-send-coding-system 'binary
1550 "Coding system to encode outgoing mail.")
1552 (defvar message-draft-coding-system
1553 mm-auto-save-coding-system
1554 "*Coding system to compose mail.
1555 If you'd like to make it possible to share draft files between XEmacs
1556 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1557 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1559 (defcustom message-send-mail-partially-limit 1000000
1560 "The limitation of messages sent as message/partial.
1561 The lower bound of message size in characters, beyond which the message
1562 should be sent in several parts. If it is nil, the size is unlimited."
1564 :group 'message-buffers
1565 :link '(custom-manual "(message)Mail Variables")
1566 :type '(choice (const :tag "unlimited" nil)
1569 (defcustom message-alternative-emails nil
1570 "*Regexp matching alternative email addresses.
1571 The first address in the To, Cc or From headers of the original
1572 article matching this variable is used as the From field of
1575 This variable has precedence over posting styles and anything that runs
1576 off `message-setup-hook'."
1577 :group 'message-headers
1578 :link '(custom-manual "(message)Message Headers")
1579 :type '(choice (const :tag "Always use primary" nil)
1582 (defcustom message-hierarchical-addresses nil
1583 "A list of hierarchical mail address definitions.
1585 Inside each entry, the first address is the \"top\" address, and
1586 subsequent addresses are subaddresses; this is used to indicate that
1587 mail sent to the first address will automatically be delivered to the
1588 subaddresses. So if the first address appears in the recipient list
1589 for a message, the subaddresses will be removed (if present) before
1590 the mail is sent. All addresses in this structure should be
1593 :group 'message-headers
1594 :type '(repeat (repeat string)))
1596 (defcustom message-mail-user-agent nil
1597 "Like `mail-user-agent'.
1598 Except if it is nil, use Gnus native MUA; if it is t, use
1601 :type '(radio (const :tag "Gnus native"
1604 (const :tag "`mail-user-agent'"
1607 (function-item :tag "Default Emacs mail"
1609 sendmail-user-agent)
1610 (function-item :tag "Emacs interface to MH"
1613 (function :tag "Other"))
1617 (defcustom message-wide-reply-confirm-recipients nil
1618 "Whether to confirm a wide reply to multiple email recipients.
1619 If this variable is nil, don't ask whether to reply to all recipients.
1620 If this variable is non-nil, pose the question \"Reply to all
1621 recipients?\" before a wide reply to multiple recipients. If the user
1622 answers yes, reply to all recipients as usual. If the user answers
1623 no, only reply back to the author."
1625 :group 'message-headers
1626 :link '(custom-manual "(message)Wide Reply")
1629 (defcustom message-user-fqdn nil
1630 "*Domain part of Message-Ids."
1632 :group 'message-headers
1633 :link '(custom-manual "(message)News Headers")
1634 :type '(radio (const :format "%v " nil)
1635 (string :format "FQDN: %v")))
1637 (defcustom message-use-idna (and (condition-case nil (require 'idna)
1639 (mm-coding-system-p 'utf-8)
1640 (executable-find idna-program)
1641 (string= (idna-to-ascii "räksmörgås")
1642 "xn--rksmrgs-5wao1o")
1644 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1645 GNU Libidn, and in particular the elisp package \"idna.el\" and
1646 the external program \"idn\", must be installed for this
1647 functionality to work."
1649 :group 'message-headers
1650 :link '(custom-manual "(message)IDNA")
1651 :type '(choice (const :tag "Ask" ask)
1652 (const :tag "Never" nil)
1653 (const :tag "Always" t)))
1655 (defcustom message-generate-hashcash (if (executable-find "hashcash") t)
1656 "*Whether to generate X-Hashcash: headers.
1657 If t, always generate hashcash headers. If `opportunistic',
1658 only generate hashcash headers if it can be done without the user
1659 waiting (i.e., only asynchronously).
1661 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1662 :group 'message-headers
1663 :link '(custom-manual "(message)Mail Headers")
1664 :type '(choice (const :tag "Always" t)
1665 (const :tag "Never" nil)
1666 (const :tag "Opportunistic" opportunistic)))
1668 ;;; Internal variables.
1670 (defvar message-sending-message "Sending...")
1671 (defvar message-buffer-list nil)
1672 (defvar message-this-is-news nil)
1673 (defvar message-this-is-mail nil)
1674 (defvar message-draft-article nil)
1675 (defvar message-mime-part nil)
1676 (defvar message-posting-charset nil)
1677 (defvar message-inserted-headers nil)
1679 ;; Byte-compiler warning
1680 (defvar gnus-active-hashtb)
1681 (defvar gnus-read-active-file)
1683 ;;; Regexp matching the delimiter of messages in UNIX mail format
1684 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1685 ;;; of rmail.el's rmail-unix-mail-delimiter.
1686 (defvar message-unix-mail-delimiter
1687 (let ((time-zone-regexp
1688 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1689 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1695 ;; Many things can happen to an RFC 822 mailbox before it is put into
1696 ;; a `From' line. The leading phrase can be stripped, e.g.
1697 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1698 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1699 ;; can be removed, e.g.
1700 ;; From: joe@y.z (Joe K
1702 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1705 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1706 ;; The mailbox can be removed or be replaced by white space, e.g.
1707 ;; From: "Joe User"{space}{tab}
1709 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1710 ;; where {space} and {tab} represent the Ascii space and tab characters.
1711 ;; We want to match the results of any of these manglings.
1712 ;; The following regexp rejects names whose first characters are
1713 ;; obviously bogus, but after that anything goes.
1714 "\\([^\0-\b\n-\r\^?].*\\)?"
1716 ;; The time the message was sent.
1717 "\\([^\0-\r \^?]+\\) +" ; day of the week
1718 "\\([^\0-\r \^?]+\\) +" ; month
1719 "\\([0-3]?[0-9]\\) +" ; day of month
1720 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1722 ;; Perhaps a time zone, specified by an abbreviation, or by a
1727 " \\([0-9][0-9]+\\) *"
1729 ;; On some systems the time zone can appear after the year, too.
1733 "\\(remote from .*\\)?"
1736 "Regexp matching the delimiter of messages in UNIX mail format.")
1738 (defvar message-unsent-separator
1739 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1740 "^ *---+ +Returned message +---+ *$\\|"
1741 "^Start of returned message$\\|"
1742 "^ *---+ +Original message +---+ *$\\|"
1743 "^ *--+ +begin message +--+ *$\\|"
1744 "^ *---+ +Original message follows +---+ *$\\|"
1745 "^ *---+ +Undelivered message follows +---+ *$\\|"
1746 "^------ This is a copy of the message, including all the headers. ------ *$\\|"
1747 "^|? *---+ +Message text follows: +---+ *|?$")
1748 "A regexp that matches the separator before the text of a failed message.")
1750 (defvar message-field-fillers
1751 '((To message-fill-field-address)
1752 (Cc message-fill-field-address)
1753 (From message-fill-field-address))
1754 "Alist of header names/filler functions.")
1756 (defvar message-header-format-alist
1771 (References . message-shorten-references)
1773 "Alist used for formatting headers.")
1775 (defvar message-options nil
1776 "Some saved answers when sending message.")
1778 (defvar message-send-mail-real-function nil
1779 "Internal send mail function.")
1781 (defvar message-bogus-system-names "^localhost\\.\\|\\.local$"
1782 "The regexp of bogus system names.")
1784 (defcustom message-valid-fqdn-regexp
1785 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1787 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1788 "aero\\|arpa\\|bitnet\\|biz\\|bofh\\|"
1789 "cat\\|com\\|coop\\|edu\\|gov\\|"
1790 "info\\|int\\|jobs\\|"
1791 "mil\\|mobi\\|museum\\|name\\|net\\|"
1792 "org\\|pro\\|travel\\|uucp\\)")
1793 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1794 ;; http://en.wikipedia.org/wiki/GTLD
1795 ;; `in the process of being approved': .asia .post .tel .sex
1796 ;; "dead" nato bitnet uucp
1797 "Regular expression that matches a valid FQDN."
1798 ;; see also: gnus-button-valid-fqdn-regexp
1800 :group 'message-headers
1803 (autoload 'gnus-alive-p "gnus-util")
1804 (autoload 'gnus-delay-article "gnus-delay")
1805 (autoload 'gnus-extract-address-components "gnus-util")
1806 (autoload 'gnus-find-method-for-group "gnus")
1807 (autoload 'gnus-group-decoded-name "gnus-group")
1808 (autoload 'gnus-group-name-charset "gnus-group")
1809 (autoload 'gnus-group-name-decode "gnus-group")
1810 (autoload 'gnus-groups-from-server "gnus")
1811 (autoload 'gnus-make-local-hook "gnus-util")
1812 (autoload 'gnus-open-server "gnus-int")
1813 (autoload 'gnus-output-to-mail "gnus-util")
1814 (autoload 'gnus-output-to-rmail "gnus-util")
1815 (autoload 'gnus-request-post "gnus-int")
1816 (autoload 'gnus-select-frame-set-input-focus "gnus-util")
1817 (autoload 'gnus-server-string "gnus")
1818 (autoload 'idna-to-ascii "idna")
1819 (autoload 'message-setup-toolbar "messagexmas")
1820 (autoload 'mh-new-draft-name "mh-comp")
1821 (autoload 'mh-send-letter "mh-comp")
1822 (autoload 'nndraft-request-associate-buffer "nndraft")
1823 (autoload 'nndraft-request-expire-articles "nndraft")
1824 (autoload 'nnvirtual-find-group-art "nnvirtual")
1825 (autoload 'rmail-dont-reply-to "mail-utils")
1826 (autoload 'rmail-msg-is-pruned "rmail")
1827 (autoload 'rmail-msg-restore-non-pruned-header "rmail")
1828 (autoload 'rmail-output "rmailout")
1833 ;;; Utility functions.
1836 (defmacro message-y-or-n-p (question show &rest text)
1837 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1838 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
1840 (defmacro message-delete-line (&optional n)
1841 "Delete the current line (and the next N lines)."
1842 `(delete-region (progn (beginning-of-line) (point))
1843 (progn (forward-line ,(or n 1)) (point))))
1845 (defun message-mark-active-p ()
1846 "Non-nil means the mark and region are currently active in this buffer."
1849 (defun message-unquote-tokens (elems)
1850 "Remove double quotes (\") from strings in list ELEMS."
1851 (mapcar (lambda (item)
1852 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item)
1853 (setq item (concat (match-string 1 item)
1854 (match-string 2 item))))
1858 (defun message-tokenize-header (header &optional separator)
1859 "Split HEADER into a list of header elements.
1860 SEPARATOR is a string of characters to be used as separators. \",\"
1861 is used by default."
1864 (let ((regexp (format "[%s]+" (or separator ",")))
1866 beg quoted elems paren)
1868 (mm-enable-multibyte)
1869 (setq beg (point-min))
1871 (goto-char (point-min))
1876 (cond ((and (> (point) beg)
1878 (and (looking-at regexp)
1881 (push (buffer-substring beg (point)) elems)
1882 (setq beg (match-end 0)))
1883 ((eq (char-after) ?\")
1884 (setq quoted (not quoted)))
1885 ((and (eq (char-after) ?\()
1888 ((and (eq (char-after) ?\))
1891 (nreverse elems)))))
1893 (defun message-mail-file-mbox-p (file)
1894 "Say whether FILE looks like a Unix mbox file."
1895 (when (and (file-exists-p file)
1896 (file-readable-p file)
1897 (file-regular-p file))
1899 (nnheader-insert-file-contents file)
1900 (goto-char (point-min))
1901 (looking-at message-unix-mail-delimiter))))
1903 (defun message-fetch-field (header &optional not-all)
1904 "The same as `mail-fetch-field', only remove all newlines.
1905 The buffer is expected to be narrowed to just the header of the message;
1906 see `message-narrow-to-headers-or-head'."
1907 (let* ((inhibit-point-motion-hooks t)
1908 (value (mail-fetch-field header nil (not not-all))))
1910 (while (string-match "\n[\t ]+" value)
1911 (setq value (replace-match " " t t value)))
1914 (defun message-field-value (header &optional not-all)
1915 "The same as `message-fetch-field', only narrow to the headers first."
1918 (message-narrow-to-headers-or-head)
1919 (message-fetch-field header not-all))))
1921 (defun message-narrow-to-field ()
1922 "Narrow the buffer to the header on the current line."
1924 (while (looking-at "[ \t]")
1930 (if (re-search-forward "^[^ \n\t]" nil t)
1933 (goto-char (point-min)))
1935 (defun message-add-header (&rest headers)
1936 "Add the HEADERS to the message header, skipping those already present."
1939 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers))
1940 (error "Invalid header `%s'" (car headers)))
1941 (setq hclean (match-string 1 (car headers)))
1943 (message-narrow-to-headers)
1944 (unless (re-search-forward (concat "^" (regexp-quote hclean) ":") nil t)
1945 (goto-char (point-max))
1946 (if (string-match "\n$" (car headers))
1947 (insert (car headers))
1948 (insert (car headers) ?\n)))))
1949 (setq headers (cdr headers))))
1951 (defmacro message-with-reply-buffer (&rest forms)
1952 "Evaluate FORMS in the reply buffer, if it exists."
1953 `(when (and message-reply-buffer
1954 (buffer-name message-reply-buffer))
1955 (with-current-buffer message-reply-buffer
1958 (put 'message-with-reply-buffer 'lisp-indent-function 0)
1959 (put 'message-with-reply-buffer 'edebug-form-spec '(body))
1961 (defun message-fetch-reply-field (header)
1962 "Fetch field HEADER from the message we're replying to."
1963 (message-with-reply-buffer
1965 (mail-narrow-to-head)
1966 (message-fetch-field header))))
1968 (defun message-strip-list-identifiers (subject)
1969 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
1970 (require 'gnus-sum) ; for gnus-list-identifiers
1971 (let ((regexp (if (stringp gnus-list-identifiers)
1972 gnus-list-identifiers
1973 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1974 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
1975 " *\\)\\)+\\(Re: +\\)?\\)") subject)
1976 (concat (substring subject 0 (match-beginning 1))
1977 (or (match-string 3 subject)
1978 (match-string 5 subject))
1983 (defun message-strip-subject-re (subject)
1984 "Remove \"Re:\" from subject lines in string SUBJECT."
1985 (if (string-match message-subject-re-regexp subject)
1986 (substring subject (match-end 0))
1989 (defcustom message-replacement-char "."
1990 "Replacement character used instead of unprintable or not decodable chars."
1991 :group 'message-various
1992 :version "22.1" ;; Gnus 5.10.9
1993 :type '(choice string
1997 ;; FIXME: We also should call `message-strip-subject-encoded-words'
1998 ;; when forwarding. Probably in `message-make-forward-subject' and
1999 ;; `message-forward-make-body'.
2001 (defun message-strip-subject-encoded-words (subject)
2002 "Fix non-decodable words in SUBJECT."
2003 ;; Cf. `gnus-simplify-subject-fully'.
2004 (let* ((case-fold-search t)
2005 (replacement-chars (format "[%s%s%s]"
2006 message-replacement-char
2007 message-replacement-char
2008 message-replacement-char))
2009 (enc-word-re "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?\\([^?]+\\)\\(\\?=\\)")
2014 (goto-char (point-min))
2015 (when (re-search-forward enc-word-re nil t)
2016 (setq cs-string (match-string 1)))))
2017 cs-coding q-or-b word-beg word-end)
2018 (if (or (not have-marker) ;; No encoded word found...
2019 ;; ... or double encoding was correct:
2020 (and (stringp cs-string)
2021 (setq cs-string (downcase cs-string))
2022 (mm-coding-system-p (intern cs-string))
2026 Decoded Subject \"%s\"
2027 contains a valid encoded word. Decode again? "
2029 (setq cs-coding (intern cs-string))))))
2033 (goto-char (point-min))
2034 (while (re-search-forward enc-word-re nil t)
2035 (setq cs-string (downcase (match-string 1))
2036 q-or-b (match-string 2)
2037 word-beg (match-beginning 0)
2038 word-end (match-end 0))
2040 (if (mm-coding-system-p (intern cs-string))
2041 (setq cs-coding (intern cs-string))
2043 ;; No double encoded subject? => bogus charset.
2046 (mm-read-coding-system
2048 Decoded Subject \"%s\"
2049 contains an encoded word. The charset `%s' is unknown or invalid.
2050 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
2052 subject cs-string message-replacement-char)))
2054 (replace-match (concat "=?" (symbol-name cs-coding)
2057 (goto-char word-beg)
2058 (re-search-forward "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?" word-end t)
2061 (if (string-match "\\`Q\\'" q-or-b)
2064 (message "Replacing non-decodable characters with \"%s\"."
2065 message-replacement-char)
2066 (while (re-search-forward "\\(=[A-F0-9][A-F0-9]\\)+"
2068 (replace-match message-replacement-char)))
2070 (message "Replacing non-decodable characters with \"%s\"."
2072 (re-search-forward "[^?]+" word-end t)
2073 (replace-match replacement-chars))
2074 (re-search-forward "\\?=")
2075 (replace-match "")))))
2076 (rfc2047-decode-region (point-min) (point-max))
2079 ;;; Start of functions adopted from `message-utils.el'.
2081 (defun message-strip-subject-trailing-was (subject)
2082 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
2083 Leading \"Re: \" is not stripped by this function. Use the function
2084 `message-strip-subject-re' for this."
2085 (let* ((query message-subject-trailing-was-query)
2090 message-subject-trailing-was-ask-regexp
2091 message-subject-trailing-was-regexp)
2094 (setq new (substring subject 0 (match-beginning 0))))
2095 (if (or (not found) (eq query nil))
2098 (if (message-y-or-n-p
2099 "Strip `(was: <old subject>)' in subject? " t
2101 "Strip `(was: <old subject>)' in subject "
2102 "and use the new one instead?\n\n"
2103 "Current subject is: \""
2105 "New subject would be: \""
2107 "See the variable `message-subject-trailing-was-query' "
2108 "to get rid of this query."
2113 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
2115 (defun message-change-subject (new-subject)
2116 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
2117 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged>
2120 (read-from-minibuffer "New subject: ")))
2121 (cond ((and (not (or (null new-subject) ; new subject not empty
2122 (zerop (string-width new-subject))
2123 (string-match "^[ \t]*$" new-subject))))
2127 (message-narrow-to-headers)
2128 (message-fetch-field "Subject"))))
2129 (cond ((not old-subject)
2130 (error "No current subject"))
2133 (regexp-quote new-subject)
2135 old-subject)) ; yes, it really is a new subject
2136 ;; delete eventual Re: prefix
2138 (message-strip-subject-re old-subject))
2139 (message-goto-subject)
2140 (message-delete-line)
2141 (insert (concat "Subject: "
2144 old-subject ")\n")))))))))
2146 (defun message-mark-inserted-region (beg end &optional verbatim)
2147 "Mark some region in the current article with enclosing tags.
2148 See `message-mark-insert-begin' and `message-mark-insert-end'.
2149 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2150 (interactive "r\nP")
2152 ;; add to the end of the region first, otherwise end would be invalid
2154 (insert (if verbatim "#v-\n" message-mark-insert-end))
2156 (insert (if verbatim "#v+\n" message-mark-insert-begin))))
2158 (defun message-mark-insert-file (file &optional verbatim)
2159 "Insert FILE at point, marking it with enclosing tags.
2160 See `message-mark-insert-begin' and `message-mark-insert-end'.
2161 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2162 (interactive "fFile to insert: \nP")
2163 ;; reverse insertion to get correct result.
2165 (insert (if verbatim "#v-\n" message-mark-insert-end))
2167 (insert-file-contents file)
2169 (insert (if verbatim "#v+\n" message-mark-insert-begin))))
2171 (defun message-add-archive-header ()
2172 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
2173 The note can be customized using `message-archive-note'. When called with a
2174 prefix argument, ask for a text to insert. If you don't want the note in the
2175 body, set `message-archive-note' to nil."
2177 (if current-prefix-arg
2178 (setq message-archive-note
2179 (read-from-minibuffer "Reason for No-Archive: "
2180 (cons message-archive-note 0))))
2182 (if (message-goto-signature)
2183 (re-search-backward message-signature-separator))
2184 (when message-archive-note
2185 (insert message-archive-note)
2187 (message-add-header message-archive-header)
2188 (message-sort-headers)))
2190 (defun message-cross-post-followup-to-header (target-group)
2191 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2192 With prefix-argument just set Follow-Up, don't cross-post."
2194 (list ; Completion based on Gnus
2195 (completing-read "Followup To: "
2196 (if (boundp 'gnus-newsrc-alist)
2198 nil nil '("poster" . 0)
2199 (if (boundp 'gnus-group-history)
2200 'gnus-group-history))))
2201 (message-remove-header "Follow[Uu]p-[Tt]o" t)
2202 (message-goto-newsgroups)
2204 ;; if we already did a crosspost before, kill old target
2205 (if (and message-cross-post-old-target
2207 (regexp-quote (concat "," message-cross-post-old-target))
2210 ;; unless (followup is to poster or user explicitly asked not
2211 ;; to cross-post, or target-group is already in Newsgroups)
2212 ;; add target-group to Newsgroups line.
2214 ;; def: cross-post, req:no
2215 (and message-cross-post-default (not current-prefix-arg))
2216 ;; def: no-cross-post, req:yes
2217 (and (not message-cross-post-default) current-prefix-arg))
2218 (not (string-match "poster" target-group))
2219 (not (string-match (regexp-quote target-group)
2220 (message-fetch-field "Newsgroups"))))
2222 (insert (concat "," target-group))))
2223 (end-of-line) ; ensure Followup: comes after Newsgroups:
2224 ;; unless new followup would be identical to Newsgroups line
2225 ;; make a new Followup-To line
2226 (if (not (string-match (concat "^[ \t]*"
2229 (message-fetch-field "Newsgroups")))
2230 (insert (concat "\nFollowup-To: " target-group)))
2231 (setq message-cross-post-old-target target-group))
2233 (defun message-cross-post-insert-note (target-group cross-post in-old
2235 "Insert a in message body note about a set Followup or Crosspost.
2236 If there have been previous notes, delete them. TARGET-GROUP specifies the
2237 group to Followup-To. When CROSS-POST is t, insert note about
2238 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2239 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2240 been made to before the user asked for a Crosspost."
2241 ;; start scanning body for previous uses
2242 (message-goto-signature)
2243 (let ((head (re-search-backward
2244 (concat "^" mail-header-separator)
2245 nil t))) ; just search in body
2246 (message-goto-signature)
2247 (while (re-search-backward
2248 (concat "^" (regexp-quote message-cross-post-note) ".*")
2250 (message-delete-line))
2251 (message-goto-signature)
2252 (while (re-search-backward
2253 (concat "^" (regexp-quote message-followup-to-note) ".*")
2255 (message-delete-line))
2257 (if (message-goto-signature)
2258 (re-search-backward message-signature-separator))
2261 (string-match "^[ \t]*poster[ \t]*$" target-group))
2262 (insert (concat message-followup-to-note target-group "\n"))
2263 (insert (concat message-cross-post-note target-group "\n")))))
2265 (defun message-cross-post-followup-to (target-group)
2266 "Crossposts message and set Followup-To to TARGET-GROUP.
2267 With prefix-argument just set Follow-Up, don't cross-post."
2269 (list ; Completion based on Gnus
2270 (completing-read "Followup To: "
2271 (if (boundp 'gnus-newsrc-alist)
2273 nil nil '("poster" . 0)
2274 (if (boundp 'gnus-group-history)
2275 'gnus-group-history))))
2276 (cond ((not (or (null target-group) ; new subject not empty
2277 (zerop (string-width target-group))
2278 (string-match "^[ \t]*$" target-group)))
2280 (let* ((old-groups (message-fetch-field "Newsgroups"))
2281 (in-old (string-match
2282 (regexp-quote target-group)
2283 (or old-groups ""))))
2284 ;; check whether target exactly matches old Newsgroups
2285 (cond ((not old-groups)
2286 (error "No current newsgroup"))
2290 (regexp-quote target-group)
2293 ;; yes, Newsgroups line must change
2294 (message-cross-post-followup-to-header target-group)
2295 ;; insert note whether we do cross-post or followup-to
2296 (funcall message-cross-post-note-function
2298 (if (or (and message-cross-post-default
2299 (not current-prefix-arg))
2300 (and (not message-cross-post-default)
2301 current-prefix-arg)) t)
2302 in-old old-groups))))))))
2304 ;;; Reduce To: to Cc: or Bcc: header
2306 (defun message-reduce-to-to-cc ()
2307 "Replace contents of To: header with contents of Cc: or Bcc: header."
2310 (save-restriction (message-narrow-to-headers)
2311 (message-fetch-field "cc")))
2313 (if (and (not cc-content)
2316 (message-narrow-to-headers)
2317 (message-fetch-field "bcc"))))
2322 (message-delete-line)
2323 (insert (concat "To: " cc-content "\n"))
2325 (message-narrow-to-headers)
2326 (message-remove-header (if bcc
2330 ;;; End of functions adopted from `message-utils.el'.
2332 (defun message-remove-header (header &optional is-regexp first reverse)
2333 "Remove HEADER in the narrowed buffer.
2334 If IS-REGEXP, HEADER is a regular expression.
2335 If FIRST, only remove the first instance of the header.
2336 Return the number of headers removed."
2337 (goto-char (point-min))
2338 (let ((regexp (if is-regexp header (concat "^" (regexp-quote header) ":")))
2340 (case-fold-search t)
2342 (while (and (not (eobp))
2345 (not (looking-at regexp))
2346 (looking-at regexp))
2353 ;; There might be a continuation header, so we have to search
2354 ;; until we find a new non-continuation line.
2357 (if (re-search-forward "^[^ \t]" nil t)
2358 (goto-char (match-beginning 0))
2361 (if (re-search-forward "^[^ \t]" nil t)
2362 (goto-char (match-beginning 0))
2363 (goto-char (point-max)))))
2366 (defun message-remove-first-header (header)
2367 "Remove the first instance of HEADER if there is more than one."
2369 (regexp (concat "^" (regexp-quote header) ":")))
2371 (goto-char (point-min))
2372 (while (re-search-forward regexp nil t)
2375 (message-remove-header header nil t)
2378 (defun message-narrow-to-headers ()
2379 "Narrow the buffer to the head of the message."
2382 (goto-char (point-min))
2383 (if (re-search-forward
2384 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
2387 (goto-char (point-min)))
2389 (defun message-narrow-to-head-1 ()
2390 "Like `message-narrow-to-head'. Don't widen."
2392 (goto-char (point-min))
2393 (if (search-forward "\n\n" nil 1)
2396 (goto-char (point-min)))
2398 ;; FIXME: clarify diffference: message-narrow-to-head,
2399 ;; message-narrow-to-headers-or-head, message-narrow-to-headers
2400 (defun message-narrow-to-head ()
2401 "Narrow the buffer to the head of the message.
2402 Point is left at the beginning of the narrowed-to region."
2404 (message-narrow-to-head-1))
2406 (defun message-narrow-to-headers-or-head ()
2407 "Narrow the buffer to the head of the message."
2410 (goto-char (point-min))
2411 (if (re-search-forward (concat "\\(\n\\)\n\\|^\\("
2412 (regexp-quote mail-header-separator)
2415 (or (match-end 1) (match-beginning 2))
2417 (goto-char (point-min)))
2419 (defun message-news-p ()
2420 "Say whether the current buffer contains a news message."
2421 (and (not message-this-is-mail)
2422 (or message-this-is-news
2425 (message-narrow-to-headers)
2426 (and (message-fetch-field "newsgroups")
2427 (not (message-fetch-field "posted-to"))))))))
2429 (defun message-mail-p ()
2430 "Say whether the current buffer contains a mail message."
2431 (and (not message-this-is-news)
2432 (or message-this-is-mail
2435 (message-narrow-to-headers)
2436 (or (message-fetch-field "to")
2437 (message-fetch-field "cc")
2438 (message-fetch-field "bcc")))))))
2440 (defun message-subscribed-p ()
2441 "Say whether we need to insert a MFT header."
2442 (or message-subscribed-regexps
2443 message-subscribed-addresses
2444 message-subscribed-address-file
2445 message-subscribed-address-functions))
2447 (defun message-next-header ()
2448 "Go to the beginning of the next header."
2450 (or (eobp) (forward-char 1))
2451 (not (if (re-search-forward "^[^ \t]" nil t)
2453 (goto-char (point-max)))))
2455 (defun message-sort-headers-1 ()
2456 "Sort the buffer as headers using `message-rank' text props."
2457 (goto-char (point-min))
2460 nil 'message-next-header
2462 (message-next-header)
2466 (or (get-text-property (point) 'message-rank)
2469 (defun message-sort-headers ()
2470 "Sort the headers of the current message according to `message-header-format-alist'."
2474 (let ((max (1+ (length message-header-format-alist)))
2476 (message-narrow-to-headers)
2477 (while (re-search-forward "^[^ \n]+:" nil t)
2479 (match-beginning 0) (1+ (match-beginning 0))
2481 (if (setq rank (length (memq (assq (intern (buffer-substring
2483 (1- (match-end 0))))
2484 message-header-format-alist)
2485 message-header-format-alist)))
2488 (message-sort-headers-1))))
2490 (defun message-kill-address ()
2491 "Kill the address under point."
2493 (let ((start (point)))
2494 (message-skip-to-next-address)
2495 (kill-region start (point))))
2498 (autoload 'Info-goto-node "info")
2499 (defvar mml2015-use)
2501 (defun message-info (&optional arg)
2502 "Display the Message manual.
2504 Prefixed with one \\[universal-argument], display the Emacs MIME
2505 manual. With two \\[universal-argument]'s, display the EasyPG or
2506 PGG manual, depending on the value of `mml2015-use'."
2508 ;; Why not `info', which is in loaddefs.el?
2509 (Info-goto-node (format "(%s)Top"
2513 ((eq arg 4) 'emacs-mime)
2514 ;; `booleanp' only available in Emacs 22+
2515 ((and (not (memq arg '(nil t)))
2529 (defvar message-mode-map nil)
2531 (unless message-mode-map
2532 (setq message-mode-map (make-keymap))
2533 (set-keymap-parent message-mode-map text-mode-map)
2534 (define-key message-mode-map "\C-c?" 'describe-mode)
2536 (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to)
2537 (define-key message-mode-map "\C-c\C-f\C-o" 'message-goto-from)
2538 (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc)
2539 (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc)
2540 (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc)
2541 (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject)
2542 (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to)
2543 (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups)
2544 (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution)
2545 (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to)
2546 (define-key message-mode-map "\C-c\C-f\C-m" 'message-goto-mail-followup-to)
2547 (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords)
2548 (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary)
2549 (define-key message-mode-map "\C-c\C-f\C-i"
2550 'message-insert-or-toggle-importance)
2551 (define-key message-mode-map "\C-c\C-f\C-a"
2552 'message-generate-unsubscribed-mail-followup-to)
2554 ;; modify headers (and insert notes in body)
2555 (define-key message-mode-map "\C-c\C-fs" 'message-change-subject)
2557 (define-key message-mode-map "\C-c\C-fx" 'message-cross-post-followup-to)
2558 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2559 (define-key message-mode-map "\C-c\C-ft" 'message-reduce-to-to-cc)
2560 (define-key message-mode-map "\C-c\C-fa" 'message-add-archive-header)
2561 ;; mark inserted text
2562 (define-key message-mode-map "\C-c\M-m" 'message-mark-inserted-region)
2563 (define-key message-mode-map "\C-c\M-f" 'message-mark-insert-file)
2565 (define-key message-mode-map "\C-c\C-b" 'message-goto-body)
2566 (define-key message-mode-map "\C-c\C-i" 'message-goto-signature)
2568 (define-key message-mode-map "\C-c\C-t" 'message-insert-to)
2569 (define-key message-mode-map "\C-c\C-fw" 'message-insert-wide-reply)
2570 (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups)
2571 (define-key message-mode-map "\C-c\C-l" 'message-to-list-only)
2572 (define-key message-mode-map "\C-c\C-f\C-e" 'message-insert-expires)
2574 (define-key message-mode-map "\C-c\C-u" 'message-insert-or-toggle-importance)
2575 (define-key message-mode-map "\C-c\M-n"
2576 'message-insert-disposition-notification-to)
2578 (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
2579 (define-key message-mode-map "\C-c\M-\C-y" 'message-yank-buffer)
2580 (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
2581 (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
2582 (define-key message-mode-map "\C-c\M-h" 'message-insert-headers)
2583 (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
2584 (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
2585 (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
2587 (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit)
2588 (define-key message-mode-map "\C-c\C-s" 'message-send)
2589 (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
2590 (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
2591 (define-key message-mode-map "\C-c\n" 'gnus-delay-article)
2593 (define-key message-mode-map "\C-c\M-k" 'message-kill-address)
2594 (define-key message-mode-map "\C-c\C-e" 'message-elide-region)
2595 (define-key message-mode-map "\C-c\C-v" 'message-delete-not-region)
2596 (define-key message-mode-map "\C-c\C-z" 'message-kill-to-signature)
2597 (define-key message-mode-map "\M-\r" 'message-newline-and-reformat)
2598 (define-key message-mode-map [remap split-line] 'message-split-line)
2600 (define-key message-mode-map "\C-c\C-a" 'mml-attach-file)
2602 (define-key message-mode-map "\C-a" 'message-beginning-of-line)
2603 (define-key message-mode-map "\t" 'message-tab)
2604 (define-key message-mode-map "\M-;" 'comment-region)
2606 (define-key message-mode-map "\M-n" 'message-display-abbrev))
2609 message-mode-menu message-mode-map "Message Menu."
2611 ["Yank Original" message-yank-original message-reply-buffer]
2612 ["Fill Yanked Message" message-fill-yanked-message t]
2613 ["Insert Signature" message-insert-signature t]
2614 ["Caesar (rot13) Message" message-caesar-buffer-body t]
2615 ["Caesar (rot13) Region" message-caesar-region (message-mark-active-p)]
2616 ["Elide Region" message-elide-region
2617 :active (message-mark-active-p)
2618 ,@(if (featurep 'xemacs) nil
2619 '(:help "Replace text in region with an ellipsis"))]
2620 ["Delete Outside Region" message-delete-not-region
2621 :active (message-mark-active-p)
2622 ,@(if (featurep 'xemacs) nil
2623 '(:help "Delete all quoted text outside region"))]
2624 ["Kill To Signature" message-kill-to-signature t]
2625 ["Newline and Reformat" message-newline-and-reformat t]
2626 ["Rename buffer" message-rename-buffer t]
2627 ["Spellcheck" ispell-message
2628 ,@(if (featurep 'xemacs) '(t)
2629 '(:help "Spellcheck this message"))]
2631 ["Insert Region Marked" message-mark-inserted-region
2632 :active (message-mark-active-p)
2633 ,@(if (featurep 'xemacs) nil
2634 '(:help "Mark region with enclosing tags"))]
2635 ["Insert File Marked..." message-mark-insert-file
2636 ,@(if (featurep 'xemacs) '(t)
2637 '(:help "Insert file at point marked with enclosing tags"))]
2639 ["Send Message" message-send-and-exit
2640 ,@(if (featurep 'xemacs) '(t)
2641 '(:help "Send this message"))]
2642 ["Postpone Message" message-dont-send
2643 ,@(if (featurep 'xemacs) '(t)
2644 '(:help "File this draft message and exit"))]
2645 ["Send at Specific Time..." gnus-delay-article
2646 ,@(if (featurep 'xemacs) '(t)
2647 '(:help "Ask, then arrange to send message at that time"))]
2648 ["Kill Message" message-kill-buffer
2649 ,@(if (featurep 'xemacs) '(t)
2650 '(:help "Delete this message without sending"))]
2652 ["Message manual" message-info
2653 ,@(if (featurep 'xemacs) '(t)
2654 '(:help "Display the Message manual"))]))
2657 message-mode-field-menu message-mode-map ""
2659 ["To" message-goto-to t]
2660 ["From" message-goto-from t]
2661 ["Subject" message-goto-subject t]
2662 ["Change subject..." message-change-subject t]
2663 ["Cc" message-goto-cc t]
2664 ["Bcc" message-goto-bcc t]
2665 ["Fcc" message-goto-fcc t]
2666 ["Reply-To" message-goto-reply-to t]
2667 ["Flag As Important" message-insert-importance-high
2668 ,@(if (featurep 'xemacs) '(t)
2669 '(:help "Mark this message as important"))]
2670 ["Flag As Unimportant" message-insert-importance-low
2671 ,@(if (featurep 'xemacs) '(t)
2672 '(:help "Mark this message as unimportant"))]
2674 message-insert-disposition-notification-to
2675 ,@(if (featurep 'xemacs) '(t)
2676 '(:help "Request a receipt notification"))]
2678 ;; (typical) news stuff
2679 ["Summary" message-goto-summary t]
2680 ["Keywords" message-goto-keywords t]
2681 ["Newsgroups" message-goto-newsgroups t]
2682 ["Fetch Newsgroups" message-insert-newsgroups t]
2683 ["Followup-To" message-goto-followup-to t]
2684 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2685 ["Crosspost / Followup-To..." message-cross-post-followup-to t]
2686 ["Distribution" message-goto-distribution t]
2687 ["Expires" message-insert-expires t ]
2688 ["X-No-Archive" message-add-archive-header t ]
2690 ;; (typical) mailing-lists stuff
2691 ["Fetch To" message-insert-to
2692 ,@(if (featurep 'xemacs) '(t)
2693 '(:help "Insert a To header that points to the author."))]
2694 ["Fetch To and Cc" message-insert-wide-reply
2695 ,@(if (featurep 'xemacs) '(t)
2697 "Insert To and Cc headers as if you were doing a wide reply."))]
2699 ["Send to list only" message-to-list-only t]
2700 ["Mail-Followup-To" message-goto-mail-followup-to t]
2701 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2702 ,@(if (featurep 'xemacs) '(t)
2703 '(:help "Insert a reasonable `Mail-Followup-To:' header."))]
2704 ["Reduce To: to Cc:" message-reduce-to-to-cc t]
2706 ["Sort Headers" message-sort-headers t]
2707 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t]
2708 ;; We hide `message-hidden-headers' by narrowing the buffer.
2709 ["Show Hidden Headers" widen t]
2710 ["Goto Body" message-goto-body t]
2711 ["Goto Signature" message-goto-signature t]))
2713 (defvar message-tool-bar-map nil)
2715 (defvar facemenu-add-face-function)
2716 (defvar facemenu-remove-face-function)
2718 ;;; Forbidden properties
2720 ;; We use `after-change-functions' to keep special text properties
2721 ;; that interfer with the normal function of message mode out of the
2724 (defcustom message-strip-special-text-properties t
2725 "Strip special properties from the message buffer.
2727 Emacs has a number of special text properties which can break message
2728 composing in various ways. If this option is set, message will strip
2729 these properties from the message composition buffer. However, some
2730 packages requires these properties to be present in order to work.
2731 If you use one of these packages, turn this option off, and hope the
2732 message composition doesn't break too bad."
2734 :group 'message-various
2735 :link '(custom-manual "(message)Various Message Variables")
2738 (defconst message-forbidden-properties
2739 ;; No reason this should be clutter up customize. We make it a
2740 ;; property list (rather than a list of property symbols), to be
2741 ;; directly useful for `remove-text-properties'.
2742 '(field nil read-only nil invisible nil intangible nil
2743 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2744 insert-behind-hooks nil point-entered nil point-left nil)
2745 ;; Other special properties:
2746 ;; category, face, display: probably doesn't do any harm.
2747 ;; fontified: is used by font-lock.
2748 ;; syntax-table, local-map: I dunno.
2749 ;; We need to add XEmacs names to the list.
2750 "Property list of with properties forbidden in message buffers.
2751 The values of the properties are ignored, only the property names are used.")
2753 (defun message-tamago-not-in-use-p (pos)
2754 "Return t when tamago version 4 is not in use at the cursor position.
2755 Tamago version 4 is a popular input method for writing Japanese text.
2756 It uses the properties `intangible', `invisible', `modification-hooks'
2757 and `read-only' when translating ascii or kana text to kanji text.
2758 These properties are essential to work, so we should never strip them."
2759 (not (and (boundp 'egg-modefull-mode)
2760 (symbol-value 'egg-modefull-mode)
2761 (or (memq (get-text-property pos 'intangible)
2762 '(its-part-1 its-part-2))
2763 (get-text-property pos 'egg-end)
2764 (get-text-property pos 'egg-lang)
2765 (get-text-property pos 'egg-start)))))
2767 (defsubst message-mail-alias-type-p (type)
2768 (if (atom message-mail-alias-type)
2769 (eq message-mail-alias-type type)
2770 (memq type message-mail-alias-type)))
2772 (defun message-strip-forbidden-properties (begin end &optional old-length)
2773 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2774 This function is intended to be called from `after-change-functions'.
2775 See also `message-forbidden-properties'."
2776 (when (and (message-mail-alias-type-p 'ecomplete)
2777 (memq this-command message-self-insert-commands))
2778 (message-display-abbrev))
2779 (when (and message-strip-special-text-properties
2780 (message-tamago-not-in-use-p begin))
2781 (let ((buffer-read-only nil)
2782 (inhibit-read-only t))
2783 (remove-text-properties begin end message-forbidden-properties))))
2786 (define-derived-mode message-mode text-mode "Message"
2787 "Major mode for editing mail and news to be sent.
2788 Like Text Mode but with these additional commands:\\<message-mode-map>
2789 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2790 C-c C-d Postpone sending the message C-c C-k Kill the message
2791 C-c C-f move to a header field (and create it if there isn't):
2792 C-c C-f C-t move to To C-c C-f C-s move to Subject
2793 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2794 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2795 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2796 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2797 C-c C-f C-o move to From (\"Originator\")
2798 C-c C-f C-f move to Followup-To
2799 C-c C-f C-m move to Mail-Followup-To
2800 C-c C-f C-e move to Expires
2801 C-c C-f C-i cycle through Importance values
2802 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2803 C-c C-f x crossposting with FollowUp-To header and note in body
2804 C-c C-f t replace To: header with contents of Cc: or Bcc:
2805 C-c C-f a Insert X-No-Archive: header and a note in the body
2806 C-c C-t `message-insert-to' (add a To header to a news followup)
2807 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2808 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2809 C-c C-b `message-goto-body' (move to beginning of message text).
2810 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2811 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2812 C-c C-y `message-yank-original' (insert current message, if any).
2813 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2814 C-c C-e `message-elide-region' (elide the text between point and mark).
2815 C-c C-v `message-delete-not-region' (remove the text outside the region).
2816 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2817 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2818 C-c C-a `mml-attach-file' (attach a file as MIME).
2819 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2820 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2821 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2822 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2823 M-RET `message-newline-and-reformat' (break the line and reformat)."
2824 (setq local-abbrev-table text-mode-abbrev-table)
2825 (set (make-local-variable 'message-reply-buffer) nil)
2826 (set (make-local-variable 'message-inserted-headers) nil)
2827 (set (make-local-variable 'message-send-actions) nil)
2828 (set (make-local-variable 'message-exit-actions) nil)
2829 (set (make-local-variable 'message-kill-actions) nil)
2830 (set (make-local-variable 'message-postpone-actions) nil)
2831 (set (make-local-variable 'message-draft-article) nil)
2832 (setq buffer-offer-save t)
2833 (set (make-local-variable 'facemenu-add-face-function)
2835 (let ((face-fun (cdr (assq face message-face-alist))))
2837 (funcall face-fun (point) end)
2838 (error "Face %s not configured for %s mode" face mode-name)))
2840 (set (make-local-variable 'facemenu-remove-face-function) t)
2841 (set (make-local-variable 'message-reply-headers) nil)
2842 (make-local-variable 'message-newsreader)
2843 (make-local-variable 'message-mailer)
2844 (make-local-variable 'message-post-method)
2845 (set (make-local-variable 'message-sent-message-via) nil)
2846 (set (make-local-variable 'message-checksum) nil)
2847 (set (make-local-variable 'message-mime-part) 0)
2848 (message-setup-fill-variables)
2849 (when message-fill-column
2850 (setq fill-column message-fill-column)
2851 (turn-on-auto-fill))
2852 ;; Allow using comment commands to add/remove quoting.
2853 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2854 (when message-yank-prefix
2855 (set (make-local-variable 'comment-start) message-yank-prefix)
2856 (set (make-local-variable 'comment-start-skip)
2857 (concat "^" (regexp-quote message-yank-prefix) "[ \t]*")))
2858 (if (featurep 'xemacs)
2859 (message-setup-toolbar)
2860 (set (make-local-variable 'font-lock-defaults)
2861 '(message-font-lock-keywords t))
2862 (if (boundp 'tool-bar-map)
2863 (set (make-local-variable 'tool-bar-map) (message-make-tool-bar))))
2864 (easy-menu-add message-mode-menu message-mode-map)
2865 (easy-menu-add message-mode-field-menu message-mode-map)
2866 (gnus-make-local-hook 'after-change-functions)
2867 ;; Mmmm... Forbidden properties...
2868 (add-hook 'after-change-functions 'message-strip-forbidden-properties
2870 ;; Allow mail alias things.
2872 ((message-mail-alias-type-p 'abbrev)
2873 (if (fboundp 'mail-abbrevs-setup)
2874 (mail-abbrevs-setup)
2875 (if (fboundp 'mail-aliases-setup) ; warning avoidance
2876 (mail-aliases-setup))))
2877 ((message-mail-alias-type-p 'ecomplete)
2879 (unless buffer-file-name
2880 (message-set-auto-save-file-name))
2881 (unless (buffer-base-buffer)
2882 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2883 ;; multibyte is not necessary at all. -- zsh
2884 (mm-enable-multibyte))
2885 (set (make-local-variable 'indent-tabs-mode) nil) ;No tabs for indentation.
2888 (defun message-setup-fill-variables ()
2889 "Setup message fill variables."
2890 (set (make-local-variable 'fill-paragraph-function)
2891 'message-fill-paragraph)
2892 (make-local-variable 'paragraph-separate)
2893 (make-local-variable 'paragraph-start)
2894 (make-local-variable 'adaptive-fill-regexp)
2895 (unless (boundp 'adaptive-fill-first-line-regexp)
2896 (setq adaptive-fill-first-line-regexp nil))
2897 (make-local-variable 'adaptive-fill-first-line-regexp)
2898 (let ((quote-prefix-regexp
2899 ;; User should change message-cite-prefix-regexp if
2900 ;; message-yank-prefix is set to an abnormal value.
2901 (concat "\\(" message-cite-prefix-regexp "\\)[ \t]*")))
2902 (setq paragraph-start
2904 (regexp-quote mail-header-separator) "$\\|"
2905 "[ \t]*$\\|" ; blank lines
2906 "-- $\\|" ; signature delimiter
2907 "---+$\\|" ; delimiters for forwarded messages
2908 page-delimiter "$\\|" ; spoiler warnings
2909 ".*wrote:$\\|" ; attribution lines
2910 quote-prefix-regexp "$\\|" ; empty lines in quoted text
2912 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
2913 (setq paragraph-separate paragraph-start)
2914 (setq adaptive-fill-regexp
2915 (concat quote-prefix-regexp "\\|" adaptive-fill-regexp))
2916 (setq adaptive-fill-first-line-regexp
2917 (concat quote-prefix-regexp "\\|"
2918 adaptive-fill-first-line-regexp)))
2919 (make-local-variable 'auto-fill-inhibit-regexp)
2920 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
2921 (setq auto-fill-inhibit-regexp nil)
2922 (make-local-variable 'normal-auto-fill-function)
2923 (setq normal-auto-fill-function 'message-do-auto-fill)
2924 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
2925 ;; In that case, ensure that it uses the right function. The real
2926 ;; solution would be not to use `define-derived-mode', and run
2927 ;; `text-mode-hook' ourself at the end of the mode.
2928 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
2929 ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
2930 ;; now careful to run parent hooks after the body. --Stef
2931 (when auto-fill-function
2932 (setq auto-fill-function normal-auto-fill-function)))
2937 ;;; Message mode commands
2940 ;;; Movement commands
2942 (defun message-goto-to ()
2943 "Move point to the To header."
2945 (message-position-on-field "To"))
2947 (defun message-goto-from ()
2948 "Move point to the From header."
2950 (message-position-on-field "From"))
2952 (defun message-goto-subject ()
2953 "Move point to the Subject header."
2955 (message-position-on-field "Subject"))
2957 (defun message-goto-cc ()
2958 "Move point to the Cc header."
2960 (message-position-on-field "Cc" "To"))
2962 (defun message-goto-bcc ()
2963 "Move point to the Bcc header."
2965 (message-position-on-field "Bcc" "Cc" "To"))
2967 (defun message-goto-fcc ()
2968 "Move point to the Fcc header."
2970 (message-position-on-field "Fcc" "To" "Newsgroups"))
2972 (defun message-goto-reply-to ()
2973 "Move point to the Reply-To header."
2975 (message-position-on-field "Reply-To" "Subject"))
2977 (defun message-goto-newsgroups ()
2978 "Move point to the Newsgroups header."
2980 (message-position-on-field "Newsgroups"))
2982 (defun message-goto-distribution ()
2983 "Move point to the Distribution header."
2985 (message-position-on-field "Distribution"))
2987 (defun message-goto-followup-to ()
2988 "Move point to the Followup-To header."
2990 (message-position-on-field "Followup-To" "Newsgroups"))
2992 (defun message-goto-mail-followup-to ()
2993 "Move point to the Mail-Followup-To header."
2995 (message-position-on-field "Mail-Followup-To" "To"))
2997 (defun message-goto-keywords ()
2998 "Move point to the Keywords header."
3000 (message-position-on-field "Keywords" "Subject"))
3002 (defun message-goto-summary ()
3003 "Move point to the Summary header."
3005 (message-position-on-field "Summary" "Subject"))
3007 (defun message-goto-body (&optional interactivep)
3008 "Move point to the beginning of the message body."
3009 (interactive (list t))
3010 (when (and interactivep
3011 (looking-at "[ \t]*\n"))
3013 (goto-char (point-min))
3014 (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
3015 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t)))
3017 (defun message-in-body-p ()
3018 "Return t if point is in the message body."
3019 (let ((body (save-excursion (message-goto-body) (point))))
3022 (defun message-goto-eoh ()
3023 "Move point to the end of the headers."
3028 (defun message-goto-signature ()
3029 "Move point to the beginning of the message signature.
3030 If there is no signature in the article, go to the end and
3033 (goto-char (point-min))
3034 (if (re-search-forward message-signature-separator nil t)
3036 (goto-char (point-max))
3039 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc)
3040 "Insert a reasonable MFT header in a post to an unsubscribed list.
3041 When making original posts to a mailing list you are not subscribed to,
3042 you have to type in a MFT header by hand. The contents, usually, are
3043 the addresses of the list and your own address. This function inserts
3044 such a header automatically. It fetches the contents of the To: header
3045 in the current mail buffer, and appends the current `user-mail-address'.
3047 If the optional argument INCLUDE-CC is non-nil, the addresses in the
3048 Cc: header are also put into the MFT."
3053 (message-narrow-to-headers)
3054 (message-remove-header "Mail-Followup-To")
3055 (setq cc (and include-cc (message-fetch-field "Cc")))
3057 (concat (message-fetch-field "To") "," cc)
3058 (message-fetch-field "To"))))
3059 (message-goto-mail-followup-to)
3060 (insert (concat tos ", " user-mail-address))))
3064 (defun message-insert-to (&optional force)
3065 "Insert a To header that points to the author of the article being replied to.
3066 If the original author requested not to be sent mail, don't insert unless the
3067 prefix FORCE is given."
3069 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
3070 (dont (and mct (or (equal (downcase mct) "never")
3071 (equal (downcase mct) "nobody"))))
3072 (to (or (message-fetch-reply-field "mail-reply-to")
3073 (message-fetch-reply-field "reply-to")
3074 (message-fetch-reply-field "from"))))
3078 "Ignoring the user request not to have copies sent via mail"
3079 "Complying with the user request not to have copies sent via mail")))
3080 (when (and force (not to))
3081 (error "No mail address in the article"))
3082 (when (and to (or force (not dont)))
3083 (message-carefully-insert-headers (list (cons 'To to))))))
3085 (defun message-insert-wide-reply ()
3086 "Insert To and Cc headers as if you were doing a wide reply."
3088 (let ((headers (message-with-reply-buffer
3089 (message-get-reply-headers t))))
3090 (message-carefully-insert-headers headers)))
3092 (defcustom message-header-synonyms
3095 "List of lists of header synonyms.
3096 E.g., if this list contains a member list with elements `Cc' and `To',
3097 then `message-carefully-insert-headers' will not insert a `To' header
3098 when the message is already `Cc'ed to the recipient."
3100 :group 'message-headers
3101 :link '(custom-manual "(message)Message Headers")
3102 :type '(repeat sexp))
3104 (defun message-carefully-insert-headers (headers)
3105 "Insert the HEADERS, an alist, into the message buffer.
3106 Does not insert the headers when they are already present there
3107 or in the synonym headers, defined by `message-header-synonyms'."
3108 ;; FIXME: Should compare only the address and not the full name. Comparison
3109 ;; should be done case-folded (and with `string=' rather than
3111 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
3112 (dolist (header headers)
3113 (let* ((header-name (symbol-name (car header)))
3114 (new-header (cdr header))
3115 (synonyms (loop for synonym in message-header-synonyms
3116 when (memq (car header) synonym) return synonym))
3118 (loop for synonym in synonyms
3119 for old-header = (mail-fetch-field (symbol-name synonym))
3120 when (and old-header (string-match new-header old-header))
3123 (message "already have `%s' in `%s'" new-header old-header)
3124 (when (and (message-position-on-field header-name)
3125 (setq old-header (mail-fetch-field header-name))
3126 (not (string-match "\\` *\\'" old-header)))
3128 (insert new-header)))))
3130 (defun message-widen-reply ()
3131 "Widen the reply to include maximum recipients."
3134 (and message-reply-buffer
3135 (buffer-name message-reply-buffer)
3136 (with-current-buffer message-reply-buffer
3137 (message-get-reply-headers t)))))
3140 (message-narrow-to-headers)
3141 (dolist (elem follow-to)
3142 (message-remove-header (symbol-name (car elem)))
3143 (goto-char (point-min))
3144 (insert (symbol-name (car elem)) ": "
3145 (cdr elem) "\n"))))))
3147 (defun message-insert-newsgroups ()
3148 "Insert the Newsgroups header from the article being replied to."
3150 (when (and (message-position-on-field "Newsgroups")
3151 (mail-fetch-field "newsgroups")
3152 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
3154 (insert (or (message-fetch-reply-field "newsgroups") "")))
3158 ;;; Various commands
3160 (defun message-delete-not-region (beg end)
3161 "Delete everything in the body of the current message outside of the region."
3166 ;; snarf citation prefix, if appropriate
3167 (unless (eq (point) (progn (beginning-of-line) (point)))
3168 (when (looking-at message-cite-prefix-regexp)
3169 (setq citeprefix (match-string 0))))
3171 (delete-region (point) (if (not (message-goto-signature))
3177 (delete-region beg (progn (message-goto-body)
3181 (insert citeprefix))))
3182 (when (message-goto-signature)
3185 (defun message-kill-to-signature (&optional arg)
3186 "Kill all text up to the signature.
3187 If a numberic argument or prefix arg is given, leave that number
3188 of lines before the signature intact."
3192 (let ((point (point)))
3193 (narrow-to-region point (point-max))
3194 (message-goto-signature)
3196 (if (and arg (numberp arg))
3197 (forward-line (- -1 arg))
3199 (unless (= point (point))
3200 (kill-region point (point))
3204 (defun message-newline-and-reformat (&optional arg not-break)
3205 "Insert four newlines, and then reformat if inside quoted text.
3206 Prefix arg means justify as well."
3207 (interactive (list (if current-prefix-arg 'full)))
3208 (let (quoted point beg end leading-space bolp fill-paragraph-function)
3209 (setq point (point))
3212 (setq bolp (= beg point))
3213 ;; Find first line of the paragraph.
3215 (while (and (not (eobp))
3216 (not (looking-at message-cite-prefix-regexp))
3217 (looking-at paragraph-start))
3220 (when (looking-at message-cite-prefix-regexp)
3221 (setq quoted (match-string 0))
3222 (goto-char (match-end 0))
3223 (looking-at "[ \t]*")
3224 (setq leading-space (match-string 0)))
3228 (< (- point beg) (length quoted)))
3229 ;; break inside the cite prefix.
3235 (while (and (not (eobp))
3236 (not (looking-at paragraph-separate))
3237 (looking-at message-cite-prefix-regexp)
3238 (equal quoted (match-string 0)))
3239 (goto-char (match-end 0))
3240 (looking-at "[ \t]*")
3241 (if (> (length leading-space) (length (match-string 0)))
3242 (setq leading-space (match-string 0)))
3246 (while (and (if (bobp) nil (forward-line -1) t)
3247 (not (looking-at paragraph-start))
3248 (looking-at message-cite-prefix-regexp)
3249 (equal quoted (match-string 0)))
3251 (goto-char (match-end 0))
3252 (looking-at "[ \t]*")
3253 (if (> (length leading-space) (length (match-string 0)))
3254 (setq leading-space (match-string 0)))))
3255 (while (and (not (eobp))
3256 (not (looking-at paragraph-separate))
3257 (not (looking-at message-cite-prefix-regexp)))
3261 (while (and (if (bobp) nil (forward-line -1) t)
3262 (not (looking-at paragraph-start))
3263 (not (looking-at message-cite-prefix-regexp)))
3264 (setq beg (point))))
3267 (narrow-to-region beg end)
3274 (setq point (point))
3275 ;; (newline 2) doesn't mark both newline's as hard, so call
3276 ;; newline twice. -jas
3279 (delete-region (point) (re-search-forward "[ \t]*"))
3280 (when (and quoted (not bolp))
3281 (insert quoted leading-space)))
3284 (let* ((adaptive-fill-regexp
3285 (regexp-quote (concat quoted leading-space)))
3286 (adaptive-fill-first-line-regexp
3287 adaptive-fill-regexp ))
3288 (fill-paragraph arg))
3289 (fill-paragraph arg))
3290 (if point (goto-char point)))))
3292 (defun message-fill-paragraph (&optional arg)
3293 "Message specific function to fill a paragraph.
3294 This function is used as the value of `fill-paragraph-function' in
3295 Message buffers and is not meant to be called directly."
3296 (interactive (list (if current-prefix-arg 'full)))
3297 (if (if (boundp 'filladapt-mode) filladapt-mode)
3299 (if (message-point-in-header-p)
3300 (message-fill-field)
3301 (message-newline-and-reformat arg t))
3304 (defun message-point-in-header-p ()
3305 "Return t if point is in the header."
3307 (not (re-search-backward
3308 (concat "^" (regexp-quote mail-header-separator) "\n") nil t))))
3310 (defun message-do-auto-fill ()
3311 "Like `do-auto-fill', but don't fill in message header."
3312 (unless (message-point-in-header-p)
3315 (defun message-insert-signature (&optional force)
3316 "Insert a signature. See documentation for variable `message-signature'."
3317 (interactive (list 0))
3320 ((and (null message-signature)
3323 (goto-char (point-max))
3324 (not (re-search-backward message-signature-separator nil t))))
3325 ((and (null message-signature)
3328 ((functionp message-signature)
3329 (funcall message-signature))