1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 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
42 ;; This is apparently necessary even though things are autoloaded.
43 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
44 ;; require mailabbrev here.
45 (if (featurep 'xemacs)
46 (require 'mail-abbrevs)
47 (require 'mailabbrev))
52 (defgroup message '((user-mail-address custom-variable)
53 (user-full-name custom-variable))
54 "Mail and news message composing."
55 :link '(custom-manual "(message)Top")
59 (put 'user-mail-address 'custom-type 'string)
60 (put 'user-full-name 'custom-type 'string)
62 (defgroup message-various nil
63 "Various Message Variables."
64 :link '(custom-manual "(message)Various Message Variables")
67 (defgroup message-buffers nil
69 :link '(custom-manual "(message)Message Buffers")
72 (defgroup message-sending nil
74 :link '(custom-manual "(message)Sending Variables")
77 (defgroup message-interface nil
79 :link '(custom-manual "(message)Interface")
82 (defgroup message-forwarding nil
84 :link '(custom-manual "(message)Forwarding")
85 :group 'message-interface)
87 (defgroup message-insertion nil
89 :link '(custom-manual "(message)Insertion")
92 (defgroup message-headers nil
94 :link '(custom-manual "(message)Message Headers")
97 (defgroup message-news nil
98 "Composing News Messages."
101 (defgroup message-mail nil
102 "Composing Mail Messages."
105 (defgroup message-faces nil
106 "Faces used for message composing."
110 (defcustom message-directory "~/Mail/"
111 "*Directory from which all other mail file variables are derived."
112 :group 'message-various
115 (defcustom message-max-buffers 10
116 "*How many buffers to keep before starting to kill them off."
117 :group 'message-buffers
120 (defcustom message-send-rename-function nil
121 "Function called to rename the buffer after sending it."
122 :group 'message-buffers
123 :type '(choice function (const nil)))
125 (defcustom message-fcc-handler-function 'message-output
126 "*A function called to save outgoing articles.
127 This function will be called with the name of the file to store the
128 article in. The default function is `message-output' which saves in Unix
130 :type '(radio (function-item message-output)
131 (function :tag "Other"))
132 :group 'message-sending)
134 (defcustom message-fcc-externalize-attachments nil
135 "If non-nil, attachments are included as external parts in Fcc copies."
138 :group 'message-sending)
140 (defcustom message-courtesy-message
141 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
142 "*This is inserted at the start of a mailed copy of a posted message.
143 If the string contains the format spec \"%s\", the Newsgroups
144 the article has been posted to will be inserted there.
145 If this variable is nil, no such courtesy message will be added."
146 :group 'message-sending
147 :type '(radio string (const nil)))
149 (defcustom message-ignored-bounced-headers
150 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
151 "*Regexp that matches headers to be removed in resent bounced mail."
152 :group 'message-interface
156 (defcustom message-from-style 'default
157 "*Specifies how \"From\" headers look.
159 If nil, they contain just the return address like:
161 If `parens', they look like:
162 king@grassland.com (Elvis Parsley)
163 If `angles', they look like:
164 Elvis Parsley <king@grassland.com>
166 Otherwise, most addresses look like `angles', but they look like
167 `parens' if `angles' would need quoting and `parens' would not."
168 :type '(choice (const :tag "simple" nil)
172 :group 'message-headers)
174 (defcustom message-insert-canlock t
175 "Whether to insert a Cancel-Lock header in news postings."
177 :group 'message-headers
180 (defcustom message-syntax-checks
181 (if message-insert-canlock '((sender . disabled)) nil)
182 ;; Guess this one shouldn't be easy to customize...
183 "*Controls what syntax checks should not be performed on outgoing posts.
184 To disable checking of long signatures, for instance, add
185 `(signature . disabled)' to this list.
187 Don't touch this variable unless you really know what you're doing.
189 Checks include `subject-cmsg', `multiple-headers', `sendsys',
190 `message-id', `from', `long-lines', `control-chars', `size',
191 `new-text', `quoting-style', `redirected-followup', `signature',
192 `approved', `sender', `empty', `empty-headers', `message-id', `from',
193 `subject', `shorten-followup-to', `existing-newsgroups',
194 `buffer-file-name', `unchanged', `newsgroups', `reply-to',
195 `continuation-headers', `long-header-lines', `invisible-text' and
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)
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'.
412 (defcustom message-signature-separator "^-- *$"
413 "Regexp matching the signature separator."
415 :link '(custom-manual "(message)Various Message Variables")
416 :group 'message-various)
418 (defcustom message-elide-ellipsis "\n[...]\n\n"
419 "*The string which is inserted for elided text."
421 :link '(custom-manual "(message)Various Commands")
422 :group 'message-various)
424 (defcustom message-interactive t
425 "Non-nil means when sending a message wait for and display errors.
426 nil means let mailer mail back a message to report errors."
427 :group 'message-sending
429 :link '(custom-manual "(message)Sending Variables")
432 (defcustom message-generate-new-buffers 'unique
433 "*Non-nil means create a new message buffer whenever `message-setup' is called.
434 If this is a function, call that function with three parameters: The type,
435 the to address and the group name. (Any of these may be nil.) The function
436 should return the new buffer name."
437 :group 'message-buffers
438 :link '(custom-manual "(message)Message Buffers")
439 :type '(choice (const :tag "off" nil)
440 (const :tag "unique" unique)
441 (const :tag "unsent" unsent)
444 (defcustom message-kill-buffer-on-exit nil
445 "*Non-nil means that the message buffer will be killed after sending a message."
446 :group 'message-buffers
447 :link '(custom-manual "(message)Message Buffers")
450 (defcustom message-kill-buffer-query t
451 "*Non-nil means that killing a modified message buffer has to be confirmed.
452 This is used by `message-kill-buffer'."
453 :version "23.0" ;; No Gnus
454 :group 'message-buffers
458 (defvar gnus-local-organization))
459 (defcustom message-user-organization
460 (or (and (boundp 'gnus-local-organization)
461 (stringp gnus-local-organization)
462 gnus-local-organization)
463 (getenv "ORGANIZATION")
465 "*String to be used as an Organization header.
466 If t, use `message-user-organization-file'."
467 :group 'message-headers
468 :type '(choice string
469 (const :tag "consult file" t)))
472 (defcustom message-user-organization-file "/usr/lib/news/organization"
473 "*Local news organization file."
475 :link '(custom-manual "(message)News Headers")
476 :group 'message-headers)
478 (defcustom message-make-forward-subject-function
479 #'message-forward-subject-name-subject
480 "*List of functions called to generate subject headers for forwarded messages.
481 The subject generated by the previous function is passed into each
484 The provided functions are:
486 * `message-forward-subject-author-subject' Source of article (author or
487 newsgroup), in brackets followed by the subject
488 * `message-forward-subject-name-subject' Source of article (name of author
489 or newsgroup), in brackets followed by the subject
490 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
492 :group 'message-forwarding
493 :link '(custom-manual "(message)Forwarding")
494 :type '(radio (function-item message-forward-subject-author-subject)
495 (function-item message-forward-subject-fwd)
496 (function-item message-forward-subject-name-subject)
497 (repeat :tag "List of functions" function)))
499 (defcustom message-forward-as-mime t
500 "*Non-nil means forward messages as an inline/rfc822 MIME section.
501 Otherwise, directly inline the old message in the forwarded message."
503 :group 'message-forwarding
504 :link '(custom-manual "(message)Forwarding")
507 (defcustom message-forward-show-mml 'best
508 "*Non-nil means show forwarded messages as MML (decoded from MIME).
509 Otherwise, forwarded messages are unchanged.
510 Can also be the symbol `best' to indicate that MML should be
511 used, except when it is a bad idea to use MML. One example where
512 it is a bad idea is when forwarding a signed or encrypted
513 message, because converting MIME to MML would invalidate the
516 :group 'message-forwarding
517 :type '(choice (const :tag "use MML" t)
518 (const :tag "don't use MML " nil)
519 (const :tag "use MML when appropriate" best)))
521 (defcustom message-forward-before-signature t
522 "*Non-nil means put forwarded message before signature, else after."
523 :group 'message-forwarding
526 (defcustom message-wash-forwarded-subjects nil
527 "*Non-nil means try to remove as much cruft as possible from the subject.
528 Done before generating the new subject of a forward."
529 :group 'message-forwarding
530 :link '(custom-manual "(message)Forwarding")
533 (defcustom message-ignored-resent-headers "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From "
534 "*All headers that match this regexp will be deleted when resending a message."
535 :group 'message-interface
536 :link '(custom-manual "(message)Resending")
537 :type '(repeat :value-to-internal (lambda (widget value)
538 (custom-split-regexp-maybe value))
539 :match (lambda (widget value)
541 (widget-editable-list-match widget value)))
544 (defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
545 "*All headers that match this regexp will be deleted when forwarding a message."
547 :group 'message-forwarding
548 :type '(repeat :value-to-internal (lambda (widget value)
549 (custom-split-regexp-maybe value))
550 :match (lambda (widget value)
552 (widget-editable-list-match widget value)))
555 (defcustom message-ignored-cited-headers "."
556 "*Delete these headers from the messages you yank."
557 :group 'message-insertion
558 :link '(custom-manual "(message)Insertion Variables")
561 (defcustom message-cite-prefix-regexp
562 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
563 "\\([ \t]*[-_.[:word:]]+>+\\|[ \t]*[]>|}+]\\)+"
564 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
565 (let (non-word-constituents)
566 (with-syntax-table text-mode-syntax-table
567 (setq non-word-constituents
569 (if (string-match "\\w" "-") "" "-")
570 (if (string-match "\\w" "_") "" "_")
571 (if (string-match "\\w" ".") "" "."))))
572 (if (equal non-word-constituents "")
573 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}+]\\)+"
574 (concat "\\([ \t]*\\(\\w\\|["
575 non-word-constituents
576 "]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
577 "*Regexp matching the longest possible citation prefix on a line."
579 :group 'message-insertion
580 :link '(custom-manual "(message)Insertion Variables")
583 (defcustom message-cancel-message "I am canceling my own article.\n"
584 "Message to be inserted in the cancel message."
585 :group 'message-interface
586 :link '(custom-manual "(message)Canceling News")
589 ;; Useful to set in site-init.el
591 (defcustom message-send-mail-function
592 (let ((program (if (boundp 'sendmail-program)
597 (string-match "/" program) ;; Skip path
598 (file-executable-p program))
599 'message-send-mail-with-sendmail)
601 (executable-find program))
602 'message-send-mail-with-sendmail)
605 "Function to call to send the current buffer as mail.
606 The headers should be delimited by a line whose contents match the
607 variable `mail-header-separator'.
609 Valid values include `message-send-mail-with-sendmail' (the default),
610 `message-send-mail-with-mh', `message-send-mail-with-qmail',
611 `message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
613 See also `send-mail-function'."
614 :type '(radio (function-item message-send-mail-with-sendmail)
615 (function-item message-send-mail-with-mh)
616 (function-item message-send-mail-with-qmail)
617 (function-item message-smtpmail-send-it)
618 (function-item smtpmail-send-it)
619 (function-item feedmail-send-it)
620 (function :tag "Other"))
621 :group 'message-sending
622 :link '(custom-manual "(message)Mail Variables")
623 :group 'message-mail)
625 (defcustom message-send-news-function 'message-send-news
626 "Function to call to send the current buffer as news.
627 The headers should be delimited by a line whose contents match the
628 variable `mail-header-separator'."
629 :group 'message-sending
631 :link '(custom-manual "(message)News Variables")
634 (defcustom message-reply-to-function nil
635 "If non-nil, function that should return a list of headers.
636 This function should pick out addresses from the To, Cc, and From headers
637 and respond with new To and Cc headers."
638 :group 'message-interface
639 :link '(custom-manual "(message)Reply")
640 :type '(choice function (const nil)))
642 (defcustom message-wide-reply-to-function nil
643 "If non-nil, function that should return a list of headers.
644 This function should pick out addresses from the To, Cc, and From headers
645 and respond with new To and Cc headers."
646 :group 'message-interface
647 :link '(custom-manual "(message)Wide Reply")
648 :type '(choice function (const nil)))
650 (defcustom message-followup-to-function nil
651 "If non-nil, function that should return a list of headers.
652 This function should pick out addresses from the To, Cc, and From headers
653 and respond with new To and Cc headers."
654 :group 'message-interface
655 :link '(custom-manual "(message)Followup")
656 :type '(choice function (const nil)))
658 (defcustom message-extra-wide-headers nil
659 "If non-nil, a list of additional address headers.
660 These are used when composing a wide reply."
661 :group 'message-sending
662 :type '(repeat string))
664 (defcustom message-use-followup-to 'ask
665 "*Specifies what to do with Followup-To header.
666 If nil, always ignore the header. If it is t, use its value, but
667 query before using the \"poster\" value. If it is the symbol `ask',
668 always query the user whether to use the value. If it is the symbol
669 `use', always use the value."
670 :group 'message-interface
671 :link '(custom-manual "(message)Followup")
672 :type '(choice (const :tag "ignore" nil)
673 (const :tag "use & query" t)
677 (defcustom message-use-mail-followup-to 'use
678 "*Specifies what to do with Mail-Followup-To header.
679 If nil, always ignore the header. If it is the symbol `ask', always
680 query the user whether to use the value. If it is the symbol `use',
681 always use the value."
683 :group 'message-interface
684 :link '(custom-manual "(message)Mailing Lists")
685 :type '(choice (const :tag "ignore" nil)
689 (defcustom message-subscribed-address-functions nil
690 "*Specifies functions for determining list subscription.
691 If nil, do not attempt to determine list subscription with functions.
692 If non-nil, this variable contains a list of functions which return
693 regular expressions to match lists. These functions can be used in
694 conjunction with `message-subscribed-regexps' and
695 `message-subscribed-addresses'."
697 :group 'message-interface
698 :link '(custom-manual "(message)Mailing Lists")
699 :type '(repeat sexp))
701 (defcustom message-subscribed-address-file nil
702 "*A file containing addresses the user is subscribed to.
703 If nil, do not look at any files to determine list subscriptions. If
704 non-nil, each line of this file should be a mailing list address."
706 :group 'message-interface
707 :link '(custom-manual "(message)Mailing Lists")
708 :type '(radio file (const nil)))
710 (defcustom message-subscribed-addresses nil
711 "*Specifies a list of addresses the user is subscribed to.
712 If nil, do not use any predefined list subscriptions. This list of
713 addresses can be used in conjunction with
714 `message-subscribed-address-functions' and `message-subscribed-regexps'."
716 :group 'message-interface
717 :link '(custom-manual "(message)Mailing Lists")
718 :type '(repeat string))
720 (defcustom message-subscribed-regexps nil
721 "*Specifies a list of addresses the user is subscribed to.
722 If nil, do not use any predefined list subscriptions. This list of
723 regular expressions can be used in conjunction with
724 `message-subscribed-address-functions' and `message-subscribed-addresses'."
726 :group 'message-interface
727 :link '(custom-manual "(message)Mailing Lists")
728 :type '(repeat regexp))
730 (defcustom message-allow-no-recipients 'ask
731 "Specifies what to do when there are no recipients other than Gcc/Fcc.
732 If it is the symbol `always', the posting is allowed. If it is the
733 symbol `never', the posting is not allowed. If it is the symbol
734 `ask', you are prompted."
736 :group 'message-interface
737 :link '(custom-manual "(message)Message Headers")
738 :type '(choice (const always)
742 (defcustom message-sendmail-f-is-evil nil
743 "*Non-nil means don't add \"-f username\" to the sendmail command line.
744 Doing so would be even more evil than leaving it out."
745 :group 'message-sending
746 :link '(custom-manual "(message)Mail Variables")
749 (defcustom message-sendmail-envelope-from nil
750 "*Envelope-from when sending mail with sendmail.
751 If this is nil, use `user-mail-address'. If it is the symbol
752 `header', use the From: header of the message."
754 :type '(choice (string :tag "From name")
755 (const :tag "Use From: header from message" header)
756 (const :tag "Use `user-mail-address'" nil))
757 :link '(custom-manual "(message)Mail Variables")
758 :group 'message-sending)
760 ;; qmail-related stuff
761 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
762 "Location of the qmail-inject program."
763 :group 'message-sending
764 :link '(custom-manual "(message)Mail Variables")
767 (defcustom message-qmail-inject-args nil
768 "Arguments passed to qmail-inject programs.
769 This should be a list of strings, one string for each argument. It
770 may also be a function.
772 For e.g., if you wish to set the envelope sender address so that bounces
773 go to the right place or to deal with listserv's usage of that address, you
774 might set this variable to '(\"-f\" \"you@some.where\")."
775 :group 'message-sending
776 :link '(custom-manual "(message)Mail Variables")
777 :type '(choice (function)
781 (defvar gnus-post-method)
782 (defvar gnus-select-method))
783 (defcustom message-post-method
784 (cond ((and (boundp 'gnus-post-method)
785 (listp gnus-post-method)
788 ((boundp 'gnus-select-method)
791 "*Method used to post news.
792 Note that when posting from inside Gnus, for instance, this
793 variable isn't used."
795 :group 'message-sending
796 ;; This should be the `gnus-select-method' widget, but that might
797 ;; create a dependence to `gnus.el'.
800 ;; FIXME: This should be a temporary workaround until someone implements a
801 ;; proper solution. If a crash happens while replying, the auto-save file
802 ;; will *not* have a `References:' header if `message-generate-headers-first'
803 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
804 (defcustom message-generate-headers-first '(references)
805 "Which headers should be generated before starting to compose a message.
806 If t, generate all required headers. This can also be a list of headers to
807 generate. The variables `message-required-news-headers' and
808 `message-required-mail-headers' specify which headers to generate.
810 Note that the variable `message-deletable-headers' specifies headers which
811 are to be deleted and then re-generated before sending, so this variable
812 will not have a visible effect for those headers."
813 :group 'message-headers
814 :link '(custom-manual "(message)Message Headers")
815 :type '(choice (const :tag "None" nil)
816 (const :tag "References" '(references))
818 (repeat (sexp :tag "Header"))))
820 (defcustom message-setup-hook nil
821 "Normal hook, run each time a new outgoing message is initialized.
822 The function `message-setup' runs this hook."
823 :group 'message-various
824 :link '(custom-manual "(message)Various Message Variables")
827 (defcustom message-cancel-hook nil
828 "Hook run when cancelling articles."
829 :group 'message-various
830 :link '(custom-manual "(message)Various Message Variables")
833 (defcustom message-signature-setup-hook nil
834 "Normal hook, run each time a new outgoing message is initialized.
835 It is run after the headers have been inserted and before
836 the signature is inserted."
837 :group 'message-various
838 :link '(custom-manual "(message)Various Message Variables")
841 (defcustom message-mode-hook nil
842 "Hook run in message mode buffers."
843 :group 'message-various
846 (defcustom message-header-hook nil
847 "Hook run in a message mode buffer narrowed to the headers."
848 :group 'message-various
851 (defcustom message-header-setup-hook nil
852 "Hook called narrowed to the headers when setting up a message buffer."
853 :group 'message-various
854 :link '(custom-manual "(message)Various Message Variables")
857 (defcustom message-minibuffer-local-map
858 (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
859 (set-keymap-parent map minibuffer-local-map)
861 "Keymap for `message-read-from-minibuffer'."
863 :group 'message-various)
866 (defcustom message-citation-line-function 'message-insert-citation-line
867 "*Function called to insert the \"Whomever writes:\" line.
869 Note that Gnus provides a feature where the reader can click on
870 `writes:' to hide the cited text. If you change this line too much,
871 people who read your message will have to change their Gnus
872 configuration. See the variable `gnus-cite-attribution-suffix'."
874 :link '(custom-manual "(message)Insertion Variables")
875 :group 'message-insertion)
878 (defcustom message-yank-prefix "> "
879 "*Prefix inserted on the lines of yanked messages.
880 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
881 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
883 :link '(custom-manual "(message)Insertion Variables")
884 :group 'message-insertion)
886 (defcustom message-yank-cited-prefix ">"
887 "*Prefix inserted on cited lines of yanked messages.
888 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
889 See also `message-yank-prefix' and `message-yank-empty-prefix'."
892 :link '(custom-manual "(message)Insertion Variables")
893 :group 'message-insertion)
895 (defcustom message-yank-empty-prefix ">"
896 "*Prefix inserted on empty lines of yanked messages.
897 See also `message-yank-prefix' and `message-yank-cited-prefix'."
900 :link '(custom-manual "(message)Insertion Variables")
901 :group 'message-insertion)
903 (defcustom message-indentation-spaces 3
904 "*Number of spaces to insert at the beginning of each cited line.
905 Used by `message-yank-original' via `message-yank-cite'."
906 :group 'message-insertion
907 :link '(custom-manual "(message)Insertion Variables")
911 (defcustom message-cite-function 'message-cite-original
912 "*Function for citing an original message.
913 Predefined functions include `message-cite-original' and
914 `message-cite-original-without-signature'.
915 Note that these functions use `mail-citation-hook' if that is non-nil."
916 :type '(radio (function-item message-cite-original)
917 (function-item message-cite-original-without-signature)
918 (function-item sc-cite-original)
919 (function :tag "Other"))
920 :link '(custom-manual "(message)Insertion Variables")
921 :group 'message-insertion)
924 (defcustom message-indent-citation-function 'message-indent-citation
925 "*Function for modifying a citation just inserted in the mail buffer.
926 This can also be a list of functions. Each function can find the
927 citation between (point) and (mark t). And each function should leave
928 point and mark around the citation text as modified."
930 :link '(custom-manual "(message)Insertion Variables")
931 :group 'message-insertion)
934 (defcustom message-signature t
935 "*String to be inserted at the end of the message buffer.
936 If t, the `message-signature-file' file will be inserted instead.
937 If a function, the result from the function will be used instead.
938 If a form, the result from the form will be used instead."
940 :link '(custom-manual "(message)Insertion Variables")
941 :group 'message-insertion)
944 (defcustom message-signature-file "~/.signature"
945 "*Name of file containing the text inserted at end of message buffer.
946 Ignored if the named file doesn't exist.
947 If nil, don't insert a signature."
948 :type '(choice file (const :tags "None" nil))
949 :link '(custom-manual "(message)Insertion Variables")
950 :group 'message-insertion)
953 (defcustom message-signature-insert-empty-line t
954 "*If non-nil, insert an empty line before the signature separator."
957 :link '(custom-manual "(message)Insertion Variables")
958 :group 'message-insertion)
960 (defcustom message-distribution-function nil
961 "*Function called to return a Distribution header."
963 :group 'message-headers
964 :link '(custom-manual "(message)News Headers")
965 :type '(choice function (const nil)))
967 (defcustom message-expires 14
968 "Number of days before your article expires."
970 :group 'message-headers
971 :link '(custom-manual "(message)News Headers")
974 (defcustom message-user-path nil
975 "If nil, use the NNTP server name in the Path header.
976 If stringp, use this; if non-nil, use no host name (user name only)."
978 :group 'message-headers
979 :link '(custom-manual "(message)News Headers")
980 :type '(choice (const :tag "nntp" nil)
982 (sexp :tag "none" :format "%t" t)))
984 (defvar message-reply-buffer nil)
985 (defvar message-reply-headers nil
986 "The headers of the current replied article.
987 It is a vector of the following headers:
988 \[number subject from date id references chars lines xref extra].")
989 (defvar message-newsreader nil)
990 (defvar message-mailer nil)
991 (defvar message-sent-message-via nil)
992 (defvar message-checksum nil)
993 (defvar message-send-actions nil
994 "A list of actions to be performed upon successful sending of a message.")
995 (defvar message-exit-actions nil
996 "A list of actions to be performed upon exiting after sending a message.")
997 (defvar message-kill-actions nil
998 "A list of actions to be performed before killing a message buffer.")
999 (defvar message-postpone-actions nil
1000 "A list of actions to be performed after postponing a message.")
1002 (define-widget 'message-header-lines 'text
1003 "All header lines must be LFD terminated."
1004 :format "%{%t%}:%n%v"
1005 :valid-regexp "^\\'"
1006 :error "All header lines must be newline terminated")
1008 (defcustom message-default-headers ""
1009 "*A string containing header lines to be inserted in outgoing messages.
1010 It is inserted before you edit the message, so you can edit or delete
1012 :group 'message-headers
1013 :link '(custom-manual "(message)Message Headers")
1014 :type 'message-header-lines)
1016 (defcustom message-default-mail-headers ""
1017 "*A string of header lines to be inserted in outgoing mails."
1018 :group 'message-headers
1019 :group 'message-mail
1020 :link '(custom-manual "(message)Mail Headers")
1021 :type 'message-header-lines)
1023 (defcustom message-default-news-headers ""
1024 "*A string of header lines to be inserted in outgoing news articles."
1025 :group 'message-headers
1026 :group 'message-news
1027 :link '(custom-manual "(message)News Headers")
1028 :type 'message-header-lines)
1030 ;; Note: could use /usr/ucb/mail instead of sendmail;
1031 ;; options -t, and -v if not interactive.
1032 (defcustom message-mailer-swallows-blank-line
1033 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1034 system-configuration)
1035 (file-readable-p "/etc/sendmail.cf")
1036 (let ((buffer (get-buffer-create " *temp*")))
1040 (insert-file-contents "/etc/sendmail.cf")
1041 (goto-char (point-min))
1042 (let ((case-fold-search nil))
1043 (re-search-forward "^OR\\>" nil t)))
1044 (kill-buffer buffer))))
1045 ;; According to RFC822, "The field-name must be composed of printable
1046 ;; ASCII characters (i. e., characters that have decimal values between
1047 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1049 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1050 "*Set this non-nil if the system's mailer runs the header and body together.
1051 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1052 The value should be an expression to test whether the problem will
1054 :group 'message-sending
1055 :link '(custom-manual "(message)Mail Variables")
1059 (define-mail-user-agent 'message-user-agent
1060 'message-mail 'message-send-and-exit
1061 'message-kill-buffer 'message-send-hook)
1063 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
1064 "If non-nil, delete the deletable headers before feeding to mh.")
1066 (defvar message-send-method-alist
1067 '((news message-news-p message-send-via-news)
1068 (mail message-mail-p message-send-via-mail))
1069 "Alist of ways to send outgoing messages.
1070 Each element has the form
1072 \(TYPE PREDICATE FUNCTION)
1074 where TYPE is a symbol that names the method; PREDICATE is a function
1075 called without any parameters to determine whether the message is
1076 a message of type TYPE; and FUNCTION is a function to be called if
1077 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1080 (defcustom message-mail-alias-type 'abbrev
1081 "*What alias expansion type to use in Message buffers.
1082 The default is `abbrev', which uses mailabbrev. nil switches
1085 :link '(custom-manual "(message)Mail Aliases")
1086 :type '(choice (const :tag "Use Mailabbrev" abbrev)
1087 (const :tag "No expansion" nil)))
1089 (defcustom message-auto-save-directory
1090 (file-name-as-directory (nnheader-concat message-directory "drafts"))
1091 "*Directory where Message auto-saves buffers if Gnus isn't running.
1092 If nil, Message won't auto-save."
1093 :group 'message-buffers
1094 :link '(custom-manual "(message)Various Message Variables")
1095 :type '(choice directory (const :tag "Don't auto-save" nil)))
1097 (defcustom message-default-charset
1098 (and (not (mm-multibyte-p)) 'iso-8859-1)
1099 "Default charset used in non-MULE Emacsen.
1100 If nil, you might be asked to input the charset."
1103 :link '(custom-manual "(message)Various Message Variables")
1106 (defcustom message-dont-reply-to-names
1107 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1108 "*A regexp specifying addresses to prune when doing wide replies.
1109 A value of nil means exclude your own user name only."
1112 :link '(custom-manual "(message)Wide Reply")
1113 :type '(choice (const :tag "Yourself" nil)
1116 (defvar message-shoot-gnksa-feet nil
1117 "*A list of GNKSA feet you are allowed to shoot.
1118 Gnus gives you all the opportunity you could possibly want for
1119 shooting yourself in the foot. Also, Gnus allows you to shoot the
1120 feet of Good Net-Keeping Seal of Approval. The following are foot
1122 `empty-article' Allow you to post an empty article;
1123 `quoted-text-only' Allow you to post quoted text only;
1124 `multiple-copies' Allow you to post multiple copies;
1125 `cancel-messages' Allow you to cancel or supersede messages from
1126 your other email addresses.")
1128 (defsubst message-gnksa-enable-p (feature)
1129 (or (not (listp message-shoot-gnksa-feet))
1130 (memq feature message-shoot-gnksa-feet)))
1132 (defcustom message-hidden-headers "^References:"
1133 "Regexp of headers to be hidden when composing new messages.
1134 This can also be a list of regexps to match headers. Or a list
1135 starting with `not' and followed by regexps."
1138 :link '(custom-manual "(message)Message Headers")
1140 :format "%{%t%}: %[Value Type%] %v"
1141 (regexp :menu-tag "regexp" :format "regexp\n%t: %v")
1142 (repeat :menu-tag "(regexp ...)" :format "(regexp ...)\n%v%i"
1143 (regexp :format "%t: %v"))
1144 (cons :menu-tag "(not regexp ...)" :format "(not regexp ...)\n%v"
1146 (repeat :format "%v%i"
1147 (regexp :format "%t: %v")))))
1149 (defcustom message-cite-articles-with-x-no-archive t
1150 "If non-nil, cite text from articles that has X-No-Archive set."
1154 ;;; Internal variables.
1155 ;;; Well, not really internal.
1157 (defvar message-mode-syntax-table
1158 (let ((table (copy-syntax-table text-mode-syntax-table)))
1159 (modify-syntax-entry ?% ". " table)
1160 (modify-syntax-entry ?> ". " table)
1161 (modify-syntax-entry ?< ". " table)
1163 "Syntax table used while in Message mode.")
1165 (defface message-header-to
1168 (:foreground "green2" :bold t))
1171 (:foreground "MidnightBlue" :bold t))
1173 (:bold t :italic t)))
1174 "Face used for displaying From headers."
1175 :group 'message-faces)
1176 ;; backward-compatibility alias
1177 (put 'message-header-to-face 'face-alias 'message-header-to)
1179 (defface message-header-cc
1182 (:foreground "green4" :bold t))
1185 (:foreground "MidnightBlue"))
1188 "Face used for displaying Cc headers."
1189 :group 'message-faces)
1190 ;; backward-compatibility alias
1191 (put 'message-header-cc-face 'face-alias 'message-header-cc)
1193 (defface message-header-subject
1196 (:foreground "green3"))
1199 (:foreground "navy blue" :bold t))
1202 "Face used for displaying subject headers."
1203 :group 'message-faces)
1204 ;; backward-compatibility alias
1205 (put 'message-header-subject-face 'face-alias 'message-header-subject)
1207 (defface message-header-newsgroups
1210 (:foreground "yellow" :bold t :italic t))
1213 (:foreground "blue4" :bold t :italic t))
1215 (:bold t :italic t)))
1216 "Face used for displaying newsgroups headers."
1217 :group 'message-faces)
1218 ;; backward-compatibility alias
1219 (put 'message-header-newsgroups-face 'face-alias 'message-header-newsgroups)
1221 (defface message-header-other
1224 (:foreground "#b00000"))
1227 (:foreground "steel blue"))
1229 (:bold t :italic t)))
1230 "Face used for displaying newsgroups headers."
1231 :group 'message-faces)
1232 ;; backward-compatibility alias
1233 (put 'message-header-other-face 'face-alias 'message-header-other)
1235 (defface message-header-name
1238 (:foreground "DarkGreen"))
1241 (:foreground "cornflower blue"))
1244 "Face used for displaying header names."
1245 :group 'message-faces)
1246 ;; backward-compatibility alias
1247 (put 'message-header-name-face 'face-alias 'message-header-name)
1249 (defface message-header-xheader
1252 (:foreground "blue"))
1255 (:foreground "blue"))
1258 "Face used for displaying X-Header headers."
1259 :group 'message-faces)
1260 ;; backward-compatibility alias
1261 (put 'message-header-xheader-face 'face-alias 'message-header-xheader)
1263 (defface message-separator
1266 (:foreground "blue3"))
1269 (:foreground "brown"))
1272 "Face used for displaying the separator."
1273 :group 'message-faces)
1274 ;; backward-compatibility alias
1275 (put 'message-separator-face 'face-alias 'message-separator)
1277 (defface message-cited-text
1280 (:foreground "red"))
1283 (:foreground "red"))
1286 "Face used for displaying cited text names."
1287 :group 'message-faces)
1288 ;; backward-compatibility alias
1289 (put 'message-cited-text-face 'face-alias 'message-cited-text)
1291 (defface message-mml
1294 (:foreground "ForestGreen"))
1297 (:foreground "ForestGreen"))
1300 "Face used for displaying MML."
1301 :group 'message-faces)
1302 ;; backward-compatibility alias
1303 (put 'message-mml-face 'face-alias 'message-mml)
1305 (defun message-font-lock-make-header-matcher (regexp)
1308 (let ((start (point)))
1311 (goto-char (point-min))
1312 (if (re-search-forward
1313 (concat "^" (regexp-quote mail-header-separator) "$")
1315 (setq limit (min limit (match-beginning 0))))
1317 (and (< start limit)
1318 (re-search-forward ,regexp limit t))))))
1319 (if (featurep 'bytecomp)
1323 (defvar message-font-lock-keywords
1324 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1325 `((,(message-font-lock-make-header-matcher
1326 (concat "^\\([Tt]o:\\)" content))
1327 (1 'message-header-name)
1328 (2 'message-header-to nil t))
1329 (,(message-font-lock-make-header-matcher
1330 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content))
1331 (1 'message-header-name)
1332 (2 'message-header-cc nil t))
1333 (,(message-font-lock-make-header-matcher
1334 (concat "^\\([Ss]ubject:\\)" content))
1335 (1 'message-header-name)
1336 (2 'message-header-subject nil t))
1337 (,(message-font-lock-make-header-matcher
1338 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content))
1339 (1 'message-header-name)
1340 (2 'message-header-newsgroups nil t))
1341 (,(message-font-lock-make-header-matcher
1342 (concat "^\\([A-Z][^: \n\t]+:\\)" content))
1343 (1 'message-header-name)
1344 (2 'message-header-other nil t))
1345 (,(message-font-lock-make-header-matcher
1346 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content))
1347 (1 'message-header-name)
1348 (2 'message-header-name))
1349 ,@(if (and mail-header-separator
1350 (not (equal mail-header-separator "")))
1351 `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
1352 1 'message-separator))
1355 (re-search-forward (concat "^\\("
1356 message-cite-prefix-regexp
1359 (0 'message-cited-text))
1360 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1362 "Additional expressions to highlight in Message mode.")
1365 ;; XEmacs does it like this. For Emacs, we have to set the
1366 ;; `font-lock-defaults' buffer-local variable.
1367 (put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
1369 (defvar message-face-alist
1370 '((bold . bold-region)
1371 (underline . underline-region)
1372 (default . (lambda (b e)
1374 (ununderline-region b e))))
1375 "Alist of mail and news faces for facemenu.
1376 The cdr of each entry is a function for applying the face to a region.")
1378 (defcustom message-send-hook nil
1379 "Hook run before sending messages.
1380 This hook is run quite early when sending."
1381 :group 'message-various
1382 :options '(ispell-message)
1383 :link '(custom-manual "(message)Various Message Variables")
1386 (defcustom message-send-mail-hook nil
1387 "Hook run before sending mail messages.
1388 This hook is run very late -- just before the message is sent as
1390 :group 'message-various
1391 :link '(custom-manual "(message)Various Message Variables")
1394 (defcustom message-send-news-hook nil
1395 "Hook run before sending news messages.
1396 This hook is run very late -- just before the message is sent as
1398 :group 'message-various
1399 :link '(custom-manual "(message)Various Message Variables")
1402 (defcustom message-sent-hook nil
1403 "Hook run after sending messages."
1404 :group 'message-various
1407 (defvar message-send-coding-system 'binary
1408 "Coding system to encode outgoing mail.")
1410 (defvar message-draft-coding-system
1411 mm-auto-save-coding-system
1412 "*Coding system to compose mail.
1413 If you'd like to make it possible to share draft files between XEmacs
1414 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1415 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1417 (defcustom message-send-mail-partially-limit 1000000
1418 "The limitation of messages sent as message/partial.
1419 The lower bound of message size in characters, beyond which the message
1420 should be sent in several parts. If it is nil, the size is unlimited."
1422 :group 'message-buffers
1423 :link '(custom-manual "(message)Mail Variables")
1424 :type '(choice (const :tag "unlimited" nil)
1427 (defcustom message-alternative-emails nil
1428 "A regexp to match the alternative email addresses.
1429 The first matched address (not primary one) is used in the From field."
1430 :group 'message-headers
1431 :link '(custom-manual "(message)Message Headers")
1432 :type '(choice (const :tag "Always use primary" nil)
1435 (defcustom message-hierarchical-addresses nil
1436 "A list of hierarchical mail address definitions.
1438 Inside each entry, the first address is the \"top\" address, and
1439 subsequent addresses are subaddresses; this is used to indicate that
1440 mail sent to the first address will automatically be delivered to the
1441 subaddresses. So if the first address appears in the recipient list
1442 for a message, the subaddresses will be removed (if present) before
1443 the mail is sent. All addresses in this structure should be
1446 :group 'message-headers
1447 :type '(repeat (repeat string)))
1449 (defcustom message-mail-user-agent nil
1450 "Like `mail-user-agent'.
1451 Except if it is nil, use Gnus native MUA; if it is t, use
1454 :type '(radio (const :tag "Gnus native"
1457 (const :tag "`mail-user-agent'"
1460 (function-item :tag "Default Emacs mail"
1462 sendmail-user-agent)
1463 (function-item :tag "Emacs interface to MH"
1466 (function :tag "Other"))
1470 (defcustom message-wide-reply-confirm-recipients nil
1471 "Whether to confirm a wide reply to multiple email recipients.
1472 If this variable is nil, don't ask whether to reply to all recipients.
1473 If this variable is non-nil, pose the question \"Reply to all
1474 recipients?\" before a wide reply to multiple recipients. If the user
1475 answers yes, reply to all recipients as usual. If the user answers
1476 no, only reply back to the author."
1478 :group 'message-headers
1479 :link '(custom-manual "(message)Wide Reply")
1482 (defcustom message-user-fqdn nil
1483 "*Domain part of Message-Ids."
1485 :group 'message-headers
1486 :link '(custom-manual "(message)News Headers")
1487 :type '(radio (const :format "%v " nil)
1488 (string :format "FQDN: %v")))
1490 (defcustom message-use-idna (and (condition-case nil (require 'idna)
1492 (mm-coding-system-p 'utf-8)
1493 (executable-find idna-program)
1495 "Whether to encode non-ASCII in domain names into ASCII according to IDNA."
1497 :group 'message-headers
1498 :link '(custom-manual "(message)IDNA")
1499 :type '(choice (const :tag "Ask" ask)
1500 (const :tag "Never" nil)
1501 (const :tag "Always" t)))
1503 (defcustom message-generate-hashcash nil
1504 "*Whether to generate X-Hashcash: headers.
1505 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1506 :group 'message-headers
1507 :link '(custom-manual "(message)Mail Headers")
1510 ;;; Internal variables.
1512 (defvar message-sending-message "Sending...")
1513 (defvar message-buffer-list nil)
1514 (defvar message-this-is-news nil)
1515 (defvar message-this-is-mail nil)
1516 (defvar message-draft-article nil)
1517 (defvar message-mime-part nil)
1518 (defvar message-posting-charset nil)
1519 (defvar message-inserted-headers nil)
1521 ;; Byte-compiler warning
1523 (defvar gnus-active-hashtb)
1524 (defvar gnus-read-active-file))
1526 ;;; Regexp matching the delimiter of messages in UNIX mail format
1527 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1528 ;;; of rmail.el's rmail-unix-mail-delimiter.
1529 (defvar message-unix-mail-delimiter
1530 (let ((time-zone-regexp
1531 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1532 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1538 ;; Many things can happen to an RFC 822 mailbox before it is put into
1539 ;; a `From' line. The leading phrase can be stripped, e.g.
1540 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1541 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1542 ;; can be removed, e.g.
1543 ;; From: joe@y.z (Joe K
1545 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1548 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1549 ;; The mailbox can be removed or be replaced by white space, e.g.
1550 ;; From: "Joe User"{space}{tab}
1552 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1553 ;; where {space} and {tab} represent the Ascii space and tab characters.
1554 ;; We want to match the results of any of these manglings.
1555 ;; The following regexp rejects names whose first characters are
1556 ;; obviously bogus, but after that anything goes.
1557 "\\([^\0-\b\n-\r\^?].*\\)?"
1559 ;; The time the message was sent.
1560 "\\([^\0-\r \^?]+\\) +" ; day of the week
1561 "\\([^\0-\r \^?]+\\) +" ; month
1562 "\\([0-3]?[0-9]\\) +" ; day of month
1563 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1565 ;; Perhaps a time zone, specified by an abbreviation, or by a
1570 " \\([0-9][0-9]+\\) *"
1572 ;; On some systems the time zone can appear after the year, too.
1576 "\\(remote from .*\\)?"
1579 "Regexp matching the delimiter of messages in UNIX mail format.")
1581 (defvar message-unsent-separator
1582 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1583 "^ *---+ +Returned message +---+ *$\\|"
1584 "^Start of returned message$\\|"
1585 "^ *---+ +Original message +---+ *$\\|"
1586 "^ *--+ +begin message +--+ *$\\|"
1587 "^ *---+ +Original message follows +---+ *$\\|"
1588 "^ *---+ +Undelivered message follows +---+ *$\\|"
1589 "^|? *---+ +Message text follows: +---+ *|?$")
1590 "A regexp that matches the separator before the text of a failed message.")
1592 (defvar message-field-fillers
1593 '((To message-fill-field-address)
1594 (Cc message-fill-field-address)
1595 (From message-fill-field-address))
1596 "Alist of header names/filler functions.")
1598 (defvar message-header-format-alist
1613 (References . message-shorten-references)
1615 "Alist used for formatting headers.")
1617 (defvar message-options nil
1618 "Some saved answers when sending message.")
1620 (defvar message-send-mail-real-function nil
1621 "Internal send mail function.")
1623 (defvar message-bogus-system-names "^localhost\\."
1624 "The regexp of bogus system names.")
1626 (defcustom message-valid-fqdn-regexp
1627 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1629 "\\([a-z][a-z]" ;; two letter country TDLs
1630 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
1631 "\\|aero\\|coop\\|info\\|name\\|museum"
1632 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
1634 "Regular expression that matches a valid FQDN."
1635 ;; see also: gnus-button-valid-fqdn-regexp
1637 :group 'message-headers
1641 (autoload 'gnus-alive-p "gnus-util")
1642 (autoload 'gnus-delay-article "gnus-delay")
1643 (autoload 'gnus-extract-address-components "gnus-util")
1644 (autoload 'gnus-find-method-for-group "gnus")
1645 (autoload 'gnus-group-decoded-name "gnus-group")
1646 (autoload 'gnus-group-name-charset "gnus-group")
1647 (autoload 'gnus-group-name-decode "gnus-group")
1648 (autoload 'gnus-groups-from-server "gnus")
1649 (autoload 'gnus-make-local-hook "gnus-util")
1650 (autoload 'gnus-open-server "gnus-int")
1651 (autoload 'gnus-output-to-mail "gnus-util")
1652 (autoload 'gnus-output-to-rmail "gnus-util")
1653 (autoload 'gnus-request-post "gnus-int")
1654 (autoload 'gnus-server-string "gnus")
1655 (autoload 'idna-to-ascii "idna")
1656 (autoload 'message-setup-toolbar "messagexmas")
1657 (autoload 'mh-new-draft-name "mh-comp")
1658 (autoload 'mh-send-letter "mh-comp")
1659 (autoload 'nndraft-request-associate-buffer "nndraft")
1660 (autoload 'nndraft-request-expire-articles "nndraft")
1661 (autoload 'nnvirtual-find-group-art "nnvirtual")
1662 (autoload 'rmail-dont-reply-to "mail-utils")
1663 (autoload 'rmail-msg-is-pruned "rmail")
1664 (autoload 'rmail-msg-restore-non-pruned-header "rmail")
1665 (autoload 'rmail-output "rmailout"))
1670 ;;; Utility functions.
1673 (defmacro message-y-or-n-p (question show &rest text)
1674 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1675 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
1677 (defmacro message-delete-line (&optional n)
1678 "Delete the current line (and the next N lines)."
1679 `(delete-region (progn (beginning-of-line) (point))
1680 (progn (forward-line ,(or n 1)) (point))))
1682 (defun message-mark-active-p ()
1683 "Non-nil means the mark and region are currently active in this buffer."
1686 (defun message-unquote-tokens (elems)
1687 "Remove double quotes (\") from strings in list ELEMS."
1688 (mapcar (lambda (item)
1689 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item)
1690 (setq item (concat (match-string 1 item)
1691 (match-string 2 item))))
1695 (defun message-tokenize-header (header &optional separator)
1696 "Split HEADER into a list of header elements.
1697 SEPARATOR is a string of characters to be used as separators. \",\"
1698 is used by default."
1701 (let ((regexp (format "[%s]+" (or separator ",")))
1703 beg quoted elems paren)
1705 (mm-enable-multibyte)
1706 (setq beg (point-min))
1708 (goto-char (point-min))
1713 (cond ((and (> (point) beg)
1715 (and (looking-at regexp)
1718 (push (buffer-substring beg (point)) elems)
1719 (setq beg (match-end 0)))
1720 ((eq (char-after) ?\")
1721 (setq quoted (not quoted)))
1722 ((and (eq (char-after) ?\()
1725 ((and (eq (char-after) ?\))
1728 (nreverse elems)))))
1730 (defun message-mail-file-mbox-p (file)
1731 "Say whether FILE looks like a Unix mbox file."
1732 (when (and (file-exists-p file)
1733 (file-readable-p file)
1734 (file-regular-p file))
1736 (nnheader-insert-file-contents file)
1737 (goto-char (point-min))
1738 (looking-at message-unix-mail-delimiter))))
1740 (defun message-fetch-field (header &optional not-all)
1741 "The same as `mail-fetch-field', only remove all newlines.
1742 The buffer is expected to be narrowed to just the header of the message;
1743 see `message-narrow-to-headers-or-head'."
1744 (let* ((inhibit-point-motion-hooks t)
1745 (value (mail-fetch-field header nil (not not-all))))
1747 (while (string-match "\n[\t ]+" value)
1748 (setq value (replace-match " " t t value)))
1751 (defun message-field-value (header &optional not-all)
1752 "The same as `message-fetch-field', only narrow to the headers first."
1755 (message-narrow-to-headers-or-head)
1756 (message-fetch-field header not-all))))
1758 (defun message-narrow-to-field ()
1759 "Narrow the buffer to the header on the current line."
1761 (while (looking-at "[ \t]")
1767 (if (re-search-forward "^[^ \n\t]" nil t)
1770 (goto-char (point-min)))
1772 (defun message-add-header (&rest headers)
1773 "Add the HEADERS to the message header, skipping those already present."
1776 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers))
1777 (error "Invalid header `%s'" (car headers)))
1778 (setq hclean (match-string 1 (car headers)))
1780 (message-narrow-to-headers)
1781 (unless (re-search-forward (concat "^" (regexp-quote hclean) ":") nil t)
1782 (goto-char (point-max))
1783 (if (string-match "\n$" (car headers))
1784 (insert (car headers))
1785 (insert (car headers) ?\n)))))
1786 (setq headers (cdr headers))))
1788 (defmacro message-with-reply-buffer (&rest forms)
1789 "Evaluate FORMS in the reply buffer, if it exists."
1790 `(when (and message-reply-buffer
1791 (buffer-name message-reply-buffer))
1793 (set-buffer message-reply-buffer)
1796 (put 'message-with-reply-buffer 'lisp-indent-function 0)
1797 (put 'message-with-reply-buffer 'edebug-form-spec '(body))
1799 (defun message-fetch-reply-field (header)
1800 "Fetch field HEADER from the message we're replying to."
1801 (message-with-reply-buffer
1803 (mail-narrow-to-head)
1804 (message-fetch-field header))))
1806 (defun message-strip-list-identifiers (subject)
1807 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
1808 (require 'gnus-sum) ; for gnus-list-identifiers
1809 (let ((regexp (if (stringp gnus-list-identifiers)
1810 gnus-list-identifiers
1811 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1812 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
1813 " *\\)\\)+\\(Re: +\\)?\\)") subject)
1814 (concat (substring subject 0 (match-beginning 1))
1815 (or (match-string 3 subject)
1816 (match-string 5 subject))
1821 (defun message-strip-subject-re (subject)
1822 "Remove \"Re:\" from subject lines in string SUBJECT."
1823 (if (string-match message-subject-re-regexp subject)
1824 (substring subject (match-end 0))
1827 ;;; Start of functions adopted from `message-utils.el'.
1829 (defun message-strip-subject-trailing-was (subject)
1830 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
1831 Leading \"Re: \" is not stripped by this function. Use the function
1832 `message-strip-subject-re' for this."
1833 (let* ((query message-subject-trailing-was-query)
1838 message-subject-trailing-was-ask-regexp
1839 message-subject-trailing-was-regexp)
1842 (setq new (substring subject 0 (match-beginning 0))))
1843 (if (or (not found) (eq query nil))
1846 (if (message-y-or-n-p
1847 "Strip `(was: <old subject>)' in subject? " t
1849 "Strip `(was: <old subject>)' in subject "
1850 "and use the new one instead?\n\n"
1851 "Current subject is: \""
1853 "New subject would be: \""
1855 "See the variable `message-subject-trailing-was-query' "
1856 "to get rid of this query."
1861 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
1864 (defun message-change-subject (new-subject)
1865 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
1866 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged>
1869 (read-from-minibuffer "New subject: ")))
1870 (cond ((and (not (or (null new-subject) ; new subject not empty
1871 (zerop (string-width new-subject))
1872 (string-match "^[ \t]*$" new-subject))))
1876 (message-narrow-to-headers)
1877 (message-fetch-field "Subject"))))
1878 (cond ((not old-subject)
1879 (error "No current subject"))
1882 (regexp-quote new-subject)
1884 old-subject)) ; yes, it really is a new subject
1885 ;; delete eventual Re: prefix
1887 (message-strip-subject-re old-subject))
1888 (message-goto-subject)
1889 (message-delete-line)
1890 (insert (concat "Subject: "
1893 old-subject ")\n")))))))))
1896 (defun message-mark-inserted-region (beg end)
1897 "Mark some region in the current article with enclosing tags.
1898 See `message-mark-insert-begin' and `message-mark-insert-end'."
1901 ;; add to the end of the region first, otherwise end would be invalid
1903 (insert message-mark-insert-end)
1905 (insert message-mark-insert-begin)))
1908 (defun message-mark-insert-file (file)
1909 "Insert FILE at point, marking it with enclosing tags.
1910 See `message-mark-insert-begin' and `message-mark-insert-end'."
1911 (interactive "fFile to insert: ")
1912 ;; reverse insertion to get correct result.
1914 (insert message-mark-insert-end)
1916 (insert-file-contents file)
1918 (insert message-mark-insert-begin)))
1921 (defun message-add-archive-header ()
1922 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
1923 The note can be customized using `message-archive-note'. When called with a
1924 prefix argument, ask for a text to insert. If you don't want the note in the
1925 body, set `message-archive-note' to nil."
1927 (if current-prefix-arg
1928 (setq message-archive-note
1929 (read-from-minibuffer "Reason for No-Archive: "
1930 (cons message-archive-note 0))))
1932 (if (message-goto-signature)
1933 (re-search-backward message-signature-separator))
1934 (when message-archive-note
1935 (insert message-archive-note)
1937 (message-add-header message-archive-header)
1938 (message-sort-headers)))
1941 (defun message-cross-post-followup-to-header (target-group)
1942 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
1943 With prefix-argument just set Follow-Up, don't cross-post."
1945 (list ; Completion based on Gnus
1946 (completing-read "Followup To: "
1947 (if (boundp 'gnus-newsrc-alist)
1949 nil nil '("poster" . 0)
1950 (if (boundp 'gnus-group-history)
1951 'gnus-group-history))))
1952 (message-remove-header "Follow[Uu]p-[Tt]o" t)
1953 (message-goto-newsgroups)
1955 ;; if we already did a crosspost before, kill old target
1956 (if (and message-cross-post-old-target
1958 (regexp-quote (concat "," message-cross-post-old-target))
1961 ;; unless (followup is to poster or user explicitly asked not
1962 ;; to cross-post, or target-group is already in Newsgroups)
1963 ;; add target-group to Newsgroups line.
1965 ;; def: cross-post, req:no
1966 (and message-cross-post-default (not current-prefix-arg))
1967 ;; def: no-cross-post, req:yes
1968 (and (not message-cross-post-default) current-prefix-arg))
1969 (not (string-match "poster" target-group))
1970 (not (string-match (regexp-quote target-group)
1971 (message-fetch-field "Newsgroups"))))
1973 (insert (concat "," target-group))))
1974 (end-of-line) ; ensure Followup: comes after Newsgroups:
1975 ;; unless new followup would be identical to Newsgroups line
1976 ;; make a new Followup-To line
1977 (if (not (string-match (concat "^[ \t]*"
1980 (message-fetch-field "Newsgroups")))
1981 (insert (concat "\nFollowup-To: " target-group)))
1982 (setq message-cross-post-old-target target-group))
1985 (defun message-cross-post-insert-note (target-group cross-post in-old
1987 "Insert a in message body note about a set Followup or Crosspost.
1988 If there have been previous notes, delete them. TARGET-GROUP specifies the
1989 group to Followup-To. When CROSS-POST is t, insert note about
1990 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
1991 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
1992 been made to before the user asked for a Crosspost."
1993 ;; start scanning body for previous uses
1994 (message-goto-signature)
1995 (let ((head (re-search-backward
1996 (concat "^" mail-header-separator)
1997 nil t))) ; just search in body
1998 (message-goto-signature)
1999 (while (re-search-backward
2000 (concat "^" (regexp-quote message-cross-post-note) ".*")
2002 (message-delete-line))
2003 (message-goto-signature)
2004 (while (re-search-backward
2005 (concat "^" (regexp-quote message-followup-to-note) ".*")
2007 (message-delete-line))
2009 (if (message-goto-signature)
2010 (re-search-backward message-signature-separator))
2013 (string-match "^[ \t]*poster[ \t]*$" target-group))
2014 (insert (concat message-followup-to-note target-group "\n"))
2015 (insert (concat message-cross-post-note target-group "\n")))))
2018 (defun message-cross-post-followup-to (target-group)
2019 "Crossposts message and set Followup-To to TARGET-GROUP.
2020 With prefix-argument just set Follow-Up, don't cross-post."
2022 (list ; Completion based on Gnus
2023 (completing-read "Followup To: "
2024 (if (boundp 'gnus-newsrc-alist)
2026 nil nil '("poster" . 0)
2027 (if (boundp 'gnus-group-history)
2028 'gnus-group-history))))
2029 (cond ((not (or (null target-group) ; new subject not empty
2030 (zerop (string-width target-group))
2031 (string-match "^[ \t]*$" target-group)))
2033 (let* ((old-groups (message-fetch-field "Newsgroups"))
2034 (in-old (string-match
2035 (regexp-quote target-group)
2036 (or old-groups ""))))
2037 ;; check whether target exactly matches old Newsgroups
2038 (cond ((not old-groups)
2039 (error "No current newsgroup"))
2043 (regexp-quote target-group)
2046 ;; yes, Newsgroups line must change
2047 (message-cross-post-followup-to-header target-group)
2048 ;; insert note whether we do cross-post or followup-to
2049 (funcall message-cross-post-note-function
2051 (if (or (and message-cross-post-default
2052 (not current-prefix-arg))
2053 (and (not message-cross-post-default)
2054 current-prefix-arg)) t)
2055 in-old old-groups))))))))
2057 ;;; Reduce To: to Cc: or Bcc: header
2060 (defun message-reduce-to-to-cc ()
2061 "Replace contents of To: header with contents of Cc: or Bcc: header."
2064 (save-restriction (message-narrow-to-headers)
2065 (message-fetch-field "cc")))
2067 (if (and (not cc-content)
2070 (message-narrow-to-headers)
2071 (message-fetch-field "bcc"))))
2076 (message-delete-line)
2077 (insert (concat "To: " cc-content "\n"))
2079 (message-narrow-to-headers)
2080 (message-remove-header (if bcc
2084 ;;; End of functions adopted from `message-utils.el'.
2086 (defun message-remove-header (header &optional is-regexp first reverse)
2087 "Remove HEADER in the narrowed buffer.
2088 If IS-REGEXP, HEADER is a regular expression.
2089 If FIRST, only remove the first instance of the header.
2090 Return the number of headers removed."
2091 (goto-char (point-min))
2092 (let ((regexp (if is-regexp header (concat "^" (regexp-quote header) ":")))
2094 (case-fold-search t)
2096 (while (and (not (eobp))
2099 (not (looking-at regexp))
2100 (looking-at regexp))
2107 ;; There might be a continuation header, so we have to search
2108 ;; until we find a new non-continuation line.
2111 (if (re-search-forward "^[^ \t]" nil t)
2112 (goto-char (match-beginning 0))
2115 (if (re-search-forward "^[^ \t]" nil t)
2116 (goto-char (match-beginning 0))
2117 (goto-char (point-max)))))
2120 (defun message-remove-first-header (header)
2121 "Remove the first instance of HEADER if there is more than one."
2123 (regexp (concat "^" (regexp-quote header) ":")))
2125 (goto-char (point-min))
2126 (while (re-search-forward regexp nil t)
2129 (message-remove-header header nil t)
2132 (defun message-narrow-to-headers ()
2133 "Narrow the buffer to the head of the message."
2136 (goto-char (point-min))
2137 (if (re-search-forward
2138 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
2141 (goto-char (point-min)))
2143 (defun message-narrow-to-head-1 ()
2144 "Like `message-narrow-to-head'. Don't widen."
2146 (goto-char (point-min))
2147 (if (search-forward "\n\n" nil 1)
2150 (goto-char (point-min)))
2152 (defun message-narrow-to-head ()
2153 "Narrow the buffer to the head of the message.
2154 Point is left at the beginning of the narrowed-to region."
2156 (message-narrow-to-head-1))
2158 (defun message-narrow-to-headers-or-head ()
2159 "Narrow the buffer to the head of the message."
2162 (goto-char (point-min))
2165 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
2166 (match-beginning 0))
2167 ((search-forward "\n\n" nil t)
2171 (goto-char (point-min)))
2173 (defun message-news-p ()
2174 "Say whether the current buffer contains a news message."
2175 (and (not message-this-is-mail)
2176 (or message-this-is-news
2179 (message-narrow-to-headers)
2180 (and (message-fetch-field "newsgroups")
2181 (not (message-fetch-field "posted-to"))))))))
2183 (defun message-mail-p ()
2184 "Say whether the current buffer contains a mail message."
2185 (and (not message-this-is-news)
2186 (or message-this-is-mail
2189 (message-narrow-to-headers)
2190 (or (message-fetch-field "to")
2191 (message-fetch-field "cc")
2192 (message-fetch-field "bcc")))))))
2194 (defun message-subscribed-p ()
2195 "Say whether we need to insert a MFT header."
2196 (or message-subscribed-regexps
2197 message-subscribed-addresses
2198 message-subscribed-address-file
2199 message-subscribed-address-functions))
2201 (defun message-next-header ()
2202 "Go to the beginning of the next header."
2204 (or (eobp) (forward-char 1))
2205 (not (if (re-search-forward "^[^ \t]" nil t)
2207 (goto-char (point-max)))))
2209 (defun message-sort-headers-1 ()
2210 "Sort the buffer as headers using `message-rank' text props."
2211 (goto-char (point-min))
2214 nil 'message-next-header
2216 (message-next-header)
2220 (or (get-text-property (point) 'message-rank)
2223 (defun message-sort-headers ()
2224 "Sort the headers of the current message according to `message-header-format-alist'."
2228 (let ((max (1+ (length message-header-format-alist)))
2230 (message-narrow-to-headers)
2231 (while (re-search-forward "^[^ \n]+:" nil t)
2233 (match-beginning 0) (1+ (match-beginning 0))
2235 (if (setq rank (length (memq (assq (intern (buffer-substring
2237 (1- (match-end 0))))
2238 message-header-format-alist)
2239 message-header-format-alist)))
2242 (message-sort-headers-1))))
2244 (defun message-kill-address ()
2245 "Kill the address under point."
2247 (let ((start (point)))
2248 (message-skip-to-next-address)
2249 (kill-region start (point))))
2259 (defvar message-mode-map nil)
2261 (unless message-mode-map
2262 (setq message-mode-map (make-keymap))
2263 (set-keymap-parent message-mode-map text-mode-map)
2264 (define-key message-mode-map "\C-c?" 'describe-mode)
2266 (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to)
2267 (define-key message-mode-map "\C-c\C-f\C-o" 'message-goto-from)
2268 (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc)
2269 (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc)
2270 (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc)
2271 (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject)
2272 (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to)
2273 (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups)
2274 (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution)
2275 (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to)
2276 (define-key message-mode-map "\C-c\C-f\C-m" 'message-goto-mail-followup-to)
2277 (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords)
2278 (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary)
2279 (define-key message-mode-map "\C-c\C-f\C-i"
2280 'message-insert-or-toggle-importance)
2281 (define-key message-mode-map "\C-c\C-f\C-a"
2282 'message-generate-unsubscribed-mail-followup-to)
2284 ;; modify headers (and insert notes in body)
2285 (define-key message-mode-map "\C-c\C-fs" 'message-change-subject)
2287 (define-key message-mode-map "\C-c\C-fx" 'message-cross-post-followup-to)
2288 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2289 (define-key message-mode-map "\C-c\C-ft" 'message-reduce-to-to-cc)
2290 (define-key message-mode-map "\C-c\C-fa" 'message-add-archive-header)
2291 ;; mark inserted text
2292 (define-key message-mode-map "\C-c\M-m" 'message-mark-inserted-region)
2293 (define-key message-mode-map "\C-c\M-f" 'message-mark-insert-file)
2295 (define-key message-mode-map "\C-c\C-b" 'message-goto-body)
2296 (define-key message-mode-map "\C-c\C-i" 'message-goto-signature)
2298 (define-key message-mode-map "\C-c\C-t" 'message-insert-to)
2299 (define-key message-mode-map "\C-c\C-fw" 'message-insert-wide-reply)
2300 (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups)
2301 (define-key message-mode-map "\C-c\C-l" 'message-to-list-only)
2303 (define-key message-mode-map "\C-c\C-u" 'message-insert-or-toggle-importance)
2304 (define-key message-mode-map "\C-c\M-n"
2305 'message-insert-disposition-notification-to)
2307 (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
2308 (define-key message-mode-map "\C-c\M-\C-y" 'message-yank-buffer)
2309 (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
2310 (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
2311 (define-key message-mode-map "\C-c\M-h" 'message-insert-headers)
2312 (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
2313 (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
2314 (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
2316 (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit)
2317 (define-key message-mode-map "\C-c\C-s" 'message-send)
2318 (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
2319 (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
2320 (define-key message-mode-map "\C-c\n" 'gnus-delay-article)
2322 (define-key message-mode-map "\C-c\M-k" 'message-kill-address)
2323 (define-key message-mode-map "\C-c\C-e" 'message-elide-region)
2324 (define-key message-mode-map "\C-c\C-v" 'message-delete-not-region)
2325 (define-key message-mode-map "\C-c\C-z" 'message-kill-to-signature)
2326 (define-key message-mode-map "\M-\r" 'message-newline-and-reformat)
2327 (define-key message-mode-map [remap split-line] 'message-split-line)
2329 (define-key message-mode-map "\C-c\C-a" 'mml-attach-file)
2331 (define-key message-mode-map "\C-a" 'message-beginning-of-line)
2332 (define-key message-mode-map "\t" 'message-tab)
2333 (define-key message-mode-map "\M-;" 'comment-region))
2336 message-mode-menu message-mode-map "Message Menu."
2338 ["Yank Original" message-yank-original message-reply-buffer]
2339 ["Fill Yanked Message" message-fill-yanked-message t]
2340 ["Insert Signature" message-insert-signature t]
2341 ["Caesar (rot13) Message" message-caesar-buffer-body t]
2342 ["Caesar (rot13) Region" message-caesar-region (message-mark-active-p)]
2343 ["Elide Region" message-elide-region
2344 :active (message-mark-active-p)
2345 ,@(if (featurep 'xemacs) nil
2346 '(:help "Replace text in region with an ellipsis"))]
2347 ["Delete Outside Region" message-delete-not-region
2348 :active (message-mark-active-p)
2349 ,@(if (featurep 'xemacs) nil
2350 '(:help "Delete all quoted text outside region"))]
2351 ["Kill To Signature" message-kill-to-signature t]
2352 ["Newline and Reformat" message-newline-and-reformat t]
2353 ["Rename buffer" message-rename-buffer t]
2354 ["Spellcheck" ispell-message
2355 ,@(if (featurep 'xemacs) '(t)
2356 '(:help "Spellcheck this message"))]
2358 ["Insert Region Marked" message-mark-inserted-region
2359 :active (message-mark-active-p)
2360 ,@(if (featurep 'xemacs) nil
2361 '(:help "Mark region with enclosing tags"))]
2362 ["Insert File Marked..." message-mark-insert-file
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Insert file at point marked with enclosing tags"))]
2366 ["Send Message" message-send-and-exit
2367 ,@(if (featurep 'xemacs) '(t)
2368 '(:help "Send this message"))]
2369 ["Postpone Message" message-dont-send
2370 ,@(if (featurep 'xemacs) '(t)
2371 '(:help "File this draft message and exit"))]
2372 ["Send at Specific Time..." gnus-delay-article
2373 ,@(if (featurep 'xemacs) '(t)
2374 '(:help "Ask, then arrange to send message at that time"))]
2375 ["Kill Message" message-kill-buffer
2376 ,@(if (featurep 'xemacs) '(t)
2377 '(:help "Delete this message without sending"))]))
2380 message-mode-field-menu message-mode-map ""
2382 ["To" message-goto-to t]
2383 ["From" message-goto-from t]
2384 ["Subject" message-goto-subject t]
2385 ["Change subject..." message-change-subject t]
2386 ["Cc" message-goto-cc t]
2387 ["Bcc" message-goto-bcc t]
2388 ["Fcc" message-goto-fcc t]
2389 ["Reply-To" message-goto-reply-to t]
2390 ["Flag As Important" message-insert-importance-high
2391 ,@(if (featurep 'xemacs) '(t)
2392 '(:help "Mark this message as important"))]
2393 ["Flag As Unimportant" message-insert-importance-low
2394 ,@(if (featurep 'xemacs) '(t)
2395 '(:help "Mark this message as unimportant"))]
2397 message-insert-disposition-notification-to
2398 ,@(if (featurep 'xemacs) '(t)
2399 '(:help "Request a receipt notification"))]
2401 ;; (typical) news stuff
2402 ["Summary" message-goto-summary t]
2403 ["Keywords" message-goto-keywords t]
2404 ["Newsgroups" message-goto-newsgroups t]
2405 ["Fetch Newsgroups" message-insert-newsgroups t]
2406 ["Followup-To" message-goto-followup-to t]
2407 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2408 ["Crosspost / Followup-To..." message-cross-post-followup-to t]
2409 ["Distribution" message-goto-distribution t]
2410 ["X-No-Archive:" message-add-archive-header t ]
2412 ;; (typical) mailing-lists stuff
2413 ["Fetch To" message-insert-to
2414 ,@(if (featurep 'xemacs) '(t)
2415 '(:help "Insert a To header that points to the author."))]
2416 ["Fetch To and Cc" message-insert-wide-reply
2417 ,@(if (featurep 'xemacs) '(t)
2419 "Insert To and Cc headers as if you were doing a wide reply."))]
2421 ["Send to list only" message-to-list-only t]
2422 ["Mail-Followup-To" message-goto-mail-followup-to t]
2423 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2424 ,@(if (featurep 'xemacs) '(t)
2425 '(:help "Insert a reasonable `Mail-Followup-To:' header."))]
2426 ["Reduce To: to Cc:" message-reduce-to-to-cc t]
2428 ["Sort Headers" message-sort-headers t]
2429 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t]
2430 ["Goto Body" message-goto-body t]
2431 ["Goto Signature" message-goto-signature t]))
2433 (defvar message-tool-bar-map nil)
2436 (defvar facemenu-add-face-function)
2437 (defvar facemenu-remove-face-function))
2439 ;;; Forbidden properties
2441 ;; We use `after-change-functions' to keep special text properties
2442 ;; that interfer with the normal function of message mode out of the
2445 (defcustom message-strip-special-text-properties t
2446 "Strip special properties from the message buffer.
2448 Emacs has a number of special text properties which can break message
2449 composing in various ways. If this option is set, message will strip
2450 these properties from the message composition buffer. However, some
2451 packages requires these properties to be present in order to work.
2452 If you use one of these packages, turn this option off, and hope the
2453 message composition doesn't break too bad."
2455 :group 'message-various
2456 :link '(custom-manual "(message)Various Message Variables")
2459 (defconst message-forbidden-properties
2460 ;; No reason this should be clutter up customize. We make it a
2461 ;; property list (rather than a list of property symbols), to be
2462 ;; directly useful for `remove-text-properties'.
2463 '(field nil read-only nil invisible nil intangible nil
2464 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2465 insert-behind-hooks nil point-entered nil point-left nil)
2466 ;; Other special properties:
2467 ;; category, face, display: probably doesn't do any harm.
2468 ;; fontified: is used by font-lock.
2469 ;; syntax-table, local-map: I dunno.
2470 ;; We need to add XEmacs names to the list.
2471 "Property list of with properties forbidden in message buffers.
2472 The values of the properties are ignored, only the property names are used.")
2474 (defun message-tamago-not-in-use-p (pos)
2475 "Return t when tamago version 4 is not in use at the cursor position.
2476 Tamago version 4 is a popular input method for writing Japanese text.
2477 It uses the properties `intangible', `invisible', `modification-hooks'
2478 and `read-only' when translating ascii or kana text to kanji text.
2479 These properties are essential to work, so we should never strip them."
2480 (not (and (boundp 'egg-modefull-mode)
2481 (symbol-value 'egg-modefull-mode)
2482 (or (memq (get-text-property pos 'intangible)
2483 '(its-part-1 its-part-2))
2484 (get-text-property pos 'egg-end)
2485 (get-text-property pos 'egg-lang)
2486 (get-text-property pos 'egg-start)))))
2488 (defun message-strip-forbidden-properties (begin end &optional old-length)
2489 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2490 This function is intended to be called from `after-change-functions'.
2491 See also `message-forbidden-properties'."
2492 (when (and message-strip-special-text-properties
2493 (message-tamago-not-in-use-p begin))
2494 (let ((buffer-read-only nil)
2495 (inhibit-read-only t))
2496 (remove-text-properties begin end message-forbidden-properties))))
2499 (define-derived-mode message-mode text-mode "Message"
2500 "Major mode for editing mail and news to be sent.
2501 Like Text Mode but with these additional commands:\\<message-mode-map>
2502 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2503 C-c C-d Postpone sending the message C-c C-k Kill the message
2504 C-c C-f move to a header field (and create it if there isn't):
2505 C-c C-f C-t move to To C-c C-f C-s move to Subject
2506 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2507 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2508 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2509 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2510 C-c C-f C-o move to From (\"Originator\")
2511 C-c C-f C-f move to Followup-To
2512 C-c C-f C-m move to Mail-Followup-To
2513 C-c C-f C-i cycle through Importance values
2514 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2515 C-c C-f x crossposting with FollowUp-To header and note in body
2516 C-c C-f t replace To: header with contents of Cc: or Bcc:
2517 C-c C-f a Insert X-No-Archive: header and a note in the body
2518 C-c C-t `message-insert-to' (add a To header to a news followup)
2519 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2520 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2521 C-c C-b `message-goto-body' (move to beginning of message text).
2522 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2523 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2524 C-c C-y `message-yank-original' (insert current message, if any).
2525 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2526 C-c C-e `message-elide-region' (elide the text between point and mark).
2527 C-c C-v `message-delete-not-region' (remove the text outside the region).
2528 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2529 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2530 C-c C-a `mml-attach-file' (attach a file as MIME).
2531 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2532 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2533 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2534 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2535 M-RET `message-newline-and-reformat' (break the line and reformat)."
2536 (setq local-abbrev-table text-mode-abbrev-table)
2537 (set (make-local-variable 'message-reply-buffer) nil)
2538 (set (make-local-variable 'message-inserted-headers) nil)
2539 (set (make-local-variable 'message-send-actions) nil)
2540 (set (make-local-variable 'message-exit-actions) nil)
2541 (set (make-local-variable 'message-kill-actions) nil)
2542 (set (make-local-variable 'message-postpone-actions) nil)
2543 (set (make-local-variable 'message-draft-article) nil)
2544 (setq buffer-offer-save t)
2545 (set (make-local-variable 'facemenu-add-face-function)
2547 (let ((face-fun (cdr (assq face message-face-alist))))
2549 (funcall face-fun (point) end)
2550 (error "Face %s not configured for %s mode" face mode-name)))
2552 (set (make-local-variable 'facemenu-remove-face-function) t)
2553 (set (make-local-variable 'message-reply-headers) nil)
2554 (make-local-variable 'message-newsreader)
2555 (make-local-variable 'message-mailer)
2556 (make-local-variable 'message-post-method)
2557 (set (make-local-variable 'message-sent-message-via) nil)
2558 (set (make-local-variable 'message-checksum) nil)
2559 (set (make-local-variable 'message-mime-part) 0)
2560 (message-setup-fill-variables)
2561 ;; Allow using comment commands to add/remove quoting.
2562 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2563 (when message-yank-prefix
2564 (set (make-local-variable 'comment-start) message-yank-prefix)
2565 (set (make-local-variable 'comment-start-skip)
2566 (concat "^" (regexp-quote message-yank-prefix) "[ \t]*")))
2567 (if (featurep 'xemacs)
2568 (message-setup-toolbar)
2569 (set (make-local-variable 'font-lock-defaults)
2570 '(message-font-lock-keywords t))
2571 (if (boundp 'tool-bar-map)
2572 (set (make-local-variable 'tool-bar-map) (message-tool-bar-map))))
2573 (easy-menu-add message-mode-menu message-mode-map)
2574 (easy-menu-add message-mode-field-menu message-mode-map)
2575 (gnus-make-local-hook 'after-change-functions)
2576 ;; Mmmm... Forbidden properties...
2577 (add-hook 'after-change-functions 'message-strip-forbidden-properties
2579 ;; Allow mail alias things.
2580 (when (eq message-mail-alias-type 'abbrev)
2581 (if (fboundp 'mail-abbrevs-setup)
2582 (mail-abbrevs-setup)
2583 (if (fboundp 'mail-aliases-setup) ; warning avoidance
2584 (mail-aliases-setup))))
2585 (unless buffer-file-name
2586 (message-set-auto-save-file-name))
2587 (unless (buffer-base-buffer)
2588 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2589 ;; multibyte is not necessary at all. -- zsh
2590 (mm-enable-multibyte))
2591 (set (make-local-variable 'indent-tabs-mode) nil) ;No tabs for indentation.
2594 (defun message-setup-fill-variables ()
2595 "Setup message fill variables."
2596 (set (make-local-variable 'fill-paragraph-function)
2597 'message-fill-paragraph)
2598 (make-local-variable 'paragraph-separate)
2599 (make-local-variable 'paragraph-start)
2600 (make-local-variable 'adaptive-fill-regexp)
2601 (unless (boundp 'adaptive-fill-first-line-regexp)
2602 (setq adaptive-fill-first-line-regexp nil))
2603 (make-local-variable 'adaptive-fill-first-line-regexp)
2604 (let ((quote-prefix-regexp
2605 ;; User should change message-cite-prefix-regexp if
2606 ;; message-yank-prefix is set to an abnormal value.
2607 (concat "\\(" message-cite-prefix-regexp "\\)[ \t]*")))
2608 (setq paragraph-start
2610 (regexp-quote mail-header-separator) "$\\|"
2611 "[ \t]*$\\|" ; blank lines
2612 "-- $\\|" ; signature delimiter
2613 "---+$\\|" ; delimiters for forwarded messages
2614 page-delimiter "$\\|" ; spoiler warnings
2615 ".*wrote:$\\|" ; attribution lines
2616 quote-prefix-regexp "$\\|" ; empty lines in quoted text
2618 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
2619 (setq paragraph-separate paragraph-start)
2620 (setq adaptive-fill-regexp
2621 (concat quote-prefix-regexp "\\|" adaptive-fill-regexp))
2622 (setq adaptive-fill-first-line-regexp
2623 (concat quote-prefix-regexp "\\|"
2624 adaptive-fill-first-line-regexp)))
2625 (make-local-variable 'auto-fill-inhibit-regexp)
2626 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
2627 (setq auto-fill-inhibit-regexp nil)
2628 (make-local-variable 'normal-auto-fill-function)
2629 (setq normal-auto-fill-function 'message-do-auto-fill)
2630 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
2631 ;; In that case, ensure that it uses the right function. The real
2632 ;; solution would be not to use `define-derived-mode', and run
2633 ;; `text-mode-hook' ourself at the end of the mode.
2634 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
2635 (when auto-fill-function
2636 (setq auto-fill-function normal-auto-fill-function)))
2641 ;;; Message mode commands
2644 ;;; Movement commands
2646 (defun message-goto-to ()
2647 "Move point to the To header."
2649 (message-position-on-field "To"))
2651 (defun message-goto-from ()
2652 "Move point to the From header."
2654 (message-position-on-field "From"))
2656 (defun message-goto-subject ()
2657 "Move point to the Subject header."
2659 (message-position-on-field "Subject"))
2661 (defun message-goto-cc ()
2662 "Move point to the Cc header."
2664 (message-position-on-field "Cc" "To"))
2666 (defun message-goto-bcc ()
2667 "Move point to the Bcc header."
2669 (message-position-on-field "Bcc" "Cc" "To"))
2671 (defun message-goto-fcc ()
2672 "Move point to the Fcc header."
2674 (message-position-on-field "Fcc" "To" "Newsgroups"))
2676 (defun message-goto-reply-to ()
2677 "Move point to the Reply-To header."
2679 (message-position-on-field "Reply-To" "Subject"))
2681 (defun message-goto-newsgroups ()
2682 "Move point to the Newsgroups header."
2684 (message-position-on-field "Newsgroups"))
2686 (defun message-goto-distribution ()
2687 "Move point to the Distribution header."
2689 (message-position-on-field "Distribution"))
2691 (defun message-goto-followup-to ()
2692 "Move point to the Followup-To header."
2694 (message-position-on-field "Followup-To" "Newsgroups"))
2696 (defun message-goto-mail-followup-to ()
2697 "Move point to the Mail-Followup-To header."
2699 (message-position-on-field "Mail-Followup-To" "To"))
2701 (defun message-goto-keywords ()
2702 "Move point to the Keywords header."
2704 (message-position-on-field "Keywords" "Subject"))
2706 (defun message-goto-summary ()
2707 "Move point to the Summary header."
2709 (message-position-on-field "Summary" "Subject"))
2711 (defun message-goto-body (&optional interactivep)
2712 "Move point to the beginning of the message body."
2713 (interactive (list t))
2714 (when (and interactivep
2715 (looking-at "[ \t]*\n"))
2717 (goto-char (point-min))
2718 (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
2719 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t)))
2721 (defun message-goto-eoh ()
2722 "Move point to the end of the headers."
2727 (defun message-goto-signature ()
2728 "Move point to the beginning of the message signature.
2729 If there is no signature in the article, go to the end and
2732 (goto-char (point-min))
2733 (if (re-search-forward message-signature-separator nil t)
2735 (goto-char (point-max))
2738 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc)
2739 "Insert a reasonable MFT header in a post to an unsubscribed list.
2740 When making original posts to a mailing list you are not subscribed to,
2741 you have to type in a MFT header by hand. The contents, usually, are
2742 the addresses of the list and your own address. This function inserts
2743 such a header automatically. It fetches the contents of the To: header
2744 in the current mail buffer, and appends the current `user-mail-address'.
2746 If the optional argument INCLUDE-CC is non-nil, the addresses in the
2747 Cc: header are also put into the MFT."
2752 (message-narrow-to-headers)
2753 (message-remove-header "Mail-Followup-To")
2754 (setq cc (and include-cc (message-fetch-field "Cc")))
2756 (concat (message-fetch-field "To") "," cc)
2757 (message-fetch-field "To"))))
2758 (message-goto-mail-followup-to)
2759 (insert (concat tos ", " user-mail-address))))
2763 (defun message-insert-to (&optional force)
2764 "Insert a To header that points to the author of the article being replied to.
2765 If the original author requested not to be sent mail, don't insert unless the
2766 prefix FORCE is given."
2768 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
2769 (dont (and mct (or (equal (downcase mct) "never")
2770 (equal (downcase mct) "nobody"))))
2771 (to (or (message-fetch-reply-field "mail-reply-to")
2772 (message-fetch-reply-field "reply-to")
2773 (message-fetch-reply-field "from"))))
2777 "Ignoring the user request not to have copies sent via mail"
2778 "Complying with the user request not to have copies sent via mail")))
2779 (when (and force (not to))
2780 (error "No mail address in the article"))
2781 (when (and to (or force (not dont)))
2782 (message-carefully-insert-headers (list (cons 'To to))))))
2784 (defun message-insert-wide-reply ()
2785 "Insert To and Cc headers as if you were doing a wide reply."
2787 (let ((headers (message-with-reply-buffer
2788 (message-get-reply-headers t))))
2789 (message-carefully-insert-headers headers)))
2791 (defcustom message-header-synonyms
2793 "List of lists of header synonyms.
2794 E.g., if this list contains a member list with elements `Cc' and `To',
2795 then `message-carefully-insert-headers' will not insert a `To' header
2796 when the message is already `Cc'ed to the recipient."
2798 :group 'message-headers
2799 :link '(custom-manual "(message)Message Headers")
2800 :type '(repeat sexp))
2802 (defun message-carefully-insert-headers (headers)
2803 "Insert the HEADERS, an alist, into the message buffer.
2804 Does not insert the headers when they are already present there
2805 or in the synonym headers, defined by `message-header-synonyms'."
2806 ;; FIXME: Should compare only the address and not the full name. Comparison
2807 ;; should be done case-folded (and with `string=' rather than
2809 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
2810 (dolist (header headers)
2811 (let* ((header-name (symbol-name (car header)))
2812 (new-header (cdr header))
2813 (synonyms (loop for synonym in message-header-synonyms
2814 when (memq (car header) synonym) return synonym))
2816 (loop for synonym in synonyms
2817 for old-header = (mail-fetch-field (symbol-name synonym))
2818 when (and old-header (string-match new-header old-header))
2821 (message "already have `%s' in `%s'" new-header old-header)
2822 (when (and (message-position-on-field header-name)
2823 (setq old-header (mail-fetch-field header-name))
2824 (not (string-match "\\` *\\'" old-header)))
2826 (insert new-header)))))
2828 (defun message-widen-reply ()
2829 "Widen the reply to include maximum recipients."
2832 (and message-reply-buffer
2833 (buffer-name message-reply-buffer)
2835 (set-buffer message-reply-buffer)
2836 (message-get-reply-headers t)))))
2839 (message-narrow-to-headers)
2840 (dolist (elem follow-to)
2841 (message-remove-header (symbol-name (car elem)))
2842 (goto-char (point-min))
2843 (insert (symbol-name (car elem)) ": "
2844 (cdr elem) "\n"))))))
2846 (defun message-insert-newsgroups ()
2847 "Insert the Newsgroups header from the article being replied to."
2849 (when (and (message-position-on-field "Newsgroups")
2850 (mail-fetch-field "newsgroups")
2851 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
2853 (insert (or (message-fetch-reply-field "newsgroups") "")))
2857 ;;; Various commands
2859 (defun message-delete-not-region (beg end)
2860 "Delete everything in the body of the current message outside of the region."
2865 ;; snarf citation prefix, if appropriate
2866 (unless (eq (point) (progn (beginning-of-line) (point)))
2867 (when (looking-at message-cite-prefix-regexp)
2868 (setq citeprefix (match-string 0))))
2870 (delete-region (point) (if (not (message-goto-signature))
2876 (delete-region beg (progn (message-goto-body)
2880 (insert citeprefix))))
2881 (when (message-goto-signature)
2884 (defun message-kill-to-signature (&optional arg)
2885 "Kill all text up to the signature.
2886 If a numberic argument or prefix arg is given, leave that number
2887 of lines before the signature intact."
2891 (let ((point (point)))
2892 (narrow-to-region point (point-max))
2893 (message-goto-signature)
2895 (if (and arg (numberp arg))
2896 (forward-line (- -1 arg))
2898 (unless (= point (point))
2899 (kill-region point (point))
2903 (defun message-newline-and-reformat (&optional arg not-break)
2904 "Insert four newlines, and then reformat if inside quoted text.
2905 Prefix arg means justify as well."
2906 (interactive (list (if current-prefix-arg 'full)))
2907 (let (quoted point beg end leading-space bolp fill-paragraph-function)
2908 (setq point (point))
2911 (setq bolp (= beg point))
2912 ;; Find first line of the paragraph.
2914 (while (and (not (eobp))
2915 (not (looking-at message-cite-prefix-regexp))
2916 (looking-at paragraph-start))
2919 (when (looking-at message-cite-prefix-regexp)
2920 (setq quoted (match-string 0))
2921 (goto-char (match-end 0))
2922 (looking-at "[ \t]*")
2923 (setq leading-space (match-string 0)))
2927 (< (- point beg) (length quoted)))
2928 ;; break inside the cite prefix.
2934 (while (and (not (eobp))
2935 (not (looking-at paragraph-separate))
2936 (looking-at message-cite-prefix-regexp)
2937 (equal quoted (match-string 0)))
2938 (goto-char (match-end 0))
2939 (looking-at "[ \t]*")
2940 (if (> (length leading-space) (length (match-string 0)))
2941 (setq leading-space (match-string 0)))
2945 (while (and (if (bobp) nil (forward-line -1) t)
2946 (not (looking-at paragraph-start))
2947 (looking-at message-cite-prefix-regexp)
2948 (equal quoted (match-string 0)))
2950 (goto-char (match-end 0))
2951 (looking-at "[ \t]*")
2952 (if (> (length leading-space) (length (match-string 0)))
2953 (setq leading-space (match-string 0)))))
2954 (while (and (not (eobp))
2955 (not (looking-at paragraph-separate))
2956 (not (looking-at message-cite-prefix-regexp)))
2960 (while (and (if (bobp) nil (forward-line -1) t)
2961 (not (looking-at paragraph-start))
2962 (not (looking-at message-cite-prefix-regexp)))
2963 (setq beg (point))))
2966 (narrow-to-region beg end)
2973 (setq point (point))
2974 ;; (newline 2) doesn't mark both newline's as hard, so call
2975 ;; newline twice. -jas
2978 (delete-region (point) (re-search-forward "[ \t]*"))
2979 (when (and quoted (not bolp))
2980 (insert quoted leading-space)))
2983 (let* ((adaptive-fill-regexp
2984 (regexp-quote (concat quoted leading-space)))
2985 (adaptive-fill-first-line-regexp
2986 adaptive-fill-regexp ))
2987 (fill-paragraph arg))
2988 (fill-paragraph arg))
2989 (if point (goto-char point)))))
2991 (defun message-fill-paragraph (&optional arg)
2992 "Like `fill-paragraph'."
2993 (interactive (list (if current-prefix-arg 'full)))
2994 (if (if (boundp 'filladapt-mode) filladapt-mode)
2996 (if (message-point-in-header-p)
2997 (message-fill-field)
2998 (message-newline-and-reformat arg t))
3001 ;; Is it better to use `mail-header-end'?
3002 (defun message-point-in-header-p ()
3003 "Return t if point is in the header."
3006 (goto-char (point-min))
3007 (not (re-search-forward
3008 (concat "^" (regexp-quote mail-header-separator) "\n")
3011 (defun message-do-auto-fill ()
3012 "Like `do-auto-fill', but don't fill in message header."
3013 (unless (message-point-in-header-p)
3016 (defun message-insert-signature (&optional force)
3017 "Insert a signature. See documentation for variable `message-signature'."
3018 (interactive (list 0))
3021 ((and (null message-signature)
3024 (goto-char (point-max))
3025 (not (re-search-backward message-signature-separator nil t))))
3026 ((and (null message-signature)
3029 ((functionp message-signature)
3030 (funcall message-signature))
3031 ((listp message-signature)
3032 (eval message-signature))
3033 (t message-signature)))
3035 (cond ((stringp signature)
3037 ((and (eq t signature)
3038 message-signature-file
3039 (file-exists-p message-signature-file))
3042 (goto-char (point-max))
3043 ;; Insert the signature.
3046 (when message-signature-insert-empty-line
3049 (if (eq signature t)
3050 (insert-file-contents message-signature-file)
3052 (goto-char (point-max))
3053 (or (bolp) (insert "\n")))))
3055 (defun message-insert-importance-high ()
3056 "Insert header to mark message as important."
3060 (message-narrow-to-headers)
3061 (message-remove-header "Importance"))
3063 (insert "Importance: high\n")))
3065 (defun message-insert-importance-low ()
3066 "Insert header to mark message as unimportant."
3070 (message-narrow-to-headers)
3071 (message-remove-header "Importance"))
3073 (insert "Importance: low\n")))
3075 (defun message-insert-or-toggle-importance ()
3076 "Insert a \"Importance: high\" header, or cycle through the header values.
3077 The three allowed values according to RFC 1327 are `high', `normal'
3081 (let ((valid '("high" "normal" "low"))
3085 (message-narrow-to-headers)
3086 (when (setq cur (message-fetch-field "Importance"))
3087 (message-remove-header "Importance")
3088 (setq new (cond ((string= cur "high")
3090 ((string= cur "low")
3095 (insert (format "Importance: %s\n" new)))))
3097 (defun message-insert-disposition-notification-to ()
3098 "Request a disposition notification (return receipt) to this message.
3099 Note that this should not be used in newsgroups."
3103 (message-narrow-to-headers)
3104 (message-remove-header "Disposition-Notification-To"))
3106 (insert (format "Disposition-Notification-To: %s\n"
3107 (or (message-field-value "Reply-to")
3108 (message-field-value "From")
3109 (message-make-from))))))
3111 (defun message-elide-region (b e)
3112 "Elide the text in the region.
3113 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3117 (insert message-elide-ellipsis))
3119 (defvar message-caesar-translation-table nil)
3121 (defun message-caesar-region (b e &optional n)
3122 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3125 (min (point) (or (mark t) (point)))
3126 (max (point) (or (mark t) (point)))
3127 (when current-prefix-arg
3128 (prefix-numeric-value current-prefix-arg))))
3130 (setq n (if (numberp n) (mod n 26) 13)) ;canonize N
3131 (unless (or (zerop n) ; no action needed for a rot of 0
3132 (= b e)) ; no region to rotate
3133 ;; We build the table, if necessary.
3134 (when (or (not message-caesar-translation-table)
3135 (/= (aref message-caesar-translation-table ?a) (+ ?a n)))
3136 (setq message-caesar-translation-table
3137 (message-make-caesar-translation-table n)))
3138 (translate-region b e message-caesar-translation-table)))
3140 (defun message-make-caesar-translation-table (n)
3141 "Create a rot table with offset N."
3143 (table (make-string 256 0)))
3144 (while (< (incf i) 256)
3147 (substring table 0 ?A)
3148 (substring table (+ ?A n) (+ ?A n (- 26 n)))
3149 (substring table ?A (+ ?A n))
3150 (substring table (+ ?A 26) ?a)
3151 (substring table (+ ?a n) (+ ?a n (- 26 n)))
3152 (substring table ?a (+ ?a n))
3153 (substring table (+ ?a 26) 255))))
3155 (defun message-caesar-buffer-body (&optional rotnum)
3156 "Caesar rotate all letters in the current buffer by 13 places.
3157 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3158 With prefix arg, specifies the number of places to rotate each letter forward.
3159 Mail and USENET news headers are not rotated."
3160 (interactive (if current-prefix-arg
3161 (list (prefix-numeric-value current-prefix-arg))
3165 (when (message-goto-body)
3166 (narrow-to-region (point) (point-max)))
3167 (message-caesar-region (point-min) (point-max) rotnum))))
3169 (defun message-pipe-buffer-body (program)
3170 "Pipe the message body in the current buffer through PROGRAM."
3173 (when (message-goto-body)
3174 (narrow-to-region (point) (point-max)))
3175 (shell-command-on-region
3176 (point-min) (point-max) program nil t))))
3178 (defun message-rename-buffer (&optional enter-string)
3179 "Rename the *message* buffer to \"*message* RECIPIENT\".
3180 If the function is run with a prefix, it will ask for a new buffer
3181 name, rather than giving an automatic name."
3182 (interactive "Pbuffer name: ")
3185 (goto-char (point-min))
3186 (narrow-to-region (point)
3187 (search-forward mail-header-separator nil 'end))
3189 (if (message-news-p) (message-fetch-field "Newsgroups")
3190 (message-fetch-field "To"))
3193 (if (string-match "," mail-to)
3194 (concat (substring mail-to 0 (match-beginning 0)) ", ...")
3196 (name-default (concat "*message* " mail-trimmed-to))
3197 (name (if enter-string
3198 (read-string "New buffer name: " name-default)
3200 (rename-buffer name t)))))
3202 (defun message-fill-yanked-message (&optional justifyp)
3203 "Fill the paragraphs of a message yanked into this one.
3204 Numeric argument means justify as well."
3207 (goto-char (point-min))
3208 (search-forward (concat "\n" mail-header-separator "\n") nil t)
3209 (let ((fill-prefix message-yank-prefix))
3210 (fill-individual-paragraphs (point) (point-max) justifyp))))
3212 (defun message-indent-citation ()
3213 "Modify text just inserted from a message to be cited.
3214 The inserted text should be the region.
3215 When this function returns, the region is again around the modified text.
3217 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3218 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3219 (let ((start (point)))
3220 ;; Remove unwanted headers.
3221 (when message-ignored-cited-headers
3226 (if (search-forward "\n\n" nil t)
3229 (message-remove-header message-ignored-cited-headers t)
3230 (when (= (point-min) (point-max))
3231 (setq all-removed t))
3232 (goto-char (point-max)))
3236 ;; Delete blank lines at the start of the buffer.
3237 (while (and (point-min)
3240 (message-delete-line))
3241 ;; Delete blank lines at the end of the buffer.
3242 (goto-char (point-max))
3245 (while (and (zerop (forward-line -1))
3247 (message-delete-line))
3248 ;; Do the indentation.
3249 (if (null message-yank-prefix)
3250 (indent-rigidly start (mark t) message-indentation-spaces)
3253 (while (< (point) (mark t))
3254 (cond ((looking-at ">")
3255 (insert message-yank-cited-prefix))
3257 (insert message-yank-empty-prefix))
3259 (insert message-yank-prefix)))
3263 (defun message-yank-original (&optional arg)
3264 "Insert the message being replied to, if any.
3265 Puts point before the text and mark after.
3266 Normally indents each nonblank line ARG spaces (default 3). However,
3267 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3269 This function uses `message-cite-function' to do the actual citing.
3271 Just \\[universal-argument] as argument means don't indent, insert no
3272 prefix, and don't delete any headers."
3274 (let ((modified (buffer-modified-p)))
3275 (when (and message-reply-buffer
3276 message-cite-function)
3277 (delete-windows-on message-reply-buffer t)
3278 (push-mark (save-excursion
3279 (insert-buffer-substring message-reply-buffer)
3282 (funcall message-cite-function))
3283 (message-exchange-point-and-mark)
3287 (setq message-checksum (message-checksum))))))
3289 (defun message-yank-buffer (buffer)
3290 "Insert BUFFER into the current buffer and quote it."
3291 (interactive "bYank buffer: ")
3292 (let ((message-reply-buffer (get-buffer buffer)))
3293 (save-window-excursion
3294 (message-yank-original))))
3296 (defun message-buffers ()
3297 "Return a list of active message buffers."
3300 (dolist (buffer (buffer-list t))
3302 (when (and (eq major-mode 'message-mode)
3303 (null message-sent-message-via))
3304 (push (buffer-name buffer) buffers))))
3305 (nreverse buffers)))
3307 (eval-when-compile (defvar mail-citation-hook)) ; Compiler directive
3309 (defun message-cite-original-1 (strip-signature)
3310 "Cite an original message.
3311 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3314 This function uses `mail-citation-hook' if that is non-nil."
3315 (if (and (boundp 'mail-citation-hook)
3317 (run-hooks 'mail-citation-hook)
3318 (let* ((start (point))
3322 (when message-indent-citation-function
3323 (if (listp message-indent-citation-function)
3324 message-indent-citation-function
3325 (list message-indent-citation-function))))
3326 ;; This function may be called by `gnus-summary-yank-message' and
3327 ;; may insert a different article from the original. So, we will
3328 ;; modify the value of `message-reply-headers' with that article.
3329 (message-reply-headers
3331 (narrow-to-region start end)
3332 (message-narrow-to-head-1)
3333 (setq x-no-archive (message-fetch-field "x-no-archive"))
3335 (or (message-fetch-field "subject") "none")
3336 (message-fetch-field "from")
3337 (message-fetch-field "date")
3338 (message-fetch-field "message-id" t)
3339 (message-fetch-field "references")
3341 (mml-quote-region start end)
3342 (when strip-signature
3346 (when (re-search-backward message-signature-separator start t)
3347 ;; Also peel off any blank lines before the signature.
3349 (while (looking-at "^[ \t]*$")
3352 (delete-region (point) end)
3353 (unless (search-backward "\n\n" start t)
3354 ;; Insert a blank line if it is peeled off.
3357 (mapc 'funcall functions)
3358 (when message-citation-line-function
3361 (funcall message-citation-line-function))
3362 (when (and x-no-archive
3363 (not message-cite-articles-with-x-no-archive)
3364 (string-match "yes" x-no-archive))
3366 (delete-region (point) (mark t))
3367 (insert "> [Quoted text removed due to X-No-Archive]\n")
3368 (forward-line -1)))))
3370 (defun message-cite-original ()
3371 "Cite function in the standard Message manner."
3372 (message-cite-original-1 nil))
3374 (defun message-cite-original-without-signature ()
3375 "Cite function in the standard Message manner.
3376 This function strips off the signature from the original message."
3377 (message-cite-original-1 t))
3379 (defun message-insert-citation-line ()
3380 "Insert a simple citation line."
3381 (when message-reply-headers
3382 (insert (mail-header-from message-reply-headers) " writes:\n\n")))
3384 (defun message-position-on-field (header &rest afters)
3385 (let ((case-fold-search t))
3388 (goto-char (point-min))
3391 (concat "^" (regexp-quote mail-header-separator) "$"))
3392 (match-beginning 0)))
3393 (goto-char (point-min))
3394 (if (re-search-forward (concat "^" (regexp-quote header) ":") nil t)
3396 (re-search-forward "^[^ \t]" nil 'move)
3398 (skip-chars-backward "\n")
3401 (not (re-search-forward
3402 (concat "^" (regexp-quote (car afters)) ":")
3406 (re-search-forward "^[^ \t]" nil 'move)
3407 (beginning-of-line))
3408 (insert header ": \n")
3412 (defun message-remove-signature ()
3413 "Remove the signature from the text between point and mark.
3414 The text will also be indented the normal way."
3416 (let ((start (point))
3418 (if (not (re-search-forward message-signature-separator (mark t) t))
3419 ;; No signature here, so we just indent the cited text.
3420 (message-indent-citation)
3421 ;; Find the last non-empty line.
3423 (while (looking-at "[ \t]*$")
3426 (setq mark (set-marker (make-marker) (point)))
3428 (message-indent-citation)
3429 ;; Enable undoing the deletion.
3431 (delete-region mark (mark t))
3432 (set-marker mark nil)))))
3437 ;;; Sending messages
3440 (defun message-send-and-exit (&optional arg)
3441 "Send message like `message-send', then, if no errors, exit from mail buffer."
3443 (let ((buf (current-buffer))
3444 (actions message-exit-actions))
3445 (when (and (message-send arg)
3447 (if message-kill-buffer-on-exit
3450 (when (eq buf (current-buffer))
3451 (message-bury buf)))
3452 (message-do-actions actions)
3455 (defun message-dont-send ()
3456 "Don't send the message you have been editing.
3457 Instead, just auto-save the buffer and then bury it."
3459 (set-buffer-modified-p t)
3461 (let ((actions message-postpone-actions))
3462 (message-bury (current-buffer))
3463 (message-do-actions actions)))
3465 (defun message-kill-buffer ()
3466 "Kill the current buffer."
3468 (when (or (not (buffer-modified-p))
3469 (not message-kill-buffer-query)
3470 (yes-or-no-p "Message modified; kill anyway? "))
3471 (let ((actions message-kill-actions)
3472 (draft-article message-draft-article)
3473 (auto-save-file-name buffer-auto-save-file-name)
3474 (file-name buffer-file-name)
3475 (modified (buffer-modified-p)))
3476 (setq buffer-file-name nil)
3477 (kill-buffer (current-buffer))
3478 (when (and (or (and auto-save-file-name
3479 (file-exists-p auto-save-file-name))
3481 (file-exists-p file-name)))
3483 ;; If the message buffer has lived in a dedicated window,
3484 ;; `kill-buffer' has killed the frame. Thus the
3485 ;; `yes-or-no-p' may show up in a lowered frame. Make sure
3486 ;; that the user can see the question by raising the
3489 (yes-or-no-p (format "Remove the backup file%s? "
3490 (if modified " too" "")))))
3492 (delete-file auto-save-file-name))
3493 (let ((message-draft-article draft-article))
3494 (message-disassociate-draft)))
3495 (message-do-actions actions))))
3497 (defun message-bury (buffer)
3498 "Bury this mail BUFFER."
3499 (let ((newbuf (other-buffer buffer)))
3500 (bury-buffer buffer)
3501 (if (and (window-dedicated-p (selected-window))
3502 (not (null (delq (selected-frame) (visible-frame-list)))))
3503 (delete-frame (selected-frame))
3504 (switch-to-buffer newbuf))))
3506 (defun message-send (&optional arg)
3507 "Send the message in the current buffer.
3508 If `message-interactive' is non-nil, wait for success indication or
3509 error messages, and inform user.
3510 Otherwise any failure is reported in a message back to the user from
3512 The usage of ARG is defined by the instance that called Message.
3513 It should typically alter the sending method in some way or other."
3515 ;; Make it possible to undo the coming changes.
3517 (let ((inhibit-read-only t))
3518 (put-text-property (point-min) (point-max) 'read-only nil))
3519 (message-fix-before-sending)
3520 (run-hooks 'message-send-hook)
3521 (message message-sending-message)
3522 (let ((alist message-send-method-alist)
3524 elem sent dont-barf-on-no-method
3525 (message-options message-options))
3526 (message-options-set-recipient)
3528 (setq elem (pop alist)))
3529 (when (funcall (cadr elem))
3530 (when (and (or (not (memq (car elem)
3531 message-sent-message-via))
3532 (message-fetch-field "supersedes")
3533 (if (or (message-gnksa-enable-p 'multiple-copies)
3534 (not (eq (car elem) 'news)))
3537 "Already sent message via %s; resend? "
3539 (error "Denied posting -- multiple copies")))
3540 (setq success (funcall (caddr elem) arg)))
3544 (let ((fcc (message-fetch-field "Fcc"))
3545 (gcc (message-fetch-field "Gcc")))
3547 (or (eq message-allow-no-recipients 'always)
3548 (and (not (eq message-allow-no-recipients 'never))
3549 (setq dont-barf-on-no-method
3551 (format "No receiver, perform %s anyway? "
3552 (cond ((and fcc gcc) "Fcc and Gcc")
3555 (error "No methods specified to send by"))
3556 (when (or dont-barf-on-no-method
3560 (run-hooks 'message-sent-hook))
3561 (message "Sending...done")
3562 ;; Mark the buffer as unmodified and delete auto-save.
3563 (set-buffer-modified-p nil)
3564 (delete-auto-save-file-if-necessary t)
3565 (message-disassociate-draft)
3566 ;; Delete other mail buffers and stuff.
3567 (message-do-send-housekeeping)
3568 (message-do-actions message-send-actions)
3572 (defun message-send-via-mail (arg)
3573 "Send the current message via mail."
3574 (message-send-mail arg))
3576 (defun message-send-via-news (arg)
3577 "Send the current message via news."
3578 (funcall message-send-news-function arg))
3580 (defmacro message-check (type &rest forms)
3581 "Eval FORMS if TYPE is to be checked."
3582 `(or (message-check-element ,type)
3586 (put 'message-check 'lisp-indent-function 1)
3587 (put 'message-check 'edebug-form-spec '(form body))
3589 (defun message-text-with-property (prop &optional start end reverse)
3590 "Return a list of start and end positions where the text has PROP.
3591 START and END bound the search, they default to `point-min' and
3592 `point-max' respectively. If REVERSE is non-nil, find text which does
3595 (setq start (point-min)))
3597 (setq end (point-max)))
3601 (setq start (text-property-any start end prop nil)))
3602 (setq next (next-single-property-change start prop nil end))
3603 (push (cons start (or next end)) regions)
3606 (or (get-text-property start prop)
3607 (and (setq start (next-single-property-change
3608 start prop nil end))
3609 (get-text-property start prop))))
3610 (setq next (text-property-any start end prop nil))
3611 (push (cons start (or next end)) regions)
3613 (nreverse regions)))
3615 (defun message-fix-before-sending ()
3616 "Do various things to make the message nice before sending it."
3617 ;; Make sure there's a newline at the end of the message.
3618 (goto-char (point-max))
3621 ;; Make the hidden headers visible.
3623 ;; Sort headers before sending the message.
3624 (message-sort-headers)
3625 ;; Make invisible text visible.
3626 ;; It doesn't seem as if this is useful, since the invisible property
3627 ;; is clobbered by an after-change hook anyhow.
3628 (message-check 'invisible-text
3629 (let ((regions (message-text-with-property 'invisible))
3633 (setq from (caar regions)
3635 regions (cdr regions))
3636 (put-text-property from to 'invisible nil)
3637 (message-overlay-put (message-make-overlay from to)
3639 (unless (yes-or-no-p
3640 "Invisible text found and made visible; continue sending? ")
3641 (error "Invisible text found and made visible")))))
3642 (message-check 'illegible-text
3645 (skip-chars-forward mm-7bit-chars)
3647 (when (let ((char (char-after)))
3648 (or (< (mm-char-int char) 128)
3649 (and (mm-multibyte-p)
3650 (memq (char-charset char)
3651 '(eight-bit-control eight-bit-graphic
3653 (not (get-text-property
3654 (point) 'untranslated-utf-8)))))
3655 (message-overlay-put (message-make-overlay (point) (1+ (point)))
3659 (skip-chars-forward mm-7bit-chars))
3662 (gnus-multiple-choice
3663 "Non-printable characters found. Continue sending?"
3664 '((?d "Remove non-printable characters and send")
3665 (?r "Replace non-printable characters with dots and send")
3666 (?i "Ignore non-printable characters and send")
3667 (?e "Continue editing"))))
3669 (error "Non-printable characters"))
3671 (skip-chars-forward mm-7bit-chars)
3673 (when (let ((char (char-after)))
3674 (or (< (mm-char-int char) 128)
3675 (and (mm-multibyte-p)
3676 ;; Fixme: Wrong for Emacs 22 and for things
3677 ;; like undecable utf-8. Should at least
3678 ;; use find-coding-systems-region.
3679 (memq (char-charset char)
3680 '(eight-bit-control eight-bit-graphic
3682 (not (get-text-property
3683 (point) 'untranslated-utf-8)))))
3685 (message-kill-all-overlays)
3687 (when (eq choice ?r)
3690 (skip-chars-forward mm-7bit-chars))))))
3692 (defun message-add-action (action &rest types)
3693 "Add ACTION to be performed when doing an exit of type TYPES."
3695 (add-to-list (intern (format "message-%s-actions" (pop types)))
3698 (defun message-delete-action (action &rest types)
3699 "Delete ACTION from lists of actions performed when doing an exit of type TYPES."
3702 (set (setq var (intern (format "message-%s-actions" (pop types))))
3703 (delq action (symbol-value var))))))
3705 (defun message-do-actions (actions)
3706 "Perform all actions in ACTIONS."
3707 ;; Now perform actions on successful sending.
3708 (dolist (action actions)
3711 ;; A simple function.