1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 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 2, or (at your option)
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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; This mode provides mail-sending facilities from within Emacs. It
29 ;; consists mainly of large chunks of code from the sendmail.el,
30 ;; gnus-msg.el and rnewspost.el files.
36 (defvar gnus-message-group-art)
37 (defvar gnus-list-identifiers)) ; gnus-sum is required where necessary
43 ;; This is apparently necessary even though things are autoloaded.
44 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
45 ;; require mailabbrev here.
46 (if (featurep 'xemacs)
47 (require 'mail-abbrevs)
48 (require 'mailabbrev))
54 (defgroup message '((user-mail-address custom-variable)
55 (user-full-name custom-variable))
56 "Mail and news message composing."
57 :link '(custom-manual "(message)Top")
61 (put 'user-mail-address 'custom-type 'string)
62 (put 'user-full-name 'custom-type 'string)
64 (defgroup message-various nil
65 "Various Message Variables."
66 :link '(custom-manual "(message)Various Message Variables")
69 (defgroup message-buffers nil
71 :link '(custom-manual "(message)Message Buffers")
74 (defgroup message-sending nil
76 :link '(custom-manual "(message)Sending Variables")
79 (defgroup message-interface nil
81 :link '(custom-manual "(message)Interface")
84 (defgroup message-forwarding nil
86 :link '(custom-manual "(message)Forwarding")
87 :group 'message-interface)
89 (defgroup message-insertion nil
91 :link '(custom-manual "(message)Insertion")
94 (defgroup message-headers nil
96 :link '(custom-manual "(message)Message Headers")
99 (defgroup message-news nil
100 "Composing News Messages."
103 (defgroup message-mail nil
104 "Composing Mail Messages."
107 (defgroup message-faces nil
108 "Faces used for message composing."
112 (defcustom message-directory "~/Mail/"
113 "*Directory from which all other mail file variables are derived."
114 :group 'message-various
117 (defcustom message-max-buffers 10
118 "*How many buffers to keep before starting to kill them off."
119 :group 'message-buffers
122 (defcustom message-send-rename-function nil
123 "Function called to rename the buffer after sending it."
124 :group 'message-buffers
125 :type '(choice function (const nil)))
127 (defcustom message-fcc-handler-function 'message-output
128 "*A function called to save outgoing articles.
129 This function will be called with the name of the file to store the
130 article in. The default function is `message-output' which saves in Unix
132 :type '(radio (function-item message-output)
133 (function :tag "Other"))
134 :group 'message-sending)
136 (defcustom message-fcc-externalize-attachments nil
137 "If non-nil, attachments are included as external parts in Fcc copies."
140 :group 'message-sending)
142 (defcustom message-courtesy-message
143 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
144 "*This is inserted at the start of a mailed copy of a posted message.
145 If the string contains the format spec \"%s\", the Newsgroups
146 the article has been posted to will be inserted there.
147 If this variable is nil, no such courtesy message will be added."
148 :group 'message-sending
149 :type '(radio string (const nil)))
151 (defcustom message-ignored-bounced-headers
152 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
153 "*Regexp that matches headers to be removed in resent bounced mail."
154 :group 'message-interface
157 (defcustom message-from-style 'default
158 "*Specifies how \"From\" headers look.
160 If nil, they contain just the return address like:
162 If `parens', they look like:
163 king@grassland.com (Elvis Parsley)
164 If `angles', they look like:
165 Elvis Parsley <king@grassland.com>
167 Otherwise, most addresses look like `angles', but they look like
168 `parens' if `angles' would need quoting and `parens' would not."
169 :type '(choice (const :tag "simple" nil)
173 :group 'message-headers)
175 (defcustom message-insert-canlock t
176 "Whether to insert a Cancel-Lock header in news postings."
178 :group 'message-headers
181 (defcustom message-syntax-checks
182 (if message-insert-canlock '((sender . disabled)) nil)
183 ;; Guess this one shouldn't be easy to customize...
184 "*Controls what syntax checks should not be performed on outgoing posts.
185 To disable checking of long signatures, for instance, add
186 `(signature . disabled)' to this list.
188 Don't touch this variable unless you really know what you're doing.
190 Checks include `approved', `continuation-headers', `control-chars',
191 `empty', `existing-newsgroups', `from', `illegible-text',
192 `invisible-text', `long-header-lines', `long-lines', `message-id',
193 `multiple-headers', `new-text', `newsgroups', `quoting-style',
194 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
195 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
196 and `valid-newsgroups'."
198 :type '(repeat sexp)) ; Fixme: improve this
200 (defcustom message-required-headers '((optional . References)
202 "*Headers to be generated or prompted for when sending a message.
203 Also see `message-required-news-headers' and
204 `message-required-mail-headers'."
207 :group 'message-headers
208 :link '(custom-manual "(message)Message Headers")
209 :type '(repeat sexp))
211 (defcustom message-draft-headers '(References From Date)
212 "*Headers to be generated when saving a draft message."
215 :group 'message-headers
216 :link '(custom-manual "(message)Message Headers")
217 :type '(repeat sexp))
219 (defcustom message-required-news-headers
220 '(From Newsgroups Subject Date Message-ID
221 (optional . Organization)
222 (optional . User-Agent))
223 "*Headers to be generated or prompted for when posting an article.
224 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
225 Message-ID. Organization, Lines, In-Reply-To, Expires, and
226 User-Agent are optional. If don't you want message to insert some
227 header, remove it from this list."
229 :group 'message-headers
230 :link '(custom-manual "(message)Message Headers")
231 :type '(repeat sexp))
233 (defcustom message-required-mail-headers
234 '(From Subject Date (optional . In-Reply-To) Message-ID
235 (optional . User-Agent))
236 "*Headers to be generated or prompted for when mailing a message.
237 It is recommended that From, Date, To, Subject and Message-ID be
238 included. Organization and User-Agent are optional."
240 :group 'message-headers
241 :link '(custom-manual "(message)Message Headers")
242 :type '(repeat sexp))
244 (defcustom message-deletable-headers '(Message-ID Date Lines)
245 "Headers to be deleted if they already exist and were generated by message previously."
246 :group 'message-headers
247 :link '(custom-manual "(message)Message Headers")
250 (defcustom message-ignored-news-headers
251 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
252 "*Regexp of headers to be removed unconditionally before posting."
254 :group 'message-headers
255 :link '(custom-manual "(message)Message Headers")
256 :type '(repeat :value-to-internal (lambda (widget value)
257 (custom-split-regexp-maybe value))
258 :match (lambda (widget value)
260 (widget-editable-list-match widget value)))
263 (defcustom message-ignored-mail-headers
264 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
265 "*Regexp of headers to be removed unconditionally before mailing."
267 :group 'message-headers
268 :link '(custom-manual "(message)Mail Headers")
271 (defcustom message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|^X-Trace:\\|^X-Complaints-To:\\|Return-Path:\\|^Supersedes:\\|^NNTP-Posting-Date:\\|^X-Trace:\\|^X-Complaints-To:\\|^Cancel-Lock:\\|^Cancel-Key:\\|^X-Hashcash:\\|^X-Payment:\\|^Approved:"
272 "*Header lines matching this regexp will be deleted before posting.
273 It's best to delete old Path and Date headers before posting to avoid
275 :group 'message-interface
276 :link '(custom-manual "(message)Superseding")
277 :type '(repeat :value-to-internal (lambda (widget value)
278 (custom-split-regexp-maybe value))
279 :match (lambda (widget value)
281 (widget-editable-list-match widget value)))
284 (defcustom message-subject-re-regexp
285 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
286 "*Regexp matching \"Re: \" in the subject line."
287 :group 'message-various
288 :link '(custom-manual "(message)Message Headers")
291 ;;; Start of variables adopted from `message-utils.el'.
293 (defcustom message-subject-trailing-was-query 'ask
294 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
295 If nil, leave the subject unchanged. If it is the symbol `ask', query
296 the user what do do. In this case, the subject is matched against
297 `message-subject-trailing-was-ask-regexp'. If
298 `message-subject-trailing-was-query' is t, always strip the trailing
299 old subject. In this case, `message-subject-trailing-was-regexp' is
302 :type '(choice (const :tag "never" nil)
303 (const :tag "always strip" t)
305 :link '(custom-manual "(message)Message Headers")
306 :group 'message-various)
308 (defcustom message-subject-trailing-was-ask-regexp
309 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
310 "*Regexp matching \"(was: <old subject>)\" in the subject line.
312 The function `message-strip-subject-trailing-was' uses this regexp if
313 `message-subject-trailing-was-query' is set to the symbol `ask'. If
314 the variable is t instead of `ask', use
315 `message-subject-trailing-was-regexp' instead.
317 It is okay to create some false positives here, as the user is asked."
319 :group 'message-various
320 :link '(custom-manual "(message)Message Headers")
323 (defcustom message-subject-trailing-was-regexp
324 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
325 "*Regexp matching \"(was: <old subject>)\" in the subject line.
327 If `message-subject-trailing-was-query' is set to t, the subject is
328 matched against `message-subject-trailing-was-regexp' in
329 `message-strip-subject-trailing-was'. You should use a regexp creating very
330 few false positives here."
332 :group 'message-various
333 :link '(custom-manual "(message)Message Headers")
336 ;;; marking inserted text
338 (defcustom message-mark-insert-begin
339 "--8<---------------cut here---------------start------------->8---\n"
340 "How to mark the beginning of some inserted text."
343 :link '(custom-manual "(message)Insertion Variables")
344 :group 'message-various)
346 (defcustom message-mark-insert-end
347 "--8<---------------cut here---------------end--------------->8---\n"
348 "How to mark the end of some inserted text."
351 :link '(custom-manual "(message)Insertion Variables")
352 :group 'message-various)
354 (defcustom message-archive-header "X-No-Archive: Yes\n"
355 "Header to insert when you don't want your article to be archived.
356 Archives \(such as groups.google.com\) respect this header."
359 :link '(custom-manual "(message)Header Commands")
360 :group 'message-various)
362 (defcustom message-archive-note
363 "X-No-Archive: Yes - save http://groups.google.com/"
364 "Note to insert why you wouldn't want this posting archived.
365 If nil, don't insert any text in the body."
367 :type '(radio string (const nil))
368 :link '(custom-manual "(message)Header Commands")
369 :group 'message-various)
371 ;;; Crossposts and Followups
372 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
373 ;; new suggestions by R. Weikusat <rw at another.de>
375 (defvar message-cross-post-old-target nil
376 "Old target for cross-posts or follow-ups.")
377 (make-variable-buffer-local 'message-cross-post-old-target)
379 (defcustom message-cross-post-default t
380 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
381 If nil, `message-cross-post-followup-to' will only do a followup. Note that
382 you can explicitly override this setting by calling
383 `message-cross-post-followup-to' with a prefix."
386 :group 'message-various)
388 (defcustom message-cross-post-note "Crosspost & Followup-To: "
389 "Note to insert before signature to notify of cross-post and follow-up."
392 :group 'message-various)
394 (defcustom message-followup-to-note "Followup-To: "
395 "Note to insert before signature to notify of follow-up only."
398 :group 'message-various)
400 (defcustom message-cross-post-note-function 'message-cross-post-insert-note
401 "Function to use to insert note about Crosspost or Followup-To.
402 The function will be called with four arguments. The function should not only
403 insert a note, but also ensure old notes are deleted. See the documentation
404 for `message-cross-post-insert-note'."
407 :group 'message-various)
409 ;;; End of variables adopted from `message-utils.el'.
411 (defcustom message-signature-separator "^-- *$"
412 "Regexp matching the signature separator."
414 :link '(custom-manual "(message)Various Message Variables")
415 :group 'message-various)
417 (defcustom message-elide-ellipsis "\n[...]\n\n"
418 "*The string which is inserted for elided text."
420 :link '(custom-manual "(message)Various Commands")
421 :group 'message-various)
423 (defcustom message-interactive t
424 "Non-nil means when sending a message wait for and display errors.
425 nil means let mailer mail back a message to report errors."
426 :group 'message-sending
428 :link '(custom-manual "(message)Sending Variables")
431 (defcustom message-generate-new-buffers 'unique
432 "*Non-nil means create a new message buffer whenever `message-setup' is called.
433 If this is a function, call that function with three parameters: The type,
434 the to address and the group name. (Any of these may be nil.) The function
435 should return the new buffer name."
436 :group 'message-buffers
437 :link '(custom-manual "(message)Message Buffers")
438 :type '(choice (const :tag "off" nil)
439 (const :tag "unique" unique)
440 (const :tag "unsent" unsent)
443 (defcustom message-kill-buffer-on-exit nil
444 "*Non-nil means that the message buffer will be killed after sending a message."
445 :group 'message-buffers
446 :link '(custom-manual "(message)Message Buffers")
449 (defcustom message-kill-buffer-query t
450 "*Non-nil means that killing a modified message buffer has to be confirmed.
451 This is used by `message-kill-buffer'."
452 :version "23.0" ;; No Gnus
453 :group 'message-buffers
457 (defvar gnus-local-organization))
458 (defcustom message-user-organization
459 (or (and (boundp 'gnus-local-organization)
460 (stringp gnus-local-organization)
461 gnus-local-organization)
462 (getenv "ORGANIZATION")
464 "*String to be used as an Organization header.
465 If t, use `message-user-organization-file'."
466 :group 'message-headers
467 :type '(choice string
468 (const :tag "consult file" t)))
470 (defcustom message-user-organization-file
472 (dolist (f (list "/etc/organization"
473 "/etc/news/organization"
474 "/usr/lib/news/organization"))
475 (when (file-readable-p f)
478 "*Local news organization file."
480 :link '(custom-manual "(message)News Headers")
481 :group 'message-headers)
483 (defcustom message-make-forward-subject-function
484 #'message-forward-subject-name-subject
485 "*List of functions called to generate subject headers for forwarded messages.
486 The subject generated by the previous function is passed into each
489 The provided functions are:
491 * `message-forward-subject-author-subject' Source of article (author or
492 newsgroup), in brackets followed by the subject
493 * `message-forward-subject-name-subject' Source of article (name of author
494 or newsgroup), in brackets followed by the subject
495 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
497 :group 'message-forwarding
498 :link '(custom-manual "(message)Forwarding")
499 :type '(radio (function-item message-forward-subject-author-subject)
500 (function-item message-forward-subject-fwd)
501 (function-item message-forward-subject-name-subject)
502 (repeat :tag "List of functions" function)))
504 (defcustom message-forward-as-mime t
505 "*Non-nil means forward messages as an inline/rfc822 MIME section.
506 Otherwise, directly inline the old message in the forwarded message."
508 :group 'message-forwarding
509 :link '(custom-manual "(message)Forwarding")
512 (defcustom message-forward-show-mml 'best
513 "*Non-nil means show forwarded messages as MML (decoded from MIME).
514 Otherwise, forwarded messages are unchanged.
515 Can also be the symbol `best' to indicate that MML should be
516 used, except when it is a bad idea to use MML. One example where
517 it is a bad idea is when forwarding a signed or encrypted
518 message, because converting MIME to MML would invalidate the
521 :group 'message-forwarding
522 :type '(choice (const :tag "use MML" t)
523 (const :tag "don't use MML " nil)
524 (const :tag "use MML when appropriate" best)))
526 (defcustom message-forward-before-signature t
527 "*Non-nil means put forwarded message before signature, else after."
528 :group 'message-forwarding
531 (defcustom message-wash-forwarded-subjects nil
532 "*Non-nil means try to remove as much cruft as possible from the subject.
533 Done before generating the new subject of a forward."
534 :group 'message-forwarding
535 :link '(custom-manual "(message)Forwarding")
538 (defcustom message-ignored-resent-headers "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From "
539 "*All headers that match this regexp will be deleted when resending a message."
540 :group 'message-interface
541 :link '(custom-manual "(message)Resending")
542 :type '(repeat :value-to-internal (lambda (widget value)
543 (custom-split-regexp-maybe value))
544 :match (lambda (widget value)
546 (widget-editable-list-match widget value)))
549 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
550 "*All headers that match this regexp will be deleted when forwarding a message."
552 :group 'message-forwarding
553 :type '(repeat :value-to-internal (lambda (widget value)
554 (custom-split-regexp-maybe value))
555 :match (lambda (widget value)
557 (widget-editable-list-match widget value)))
560 (defcustom message-ignored-cited-headers "."
561 "*Delete these headers from the messages you yank."
562 :group 'message-insertion
563 :link '(custom-manual "(message)Insertion Variables")
566 (defcustom message-cite-prefix-regexp
567 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
568 "\\([ \t]*[-_.[:word:]]+>+\\|[ \t]*[]>|}+]\\)+"
569 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
570 (let (non-word-constituents)
571 (with-syntax-table text-mode-syntax-table
572 (setq non-word-constituents
574 (if (string-match "\\w" "-") "" "-")
575 (if (string-match "\\w" "_") "" "_")
576 (if (string-match "\\w" ".") "" "."))))
577 (if (equal non-word-constituents "")
578 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}+]\\)+"
579 (concat "\\([ \t]*\\(\\w\\|["
580 non-word-constituents
581 "]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
582 "*Regexp matching the longest possible citation prefix on a line."
584 :group 'message-insertion
585 :link '(custom-manual "(message)Insertion Variables")
588 (defcustom message-cancel-message "I am canceling my own article.\n"
589 "Message to be inserted in the cancel message."
590 :group 'message-interface
591 :link '(custom-manual "(message)Canceling News")
594 ;; Useful to set in site-init.el
595 (defcustom message-send-mail-function
596 (let ((program (if (boundp 'sendmail-program)
601 (string-match "/" program) ;; Skip path
602 (file-executable-p program))
603 'message-send-mail-with-sendmail)
605 (executable-find program))
606 'message-send-mail-with-sendmail)
609 "Function to call to send the current buffer as mail.
610 The headers should be delimited by a line whose contents match the
611 variable `mail-header-separator'.
613 Valid values include `message-send-mail-with-sendmail' (the default),
614 `message-send-mail-with-mh', `message-send-mail-with-qmail',
615 `message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
617 See also `send-mail-function'."
618 :type '(radio (function-item message-send-mail-with-sendmail)
619 (function-item message-send-mail-with-mh)
620 (function-item message-send-mail-with-qmail)
621 (function-item message-smtpmail-send-it)
622 (function-item smtpmail-send-it)
623 (function-item feedmail-send-it)
624 (function :tag "Other"))
625 :group 'message-sending
626 :link '(custom-manual "(message)Mail Variables")
627 :group 'message-mail)
629 (defcustom message-send-news-function 'message-send-news
630 "Function to call to send the current buffer as news.
631 The headers should be delimited by a line whose contents match the
632 variable `mail-header-separator'."
633 :group 'message-sending
635 :link '(custom-manual "(message)News Variables")
638 (defcustom message-reply-to-function nil
639 "If non-nil, function that should return a list of headers.
640 This function should pick out addresses from the To, Cc, and From headers
641 and respond with new To and Cc headers."
642 :group 'message-interface
643 :link '(custom-manual "(message)Reply")
644 :type '(choice function (const nil)))
646 (defcustom message-wide-reply-to-function nil
647 "If non-nil, function that should return a list of headers.
648 This function should pick out addresses from the To, Cc, and From headers
649 and respond with new To and Cc headers."
650 :group 'message-interface
651 :link '(custom-manual "(message)Wide Reply")
652 :type '(choice function (const nil)))
654 (defcustom message-followup-to-function nil
655 "If non-nil, function that should return a list of headers.
656 This function should pick out addresses from the To, Cc, and From headers
657 and respond with new To and Cc headers."
658 :group 'message-interface
659 :link '(custom-manual "(message)Followup")
660 :type '(choice function (const nil)))
662 (defcustom message-extra-wide-headers nil
663 "If non-nil, a list of additional address headers.
664 These are used when composing a wide reply."
665 :group 'message-sending
666 :type '(repeat string))
668 (defcustom message-use-followup-to 'ask
669 "*Specifies what to do with Followup-To header.
670 If nil, always ignore the header. If it is t, use its value, but
671 query before using the \"poster\" value. If it is the symbol `ask',
672 always query the user whether to use the value. If it is the symbol
673 `use', always use the value."
674 :group 'message-interface
675 :link '(custom-manual "(message)Followup")
676 :type '(choice (const :tag "ignore" nil)
677 (const :tag "use & query" t)
681 (defcustom message-use-mail-followup-to 'use
682 "*Specifies what to do with Mail-Followup-To header.
683 If nil, always ignore the header. If it is the symbol `ask', always
684 query the user whether to use the value. If it is the symbol `use',
685 always use the value."
687 :group 'message-interface
688 :link '(custom-manual "(message)Mailing Lists")
689 :type '(choice (const :tag "ignore" nil)
693 (defcustom message-subscribed-address-functions nil
694 "*Specifies functions for determining list subscription.
695 If nil, do not attempt to determine list subscription with functions.
696 If non-nil, this variable contains a list of functions which return
697 regular expressions to match lists. These functions can be used in
698 conjunction with `message-subscribed-regexps' and
699 `message-subscribed-addresses'."
701 :group 'message-interface
702 :link '(custom-manual "(message)Mailing Lists")
703 :type '(repeat sexp))
705 (defcustom message-subscribed-address-file nil
706 "*A file containing addresses the user is subscribed to.
707 If nil, do not look at any files to determine list subscriptions. If
708 non-nil, each line of this file should be a mailing list address."
710 :group 'message-interface
711 :link '(custom-manual "(message)Mailing Lists")
712 :type '(radio file (const nil)))
714 (defcustom message-subscribed-addresses nil
715 "*Specifies a list of addresses the user is subscribed to.
716 If nil, do not use any predefined list subscriptions. This list of
717 addresses can be used in conjunction with
718 `message-subscribed-address-functions' and `message-subscribed-regexps'."
720 :group 'message-interface
721 :link '(custom-manual "(message)Mailing Lists")
722 :type '(repeat string))
724 (defcustom message-subscribed-regexps nil
725 "*Specifies a list of addresses the user is subscribed to.
726 If nil, do not use any predefined list subscriptions. This list of
727 regular expressions can be used in conjunction with
728 `message-subscribed-address-functions' and `message-subscribed-addresses'."
730 :group 'message-interface
731 :link '(custom-manual "(message)Mailing Lists")
732 :type '(repeat regexp))
734 (defcustom message-allow-no-recipients 'ask
735 "Specifies what to do when there are no recipients other than Gcc/Fcc.
736 If it is the symbol `always', the posting is allowed. If it is the
737 symbol `never', the posting is not allowed. If it is the symbol
738 `ask', you are prompted."
740 :group 'message-interface
741 :link '(custom-manual "(message)Message Headers")
742 :type '(choice (const always)
746 (defcustom message-sendmail-f-is-evil nil
747 "*Non-nil means don't add \"-f username\" to the sendmail command line.
748 Doing so would be even more evil than leaving it out."
749 :group 'message-sending
750 :link '(custom-manual "(message)Mail Variables")
753 (defcustom message-sendmail-envelope-from nil
754 "*Envelope-from when sending mail with sendmail.
755 If this is nil, use `user-mail-address'. If it is the symbol
756 `header', use the From: header of the message."
758 :type '(choice (string :tag "From name")
759 (const :tag "Use From: header from message" header)
760 (const :tag "Use `user-mail-address'" nil))
761 :link '(custom-manual "(message)Mail Variables")
762 :group 'message-sending)
764 ;; qmail-related stuff
765 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
766 "Location of the qmail-inject program."
767 :group 'message-sending
768 :link '(custom-manual "(message)Mail Variables")
771 (defcustom message-qmail-inject-args nil
772 "Arguments passed to qmail-inject programs.
773 This should be a list of strings, one string for each argument. It
774 may also be a function.
776 For e.g., if you wish to set the envelope sender address so that bounces
777 go to the right place or to deal with listserv's usage of that address, you
778 might set this variable to '(\"-f\" \"you@some.where\")."
779 :group 'message-sending
780 :link '(custom-manual "(message)Mail Variables")
781 :type '(choice (function)
785 (defvar gnus-post-method)
786 (defvar gnus-select-method))
787 (defcustom message-post-method
788 (cond ((and (boundp 'gnus-post-method)
789 (listp gnus-post-method)
792 ((boundp 'gnus-select-method)
795 "*Method used to post news.
796 Note that when posting from inside Gnus, for instance, this
797 variable isn't used."
799 :group 'message-sending
800 ;; This should be the `gnus-select-method' widget, but that might
801 ;; create a dependence to `gnus.el'.
804 ;; FIXME: This should be a temporary workaround until someone implements a
805 ;; proper solution. If a crash happens while replying, the auto-save file
806 ;; will *not* have a `References:' header if `message-generate-headers-first'
807 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
808 (defcustom message-generate-headers-first '(references)
809 "Which headers should be generated before starting to compose a message.
810 If t, generate all required headers. This can also be a list of headers to
811 generate. The variables `message-required-news-headers' and
812 `message-required-mail-headers' specify which headers to generate.
814 Note that the variable `message-deletable-headers' specifies headers which
815 are to be deleted and then re-generated before sending, so this variable
816 will not have a visible effect for those headers."
817 :group 'message-headers
818 :link '(custom-manual "(message)Message Headers")
819 :type '(choice (const :tag "None" nil)
820 (const :tag "References" '(references))
822 (repeat (sexp :tag "Header"))))
824 (defcustom message-setup-hook nil
825 "Normal hook, run each time a new outgoing message is initialized.
826 The function `message-setup' runs this hook."
827 :group 'message-various
828 :link '(custom-manual "(message)Various Message Variables")
831 (defcustom message-cancel-hook nil
832 "Hook run when cancelling articles."
833 :group 'message-various
834 :link '(custom-manual "(message)Various Message Variables")
837 (defcustom message-signature-setup-hook nil
838 "Normal hook, run each time a new outgoing message is initialized.
839 It is run after the headers have been inserted and before
840 the signature is inserted."
841 :group 'message-various
842 :link '(custom-manual "(message)Various Message Variables")
845 (defcustom message-mode-hook nil
846 "Hook run in message mode buffers."
847 :group 'message-various
850 (defcustom message-header-hook nil
851 "Hook run in a message mode buffer narrowed to the headers."
852 :group 'message-various
855 (defcustom message-header-setup-hook nil
856 "Hook called narrowed to the headers when setting up a message buffer."
857 :group 'message-various
858 :link '(custom-manual "(message)Various Message Variables")
861 (defcustom message-minibuffer-local-map
862 (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
863 (set-keymap-parent map minibuffer-local-map)
865 "Keymap for `message-read-from-minibuffer'."
867 :group 'message-various)
869 (defcustom message-citation-line-function 'message-insert-citation-line
870 "*Function called to insert the \"Whomever writes:\" line.
872 Predefined functions include `message-insert-citation-line' and
873 `message-insert-formated-citation-line' (see the variable
874 `message-citation-line-format').
876 Note that Gnus provides a feature where the reader can click on
877 `writes:' to hide the cited text. If you change this line too much,
878 people who read your message will have to change their Gnus
879 configuration. See the variable `gnus-cite-attribution-suffix'."
881 (function-item :tag "plain" message-insert-citation-line)
882 (function-item :tag "formatted" message-insert-formated-citation-line)
883 (function :tag "Other"))
884 :link '(custom-manual "(message)Insertion Variables")
885 :group 'message-insertion)
887 (defcustom message-citation-line-format "On %a, %b %d %Y, %n wrote:"
888 "Format of the \"Whomever writes:\" line.
890 The string is formatted using `format-spec'. The following
891 constructs are replaced:
893 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
894 %n The mail address, e.g. \"john.doe@example.invalid\".
895 %N The real name if present, e.g.: \"John Doe\", else fall
896 back to the mail address.
897 %F The first name if present, e.g.: \"John\".
898 %L The last name if present, e.g.: \"Doe\".
900 All other format specifiers are passed to `format-time-string'
901 which is called using the date from the article your replying to.
902 Extracting the first (%F) and last name (%L) is done
903 heuristically, so you should always check it yourself.
905 Please also read the note in the documentation of
906 `message-citation-line-function'."
907 :type '(choice (const :tag "Plain" "%f writes:")
908 (const :tag "Include date" "On %a, %b %d %Y, %n wrote:")
910 :link '(custom-manual "(message)Insertion Variables")
911 :version "23.0" ;; No Gnus
912 :group 'message-insertion)
914 (defcustom message-yank-prefix "> "
915 "*Prefix inserted on the lines of yanked messages.
916 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
917 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
919 :link '(custom-manual "(message)Insertion Variables")
920 :group 'message-insertion)
922 (defcustom message-yank-cited-prefix ">"
923 "*Prefix inserted on cited lines of yanked messages.
924 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
925 See also `message-yank-prefix' and `message-yank-empty-prefix'."
928 :link '(custom-manual "(message)Insertion Variables")
929 :group 'message-insertion)
931 (defcustom message-yank-empty-prefix ">"
932 "*Prefix inserted on empty lines of yanked messages.
933 See also `message-yank-prefix' and `message-yank-cited-prefix'."
936 :link '(custom-manual "(message)Insertion Variables")
937 :group 'message-insertion)
939 (defcustom message-indentation-spaces 3
940 "*Number of spaces to insert at the beginning of each cited line.
941 Used by `message-yank-original' via `message-yank-cite'."
942 :group 'message-insertion
943 :link '(custom-manual "(message)Insertion Variables")
946 (defcustom message-cite-function 'message-cite-original
947 "*Function for citing an original message.
948 Predefined functions include `message-cite-original' and
949 `message-cite-original-without-signature'.
950 Note that these functions use `mail-citation-hook' if that is non-nil."
951 :type '(radio (function-item message-cite-original)
952 (function-item message-cite-original-without-signature)
953 (function-item sc-cite-original)
954 (function :tag "Other"))
955 :link '(custom-manual "(message)Insertion Variables")
956 :group 'message-insertion)
958 (defcustom message-indent-citation-function 'message-indent-citation
959 "*Function for modifying a citation just inserted in the mail buffer.
960 This can also be a list of functions. Each function can find the
961 citation between (point) and (mark t). And each function should leave
962 point and mark around the citation text as modified."
964 :link '(custom-manual "(message)Insertion Variables")
965 :group 'message-insertion)
967 (defcustom message-signature t
968 "*String to be inserted at the end of the message buffer.
969 If t, the `message-signature-file' file will be inserted instead.
970 If a function, the result from the function will be used instead.
971 If a form, the result from the form will be used instead."
973 :link '(custom-manual "(message)Insertion Variables")
974 :group 'message-insertion)
976 (defcustom message-signature-file "~/.signature"
977 "*Name of file containing the text inserted at end of message buffer.
978 Ignored if the named file doesn't exist.
979 If nil, don't insert a signature."
980 :type '(choice file (const :tags "None" nil))
981 :link '(custom-manual "(message)Insertion Variables")
982 :group 'message-insertion)
984 (defcustom message-signature-insert-empty-line t
985 "*If non-nil, insert an empty line before the signature separator."
988 :link '(custom-manual "(message)Insertion Variables")
989 :group 'message-insertion)
991 (defcustom message-distribution-function nil
992 "*Function called to return a Distribution header."
994 :group 'message-headers
995 :link '(custom-manual "(message)News Headers")
996 :type '(choice function (const nil)))
998 (defcustom message-expires 14
999 "Number of days before your article expires."
1000 :group 'message-news
1001 :group 'message-headers
1002 :link '(custom-manual "(message)News Headers")
1005 (defcustom message-user-path nil
1006 "If nil, use the NNTP server name in the Path header.
1007 If stringp, use this; if non-nil, use no host name (user name only)."
1008 :group 'message-news
1009 :group 'message-headers
1010 :link '(custom-manual "(message)News Headers")
1011 :type '(choice (const :tag "nntp" nil)
1012 (string :tag "name")
1013 (sexp :tag "none" :format "%t" t)))
1015 (defvar message-reply-buffer nil)
1016 (defvar message-reply-headers nil
1017 "The headers of the current replied article.
1018 It is a vector of the following headers:
1019 \[number subject from date id references chars lines xref extra].")
1020 (defvar message-newsreader nil)
1021 (defvar message-mailer nil)
1022 (defvar message-sent-message-via nil)
1023 (defvar message-checksum nil)
1024 (defvar message-send-actions nil
1025 "A list of actions to be performed upon successful sending of a message.")
1026 (defvar message-exit-actions nil
1027 "A list of actions to be performed upon exiting after sending a message.")
1028 (defvar message-kill-actions nil
1029 "A list of actions to be performed before killing a message buffer.")
1030 (defvar message-postpone-actions nil
1031 "A list of actions to be performed after postponing a message.")
1033 (define-widget 'message-header-lines 'text
1034 "All header lines must be LFD terminated."
1035 :format "%{%t%}:%n%v"
1036 :valid-regexp "^\\'"
1037 :error "All header lines must be newline terminated")
1039 (defcustom message-default-headers ""
1040 "*A string containing header lines to be inserted in outgoing messages.
1041 It is inserted before you edit the message, so you can edit or delete
1043 :group 'message-headers
1044 :link '(custom-manual "(message)Message Headers")
1045 :type 'message-header-lines)
1047 (defcustom message-default-mail-headers ""
1048 "*A string of header lines to be inserted in outgoing mails."
1049 :group 'message-headers
1050 :group 'message-mail
1051 :link '(custom-manual "(message)Mail Headers")
1052 :type 'message-header-lines)
1054 (defcustom message-default-news-headers ""
1055 "*A string of header lines to be inserted in outgoing news articles."
1056 :group 'message-headers
1057 :group 'message-news
1058 :link '(custom-manual "(message)News Headers")
1059 :type 'message-header-lines)
1061 ;; Note: could use /usr/ucb/mail instead of sendmail;
1062 ;; options -t, and -v if not interactive.
1063 (defcustom message-mailer-swallows-blank-line
1064 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1065 system-configuration)
1066 (file-readable-p "/etc/sendmail.cf")
1067 (let ((buffer (get-buffer-create " *temp*")))
1071 (insert-file-contents "/etc/sendmail.cf")
1072 (goto-char (point-min))
1073 (let ((case-fold-search nil))
1074 (re-search-forward "^OR\\>" nil t)))
1075 (kill-buffer buffer))))
1076 ;; According to RFC822, "The field-name must be composed of printable
1077 ;; ASCII characters (i. e., characters that have decimal values between
1078 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1080 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1081 "*Set this non-nil if the system's mailer runs the header and body together.
1082 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1083 The value should be an expression to test whether the problem will
1085 :group 'message-sending
1086 :link '(custom-manual "(message)Mail Variables")
1090 (define-mail-user-agent 'message-user-agent
1091 'message-mail 'message-send-and-exit
1092 'message-kill-buffer 'message-send-hook)
1094 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1095 "If non-nil, delete the deletable headers before feeding to mh.")
1097 (defvar message-send-method-alist
1098 '((news message-news-p message-send-via-news)
1099 (mail message-mail-p message-send-via-mail))
1100 "Alist of ways to send outgoing messages.
1101 Each element has the form
1103 \(TYPE PREDICATE FUNCTION)
1105 where TYPE is a symbol that names the method; PREDICATE is a function
1106 called without any parameters to determine whether the message is
1107 a message of type TYPE; and FUNCTION is a function to be called if
1108 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1111 (defcustom message-mail-alias-type 'abbrev
1112 "*What alias expansion type to use in Message buffers.
1113 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1114 an electric completion mode. nil switches mail aliases off.
1115 This can also be a list of values."
1117 :link '(custom-manual "(message)Mail Aliases")
1118 :type '(choice (const :tag "Use Mailabbrev" abbrev)
1119 (const :tag "Use ecomplete" ecomplete)
1120 (const :tag "No expansion" nil)))
1122 (defcustom message-self-insert-commands '(self-insert-command)
1123 "List of `self-insert-command's used to trigger ecomplete.
1124 When one of those commands is invoked to enter a character in To or Cc
1125 header, ecomplete will suggest the candidates of recipients (see also
1126 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1127 text and it replaces `self-insert-command' with the other command, e.g.
1128 `egg-self-insert-command', you may want to add it to this list."
1129 :group 'message-various
1130 :type '(repeat function))
1132 (defcustom message-auto-save-directory
1133 (file-name-as-directory (nnheader-concat message-directory "drafts"))
1134 "*Directory where Message auto-saves buffers if Gnus isn't running.
1135 If nil, Message won't auto-save."
1136 :group 'message-buffers
1137 :link '(custom-manual "(message)Various Message Variables")
1138 :type '(choice directory (const :tag "Don't auto-save" nil)))
1140 (defcustom message-default-charset
1141 (and (not (mm-multibyte-p)) 'iso-8859-1)
1142 "Default charset used in non-MULE Emacsen.
1143 If nil, you might be asked to input the charset."
1146 :link '(custom-manual "(message)Various Message Variables")
1149 (defcustom message-dont-reply-to-names
1150 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1151 "*Addresses to prune when doing wide replies.
1152 This can be a regexp or a list of regexps. Also, a value of nil means
1153 exclude your own user name only."
1156 :link '(custom-manual "(message)Wide Reply")
1157 :type '(choice (const :tag "Yourself" nil)
1159 (repeat :tag "Regexp List" regexp)))
1161 ;; #### FIXME: this might become a generally usefull function at some point
1163 (defsubst message-dont-reply-to-names ()
1164 "Potentially convert a list of regexps into a single one."
1165 (cond ((null message-dont-reply-to-names)
1167 ((stringp message-dont-reply-to-names)
1168 message-dont-reply-to-names)
1169 ((listp message-dont-reply-to-names)
1170 (mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
1171 message-dont-reply-to-names
1174 (defvar message-shoot-gnksa-feet nil
1175 "*A list of GNKSA feet you are allowed to shoot.
1176 Gnus gives you all the opportunity you could possibly want for
1177 shooting yourself in the foot. Also, Gnus allows you to shoot the
1178 feet of Good Net-Keeping Seal of Approval. The following are foot
1180 `empty-article' Allow you to post an empty article;
1181 `quoted-text-only' Allow you to post quoted text only;
1182 `multiple-copies' Allow you to post multiple copies;
1183 `cancel-messages' Allow you to cancel or supersede messages from
1184 your other email addresses.")
1186 (defsubst message-gnksa-enable-p (feature)
1187 (or (not (listp message-shoot-gnksa-feet))
1188 (memq feature message-shoot-gnksa-feet)))
1190 (defcustom message-hidden-headers '("^References:" "^Face:" "^X-Face:"
1192 "Regexp of headers to be hidden when composing new messages.
1193 This can also be a list of regexps to match headers. Or a list
1194 starting with `not' and followed by regexps."
1197 :link '(custom-manual "(message)Message Headers")
1199 :format "%{%t%}: %[Value Type%] %v"
1200 (regexp :menu-tag "regexp" :format "regexp\n%t: %v")
1201 (repeat :menu-tag "(regexp ...)" :format "(regexp ...)\n%v%i"
1202 (regexp :format "%t: %v"))
1203 (cons :menu-tag "(not regexp ...)" :format "(not regexp ...)\n%v"
1205 (repeat :format "%v%i"
1206 (regexp :format "%t: %v")))))
1208 (defcustom message-cite-articles-with-x-no-archive t
1209 "If non-nil, cite text from articles that has X-No-Archive set."
1213 ;;; Internal variables.
1214 ;;; Well, not really internal.
1216 (defvar message-mode-syntax-table
1217 (let ((table (copy-syntax-table text-mode-syntax-table)))
1218 (modify-syntax-entry ?% ". " table)
1219 (modify-syntax-entry ?> ". " table)
1220 (modify-syntax-entry ?< ". " table)
1222 "Syntax table used while in Message mode.")
1224 (defface message-header-to
1227 (:foreground "green2" :bold t))
1230 (:foreground "MidnightBlue" :bold t))
1232 (:bold t :italic t)))
1233 "Face used for displaying From headers."
1234 :group 'message-faces)
1235 ;; backward-compatibility alias
1236 (put 'message-header-to-face 'face-alias 'message-header-to)
1238 (defface message-header-cc
1241 (:foreground "green4" :bold t))
1244 (:foreground "MidnightBlue"))
1247 "Face used for displaying Cc headers."
1248 :group 'message-faces)
1249 ;; backward-compatibility alias
1250 (put 'message-header-cc-face 'face-alias 'message-header-cc)
1252 (defface message-header-subject
1255 (:foreground "green3"))
1258 (:foreground "navy blue" :bold t))
1261 "Face used for displaying subject headers."
1262 :group 'message-faces)
1263 ;; backward-compatibility alias
1264 (put 'message-header-subject-face 'face-alias 'message-header-subject)
1266 (defface message-header-newsgroups
1269 (:foreground "yellow" :bold t :italic t))
1272 (:foreground "blue4" :bold t :italic t))
1274 (:bold t :italic t)))
1275 "Face used for displaying newsgroups headers."
1276 :group 'message-faces)
1277 ;; backward-compatibility alias
1278 (put 'message-header-newsgroups-face 'face-alias 'message-header-newsgroups)
1280 (defface message-header-other
1283 (:foreground "#b00000"))
1286 (:foreground "steel blue"))
1288 (:bold t :italic t)))
1289 "Face used for displaying newsgroups headers."
1290 :group 'message-faces)
1291 ;; backward-compatibility alias
1292 (put 'message-header-other-face 'face-alias 'message-header-other)
1294 (defface message-header-name
1297 (:foreground "DarkGreen"))
1300 (:foreground "cornflower blue"))
1303 "Face used for displaying header names."
1304 :group 'message-faces)
1305 ;; backward-compatibility alias
1306 (put 'message-header-name-face 'face-alias 'message-header-name)
1308 (defface message-header-xheader
1311 (:foreground "blue"))
1314 (:foreground "blue"))
1317 "Face used for displaying X-Header headers."
1318 :group 'message-faces)
1319 ;; backward-compatibility alias
1320 (put 'message-header-xheader-face 'face-alias 'message-header-xheader)
1322 (defface message-separator
1325 (:foreground "blue3"))
1328 (:foreground "brown"))
1331 "Face used for displaying the separator."
1332 :group 'message-faces)
1333 ;; backward-compatibility alias
1334 (put 'message-separator-face 'face-alias 'message-separator)
1336 (defface message-cited-text
1339 (:foreground "red"))
1342 (:foreground "red"))
1345 "Face used for displaying cited text names."
1346 :group 'message-faces)
1347 ;; backward-compatibility alias
1348 (put 'message-cited-text-face 'face-alias 'message-cited-text)
1350 (defface message-mml
1353 (:foreground "ForestGreen"))
1356 (:foreground "ForestGreen"))
1359 "Face used for displaying MML."
1360 :group 'message-faces)
1361 ;; backward-compatibility alias
1362 (put 'message-mml-face 'face-alias 'message-mml)
1364 (defun message-font-lock-make-header-matcher (regexp)
1367 (let ((start (point)))
1370 (goto-char (point-min))
1371 (if (re-search-forward
1372 (concat "^" (regexp-quote mail-header-separator) "$")
1374 (setq limit (min limit (match-beginning 0))))
1376 (and (< start limit)
1377 (re-search-forward ,regexp limit t))))))
1378 (if (featurep 'bytecomp)
1382 (defvar message-font-lock-keywords
1383 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1384 `((,(message-font-lock-make-header-matcher
1385 (concat "^\\([Tt]o:\\)" content))
1386 (1 'message-header-name)
1387 (2 'message-header-to nil t))
1388 (,(message-font-lock-make-header-matcher
1389 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1390 (1 'message-header-name)
1391 (2 'message-header-cc nil t))
1392 (,(message-font-lock-make-header-matcher
1393 (concat "^\\([Ss]ubject:\\)" content))
1394 (1 'message-header-name)
1395 (2 'message-header-subject nil t))
1396 (,(message-font-lock-make-header-matcher
1397 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content))
1398 (1 'message-header-name)
1399 (2 'message-header-newsgroups nil t))
1400 (,(message-font-lock-make-header-matcher
1401 (concat "^\\([A-Z][^: \n\t]+:\\)" content))
1402 (1 'message-header-name)
1403 (2 'message-header-other nil t))
1404 (,(message-font-lock-make-header-matcher
1405 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content))
1406 (1 'message-header-name)
1407 (2 'message-header-name))
1408 ,@(if (and mail-header-separator
1409 (not (equal mail-header-separator "")))
1410 `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
1411 1 'message-separator))
1414 (re-search-forward (concat "^\\("
1415 message-cite-prefix-regexp
1418 (0 'message-cited-text))
1419 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1421 "Additional expressions to highlight in Message mode.")
1424 ;; XEmacs does it like this. For Emacs, we have to set the
1425 ;; `font-lock-defaults' buffer-local variable.
1426 (put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
1428 (defvar message-face-alist
1429 '((bold . message-bold-region)
1430 (underline . underline-region)
1431 (default . (lambda (b e)
1432 (message-unbold-region b e)
1433 (ununderline-region b e))))
1434 "Alist of mail and news faces for facemenu.
1435 The cdr of each entry is a function for applying the face to a region.")
1437 (defcustom message-send-hook nil
1438 "Hook run before sending messages.
1439 This hook is run quite early when sending."
1440 :group 'message-various
1441 :options '(ispell-message)
1442 :link '(custom-manual "(message)Various Message Variables")
1445 (defcustom message-send-mail-hook nil
1446 "Hook run before sending mail messages.
1447 This hook is run very late -- just before the message is sent as
1449 :group 'message-various
1450 :link '(custom-manual "(message)Various Message Variables")
1453 (defcustom message-send-news-hook nil
1454 "Hook run before sending news messages.
1455 This hook is run very late -- just before the message is sent as
1457 :group 'message-various
1458 :link '(custom-manual "(message)Various Message Variables")
1461 (defcustom message-sent-hook nil
1462 "Hook run after sending messages."
1463 :group 'message-various
1466 (defvar message-send-coding-system 'binary
1467 "Coding system to encode outgoing mail.")
1469 (defvar message-draft-coding-system
1470 mm-auto-save-coding-system
1471 "*Coding system to compose mail.
1472 If you'd like to make it possible to share draft files between XEmacs
1473 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1474 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1476 (defcustom message-send-mail-partially-limit 1000000
1477 "The limitation of messages sent as message/partial.
1478 The lower bound of message size in characters, beyond which the message
1479 should be sent in several parts. If it is nil, the size is unlimited."
1481 :group 'message-buffers
1482 :link '(custom-manual "(message)Mail Variables")
1483 :type '(choice (const :tag "unlimited" nil)
1486 (defcustom message-alternative-emails nil
1487 "*Regexp matching alternative email addresses.
1488 The first address in the To, Cc or From headers of the original
1489 article matching this variable is used as the From field of
1492 This variable has precedence over posting styles and anything that runs
1493 off `message-setup-hook'."
1494 :group 'message-headers
1495 :link '(custom-manual "(message)Message Headers")
1496 :type '(choice (const :tag "Always use primary" nil)
1499 (defcustom message-hierarchical-addresses nil
1500 "A list of hierarchical mail address definitions.
1502 Inside each entry, the first address is the \"top\" address, and
1503 subsequent addresses are subaddresses; this is used to indicate that
1504 mail sent to the first address will automatically be delivered to the
1505 subaddresses. So if the first address appears in the recipient list
1506 for a message, the subaddresses will be removed (if present) before
1507 the mail is sent. All addresses in this structure should be
1510 :group 'message-headers
1511 :type '(repeat (repeat string)))
1513 (defcustom message-mail-user-agent nil
1514 "Like `mail-user-agent'.
1515 Except if it is nil, use Gnus native MUA; if it is t, use
1518 :type '(radio (const :tag "Gnus native"
1521 (const :tag "`mail-user-agent'"
1524 (function-item :tag "Default Emacs mail"
1526 sendmail-user-agent)
1527 (function-item :tag "Emacs interface to MH"
1530 (function :tag "Other"))
1534 (defcustom message-wide-reply-confirm-recipients nil
1535 "Whether to confirm a wide reply to multiple email recipients.
1536 If this variable is nil, don't ask whether to reply to all recipients.
1537 If this variable is non-nil, pose the question \"Reply to all
1538 recipients?\" before a wide reply to multiple recipients. If the user
1539 answers yes, reply to all recipients as usual. If the user answers
1540 no, only reply back to the author."
1542 :group 'message-headers
1543 :link '(custom-manual "(message)Wide Reply")
1546 (defcustom message-user-fqdn nil
1547 "*Domain part of Message-Ids."
1549 :group 'message-headers
1550 :link '(custom-manual "(message)News Headers")
1551 :type '(radio (const :format "%v " nil)
1552 (string :format "FQDN: %v")))
1554 (defcustom message-use-idna (and (condition-case nil (require 'idna)
1556 (mm-coding-system-p 'utf-8)
1557 (executable-find idna-program)
1558 (string= (idna-to-ascii "räksmörgås")
1559 "xn--rksmrgs-5wao1o")
1561 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1562 GNU Libidn, and in particular the elisp package \"idna.el\" and
1563 the external program \"idn\", must be installed for this
1564 functionality to work."
1566 :group 'message-headers
1567 :link '(custom-manual "(message)IDNA")
1568 :type '(choice (const :tag "Ask" ask)
1569 (const :tag "Never" nil)
1570 (const :tag "Always" t)))
1572 (defcustom message-generate-hashcash (if (executable-find "hashcash") t)
1573 "*Whether to generate X-Hashcash: headers.
1574 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1575 :group 'message-headers
1576 :link '(custom-manual "(message)Mail Headers")
1579 ;;; Internal variables.
1581 (defvar message-sending-message "Sending...")
1582 (defvar message-buffer-list nil)
1583 (defvar message-this-is-news nil)
1584 (defvar message-this-is-mail nil)
1585 (defvar message-draft-article nil)
1586 (defvar message-mime-part nil)
1587 (defvar message-posting-charset nil)
1588 (defvar message-inserted-headers nil)
1590 ;; Byte-compiler warning
1592 (defvar gnus-active-hashtb)
1593 (defvar gnus-read-active-file))
1595 ;;; Regexp matching the delimiter of messages in UNIX mail format
1596 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1597 ;;; of rmail.el's rmail-unix-mail-delimiter.
1598 (defvar message-unix-mail-delimiter
1599 (let ((time-zone-regexp
1600 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1601 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1607 ;; Many things can happen to an RFC 822 mailbox before it is put into
1608 ;; a `From' line. The leading phrase can be stripped, e.g.
1609 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1610 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1611 ;; can be removed, e.g.
1612 ;; From: joe@y.z (Joe K
1614 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1617 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1618 ;; The mailbox can be removed or be replaced by white space, e.g.
1619 ;; From: "Joe User"{space}{tab}
1621 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1622 ;; where {space} and {tab} represent the Ascii space and tab characters.
1623 ;; We want to match the results of any of these manglings.
1624 ;; The following regexp rejects names whose first characters are
1625 ;; obviously bogus, but after that anything goes.
1626 "\\([^\0-\b\n-\r\^?].*\\)?"
1628 ;; The time the message was sent.
1629 "\\([^\0-\r \^?]+\\) +" ; day of the week
1630 "\\([^\0-\r \^?]+\\) +" ; month
1631 "\\([0-3]?[0-9]\\) +" ; day of month
1632 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1634 ;; Perhaps a time zone, specified by an abbreviation, or by a
1639 " \\([0-9][0-9]+\\) *"
1641 ;; On some systems the time zone can appear after the year, too.
1645 "\\(remote from .*\\)?"
1648 "Regexp matching the delimiter of messages in UNIX mail format.")
1650 (defvar message-unsent-separator
1651 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1652 "^ *---+ +Returned message +---+ *$\\|"
1653 "^Start of returned message$\\|"
1654 "^ *---+ +Original message +---+ *$\\|"
1655 "^ *--+ +begin message +--+ *$\\|"
1656 "^ *---+ +Original message follows +---+ *$\\|"
1657 "^ *---+ +Undelivered message follows +---+ *$\\|"
1658 "^|? *---+ +Message text follows: +---+ *|?$")
1659 "A regexp that matches the separator before the text of a failed message.")
1661 (defvar message-field-fillers
1662 '((To message-fill-field-address)
1663 (Cc message-fill-field-address)
1664 (From message-fill-field-address))
1665 "Alist of header names/filler functions.")
1667 (defvar message-header-format-alist
1682 (References . message-shorten-references)
1684 "Alist used for formatting headers.")
1686 (defvar message-options nil
1687 "Some saved answers when sending message.")
1689 (defvar message-send-mail-real-function nil
1690 "Internal send mail function.")
1692 (defvar message-bogus-system-names "^localhost\\."
1693 "The regexp of bogus system names.")
1695 (defcustom message-valid-fqdn-regexp
1696 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1698 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1699 "aero\\|arpa\\|bitnet\\|biz\\|bofh\\|"
1700 "cat\\|com\\|coop\\|edu\\|gov\\|"
1701 "info\\|int\\|jobs\\|"
1702 "mil\\|mobi\\|museum\\|name\\|net\\|"
1703 "org\\|pro\\|travel\\|uucp\\)")
1704 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1705 ;; http://en.wikipedia.org/wiki/GTLD
1706 ;; `in the process of being approved': .asia .post .tel .sex
1707 ;; "dead" nato bitnet uucp
1708 "Regular expression that matches a valid FQDN."
1709 ;; see also: gnus-button-valid-fqdn-regexp
1711 :group 'message-headers
1715 (autoload 'gnus-alive-p "gnus-util")
1716 (autoload 'gnus-delay-article "gnus-delay")
1717 (autoload 'gnus-extract-address-components "gnus-util")
1718 (autoload 'gnus-find-method-for-group "gnus")
1719 (autoload 'gnus-group-decoded-name "gnus-group")
1720 (autoload 'gnus-group-name-charset "gnus-group")
1721 (autoload 'gnus-group-name-decode "gnus-group")
1722 (autoload 'gnus-groups-from-server "gnus")
1723 (autoload 'gnus-make-local-hook "gnus-util")
1724 (autoload 'gnus-open-server "gnus-int")
1725 (autoload 'gnus-output-to-mail "gnus-util")
1726 (autoload 'gnus-output-to-rmail "gnus-util")
1727 (autoload 'gnus-request-post "gnus-int")
1728 (autoload 'gnus-server-string "gnus")
1729 (autoload 'idna-to-ascii "idna")
1730 (autoload 'message-setup-toolbar "messagexmas")
1731 (autoload 'mh-new-draft-name "mh-comp")
1732 (autoload 'mh-send-letter "mh-comp")
1733 (autoload 'nndraft-request-associate-buffer "nndraft")
1734 (autoload 'nndraft-request-expire-articles "nndraft")
1735 (autoload 'nnvirtual-find-group-art "nnvirtual")
1736 (autoload 'rmail-dont-reply-to "mail-utils")
1737 (autoload 'rmail-msg-is-pruned "rmail")
1738 (autoload 'rmail-msg-restore-non-pruned-header "rmail")
1739 (autoload 'rmail-output "rmailout"))
1744 ;;; Utility functions.
1747 (defmacro message-y-or-n-p (question show &rest text)
1748 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1749 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
1751 (defmacro message-delete-line (&optional n)
1752 "Delete the current line (and the next N lines)."
1753 `(delete-region (progn (beginning-of-line) (point))
1754 (progn (forward-line ,(or n 1)) (point))))
1756 (defun message-mark-active-p ()
1757 "Non-nil means the mark and region are currently active in this buffer."
1760 (defun message-unquote-tokens (elems)
1761 "Remove double quotes (\") from strings in list ELEMS."
1762 (mapcar (lambda (item)
1763 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item)
1764 (setq item (concat (match-string 1 item)
1765 (match-string 2 item))))
1769 (defun message-tokenize-header (header &optional separator)
1770 "Split HEADER into a list of header elements.
1771 SEPARATOR is a string of characters to be used as separators. \",\"
1772 is used by default."
1775 (let ((regexp (format "[%s]+" (or separator ",")))
1777 beg quoted elems paren)
1779 (mm-enable-multibyte)
1780 (setq beg (point-min))
1782 (goto-char (point-min))
1787 (cond ((and (> (point) beg)
1789 (and (looking-at regexp)
1792 (push (buffer-substring beg (point)) elems)
1793 (setq beg (match-end 0)))
1794 ((eq (char-after) ?\")
1795 (setq quoted (not quoted)))
1796 ((and (eq (char-after) ?\()
1799 ((and (eq (char-after) ?\))
1802 (nreverse elems)))))
1804 (defun message-mail-file-mbox-p (file)
1805 "Say whether FILE looks like a Unix mbox file."
1806 (when (and (file-exists-p file)
1807 (file-readable-p file)
1808 (file-regular-p file))
1810 (nnheader-insert-file-contents file)
1811 (goto-char (point-min))
1812 (looking-at message-unix-mail-delimiter))))
1814 (defun message-fetch-field (header &optional not-all)
1815 "The same as `mail-fetch-field', only remove all newlines.
1816 The buffer is expected to be narrowed to just the header of the message;
1817 see `message-narrow-to-headers-or-head'."
1818 (let* ((inhibit-point-motion-hooks t)
1819 (value (mail-fetch-field header nil (not not-all))))
1821 (while (string-match "\n[\t ]+" value)
1822 (setq value (replace-match " " t t value)))
1825 (defun message-field-value (header &optional not-all)
1826 "The same as `message-fetch-field', only narrow to the headers first."
1829 (message-narrow-to-headers-or-head)
1830 (message-fetch-field header not-all))))
1832 (defun message-narrow-to-field ()
1833 "Narrow the buffer to the header on the current line."
1835 (while (looking-at "[ \t]")
1841 (if (re-search-forward "^[^ \n\t]" nil t)
1844 (goto-char (point-min)))
1846 (defun message-add-header (&rest headers)
1847 "Add the HEADERS to the message header, skipping those already present."
1850 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers))
1851 (error "Invalid header `%s'" (car headers)))
1852 (setq hclean (match-string 1 (car headers)))
1854 (message-narrow-to-headers)
1855 (unless (re-search-forward (concat "^" (regexp-quote hclean) ":") nil t)
1856 (goto-char (point-max))
1857 (if (string-match "\n$" (car headers))
1858 (insert (car headers))
1859 (insert (car headers) ?\n)))))
1860 (setq headers (cdr headers))))
1862 (defmacro message-with-reply-buffer (&rest forms)
1863 "Evaluate FORMS in the reply buffer, if it exists."
1864 `(when (and message-reply-buffer
1865 (buffer-name message-reply-buffer))
1867 (set-buffer message-reply-buffer)
1870 (put 'message-with-reply-buffer 'lisp-indent-function 0)
1871 (put 'message-with-reply-buffer 'edebug-form-spec '(body))
1873 (defun message-fetch-reply-field (header)
1874 "Fetch field HEADER from the message we're replying to."
1875 (message-with-reply-buffer
1877 (mail-narrow-to-head)
1878 (message-fetch-field header))))
1880 (defun message-strip-list-identifiers (subject)
1881 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
1882 (require 'gnus-sum) ; for gnus-list-identifiers
1883 (let ((regexp (if (stringp gnus-list-identifiers)
1884 gnus-list-identifiers
1885 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1886 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
1887 " *\\)\\)+\\(Re: +\\)?\\)") subject)
1888 (concat (substring subject 0 (match-beginning 1))
1889 (or (match-string 3 subject)
1890 (match-string 5 subject))
1895 (defun message-strip-subject-re (subject)
1896 "Remove \"Re:\" from subject lines in string SUBJECT."
1897 (if (string-match message-subject-re-regexp subject)
1898 (substring subject (match-end 0))
1901 ;;; Start of functions adopted from `message-utils.el'.
1903 (defun message-strip-subject-trailing-was (subject)
1904 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
1905 Leading \"Re: \" is not stripped by this function. Use the function
1906 `message-strip-subject-re' for this."
1907 (let* ((query message-subject-trailing-was-query)
1912 message-subject-trailing-was-ask-regexp
1913 message-subject-trailing-was-regexp)
1916 (setq new (substring subject 0 (match-beginning 0))))
1917 (if (or (not found) (eq query nil))
1920 (if (message-y-or-n-p
1921 "Strip `(was: <old subject>)' in subject? " t
1923 "Strip `(was: <old subject>)' in subject "
1924 "and use the new one instead?\n\n"
1925 "Current subject is: \""
1927 "New subject would be: \""
1929 "See the variable `message-subject-trailing-was-query' "
1930 "to get rid of this query."
1935 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
1937 (defun message-change-subject (new-subject)
1938 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
1939 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged>
1942 (read-from-minibuffer "New subject: ")))
1943 (cond ((and (not (or (null new-subject) ; new subject not empty
1944 (zerop (string-width new-subject))
1945 (string-match "^[ \t]*$" new-subject))))
1949 (message-narrow-to-headers)
1950 (message-fetch-field "Subject"))))
1951 (cond ((not old-subject)
1952 (error "No current subject"))
1955 (regexp-quote new-subject)
1957 old-subject)) ; yes, it really is a new subject
1958 ;; delete eventual Re: prefix
1960 (message-strip-subject-re old-subject))
1961 (message-goto-subject)
1962 (message-delete-line)
1963 (insert (concat "Subject: "
1966 old-subject ")\n")))))))))
1968 (defun message-mark-inserted-region (beg end &optional verbatim)
1969 "Mark some region in the current article with enclosing tags.
1970 See `message-mark-insert-begin' and `message-mark-insert-end'.
1971 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
1972 (interactive "r\nP")
1974 ;; add to the end of the region first, otherwise end would be invalid
1976 (insert (if verbatim "#v-\n" message-mark-insert-end))
1978 (insert (if verbatim "#v+\n" message-mark-insert-begin))))
1980 (defun message-mark-insert-file (file &optional verbatim)
1981 "Insert FILE at point, marking it with enclosing tags.
1982 See `message-mark-insert-begin' and `message-mark-insert-end'.
1983 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
1984 (interactive "fFile to insert: \nP")
1985 ;; reverse insertion to get correct result.
1987 (insert (if verbatim "#v-\n" message-mark-insert-end))
1989 (insert-file-contents file)
1991 (insert (if verbatim "#v+\n" message-mark-insert-begin))))
1993 (defun message-add-archive-header ()
1994 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
1995 The note can be customized using `message-archive-note'. When called with a
1996 prefix argument, ask for a text to insert. If you don't want the note in the
1997 body, set `message-archive-note' to nil."
1999 (if current-prefix-arg
2000 (setq message-archive-note
2001 (read-from-minibuffer "Reason for No-Archive: "
2002 (cons message-archive-note 0))))
2004 (if (message-goto-signature)
2005 (re-search-backward message-signature-separator))
2006 (when message-archive-note
2007 (insert message-archive-note)
2009 (message-add-header message-archive-header)
2010 (message-sort-headers)))
2012 (defun message-cross-post-followup-to-header (target-group)
2013 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2014 With prefix-argument just set Follow-Up, don't cross-post."
2016 (list ; Completion based on Gnus
2017 (completing-read "Followup To: "
2018 (if (boundp 'gnus-newsrc-alist)
2020 nil nil '("poster" . 0)
2021 (if (boundp 'gnus-group-history)
2022 'gnus-group-history))))
2023 (message-remove-header "Follow[Uu]p-[Tt]o" t)
2024 (message-goto-newsgroups)
2026 ;; if we already did a crosspost before, kill old target
2027 (if (and message-cross-post-old-target
2029 (regexp-quote (concat "," message-cross-post-old-target))
2032 ;; unless (followup is to poster or user explicitly asked not
2033 ;; to cross-post, or target-group is already in Newsgroups)
2034 ;; add target-group to Newsgroups line.
2036 ;; def: cross-post, req:no
2037 (and message-cross-post-default (not current-prefix-arg))
2038 ;; def: no-cross-post, req:yes
2039 (and (not message-cross-post-default) current-prefix-arg))
2040 (not (string-match "poster" target-group))
2041 (not (string-match (regexp-quote target-group)
2042 (message-fetch-field "Newsgroups"))))
2044 (insert (concat "," target-group))))
2045 (end-of-line) ; ensure Followup: comes after Newsgroups:
2046 ;; unless new followup would be identical to Newsgroups line
2047 ;; make a new Followup-To line
2048 (if (not (string-match (concat "^[ \t]*"
2051 (message-fetch-field "Newsgroups")))
2052 (insert (concat "\nFollowup-To: " target-group)))
2053 (setq message-cross-post-old-target target-group))
2055 (defun message-cross-post-insert-note (target-group cross-post in-old
2057 "Insert a in message body note about a set Followup or Crosspost.
2058 If there have been previous notes, delete them. TARGET-GROUP specifies the
2059 group to Followup-To. When CROSS-POST is t, insert note about
2060 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2061 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2062 been made to before the user asked for a Crosspost."
2063 ;; start scanning body for previous uses
2064 (message-goto-signature)
2065 (let ((head (re-search-backward
2066 (concat "^" mail-header-separator)
2067 nil t))) ; just search in body
2068 (message-goto-signature)
2069 (while (re-search-backward
2070 (concat "^" (regexp-quote message-cross-post-note) ".*")
2072 (message-delete-line))
2073 (message-goto-signature)
2074 (while (re-search-backward
2075 (concat "^" (regexp-quote message-followup-to-note) ".*")
2077 (message-delete-line))
2079 (if (message-goto-signature)
2080 (re-search-backward message-signature-separator))
2083 (string-match "^[ \t]*poster[ \t]*$" target-group))
2084 (insert (concat message-followup-to-note target-group "\n"))
2085 (insert (concat message-cross-post-note target-group "\n")))))
2087 (defun message-cross-post-followup-to (target-group)
2088 "Crossposts message and set Followup-To to TARGET-GROUP.
2089 With prefix-argument just set Follow-Up, don't cross-post."
2091 (list ; Completion based on Gnus
2092 (completing-read "Followup To: "
2093 (if (boundp 'gnus-newsrc-alist)
2095 nil nil '("poster" . 0)
2096 (if (boundp 'gnus-group-history)
2097 'gnus-group-history))))
2098 (cond ((not (or (null target-group) ; new subject not empty
2099 (zerop (string-width target-group))
2100 (string-match "^[ \t]*$" target-group)))
2102 (let* ((old-groups (message-fetch-field "Newsgroups"))
2103 (in-old (string-match
2104 (regexp-quote target-group)
2105 (or old-groups ""))))
2106 ;; check whether target exactly matches old Newsgroups
2107 (cond ((not old-groups)
2108 (error "No current newsgroup"))
2112 (regexp-quote target-group)
2115 ;; yes, Newsgroups line must change
2116 (message-cross-post-followup-to-header target-group)
2117 ;; insert note whether we do cross-post or followup-to
2118 (funcall message-cross-post-note-function
2120 (if (or (and message-cross-post-default
2121 (not current-prefix-arg))
2122 (and (not message-cross-post-default)
2123 current-prefix-arg)) t)
2124 in-old old-groups))))))))
2126 ;;; Reduce To: to Cc: or Bcc: header
2128 (defun message-reduce-to-to-cc ()
2129 "Replace contents of To: header with contents of Cc: or Bcc: header."
2132 (save-restriction (message-narrow-to-headers)
2133 (message-fetch-field "cc")))
2135 (if (and (not cc-content)
2138 (message-narrow-to-headers)
2139 (message-fetch-field "bcc"))))
2144 (message-delete-line)
2145 (insert (concat "To: " cc-content "\n"))
2147 (message-narrow-to-headers)
2148 (message-remove-header (if bcc
2152 ;;; End of functions adopted from `message-utils.el'.
2154 (defun message-remove-header (header &optional is-regexp first reverse)
2155 "Remove HEADER in the narrowed buffer.
2156 If IS-REGEXP, HEADER is a regular expression.
2157 If FIRST, only remove the first instance of the header.
2158 Return the number of headers removed."
2159 (goto-char (point-min))
2160 (let ((regexp (if is-regexp header (concat "^" (regexp-quote header) ":")))
2162 (case-fold-search t)
2164 (while (and (not (eobp))
2167 (not (looking-at regexp))
2168 (looking-at regexp))
2175 ;; There might be a continuation header, so we have to search
2176 ;; until we find a new non-continuation line.
2179 (if (re-search-forward "^[^ \t]" nil t)
2180 (goto-char (match-beginning 0))
2183 (if (re-search-forward "^[^ \t]" nil t)
2184 (goto-char (match-beginning 0))
2185 (goto-char (point-max)))))
2188 (defun message-remove-first-header (header)
2189 "Remove the first instance of HEADER if there is more than one."
2191 (regexp (concat "^" (regexp-quote header) ":")))
2193 (goto-char (point-min))
2194 (while (re-search-forward regexp nil t)
2197 (message-remove-header header nil t)
2200 (defun message-narrow-to-headers ()
2201 "Narrow the buffer to the head of the message."
2204 (goto-char (point-min))
2205 (if (re-search-forward
2206 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
2209 (goto-char (point-min)))
2211 (defun message-narrow-to-head-1 ()
2212 "Like `message-narrow-to-head'. Don't widen."
2214 (goto-char (point-min))
2215 (if (search-forward "\n\n" nil 1)
2218 (goto-char (point-min)))
2220 (defun message-narrow-to-head ()
2221 "Narrow the buffer to the head of the message.
2222 Point is left at the beginning of the narrowed-to region."
2224 (message-narrow-to-head-1))
2226 (defun message-narrow-to-headers-or-head ()
2227 "Narrow the buffer to the head of the message."
2230 (goto-char (point-min))
2233 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
2234 (match-beginning 0))
2235 ((search-forward "\n\n" nil t)
2239 (goto-char (point-min)))
2241 (defun message-news-p ()
2242 "Say whether the current buffer contains a news message."
2243 (and (not message-this-is-mail)
2244 (or message-this-is-news
2247 (message-narrow-to-headers)
2248 (and (message-fetch-field "newsgroups")
2249 (not (message-fetch-field "posted-to"))))))))
2251 (defun message-mail-p ()
2252 "Say whether the current buffer contains a mail message."
2253 (and (not message-this-is-news)
2254 (or message-this-is-mail
2257 (message-narrow-to-headers)
2258 (or (message-fetch-field "to")
2259 (message-fetch-field "cc")
2260 (message-fetch-field "bcc")))))))
2262 (defun message-subscribed-p ()
2263 "Say whether we need to insert a MFT header."
2264 (or message-subscribed-regexps
2265 message-subscribed-addresses
2266 message-subscribed-address-file
2267 message-subscribed-address-functions))
2269 (defun message-next-header ()
2270 "Go to the beginning of the next header."
2272 (or (eobp) (forward-char 1))
2273 (not (if (re-search-forward "^[^ \t]" nil t)
2275 (goto-char (point-max)))))
2277 (defun message-sort-headers-1 ()
2278 "Sort the buffer as headers using `message-rank' text props."
2279 (goto-char (point-min))
2282 nil 'message-next-header
2284 (message-next-header)
2288 (or (get-text-property (point) 'message-rank)
2291 (defun message-sort-headers ()
2292 "Sort the headers of the current message according to `message-header-format-alist'."
2296 (let ((max (1+ (length message-header-format-alist)))
2298 (message-narrow-to-headers)
2299 (while (re-search-forward "^[^ \n]+:" nil t)
2301 (match-beginning 0) (1+ (match-beginning 0))
2303 (if (setq rank (length (memq (assq (intern (buffer-substring
2305 (1- (match-end 0))))
2306 message-header-format-alist)
2307 message-header-format-alist)))
2310 (message-sort-headers-1))))
2312 (defun message-kill-address ()
2313 "Kill the address under point."
2315 (let ((start (point)))
2316 (message-skip-to-next-address)
2317 (kill-region start (point))))
2320 (defun message-info (&optional arg)
2321 "Display the Message manual.
2323 Prefixed with one \\[universal-argument], display the Emacs MIME manual.
2324 Prefixed with two \\[universal-argument]'s, display the PGG manual."
2326 (cond ((eq arg 16) (Info-goto-node "(pgg)Top"))
2327 ((eq arg 4) (Info-goto-node "(emacs-mime)Top"))
2328 (t (Info-goto-node "(message)Top"))))
2338 (defvar message-mode-map nil)
2340 (unless message-mode-map
2341 (setq message-mode-map (make-keymap))
2342 (set-keymap-parent message-mode-map text-mode-map)
2343 (define-key message-mode-map "\C-c?" 'describe-mode)
2345 (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to)
2346 (define-key message-mode-map "\C-c\C-f\C-o" 'message-goto-from)
2347 (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc)
2348 (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc)
2349 (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc)
2350 (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject)
2351 (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to)
2352 (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups)
2353 (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution)
2354 (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to)
2355 (define-key message-mode-map "\C-c\C-f\C-m" 'message-goto-mail-followup-to)
2356 (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords)
2357 (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary)
2358 (define-key message-mode-map "\C-c\C-f\C-i"
2359 'message-insert-or-toggle-importance)
2360 (define-key message-mode-map "\C-c\C-f\C-a"
2361 'message-generate-unsubscribed-mail-followup-to)
2363 ;; modify headers (and insert notes in body)
2364 (define-key message-mode-map "\C-c\C-fs" 'message-change-subject)
2366 (define-key message-mode-map "\C-c\C-fx" 'message-cross-post-followup-to)
2367 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2368 (define-key message-mode-map "\C-c\C-ft" 'message-reduce-to-to-cc)
2369 (define-key message-mode-map "\C-c\C-fa" 'message-add-archive-header)
2370 ;; mark inserted text
2371 (define-key message-mode-map "\C-c\M-m" 'message-mark-inserted-region)
2372 (define-key message-mode-map "\C-c\M-f" 'message-mark-insert-file)
2374 (define-key message-mode-map "\C-c\C-b" 'message-goto-body)
2375 (define-key message-mode-map "\C-c\C-i" 'message-goto-signature)
2377 (define-key message-mode-map "\C-c\C-t" 'message-insert-to)
2378 (define-key message-mode-map "\C-c\C-fw" 'message-insert-wide-reply)
2379 (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups)
2380 (define-key message-mode-map "\C-c\C-l" 'message-to-list-only)
2381 (define-key message-mode-map "\C-c\C-f\C-e" 'message-insert-expires)
2383 (define-key message-mode-map "\C-c\C-u" 'message-insert-or-toggle-importance)
2384 (define-key message-mode-map "\C-c\M-n"
2385 'message-insert-disposition-notification-to)
2387 (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
2388 (define-key message-mode-map "\C-c\M-\C-y" 'message-yank-buffer)
2389 (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
2390 (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
2391 (define-key message-mode-map "\C-c\M-h" 'message-insert-headers)
2392 (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
2393 (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
2394 (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
2396 (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit)
2397 (define-key message-mode-map "\C-c\C-s" 'message-send)
2398 (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
2399 (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
2400 (define-key message-mode-map "\C-c\n" 'gnus-delay-article)
2402 (define-key message-mode-map "\C-c\M-k" 'message-kill-address)
2403 (define-key message-mode-map "\C-c\C-e" 'message-elide-region)
2404 (define-key message-mode-map "\C-c\C-v" 'message-delete-not-region)
2405 (define-key message-mode-map "\C-c\C-z" 'message-kill-to-signature)
2406 (define-key message-mode-map "\M-\r" 'message-newline-and-reformat)
2407 (define-key message-mode-map [remap split-line] 'message-split-line)
2409 (define-key message-mode-map "\C-c\C-a" 'mml-attach-file)
2411 (define-key message-mode-map "\C-a" 'message-beginning-of-line)
2412 (define-key message-mode-map "\t" 'message-tab)
2413 (define-key message-mode-map "\M-;" 'comment-region)
2415 (define-key message-mode-map "\M-n" 'message-display-abbrev))
2418 message-mode-menu message-mode-map "Message Menu."
2420 ["Yank Original" message-yank-original message-reply-buffer]
2421 ["Fill Yanked Message" message-fill-yanked-message t]
2422 ["Insert Signature" message-insert-signature t]
2423 ["Caesar (rot13) Message" message-caesar-buffer-body t]
2424 ["Caesar (rot13) Region" message-caesar-region (message-mark-active-p)]
2425 ["Elide Region" message-elide-region
2426 :active (message-mark-active-p)
2427 ,@(if (featurep 'xemacs) nil
2428 '(:help "Replace text in region with an ellipsis"))]
2429 ["Delete Outside Region" message-delete-not-region
2430 :active (message-mark-active-p)
2431 ,@(if (featurep 'xemacs) nil
2432 '(:help "Delete all quoted text outside region"))]
2433 ["Kill To Signature" message-kill-to-signature t]
2434 ["Newline and Reformat" message-newline-and-reformat t]
2435 ["Rename buffer" message-rename-buffer t]
2436 ["Spellcheck" ispell-message
2437 ,@(if (featurep 'xemacs) '(t)
2438 '(:help "Spellcheck this message"))]
2440 ["Insert Region Marked" message-mark-inserted-region
2441 :active (message-mark-active-p)
2442 ,@(if (featurep 'xemacs) nil
2443 '(:help "Mark region with enclosing tags"))]
2444 ["Insert File Marked..." message-mark-insert-file
2445 ,@(if (featurep 'xemacs) '(t)
2446 '(:help "Insert file at point marked with enclosing tags"))]
2448 ["Send Message" message-send-and-exit
2449 ,@(if (featurep 'xemacs) '(t)
2450 '(:help "Send this message"))]
2451 ["Postpone Message" message-dont-send
2452 ,@(if (featurep 'xemacs) '(t)
2453 '(:help "File this draft message and exit"))]
2454 ["Send at Specific Time..." gnus-delay-article
2455 ,@(if (featurep 'xemacs) '(t)
2456 '(:help "Ask, then arrange to send message at that time"))]
2457 ["Kill Message" message-kill-buffer
2458 ,@(if (featurep 'xemacs) '(t)
2459 '(:help "Delete this message without sending"))]
2461 ["Message manual" message-info
2462 ,@(if (featurep 'xemacs) '(t)
2463 '(:help "Display the Message manual"))]))
2466 message-mode-field-menu message-mode-map ""
2468 ["To" message-goto-to t]
2469 ["From" message-goto-from t]
2470 ["Subject" message-goto-subject t]
2471 ["Change subject..." message-change-subject t]
2472 ["Cc" message-goto-cc t]
2473 ["Bcc" message-goto-bcc t]
2474 ["Fcc" message-goto-fcc t]
2475 ["Reply-To" message-goto-reply-to t]
2476 ["Flag As Important" message-insert-importance-high
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Mark this message as important"))]
2479 ["Flag As Unimportant" message-insert-importance-low
2480 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "Mark this message as unimportant"))]
2483 message-insert-disposition-notification-to
2484 ,@(if (featurep 'xemacs) '(t)
2485 '(:help "Request a receipt notification"))]
2487 ;; (typical) news stuff
2488 ["Summary" message-goto-summary t]
2489 ["Keywords" message-goto-keywords t]
2490 ["Newsgroups" message-goto-newsgroups t]
2491 ["Fetch Newsgroups" message-insert-newsgroups t]
2492 ["Followup-To" message-goto-followup-to t]
2493 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2494 ["Crosspost / Followup-To..." message-cross-post-followup-to t]
2495 ["Distribution" message-goto-distribution t]
2496 ["Expires" message-insert-expires t ]
2497 ["X-No-Archive" message-add-archive-header t ]
2499 ;; (typical) mailing-lists stuff
2500 ["Fetch To" message-insert-to
2501 ,@(if (featurep 'xemacs) '(t)
2502 '(:help "Insert a To header that points to the author."))]
2503 ["Fetch To and Cc" message-insert-wide-reply
2504 ,@(if (featurep 'xemacs) '(t)
2506 "Insert To and Cc headers as if you were doing a wide reply."))]
2508 ["Send to list only" message-to-list-only t]
2509 ["Mail-Followup-To" message-goto-mail-followup-to t]
2510 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2511 ,@(if (featurep 'xemacs) '(t)
2512 '(:help "Insert a reasonable `Mail-Followup-To:' header."))]
2513 ["Reduce To: to Cc:" message-reduce-to-to-cc t]
2515 ["Sort Headers" message-sort-headers t]
2516 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t]
2517 ;; We hide `message-hidden-headers' by narrowing the buffer.
2518 ["Show Hidden Headers" widen t]
2519 ["Goto Body" message-goto-body t]
2520 ["Goto Signature" message-goto-signature t]))
2522 (defvar message-tool-bar-map nil)
2525 (defvar facemenu-add-face-function)
2526 (defvar facemenu-remove-face-function))
2528 ;;; Forbidden properties
2530 ;; We use `after-change-functions' to keep special text properties
2531 ;; that interfer with the normal function of message mode out of the
2534 (defcustom message-strip-special-text-properties t
2535 "Strip special properties from the message buffer.
2537 Emacs has a number of special text properties which can break message
2538 composing in various ways. If this option is set, message will strip
2539 these properties from the message composition buffer. However, some
2540 packages requires these properties to be present in order to work.
2541 If you use one of these packages, turn this option off, and hope the
2542 message composition doesn't break too bad."
2544 :group 'message-various
2545 :link '(custom-manual "(message)Various Message Variables")
2548 (defconst message-forbidden-properties
2549 ;; No reason this should be clutter up customize. We make it a
2550 ;; property list (rather than a list of property symbols), to be
2551 ;; directly useful for `remove-text-properties'.
2552 '(field nil read-only nil invisible nil intangible nil
2553 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2554 insert-behind-hooks nil point-entered nil point-left nil)
2555 ;; Other special properties:
2556 ;; category, face, display: probably doesn't do any harm.
2557 ;; fontified: is used by font-lock.
2558 ;; syntax-table, local-map: I dunno.
2559 ;; We need to add XEmacs names to the list.
2560 "Property list of with properties forbidden in message buffers.
2561 The values of the properties are ignored, only the property names are used.")
2563 (defun message-tamago-not-in-use-p (pos)
2564 "Return t when tamago version 4 is not in use at the cursor position.
2565 Tamago version 4 is a popular input method for writing Japanese text.
2566 It uses the properties `intangible', `invisible', `modification-hooks'
2567 and `read-only' when translating ascii or kana text to kanji text.
2568 These properties are essential to work, so we should never strip them."
2569 (not (and (boundp 'egg-modefull-mode)
2570 (symbol-value 'egg-modefull-mode)
2571 (or (memq (get-text-property pos 'intangible)
2572 '(its-part-1 its-part-2))
2573 (get-text-property pos 'egg-end)
2574 (get-text-property pos 'egg-lang)
2575 (get-text-property pos 'egg-start)))))
2577 (defsubst message-mail-alias-type-p (type)
2578 (if (atom message-mail-alias-type)
2579 (eq message-mail-alias-type type)
2580 (memq type message-mail-alias-type)))
2582 (defun message-strip-forbidden-properties (begin end &optional old-length)
2583 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2584 This function is intended to be called from `after-change-functions'.
2585 See also `message-forbidden-properties'."
2586 (when (and (message-mail-alias-type-p 'ecomplete)
2587 (memq this-command message-self-insert-commands))
2588 (message-display-abbrev))
2589 (when (and message-strip-special-text-properties
2590 (message-tamago-not-in-use-p begin))
2591 (let ((buffer-read-only nil)
2592 (inhibit-read-only t))
2593 (remove-text-properties begin end message-forbidden-properties))))
2596 (define-derived-mode message-mode text-mode "Message"
2597 "Major mode for editing mail and news to be sent.
2598 Like Text Mode but with these additional commands:\\<message-mode-map>
2599 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2600 C-c C-d Postpone sending the message C-c C-k Kill the message
2601 C-c C-f move to a header field (and create it if there isn't):
2602 C-c C-f C-t move to To C-c C-f C-s move to Subject
2603 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2604 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2605 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2606 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2607 C-c C-f C-o move to From (\"Originator\")
2608 C-c C-f C-f move to Followup-To
2609 C-c C-f C-m move to Mail-Followup-To
2610 C-c C-f C-e move to Expires
2611 C-c C-f C-i cycle through Importance values
2612 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2613 C-c C-f x crossposting with FollowUp-To header and note in body
2614 C-c C-f t replace To: header with contents of Cc: or Bcc:
2615 C-c C-f a Insert X-No-Archive: header and a note in the body
2616 C-c C-t `message-insert-to' (add a To header to a news followup)
2617 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2618 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2619 C-c C-b `message-goto-body' (move to beginning of message text).
2620 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2621 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2622 C-c C-y `message-yank-original' (insert current message, if any).
2623 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2624 C-c C-e `message-elide-region' (elide the text between point and mark).
2625 C-c C-v `message-delete-not-region' (remove the text outside the region).
2626 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2627 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2628 C-c C-a `mml-attach-file' (attach a file as MIME).
2629 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2630 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2631 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2632 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2633 M-RET `message-newline-and-reformat' (break the line and reformat)."
2634 (setq local-abbrev-table text-mode-abbrev-table)
2635 (set (make-local-variable 'message-reply-buffer) nil)
2636 (set (make-local-variable 'message-inserted-headers) nil)
2637 (set (make-local-variable 'message-send-actions) nil)
2638 (set (make-local-variable 'message-exit-actions) nil)
2639 (set (make-local-variable 'message-kill-actions) nil)
2640 (set (make-local-variable 'message-postpone-actions) nil)
2641 (set (make-local-variable 'message-draft-article) nil)
2642 (setq buffer-offer-save t)
2643 (set (make-local-variable 'facemenu-add-face-function)
2645 (let ((face-fun (cdr (assq face message-face-alist))))
2647 (funcall face-fun (point) end)
2648 (error "Face %s not configured for %s mode" face mode-name)))
2650 (set (make-local-variable 'facemenu-remove-face-function) t)
2651 (set (make-local-variable 'message-reply-headers) nil)
2652 (make-local-variable 'message-newsreader)
2653 (make-local-variable 'message-mailer)
2654 (make-local-variable 'message-post-method)
2655 (set (make-local-variable 'message-sent-message-via) nil)
2656 (set (make-local-variable 'message-checksum) nil)
2657 (set (make-local-variable 'message-mime-part) 0)
2658 (message-setup-fill-variables)
2659 ;; Allow using comment commands to add/remove quoting.
2660 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2661 (when message-yank-prefix
2662 (set (make-local-variable 'comment-start) message-yank-prefix)
2663 (set (make-local-variable 'comment-start-skip)
2664 (concat "^" (regexp-quote message-yank-prefix) "[ \t]*")))
2665 (if (featurep 'xemacs)
2666 (message-setup-toolbar)
2667 (set (make-local-variable 'font-lock-defaults)
2668 '(message-font-lock-keywords t))
2669 (if (boundp 'tool-bar-map)
2670 (set (make-local-variable 'tool-bar-map) (message-make-tool-bar))))
2671 (easy-menu-add message-mode-menu message-mode-map)
2672 (easy-menu-add message-mode-field-menu message-mode-map)
2673 (gnus-make-local-hook 'after-change-functions)
2674 ;; Mmmm... Forbidden properties...
2675 (add-hook 'after-change-functions 'message-strip-forbidden-properties
2677 ;; Allow mail alias things.
2679 ((message-mail-alias-type-p 'abbrev)
2680 (if (fboundp 'mail-abbrevs-setup)
2681 (mail-abbrevs-setup)
2682 (if (fboundp 'mail-aliases-setup) ; warning avoidance
2683 (mail-aliases-setup))))
2684 ((message-mail-alias-type-p 'ecomplete)
2686 (unless buffer-file-name
2687 (message-set-auto-save-file-name))
2688 (unless (buffer-base-buffer)
2689 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2690 ;; multibyte is not necessary at all. -- zsh
2691 (mm-enable-multibyte))
2692 (set (make-local-variable 'indent-tabs-mode) nil) ;No tabs for indentation.
2695 (defun message-setup-fill-variables ()
2696 "Setup message fill variables."
2697 (set (make-local-variable 'fill-paragraph-function)
2698 'message-fill-paragraph)
2699 (make-local-variable 'paragraph-separate)
2700 (make-local-variable 'paragraph-start)
2701 (make-local-variable 'adaptive-fill-regexp)
2702 (unless (boundp 'adaptive-fill-first-line-regexp)
2703 (setq adaptive-fill-first-line-regexp nil))
2704 (make-local-variable 'adaptive-fill-first-line-regexp)
2705 (let ((quote-prefix-regexp
2706 ;; User should change message-cite-prefix-regexp if
2707 ;; message-yank-prefix is set to an abnormal value.
2708 (concat "\\(" message-cite-prefix-regexp "\\)[ \t]*")))
2709 (setq paragraph-start
2711 (regexp-quote mail-header-separator) "$\\|"
2712 "[ \t]*$\\|" ; blank lines
2713 "-- $\\|" ; signature delimiter
2714 "---+$\\|" ; delimiters for forwarded messages
2715 page-delimiter "$\\|" ; spoiler warnings
2716 ".*wrote:$\\|" ; attribution lines
2717 quote-prefix-regexp "$\\|" ; empty lines in quoted text
2719 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
2720 (setq paragraph-separate paragraph-start)
2721 (setq adaptive-fill-regexp
2722 (concat quote-prefix-regexp "\\|" adaptive-fill-regexp))
2723 (setq adaptive-fill-first-line-regexp
2724 (concat quote-prefix-regexp "\\|"
2725 adaptive-fill-first-line-regexp)))
2726 (make-local-variable 'auto-fill-inhibit-regexp)
2727 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
2728 (setq auto-fill-inhibit-regexp nil)
2729 (make-local-variable 'normal-auto-fill-function)
2730 (setq normal-auto-fill-function 'message-do-auto-fill)
2731 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
2732 ;; In that case, ensure that it uses the right function. The real
2733 ;; solution would be not to use `define-derived-mode', and run
2734 ;; `text-mode-hook' ourself at the end of the mode.
2735 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
2736 (when auto-fill-function
2737 (setq auto-fill-function normal-auto-fill-function)))
2742 ;;; Message mode commands
2745 ;;; Movement commands
2747 (defun message-goto-to ()
2748 "Move point to the To header."
2750 (message-position-on-field "To"))
2752 (defun message-goto-from ()
2753 "Move point to the From header."
2755 (message-position-on-field "From"))
2757 (defun message-goto-subject ()
2758 "Move point to the Subject header."
2760 (message-position-on-field "Subject"))
2762 (defun message-goto-cc ()
2763 "Move point to the Cc header."
2765 (message-position-on-field "Cc" "To"))
2767 (defun message-goto-bcc ()
2768 "Move point to the Bcc header."
2770 (message-position-on-field "Bcc" "Cc" "To"))
2772 (defun message-goto-fcc ()
2773 "Move point to the Fcc header."
2775 (message-position-on-field "Fcc" "To" "Newsgroups"))
2777 (defun message-goto-reply-to ()
2778 "Move point to the Reply-To header."
2780 (message-position-on-field "Reply-To" "Subject"))
2782 (defun message-goto-newsgroups ()
2783 "Move point to the Newsgroups header."
2785 (message-position-on-field "Newsgroups"))
2787 (defun message-goto-distribution ()
2788 "Move point to the Distribution header."
2790 (message-position-on-field "Distribution"))
2792 (defun message-goto-followup-to ()
2793 "Move point to the Followup-To header."
2795 (message-position-on-field "Followup-To" "Newsgroups"))
2797 (defun message-goto-mail-followup-to ()
2798 "Move point to the Mail-Followup-To header."
2800 (message-position-on-field "Mail-Followup-To" "To"))
2802 (defun message-goto-keywords ()
2803 "Move point to the Keywords header."
2805 (message-position-on-field "Keywords" "Subject"))
2807 (defun message-goto-summary ()
2808 "Move point to the Summary header."
2810 (message-position-on-field "Summary" "Subject"))
2812 (defun message-goto-body (&optional interactivep)
2813 "Move point to the beginning of the message body."
2814 (interactive (list t))
2815 (when (and interactivep
2816 (looking-at "[ \t]*\n"))
2818 (goto-char (point-min))
2819 (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
2820 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t)))
2822 (defun message-in-body-p ()
2823 "Return t if point is in the message body."
2824 (let ((body (save-excursion (message-goto-body) (point))))
2827 (defun message-goto-eoh ()
2828 "Move point to the end of the headers."
2833 (defun message-goto-signature ()
2834 "Move point to the beginning of the message signature.
2835 If there is no signature in the article, go to the end and
2838 (goto-char (point-min))
2839 (if (re-search-forward message-signature-separator nil t)
2841 (goto-char (point-max))
2844 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc)
2845 "Insert a reasonable MFT header in a post to an unsubscribed list.
2846 When making original posts to a mailing list you are not subscribed to,
2847 you have to type in a MFT header by hand. The contents, usually, are
2848 the addresses of the list and your own address. This function inserts
2849 such a header automatically. It fetches the contents of the To: header
2850 in the current mail buffer, and appends the current `user-mail-address'.
2852 If the optional argument INCLUDE-CC is non-nil, the addresses in the
2853 Cc: header are also put into the MFT."
2858 (message-narrow-to-headers)
2859 (message-remove-header "Mail-Followup-To")
2860 (setq cc (and include-cc (message-fetch-field "Cc")))
2862 (concat (message-fetch-field "To") "," cc)
2863 (message-fetch-field "To"))))
2864 (message-goto-mail-followup-to)
2865 (insert (concat tos ", " user-mail-address))))
2869 (defun message-insert-to (&optional force)
2870 "Insert a To header that points to the author of the article being replied to.
2871 If the original author requested not to be sent mail, don't insert unless the
2872 prefix FORCE is given."
2874 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
2875 (dont (and mct (or (equal (downcase mct) "never")
2876 (equal (downcase mct) "nobody"))))
2877 (to (or (message-fetch-reply-field "mail-reply-to")
2878 (message-fetch-reply-field "reply-to")
2879 (message-fetch-reply-field "from"))))
2883 "Ignoring the user request not to have copies sent via mail"
2884 "Complying with the user request not to have copies sent via mail")))
2885 (when (and force (not to))
2886 (error "No mail address in the article"))
2887 (when (and to (or force (not dont)))
2888 (message-carefully-insert-headers (list (cons 'To to))))))
2890 (defun message-insert-wide-reply ()
2891 "Insert To and Cc headers as if you were doing a wide reply."
2893 (let ((headers (message-with-reply-buffer
2894 (message-get-reply-headers t))))
2895 (message-carefully-insert-headers headers)))
2897 (defcustom message-header-synonyms
2900 "List of lists of header synonyms.
2901 E.g., if this list contains a member list with elements `Cc' and `To',
2902 then `message-carefully-insert-headers' will not insert a `To' header
2903 when the message is already `Cc'ed to the recipient."
2905 :group 'message-headers
2906 :link '(custom-manual "(message)Message Headers")
2907 :type '(repeat sexp))
2909 (defun message-carefully-insert-headers (headers)
2910 "Insert the HEADERS, an alist, into the message buffer.
2911 Does not insert the headers when they are already present there
2912 or in the synonym headers, defined by `message-header-synonyms'."
2913 ;; FIXME: Should compare only the address and not the full name. Comparison
2914 ;; should be done case-folded (and with `string=' rather than
2916 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
2917 (dolist (header headers)
2918 (let* ((header-name (symbol-name (car header)))
2919 (new-header (cdr header))
2920 (synonyms (loop for synonym in message-header-synonyms
2921 when (memq (car header) synonym) return synonym))
2923 (loop for synonym in synonyms
2924 for old-header = (mail-fetch-field (symbol-name synonym))
2925 when (and old-header (string-match new-header old-header))
2928 (message "already have `%s' in `%s'" new-header old-header)
2929 (when (and (message-position-on-field header-name)
2930 (setq old-header (mail-fetch-field header-name))
2931 (not (string-match "\\` *\\'" old-header)))
2933 (insert new-header)))))
2935 (defun message-widen-reply ()
2936 "Widen the reply to include maximum recipients."
2939 (and message-reply-buffer
2940 (buffer-name message-reply-buffer)
2942 (set-buffer message-reply-buffer)
2943 (message-get-reply-headers t)))))
2946 (message-narrow-to-headers)
2947 (dolist (elem follow-to)
2948 (message-remove-header (symbol-name (car elem)))
2949 (goto-char (point-min))
2950 (insert (symbol-name (car elem)) ": "
2951 (cdr elem) "\n"))))))
2953 (defun message-insert-newsgroups ()
2954 "Insert the Newsgroups header from the article being replied to."
2956 (when (and (message-position-on-field "Newsgroups")
2957 (mail-fetch-field "newsgroups")
2958 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
2960 (insert (or (message-fetch-reply-field "newsgroups") "")))
2964 ;;; Various commands
2966 (defun message-delete-not-region (beg end)
2967 "Delete everything in the body of the current message outside of the region."
2972 ;; snarf citation prefix, if appropriate
2973 (unless (eq (point) (progn (beginning-of-line) (point)))
2974 (when (looking-at message-cite-prefix-regexp)
2975 (setq citeprefix (match-string 0))))
2977 (delete-region (point) (if (not (message-goto-signature))
2983 (delete-region beg (progn (message-goto-body)
2987 (insert citeprefix))))
2988 (when (message-goto-signature)
2991 (defun message-kill-to-signature (&optional arg)
2992 "Kill all text up to the signature.
2993 If a numberic argument or prefix arg is given, leave that number
2994 of lines before the signature intact."
2998 (let ((point (point)))
2999 (narrow-to-region point (point-max))
3000 (message-goto-signature)
3002 (if (and arg (numberp arg))
3003 (forward-line (- -1 arg))
3005 (unless (= point (point))
3006 (kill-region point (point))
3010 (defun message-newline-and-reformat (&optional arg not-break)
3011 "Insert four newlines, and then reformat if inside quoted text.
3012 Prefix arg means justify as well."
3013 (interactive (list (if current-prefix-arg 'full)))
3014 (let (quoted point beg end leading-space bolp fill-paragraph-function)
3015 (setq point (point))
3018 (setq bolp (= beg point))
3019 ;; Find first line of the paragraph.
3021 (while (and (not (eobp))
3022 (not (looking-at message-cite-prefix-regexp))
3023 (looking-at paragraph-start))
3026 (when (looking-at message-cite-prefix-regexp)
3027 (setq quoted (match-string 0))
3028 (goto-char (match-end 0))
3029 (looking-at "[ \t]*")
3030 (setq leading-space (match-string 0)))
3034 (< (- point beg) (length quoted)))
3035 ;; break inside the cite prefix.
3041 (while (and (not (eobp))
3042 (not (looking-at paragraph-separate))
3043 (looking-at message-cite-prefix-regexp)
3044 (equal quoted (match-string 0)))
3045 (goto-char (match-end 0))
3046 (looking-at "[ \t]*")
3047 (if (> (length leading-space) (length (match-string 0)))
3048 (setq leading-space (match-string 0)))
3052 (while (and (if (bobp) nil (forward-line -1) t)
3053 (not (looking-at paragraph-start))
3054 (looking-at message-cite-prefix-regexp)
3055 (equal quoted (match-string 0)))
3057 (goto-char (match-end 0))
3058 (looking-at "[ \t]*")
3059 (if (> (length leading-space) (length (match-string 0)))
3060 (setq leading-space (match-string 0)))))
3061 (while (and (not (eobp))
3062 (not (looking-at paragraph-separate))
3063 (not (looking-at message-cite-prefix-regexp)))
3067 (while (and (if (bobp) nil (forward-line -1) t)
3068 (not (looking-at paragraph-start))
3069 (not (looking-at message-cite-prefix-regexp)))
3070 (setq beg (point))))
3073 (narrow-to-region beg end)
3080 (setq point (point))
3081 ;; (newline 2) doesn't mark both newline's as hard, so call
3082 ;; newline twice. -jas
3085 (delete-region (point) (re-search-forward "[ \t]*"))
3086 (when (and quoted (not bolp))
3087 (insert quoted leading-space)))
3090 (let* ((adaptive-fill-regexp
3091 (regexp-quote (concat quoted leading-space)))
3092 (adaptive-fill-first-line-regexp
3093 adaptive-fill-regexp ))
3094 (fill-paragraph arg))
3095 (fill-paragraph arg))
3096 (if point (goto-char point)))))
3098 (defun message-fill-paragraph (&optional arg)
3099 "Message specific function to fill a paragraph.
3100 This function is used as the value of `fill-paragraph-function' in
3101 Message buffers and is not meant to be called directly."
3102 (interactive (list (if current-prefix-arg 'full)))
3103 (if (if (boundp 'filladapt-mode) filladapt-mode)
3105 (if (message-point-in-header-p)
3106 (message-fill-field)
3107 (message-newline-and-reformat arg t))
3110 (defun message-point-in-header-p ()
3111 "Return t if point is in the header."
3113 (not (re-search-backward
3114 (concat "^" (regexp-quote mail-header-separator) "\n") nil t))))
3116 (defun message-do-auto-fill ()
3117 "Like `do-auto-fill', but don't fill in message header."
3118 (unless (message-point-in-header-p)
3121 (defun message-insert-signature (&optional force)
3122 "Insert a signature. See documentation for variable `message-signature'."
3123 (interactive (list 0))
3126 ((and (null message-signature)
3129 (goto-char (point-max))
3130 (not (re-search-backward message-signature-separator nil t))))
3131 ((and (null message-signature)
3134 ((functionp message-signature)
3135 (funcall message-signature))
3136 ((listp message-signature)
3137 (eval message-signature))
3138 (t message-signature)))
3140 (cond ((stringp signature)
3142 ((and (eq t signature)
3143 message-signature-file
3144 (file-exists-p message-signature-file))
3147 (goto-char (point-max))
3148 ;; Insert the signature.
3151 (when message-signature-insert-empty-line
3154 (if (eq signature t)
3155 (insert-file-contents message-signature-file)
3157 (goto-char (point-max))
3158 (or (bolp) (insert "\n")))))
3160 (defun message-insert-importance-high ()
3161 "Insert header to mark message as important."
3165 (message-narrow-to-headers)
3166 (message-remove-header "Importance"))
3168 (insert "Importance: high\n")))
3170 (defun message-insert-importance-low ()
3171 "Insert header to mark message as unimportant."
3175 (message-narrow-to-headers)
3176 (message-remove-header "Importance"))
3178 (insert "Importance: low\n")))
3180 (defun message-insert-or-toggle-importance ()
3181 "Insert a \"Importance: high\" header, or cycle through the header values.
3182 The three allowed values according to RFC 1327 are `high', `normal'
3186 (let ((valid '("high" "normal" "low"))
3190 (message-narrow-to-headers)
3191 (when (setq cur (message-fetch-field "Importance"))
3192 (message-remove-header "Importance")
3193 (setq new (cond ((string= cur "high")
3195 ((string= cur "low")
3200 (insert (format "Importance: %s\n" new)))))
3202 (defun message-insert-disposition-notification-to ()
3203 "Request a disposition notification (return receipt) to this message.
3204 Note that this should not be used in newsgroups."
3208 (message-narrow-to-headers)
3209 (message-remove-header "Disposition-Notification-To"))
3211 (insert (format "Disposition-Notification-To: %s\n"
3212 (or (message-field-value "Reply-to")
3213 (message-field-value "From")
3214 (message-make-from))))))
3216 (defun message-elide-region (b e)
3217 "Elide the text in the region.
3218 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3222 (insert message-elide-ellipsis))
3224 (defvar message-caesar-translation-table nil)
3226 (defun message-caesar-region (b e &optional n)
3227 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3230 (min (point) (or (mark t) (point)))
3231 (max (point) (or (mark t) (point)))
3232 (when current-prefix-arg
3233 (prefix-numeric-value current-prefix-arg))))
3235 (setq n (if (numberp n) (mod n 26) 13)) ;canonize N
3236 (unless (or (zerop n) ; no action needed for a rot of 0
3237 (= b e)) ; no region to rotate
3238 ;; We build the table, if necessary.
3239 (when (or (not message-caesar-translation-table)
3240 (/= (aref message-caesar-translation-table ?a) (+ ?a n)))
3241 (setq message-caesar-translation-table
3242 (message-make-caesar-translation-table n)))
3243 (translate-region b e message-caesar-translation-table)))
3245 (defun message-make-caesar-translation-table (n)
3246 "Create a rot table with offset N."
3248 (table (make-string 256 0)))
3249 (while (< (incf i) 256)
3252 (substring table 0 ?A)
3253 (substring table (+ ?A n) (+ ?A n (- 26 n)))
3254 (substring table ?A (+ ?A n))
3255 (substring table (+ ?A 26) ?a)
3256 (substring table (+ ?a n) (+ ?a n (- 26 n)))
3257 (substring table ?a (+ ?a n))
3258 (substring table (+ ?a 26) 255))))
3260 (defun message-caesar-buffer-body (&optional rotnum wide)
3261 "Caesar rotate all letters in the current buffer by 13 places.
3262 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3263 With prefix arg, specifies the number of places to rotate each letter forward.
3264 Mail and USENET news headers are not rotated unless WIDE is non-nil."
3265 (interactive (if current-prefix-arg
3266 (list (prefix-numeric-value current-prefix-arg))
3270 (when (and (not wide) (message-goto-body))
3271 (narrow-to-region (point) (point-max)))
3272 (message-caesar-region (point-min) (point-max) rotnum))))
3274 (defun message-pipe-buffer-body (program)
3275 "Pipe the message body in the current buffer through PROGRAM."
3278 (when (message-goto-body)
3279 (narrow-to-region (point) (point-max)))
3280 (shell-command-on-region
3281 (point-min) (point-max) program nil t))))
3283 (defun message-rename-buffer (&optional enter-string)
3284 "Rename the *message* buffer to \"*message* RECIPIENT\".
3285 If the function is run with a prefix, it will ask for a new buffer
3286 name, rather than giving an automatic name."
3287 (interactive "Pbuffer name: ")
3290 (goto-char (point-min))
3291 (narrow-to-region (point)
3292 (search-forward mail-header-separator nil 'end))
3294 (if (message-news-p) (message-fetch-field "Newsgroups")
3295 (message-fetch-field "To"))
3298 (if (string-match "," mail-to)
3299 (concat (substring mail-to 0 (match-beginning 0)) ", ...")
3301 (name-default (concat "*message* " mail-trimmed-to))
3302 (name (if enter-string
3303 (read-string "New buffer name: " name-default)
3305 (rename-buffer name t)))))
3307 (defun message-fill-yanked-message (&optional justifyp)
3308 "Fill the paragraphs of a message yanked into this one.
3309 Numeric argument means justify as well."
3312 (goto-char (point-min))
3313 (search-forward (concat "\n" mail-header-separator "\n") nil t)
3314 (let ((fill-prefix message-yank-prefix))
3315 (fill-individual-paragraphs (point) (point-max) justifyp))))
3317 (defun message-indent-citation (&optional start end yank-only)
3318 "Modify text just inserted from a message to be cited.
3319 The inserted text should be the region.
3320 When this function returns, the region is again around the modified text.
3322 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3323 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3324 (unless start (setq start (point)))
3326 ;; Remove unwanted headers.
3327 (when message-ignored-cited-headers
3332 (if (search-forward "\n\n" nil t)
3335 (message-remove-header message-ignored-cited-headers t)
3336 (when (= (point-min) (point-max))
3337 (setq all-removed t))
3338 (goto-char (point-max)))
3342 ;; Delete blank lines at the start of the buffer.
3343 (while (and (point-min)
3346 (message-delete-line))
3347 ;; Delete blank lines at the end of the buffer.
3348 (goto-char (point-max))
3351 (while (and (zerop (forward-line -1))
3353 (message-delete-line)))
3354 ;; Do the indentation.
3355 (if (null message-yank-prefix)
3356 (indent-rigidly start (or end (mark t)) message-indentation-spaces)
3359 (while (< (point) (or end (mark t)))
3360 (cond ((looking-at ">")
3361 (insert message-yank-cited-prefix))
3363 (insert message-yank-empty-prefix))
3365 (insert message-yank-prefix)))
3369 (defvar message-cite-reply-above nil
3370 "If non-nil, start own text above the quote.
3372 Note: Top posting is bad netiquette. Don't use it unless you
3373 really must. You probably want to set variable only for specific
3374 groups, e.g. using `gnus-posting-styles':
3376 (eval (set (make-local-variable 'message-cite-reply-above) t))
3378 This variable has no effect in news postings.")
3380 (defun message-yank-original (&optional arg)
3381 "Insert the message being replied to, if any.
3382 Puts point before the text and mark after.
3383 Normally indents each nonblank line ARG spaces (default 3). However,
3384 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3386 This function uses `message-cite-function' to do the actual citing.
3388 Just \\[universal-argument] as argument means don't indent, insert no
3389 prefix, and don't delete any headers."
3391 (let ((modified (buffer-modified-p))
3393 (when (and message-reply-buffer
3394 message-cite-function)
3395 (when message-cite-reply-above
3396 (if (and (not (message-news-p))
3397 (or (eq message-cite-reply-above 'is-evil)
3399 Top posting is bad netiquette. Please don't top post unless you really must.
3400 Really top post? ")))
3403 (buffer-substring (message-goto-body)
3405 (delete-region (message-goto-body) (point-max)))
3406 (set (make-local-variable 'message-cite-reply-above) nil)))
3407 (delete-windows-on message-reply-buffer t)
3408 (push-mark (save-excursion
3409 (insert-buffer-substring message-reply-buffer)
3412 (funcall message-cite-function))
3413 (if message-cite-reply-above
3419 (message-exchange-point-and-mark))
3420 (message-exchange-point-and-mark))
3424 (setq message-checksum (message-checksum))))))
3426 (defun message-yank-buffer (buffer)
3427 "Insert BUFFER into the current buffer and quote it."
3428 (interactive "bYank buffer: ")
3429 (let ((message-reply-buffer (get-buffer buffer)))
3430 (save-window-excursion
3431 (message-yank-original))))
3433 (defun message-buffers ()
3434 "Return a list of active message buffers."
3437 (dolist (buffer (buffer-list t))
3439 (when (and (eq major-mode 'message-mode)
3440 (null message-sent-message-via))
3441 (push (buffer-name buffer) buffers))))
3442 (nreverse buffers)))
3444 (eval-when-compile (defvar mail-citation-hook)) ; Compiler directive
3446 (defun message-cite-original-1 (strip-signature)
3447 "Cite an original message.
3448 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3451 This function uses `mail-citation-hook' if that is non-nil."
3452 (if (and (boundp 'mail-citation-hook)
3454 (run-hooks 'mail-citation-hook)
3455 (let* ((start (point))
3459 (when message-indent-citation-function
3460 (if (listp message-indent-citation-function)
3461 message-indent-citation-function
3462 (list message-indent-citation-function))))
3463 ;; This function may be called by `gnus-summary-yank-message' and
3464 ;; may insert a different article from the original. So, we will
3465 ;; modify the value of `message-reply-headers' with that article.
3466 (message-reply-headers
3468 (narrow-to-region start end)
3469 (message-narrow-to-head-1)
3470 (setq x-no-archive (message-fetch-field "x-no-archive"))
3472 (or (message-fetch-field "subject") "none")
3473 (or (message-fetch-field "from") "nobody")
3474 (message-fetch-field "date")
3475 (message-fetch-field "message-id" t)
3476 (message-fetch-field "references")
3478 (mml-quote-region start end)
3479 (when strip-signature
3483 (when (re-search-backward message-signature-separator start t)
3484 ;; Also peel off any blank lines before the signature.
3486 (while (looking-at "^[ \t]*$")
3489 (delete-region (point) end)
3490 (unless (search-backward "\n\n" start t)
3491 ;; Insert a blank line if it is peeled off.
3494 (mapc 'funcall functions)
3495 (when message-citation-line-function
3498 (funcall message-citation-line-function))
3499 (when (and x-no-archive
3500 (not message-cite-articles-with-x-no-archive)
3501 (string-match "yes" x-no-archive))
3503 (delete-region (point) (mark t))
3504 (insert "> [Quoted text removed due to X-No-Archive]\n")
3506 (forward-line -1)))))
3508 (defun message-cite-original ()
3509 "Cite function in the standard Message manner."
3510 (message-cite-original-1 nil))
3512 (defun message-insert-formated-citation-line (&optional from date)
3513 "Function that inserts a formated citation line.
3515 See `message-citation-line-format'."
3516 ;; The optional args are for testing/debugging. They will disappear later.
3518 ;; (with-temp-buffer
3519 ;; (message-insert-formated-citation-line
3520 ;; "John Doe <john.doe@example.invalid>"
3523 (when (or message-reply-headers (and from date))
3525 (setq from (mail-header-from message-reply-headers)))
3526 (let* ((data (condition-case ()
3527 (funcall (if (boundp gnus-extract-address-components)
3528 gnus-extract-address-components
3529 'mail-extract-address-components)
3535 (net (car (cdr data)))
3536 (name-or-net (or (car data)
3537 (car (cdr data)) from))
3541 ;; We need Gnus functionality if the user wants date or time from
3542 ;; the original article:
3543 (when (string-match "%[^EFLn]" message-citation-line-format)
3544 (autoload 'gnus-date-get-time "gnus-util")
3545 (gnus-date-get-time (mail-header-date message-reply-headers)))))
3548 (when (stringp name)
3549 ;; Guess first name and last name:
3550 (cond ((string-match
3551 "\\`\\(\\w\\|[-.]\\)+ \\(\\w\\|[-.]\\)+\\'" name)
3552 (setq fname (nth 0 (split-string name "[ \t]+"))
3553 lname (nth 1 (split-string name "[ \t]+"))))
3555 "\\`\\(\\w\\|[-.]\\)+, \\(\\w\\|[-.]\\)+\\'" name)
3556 (setq fname (nth 1 (split-string name "[ \t,]+"))
3557 lname (nth 0 (split-string name "[ \t,]+"))))
3559 "\\`\\(\\w\\|[-.]\\)+\\'" name)
3562 ;; The following letters are not used in `format-time-string':
3563 (push ?E lst) (push net lst)
3564 (push ?F lst) (push fname lst)
3565 ;; We might want to use "" instead of "<X>" later.
3566 (push ?J lst) (push "<J>" lst)
3567 (push ?K lst) (push "<K>" lst)
3568 (push ?L lst) (push lname lst)
3569 (push ?N lst) (push "<N>" lst)
3570 (push ?O lst) (push "<O>" lst)
3571 (push ?P lst) (push "<P>" lst)
3572 (push ?Q lst) (push "<Q>" lst)
3573 (push ?f lst) (push from lst)
3574 (push ?i lst) (push "<i>" lst)
3575 (push ?n lst) (push name-or-net lst)
3576 (push ?o lst) (push "<o>" lst)
3577 (push ?q lst) (push "<q>" lst)
3578 (push ?t lst) (push "<t>" lst)
3579 (push ?v lst) (push "<v>" lst)
3580 ;; Delegate the rest to `format-time-string':
3582 (when (and (not (memq i lst))
3587 (push (condition-case nil
3588 (progn (format-time-string (format "%%%c" i)
3594 (spec (apply 'format-spec-make flist)))
3595 (insert (format-spec message-citation-line-format spec)))
3599 (defun message-cite-original-without-signature ()
3600 "Cite function in the standard Message manner.
3601 This function strips off the signature from the original message."
3602 (message-cite-original-1 t))
3604 (defun message-insert-citation-line ()
3605 "Insert a simple citation line."
3606 (when message-reply-headers
3607 (insert (mail-header-from message-reply-headers) " writes:")
3611 (defun message-position-on-field (header &rest afters)
3612 (let ((case-fold-search t))
3615 (goto-char (point-min))
3618 (concat "^" (regexp-quote mail-header-separator) "$"))
3619 (match-beginning 0)))
3620 (goto-char (point-min))