1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, 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.
35 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
44 ;; This is apparently necessary even though things are autoloaded.
45 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
46 ;; require mailabbrev here.
47 (if (featurep 'xemacs
)
48 (require 'mail-abbrevs
)
49 (require 'mailabbrev
))
55 (autoload 'mailclient-send-it
"mailclient") ;; Emacs 22 or contrib/
57 (defvar gnus-message-group-art
)
58 (defvar gnus-list-identifiers
) ; gnus-sum is required where necessary
59 (defvar rmail-enable-mime-composing
)
61 (defgroup message
'((user-mail-address custom-variable
)
62 (user-full-name custom-variable
))
63 "Mail and news message composing."
64 :link
'(custom-manual "(message)Top")
68 (put 'user-mail-address
'custom-type
'string
)
69 (put 'user-full-name
'custom-type
'string
)
71 (defgroup message-various nil
72 "Various Message Variables."
73 :link
'(custom-manual "(message)Various Message Variables")
76 (defgroup message-buffers nil
78 :link
'(custom-manual "(message)Message Buffers")
81 (defgroup message-sending nil
83 :link
'(custom-manual "(message)Sending Variables")
86 (defgroup message-interface nil
88 :link
'(custom-manual "(message)Interface")
91 (defgroup message-forwarding nil
93 :link
'(custom-manual "(message)Forwarding")
94 :group
'message-interface
)
96 (defgroup message-insertion nil
98 :link
'(custom-manual "(message)Insertion")
101 (defgroup message-headers nil
103 :link
'(custom-manual "(message)Message Headers")
106 (defgroup message-news nil
107 "Composing News Messages."
110 (defgroup message-mail nil
111 "Composing Mail Messages."
114 (defgroup message-faces nil
115 "Faces used for message composing."
119 (defcustom message-directory
"~/Mail/"
120 "*Directory from which all other mail file variables are derived."
121 :group
'message-various
124 (defcustom message-max-buffers
10
125 "*How many buffers to keep before starting to kill them off."
126 :group
'message-buffers
129 (defcustom message-send-rename-function nil
130 "Function called to rename the buffer after sending it."
131 :group
'message-buffers
132 :type
'(choice function
(const nil
)))
134 (defcustom message-fcc-handler-function
'message-output
135 "*A function called to save outgoing articles.
136 This function will be called with the name of the file to store the
137 article in. The default function is `message-output' which saves in Unix
139 :type
'(radio (function-item message-output
)
140 (function :tag
"Other"))
141 :group
'message-sending
)
143 (defcustom message-fcc-externalize-attachments nil
144 "If non-nil, attachments are included as external parts in Fcc copies."
147 :group
'message-sending
)
149 (defcustom message-courtesy-message
150 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
151 "*This is inserted at the start of a mailed copy of a posted message.
152 If the string contains the format spec \"%s\", the Newsgroups
153 the article has been posted to will be inserted there.
154 If this variable is nil, no such courtesy message will be added."
155 :group
'message-sending
156 :type
'(radio string
(const nil
)))
158 (defcustom message-ignored-bounced-headers
159 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
160 "*Regexp that matches headers to be removed in resent bounced mail."
161 :group
'message-interface
164 (defcustom message-from-style
'default
165 "*Specifies how \"From\" headers look.
167 If nil, they contain just the return address like:
169 If `parens', they look like:
170 king@grassland.com (Elvis Parsley)
171 If `angles', they look like:
172 Elvis Parsley <king@grassland.com>
174 Otherwise, most addresses look like `angles', but they look like
175 `parens' if `angles' would need quoting and `parens' would not."
176 :type
'(choice (const :tag
"simple" nil
)
180 :group
'message-headers
)
182 (defcustom message-insert-canlock t
183 "Whether to insert a Cancel-Lock header in news postings."
185 :group
'message-headers
188 (defcustom message-syntax-checks
189 (if message-insert-canlock
'((sender . disabled
)) nil
)
190 ;; Guess this one shouldn't be easy to customize...
191 "*Controls what syntax checks should not be performed on outgoing posts.
192 To disable checking of long signatures, for instance, add
193 `(signature . disabled)' to this list.
195 Don't touch this variable unless you really know what you're doing.
197 Checks include `approved', `bogus-recipient', `continuation-headers',
198 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
199 `invisible-text', `long-header-lines', `long-lines', `message-id',
200 `multiple-headers', `new-text', `newsgroups', `quoting-style',
201 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
202 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
203 and `valid-newsgroups'."
205 :type
'(repeat sexp
)) ; Fixme: improve this
207 (defcustom message-required-headers
'((optional . References
)
209 "*Headers to be generated or prompted for when sending a message.
210 Also see `message-required-news-headers' and
211 `message-required-mail-headers'."
214 :group
'message-headers
215 :link
'(custom-manual "(message)Message Headers")
216 :type
'(repeat sexp
))
218 (defcustom message-draft-headers
'(References From Date
)
219 "*Headers to be generated when saving a draft message."
222 :group
'message-headers
223 :link
'(custom-manual "(message)Message Headers")
224 :type
'(repeat sexp
))
226 (defcustom message-required-news-headers
227 '(From Newsgroups Subject Date Message-ID
228 (optional . Organization
)
229 (optional . User-Agent
))
230 "*Headers to be generated or prompted for when posting an article.
231 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
232 Message-ID. Organization, Lines, In-Reply-To, Expires, and
233 User-Agent are optional. If you don't want message to insert some
234 header, remove it from this list."
236 :group
'message-headers
237 :link
'(custom-manual "(message)Message Headers")
238 :type
'(repeat sexp
))
240 (defcustom message-required-mail-headers
241 '(From Subject Date
(optional . In-Reply-To
) Message-ID
242 (optional . User-Agent
))
243 "*Headers to be generated or prompted for when mailing a message.
244 It is recommended that From, Date, To, Subject and Message-ID be
245 included. Organization and User-Agent are optional."
247 :group
'message-headers
248 :link
'(custom-manual "(message)Message Headers")
249 :type
'(repeat sexp
))
251 (defcustom message-deletable-headers
'(Message-ID Date Lines
)
252 "Headers to be deleted if they already exist and were generated by message previously."
253 :group
'message-headers
254 :link
'(custom-manual "(message)Message Headers")
257 (defcustom message-ignored-news-headers
258 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
259 "*Regexp of headers to be removed unconditionally before posting."
261 :group
'message-headers
262 :link
'(custom-manual "(message)Message Headers")
263 :type
'(repeat :value-to-internal
(lambda (widget value
)
264 (custom-split-regexp-maybe value
))
265 :match
(lambda (widget value
)
267 (widget-editable-list-match widget value
)))
270 (defcustom message-ignored-mail-headers
271 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
272 "*Regexp of headers to be removed unconditionally before mailing."
274 :group
'message-headers
275 :link
'(custom-manual "(message)Mail Headers")
278 (defcustom message-ignored-supersedes-headers
"^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|^X-Trace:\\|^X-ID:\\|^X-Complaints-To:\\|Return-Path:\\|^Supersedes:\\|^NNTP-Posting-Date:\\|^X-Trace:\\|^X-Complaints-To:\\|^Cancel-Lock:\\|^Cancel-Key:\\|^X-Hashcash:\\|^X-Payment:\\|^Approved:"
279 "*Header lines matching this regexp will be deleted before posting.
280 It's best to delete old Path and Date headers before posting to avoid
282 :group
'message-interface
283 :link
'(custom-manual "(message)Superseding")
284 :type
'(repeat :value-to-internal
(lambda (widget value
)
285 (custom-split-regexp-maybe value
))
286 :match
(lambda (widget value
)
288 (widget-editable-list-match widget value
)))
291 (defcustom message-subject-re-regexp
292 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
293 "*Regexp matching \"Re: \" in the subject line."
294 :group
'message-various
295 :link
'(custom-manual "(message)Message Headers")
298 ;;; Start of variables adopted from `message-utils.el'.
300 (defcustom message-subject-trailing-was-query
'ask
301 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
302 If nil, leave the subject unchanged. If it is the symbol `ask', query
303 the user what do do. In this case, the subject is matched against
304 `message-subject-trailing-was-ask-regexp'. If
305 `message-subject-trailing-was-query' is t, always strip the trailing
306 old subject. In this case, `message-subject-trailing-was-regexp' is
309 :type
'(choice (const :tag
"never" nil
)
310 (const :tag
"always strip" t
)
312 :link
'(custom-manual "(message)Message Headers")
313 :group
'message-various
)
315 (defcustom message-subject-trailing-was-ask-regexp
316 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
317 "*Regexp matching \"(was: <old subject>)\" in the subject line.
319 The function `message-strip-subject-trailing-was' uses this regexp if
320 `message-subject-trailing-was-query' is set to the symbol `ask'. If
321 the variable is t instead of `ask', use
322 `message-subject-trailing-was-regexp' instead.
324 It is okay to create some false positives here, as the user is asked."
326 :group
'message-various
327 :link
'(custom-manual "(message)Message Headers")
330 (defcustom message-subject-trailing-was-regexp
331 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
332 "*Regexp matching \"(was: <old subject>)\" in the subject line.
334 If `message-subject-trailing-was-query' is set to t, the subject is
335 matched against `message-subject-trailing-was-regexp' in
336 `message-strip-subject-trailing-was'. You should use a regexp creating very
337 few false positives here."
339 :group
'message-various
340 :link
'(custom-manual "(message)Message Headers")
343 ;;; marking inserted text
345 (defcustom message-mark-insert-begin
346 "--8<---------------cut here---------------start------------->8---\n"
347 "How to mark the beginning of some inserted text."
350 :link
'(custom-manual "(message)Insertion Variables")
351 :group
'message-various
)
353 (defcustom message-mark-insert-end
354 "--8<---------------cut here---------------end--------------->8---\n"
355 "How to mark the end of some inserted text."
358 :link
'(custom-manual "(message)Insertion Variables")
359 :group
'message-various
)
361 (defcustom message-archive-header
"X-No-Archive: Yes\n"
362 "Header to insert when you don't want your article to be archived.
363 Archives \(such as groups.google.com\) respect this header."
366 :link
'(custom-manual "(message)Header Commands")
367 :group
'message-various
)
369 (defcustom message-archive-note
370 "X-No-Archive: Yes - save http://groups.google.com/"
371 "Note to insert why you wouldn't want this posting archived.
372 If nil, don't insert any text in the body."
374 :type
'(radio string
(const nil
))
375 :link
'(custom-manual "(message)Header Commands")
376 :group
'message-various
)
378 ;;; Crossposts and Followups
379 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
380 ;; new suggestions by R. Weikusat <rw at another.de>
382 (defvar message-cross-post-old-target nil
383 "Old target for cross-posts or follow-ups.")
384 (make-variable-buffer-local 'message-cross-post-old-target
)
386 (defcustom message-cross-post-default t
387 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
388 If nil, `message-cross-post-followup-to' will only do a followup. Note that
389 you can explicitly override this setting by calling
390 `message-cross-post-followup-to' with a prefix."
393 :group
'message-various
)
395 (defcustom message-cross-post-note
"Crosspost & Followup-To: "
396 "Note to insert before signature to notify of cross-post and follow-up."
399 :group
'message-various
)
401 (defcustom message-followup-to-note
"Followup-To: "
402 "Note to insert before signature to notify of follow-up only."
405 :group
'message-various
)
407 (defcustom message-cross-post-note-function
'message-cross-post-insert-note
408 "Function to use to insert note about Crosspost or Followup-To.
409 The function will be called with four arguments. The function should not only
410 insert a note, but also ensure old notes are deleted. See the documentation
411 for `message-cross-post-insert-note'."
414 :group
'message-various
)
416 ;;; End of variables adopted from `message-utils.el'.
418 (defcustom message-signature-separator
"^-- $"
419 "Regexp matching the signature separator.
420 This variable is used to strip off the signature from quoted text
421 when `message-cite-function' is
422 `message-cite-original-without-signature'. Most useful values
423 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
425 :type
'(choice (const :tag
"strict" "^-- $")
426 (const :tag
"loose" "^-- *$")
428 :version
"23.1" ;; No Gnus (changed default)
429 :link
'(custom-manual "(message)Various Message Variables")
430 :group
'message-various
)
432 (defcustom message-elide-ellipsis
"\n[...]\n\n"
433 "*The string which is inserted for elided text."
435 :link
'(custom-manual "(message)Various Commands")
436 :group
'message-various
)
438 (defcustom message-interactive t
439 "Non-nil means when sending a message wait for and display errors.
440 nil means let mailer mail back a message to report errors."
441 :group
'message-sending
443 :link
'(custom-manual "(message)Sending Variables")
446 (defcustom message-generate-new-buffers
'unique
447 "*Say whether to create a new message buffer to compose a message.
448 Valid values include:
451 Generate the buffer name in the Message way (e.g., *mail*, *news*,
452 *mail to whom*, *news on group*, etc.) and continue editing in the
453 existing buffer of that name. If there is no such buffer, it will
457 Create the new buffer with the name generated in the Message way.
460 Similar to `unique' but the buffer name begins with \"*unsent \".
463 Similar to nil but the buffer name is simpler like *mail message*.
466 If this is a function, call that function with three parameters:
467 The type, the To address and the group name (any of these may be nil).
468 The function should return the new buffer name."
469 :group
'message-buffers
470 :link
'(custom-manual "(message)Message Buffers")
471 :type
'(choice (const nil
)
472 (sexp :tag
"unique" :format
"unique\n" :value unique
473 :match
(lambda (widget value
) (memq value
'(unique t
))))
476 (function :format
"\n %{%t%}: %v")))
478 (defcustom message-kill-buffer-on-exit nil
479 "*Non-nil means that the message buffer will be killed after sending a message."
480 :group
'message-buffers
481 :link
'(custom-manual "(message)Message Buffers")
484 (defcustom message-kill-buffer-query t
485 "*Non-nil means that killing a modified message buffer has to be confirmed.
486 This is used by `message-kill-buffer'."
487 :version
"23.1" ;; No Gnus
488 :group
'message-buffers
491 (defvar gnus-local-organization
)
492 (defcustom message-user-organization
493 (or (and (boundp 'gnus-local-organization
)
494 (stringp gnus-local-organization
)
495 gnus-local-organization
)
496 (getenv "ORGANIZATION")
498 "*String to be used as an Organization header.
499 If t, use `message-user-organization-file'."
500 :group
'message-headers
501 :type
'(choice string
502 (const :tag
"consult file" t
)))
504 (defcustom message-user-organization-file
506 (dolist (f (list "/etc/organization"
507 "/etc/news/organization"
508 "/usr/lib/news/organization"))
509 (when (file-readable-p f
)
512 "*Local news organization file."
514 :link
'(custom-manual "(message)News Headers")
515 :group
'message-headers
)
517 (defcustom message-make-forward-subject-function
518 #'message-forward-subject-name-subject
519 "*List of functions called to generate subject headers for forwarded messages.
520 The subject generated by the previous function is passed into each
523 The provided functions are:
525 * `message-forward-subject-author-subject' Source of article (author or
526 newsgroup), in brackets followed by the subject
527 * `message-forward-subject-name-subject' Source of article (name of author
528 or newsgroup), in brackets followed by the subject
529 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
531 :group
'message-forwarding
532 :link
'(custom-manual "(message)Forwarding")
533 :type
'(radio (function-item message-forward-subject-author-subject
)
534 (function-item message-forward-subject-fwd
)
535 (function-item message-forward-subject-name-subject
)
536 (repeat :tag
"List of functions" function
)))
538 (defcustom message-forward-as-mime t
539 "*Non-nil means forward messages as an inline/rfc822 MIME section.
540 Otherwise, directly inline the old message in the forwarded message."
542 :group
'message-forwarding
543 :link
'(custom-manual "(message)Forwarding")
546 (defcustom message-forward-show-mml
'best
547 "*Non-nil means show forwarded messages as MML (decoded from MIME).
548 Otherwise, forwarded messages are unchanged.
549 Can also be the symbol `best' to indicate that MML should be
550 used, except when it is a bad idea to use MML. One example where
551 it is a bad idea is when forwarding a signed or encrypted
552 message, because converting MIME to MML would invalidate the
555 :group
'message-forwarding
556 :type
'(choice (const :tag
"use MML" t
)
557 (const :tag
"don't use MML " nil
)
558 (const :tag
"use MML when appropriate" best
)))
560 (defcustom message-forward-before-signature t
561 "*Non-nil means put forwarded message before signature, else after."
562 :group
'message-forwarding
565 (defcustom message-wash-forwarded-subjects nil
566 "*Non-nil means try to remove as much cruft as possible from the subject.
567 Done before generating the new subject of a forward."
568 :group
'message-forwarding
569 :link
'(custom-manual "(message)Forwarding")
572 (defcustom message-ignored-resent-headers
573 ;; `Delivered-To' needs to be removed because some mailers use it to
574 ;; detect loops, so if you resend a message to an address that ultimately
575 ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
576 ;; case you may be removed from the list on the grounds that mail to you
577 ;; bounced with a "mailing loop" error).
578 "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
579 "*All headers that match this regexp will be deleted when resending a message."
580 :group
'message-interface
581 :link
'(custom-manual "(message)Resending")
582 :type
'(repeat :value-to-internal
(lambda (widget value
)
583 (custom-split-regexp-maybe value
))
584 :match
(lambda (widget value
)
586 (widget-editable-list-match widget value
)))
589 (defcustom message-forward-ignored-headers
"^Content-Transfer-Encoding:\\|^X-Gnus"
590 "*All headers that match this regexp will be deleted when forwarding a message."
592 :group
'message-forwarding
593 :type
'(repeat :value-to-internal
(lambda (widget value
)
594 (custom-split-regexp-maybe value
))
595 :match
(lambda (widget value
)
597 (widget-editable-list-match widget value
)))
600 (defcustom message-ignored-cited-headers
"."
601 "*Delete these headers from the messages you yank."
602 :group
'message-insertion
603 :link
'(custom-manual "(message)Insertion Variables")
606 (defcustom message-cite-prefix-regexp
607 (if (string-match "[[:digit:]]" "1")
608 ;; Support POSIX? XEmacs 21.5.27 doesn't.
609 "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|}]\\)+"
610 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
611 (let (non-word-constituents)
612 (with-syntax-table text-mode-syntax-table
613 (setq non-word-constituents
615 (if (string-match "\\w" "_") "" "_")
616 (if (string-match "\\w" ".") "" "."))))
617 (if (equal non-word-constituents
"")
618 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}]\\)+"
619 (concat "\\([ \t]*\\(\\w\\|["
620 non-word-constituents
621 "]\\)+>+\\|[ \t]*[]>|}]\\)+"))))
622 "*Regexp matching the longest possible citation prefix on a line."
624 :group
'message-insertion
625 :link
'(custom-manual "(message)Insertion Variables")
627 :set
(lambda (symbol value
)
629 (custom-set-default symbol value
)
630 (if (boundp 'gnus-message-cite-prefix-regexp
)
631 (setq gnus-message-cite-prefix-regexp
632 (concat "^\\(?:" value
"\\)"))))))
634 (defcustom message-cancel-message
"I am canceling my own article.\n"
635 "Message to be inserted in the cancel message."
636 :group
'message-interface
637 :link
'(custom-manual "(message)Canceling News")
640 (defvar smtpmail-default-smtp-server
)
642 (defun message-send-mail-function ()
643 "Return suitable value for the variable `message-send-mail-function'."
644 (cond ((and (require 'sendmail
)
645 (boundp 'sendmail-program
)
647 (executable-find sendmail-program
))
648 'message-send-mail-with-sendmail
)
649 ((and (locate-library "smtpmail")
651 smtpmail-default-smtp-server
)
652 'message-smtpmail-send-it
)
653 ((locate-library "mailclient")
654 'message-send-mail-with-mailclient
)
657 (error "Don't know how to send mail. Please customize `message-send-mail-function'")))))
659 ;; Useful to set in site-init.el
660 (defcustom message-send-mail-function
(message-send-mail-function)
661 "Function to call to send the current buffer as mail.
662 The headers should be delimited by a line whose contents match the
663 variable `mail-header-separator'.
665 Valid values include `message-send-mail-with-sendmail'
666 `message-send-mail-with-mh', `message-send-mail-with-qmail',
667 `message-smtpmail-send-it', `smtpmail-send-it',
668 `feedmail-send-it' and `message-send-mail-with-mailclient'. The
669 default is system dependent and determined by the function
670 `message-send-mail-function'.
672 See also `send-mail-function'."
673 :type
'(radio (function-item message-send-mail-with-sendmail
)
674 (function-item message-send-mail-with-mh
)
675 (function-item message-send-mail-with-qmail
)
676 (function-item message-smtpmail-send-it
)
677 (function-item smtpmail-send-it
)
678 (function-item feedmail-send-it
)
679 (function-item message-send-mail-with-mailclient
680 :tag
"Use Mailclient package")
681 (function :tag
"Other"))
682 :group
'message-sending
683 :version
"23.1" ;; No Gnus
684 :initialize
'custom-initialize-default
685 :link
'(custom-manual "(message)Mail Variables")
686 :group
'message-mail
)
688 (defcustom message-send-news-function
'message-send-news
689 "Function to call to send the current buffer as news.
690 The headers should be delimited by a line whose contents match the
691 variable `mail-header-separator'."
692 :group
'message-sending
694 :link
'(custom-manual "(message)News Variables")
697 (defcustom message-reply-to-function nil
698 "If non-nil, function that should return a list of headers.
699 This function should pick out addresses from the To, Cc, and From headers
700 and respond with new To and Cc headers."
701 :group
'message-interface
702 :link
'(custom-manual "(message)Reply")
703 :type
'(choice function
(const nil
)))
705 (defcustom message-wide-reply-to-function nil
706 "If non-nil, function that should return a list of headers.
707 This function should pick out addresses from the To, Cc, and From headers
708 and respond with new To and Cc headers."
709 :group
'message-interface
710 :link
'(custom-manual "(message)Wide Reply")
711 :type
'(choice function
(const nil
)))
713 (defcustom message-followup-to-function nil
714 "If non-nil, function that should return a list of headers.
715 This function should pick out addresses from the To, Cc, and From headers
716 and respond with new To and Cc headers."
717 :group
'message-interface
718 :link
'(custom-manual "(message)Followup")
719 :type
'(choice function
(const nil
)))
721 (defcustom message-extra-wide-headers nil
722 "If non-nil, a list of additional address headers.
723 These are used when composing a wide reply."
724 :group
'message-sending
725 :type
'(repeat string
))
727 (defcustom message-use-followup-to
'ask
728 "*Specifies what to do with Followup-To header.
729 If nil, always ignore the header. If it is t, use its value, but
730 query before using the \"poster\" value. If it is the symbol `ask',
731 always query the user whether to use the value. If it is the symbol
732 `use', always use the value."
733 :group
'message-interface
734 :link
'(custom-manual "(message)Followup")
735 :type
'(choice (const :tag
"ignore" nil
)
736 (const :tag
"use & query" t
)
740 (defcustom message-use-mail-followup-to
'use
741 "*Specifies what to do with Mail-Followup-To header.
742 If nil, always ignore the header. If it is the symbol `ask', always
743 query the user whether to use the value. If it is the symbol `use',
744 always use the value."
746 :group
'message-interface
747 :link
'(custom-manual "(message)Mailing Lists")
748 :type
'(choice (const :tag
"ignore" nil
)
752 (defcustom message-subscribed-address-functions nil
753 "*Specifies functions for determining list subscription.
754 If nil, do not attempt to determine list subscription with functions.
755 If non-nil, this variable contains a list of functions which return
756 regular expressions to match lists. These functions can be used in
757 conjunction with `message-subscribed-regexps' and
758 `message-subscribed-addresses'."
760 :group
'message-interface
761 :link
'(custom-manual "(message)Mailing Lists")
762 :type
'(repeat sexp
))
764 (defcustom message-subscribed-address-file nil
765 "*A file containing addresses the user is subscribed to.
766 If nil, do not look at any files to determine list subscriptions. If
767 non-nil, each line of this file should be a mailing list address."
769 :group
'message-interface
770 :link
'(custom-manual "(message)Mailing Lists")
771 :type
'(radio file
(const nil
)))
773 (defcustom message-subscribed-addresses nil
774 "*Specifies a list of addresses the user is subscribed to.
775 If nil, do not use any predefined list subscriptions. This list of
776 addresses can be used in conjunction with
777 `message-subscribed-address-functions' and `message-subscribed-regexps'."
779 :group
'message-interface
780 :link
'(custom-manual "(message)Mailing Lists")
781 :type
'(repeat string
))
783 (defcustom message-subscribed-regexps nil
784 "*Specifies a list of addresses the user is subscribed to.
785 If nil, do not use any predefined list subscriptions. This list of
786 regular expressions can be used in conjunction with
787 `message-subscribed-address-functions' and `message-subscribed-addresses'."
789 :group
'message-interface
790 :link
'(custom-manual "(message)Mailing Lists")
791 :type
'(repeat regexp
))
793 (defcustom message-allow-no-recipients
'ask
794 "Specifies what to do when there are no recipients other than Gcc/Fcc.
795 If it is the symbol `always', the posting is allowed. If it is the
796 symbol `never', the posting is not allowed. If it is the symbol
797 `ask', you are prompted."
799 :group
'message-interface
800 :link
'(custom-manual "(message)Message Headers")
801 :type
'(choice (const always
)
805 (defcustom message-sendmail-f-is-evil nil
806 "*Non-nil means don't add \"-f username\" to the sendmail command line.
807 Doing so would be even more evil than leaving it out."
808 :group
'message-sending
809 :link
'(custom-manual "(message)Mail Variables")
812 (defcustom message-sendmail-envelope-from nil
813 "*Envelope-from when sending mail with sendmail.
814 If this is nil, use `user-mail-address'. If it is the symbol
815 `header', use the From: header of the message."
817 :type
'(choice (string :tag
"From name")
818 (const :tag
"Use From: header from message" header
)
819 (const :tag
"Use `user-mail-address'" nil
))
820 :link
'(custom-manual "(message)Mail Variables")
821 :group
'message-sending
)
823 (defcustom message-sendmail-extra-arguments nil
824 "Additional arguments to `sendmail-program'."
825 ;; E.g. '("-a" "account") for msmtp
826 :version
"23.1" ;; No Gnus
827 :type
'(repeat string
)
828 ;; :link '(custom-manual "(message)Mail Variables")
829 :group
'message-sending
)
831 ;; qmail-related stuff
832 (defcustom message-qmail-inject-program
"/var/qmail/bin/qmail-inject"
833 "Location of the qmail-inject program."
834 :group
'message-sending
835 :link
'(custom-manual "(message)Mail Variables")
838 (defcustom message-qmail-inject-args nil
839 "Arguments passed to qmail-inject programs.
840 This should be a list of strings, one string for each argument. It
841 may also be a function.
843 For e.g., if you wish to set the envelope sender address so that bounces
844 go to the right place or to deal with listserv's usage of that address, you
845 might set this variable to '(\"-f\" \"you@some.where\")."
846 :group
'message-sending
847 :link
'(custom-manual "(message)Mail Variables")
848 :type
'(choice (function)
851 (defvar gnus-post-method
)
852 (defvar gnus-select-method
)
853 (defcustom message-post-method
854 (cond ((and (boundp 'gnus-post-method
)
855 (listp gnus-post-method
)
858 ((boundp 'gnus-select-method
)
861 "*Method used to post news.
862 Note that when posting from inside Gnus, for instance, this
863 variable isn't used."
865 :group
'message-sending
866 ;; This should be the `gnus-select-method' widget, but that might
867 ;; create a dependence to `gnus.el'.
870 ;; FIXME: This should be a temporary workaround until someone implements a
871 ;; proper solution. If a crash happens while replying, the auto-save file
872 ;; will *not* have a `References:' header if `message-generate-headers-first'
873 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
874 (defcustom message-generate-headers-first
'(references)
875 "Which headers should be generated before starting to compose a message.
876 If t, generate all required headers. This can also be a list of headers to
877 generate. The variables `message-required-news-headers' and
878 `message-required-mail-headers' specify which headers to generate.
880 Note that the variable `message-deletable-headers' specifies headers which
881 are to be deleted and then re-generated before sending, so this variable
882 will not have a visible effect for those headers."
883 :group
'message-headers
884 :link
'(custom-manual "(message)Message Headers")
885 :type
'(choice (const :tag
"None" nil
)
886 (const :tag
"References" '(references))
888 (repeat (sexp :tag
"Header"))))
890 (defcustom message-fill-column
72
891 "Column beyond which automatic line-wrapping should happen.
892 Local value for message buffers. If non-nil, also turn on
893 auto-fill in message buffers."
894 :group
'message-various
895 ;; :link '(custom-manual "(message)Message Headers")
896 :type
'(choice (const :tag
"Don't turn on auto fill" nil
)
899 (defcustom message-setup-hook nil
900 "Normal hook, run each time a new outgoing message is initialized.
901 The function `message-setup' runs this hook."
902 :group
'message-various
903 :link
'(custom-manual "(message)Various Message Variables")
906 (defcustom message-cancel-hook nil
907 "Hook run when cancelling articles."
908 :group
'message-various
909 :link
'(custom-manual "(message)Various Message Variables")
912 (defcustom message-signature-setup-hook nil
913 "Normal hook, run each time a new outgoing message is initialized.
914 It is run after the headers have been inserted and before
915 the signature is inserted."
916 :group
'message-various
917 :link
'(custom-manual "(message)Various Message Variables")
920 (defcustom message-mode-hook nil
921 "Hook run in message mode buffers."
922 :group
'message-various
925 (defcustom message-header-hook nil
926 "Hook run in a message mode buffer narrowed to the headers."
927 :group
'message-various
930 (defcustom message-header-setup-hook nil
931 "Hook called narrowed to the headers when setting up a message buffer."
932 :group
'message-various
933 :link
'(custom-manual "(message)Various Message Variables")
936 (defcustom message-minibuffer-local-map
937 (let ((map (make-sparse-keymap 'message-minibuffer-local-map
)))
938 (set-keymap-parent map minibuffer-local-map
)
940 "Keymap for `message-read-from-minibuffer'."
942 :group
'message-various
)
944 (defcustom message-citation-line-function
'message-insert-citation-line
945 "*Function called to insert the \"Whomever writes:\" line.
947 Predefined functions include `message-insert-citation-line' and
948 `message-insert-formatted-citation-line' (see the variable
949 `message-citation-line-format').
951 Note that Gnus provides a feature where the reader can click on
952 `writes:' to hide the cited text. If you change this line too much,
953 people who read your message will have to change their Gnus
954 configuration. See the variable `gnus-cite-attribution-suffix'."
956 (function-item :tag
"plain" message-insert-citation-line
)
957 (function-item :tag
"formatted" message-insert-formatted-citation-line
)
958 (function :tag
"Other"))
959 :link
'(custom-manual "(message)Insertion Variables")
960 :group
'message-insertion
)
962 (defcustom message-citation-line-format
"On %a, %b %d %Y, %N wrote:\n"
963 "Format of the \"Whomever writes:\" line.
965 The string is formatted using `format-spec'. The following
966 constructs are replaced:
968 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
969 %n The mail address, e.g. \"john.doe@example.invalid\".
970 %N The real name if present, e.g.: \"John Doe\", else fall
971 back to the mail address.
972 %F The first name if present, e.g.: \"John\".
973 %L The last name if present, e.g.: \"Doe\".
975 All other format specifiers are passed to `format-time-string'
976 which is called using the date from the article your replying to.
977 Extracting the first (%F) and last name (%L) is done
978 heuristically, so you should always check it yourself.
980 Please also read the note in the documentation of
981 `message-citation-line-function'."
982 :type
'(choice (const :tag
"Plain" "%f writes:")
983 (const :tag
"Include date" "On %a, %b %d %Y, %n wrote:")
985 :link
'(custom-manual "(message)Insertion Variables")
986 :version
"23.1" ;; No Gnus
987 :group
'message-insertion
)
989 (defcustom message-yank-prefix
"> "
990 "*Prefix inserted on the lines of yanked messages.
991 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
992 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
994 :link
'(custom-manual "(message)Insertion Variables")
995 :group
'message-insertion
)
997 (defcustom message-yank-cited-prefix
">"
998 "*Prefix inserted on cited lines of yanked messages.
999 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1000 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1003 :link
'(custom-manual "(message)Insertion Variables")
1004 :group
'message-insertion
)
1006 (defcustom message-yank-empty-prefix
">"
1007 "*Prefix inserted on empty lines of yanked messages.
1008 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1011 :link
'(custom-manual "(message)Insertion Variables")
1012 :group
'message-insertion
)
1014 (defcustom message-indentation-spaces
3
1015 "*Number of spaces to insert at the beginning of each cited line.
1016 Used by `message-yank-original' via `message-yank-cite'."
1017 :group
'message-insertion
1018 :link
'(custom-manual "(message)Insertion Variables")
1021 (defcustom message-cite-function
'message-cite-original-without-signature
1022 "*Function for citing an original message.
1023 Predefined functions include `message-cite-original' and
1024 `message-cite-original-without-signature'.
1025 Note that these functions use `mail-citation-hook' if that is non-nil."
1026 :type
'(radio (function-item message-cite-original
)
1027 (function-item message-cite-original-without-signature
)
1028 (function-item sc-cite-original
)
1029 (function :tag
"Other"))
1030 :link
'(custom-manual "(message)Insertion Variables")
1031 :version
"23.1" ;; No Gnus (changed default)
1032 :group
'message-insertion
)
1034 (defcustom message-indent-citation-function
'message-indent-citation
1035 "*Function for modifying a citation just inserted in the mail buffer.
1036 This can also be a list of functions. Each function can find the
1037 citation between (point) and (mark t). And each function should leave
1038 point and mark around the citation text as modified."
1040 :link
'(custom-manual "(message)Insertion Variables")
1041 :group
'message-insertion
)
1043 (defcustom message-signature t
1044 "*String to be inserted at the end of the message buffer.
1045 If t, the `message-signature-file' file will be inserted instead.
1046 If a function, the result from the function will be used instead.
1047 If a form, the result from the form will be used instead."
1049 :link
'(custom-manual "(message)Insertion Variables")
1050 :group
'message-insertion
)
1052 (defcustom message-signature-file
"~/.signature"
1053 "*Name of file containing the text inserted at end of message buffer.
1054 Ignored if the named file doesn't exist.
1055 If nil, don't insert a signature.
1056 If a path is specified, the value of `message-signature-directory' is ignored,
1058 :type
'(choice file
(const :tags
"None" nil
))
1059 :link
'(custom-manual "(message)Insertion Variables")
1060 :group
'message-insertion
)
1062 (defcustom message-signature-directory nil
1063 "*Name of directory containing signature files.
1064 Comes in handy if you have many such files, handled via posting styles for
1066 If nil, `message-signature-file' is expected to specify the directory if
1068 :type
'(choice string
(const :tags
"None" nil
))
1069 :link
'(custom-manual "(message)Insertion Variables")
1070 :group
'message-insertion
)
1072 (defcustom message-signature-insert-empty-line t
1073 "*If non-nil, insert an empty line before the signature separator."
1076 :link
'(custom-manual "(message)Insertion Variables")
1077 :group
'message-insertion
)
1079 (defcustom message-distribution-function nil
1080 "*Function called to return a Distribution header."
1081 :group
'message-news
1082 :group
'message-headers
1083 :link
'(custom-manual "(message)News Headers")
1084 :type
'(choice function
(const nil
)))
1086 (defcustom message-expires
14
1087 "Number of days before your article expires."
1088 :group
'message-news
1089 :group
'message-headers
1090 :link
'(custom-manual "(message)News Headers")
1093 (defcustom message-user-path nil
1094 "If nil, use the NNTP server name in the Path header.
1095 If stringp, use this; if non-nil, use no host name (user name only)."
1096 :group
'message-news
1097 :group
'message-headers
1098 :link
'(custom-manual "(message)News Headers")
1099 :type
'(choice (const :tag
"nntp" nil
)
1100 (string :tag
"name")
1101 (sexp :tag
"none" :format
"%t" t
)))
1103 (defvar message-reply-buffer nil
)
1104 (defvar message-reply-headers nil
1105 "The headers of the current replied article.
1106 It is a vector of the following headers:
1107 \[number subject from date id references chars lines xref extra].")
1108 (defvar message-newsreader nil
)
1109 (defvar message-mailer nil
)
1110 (defvar message-sent-message-via nil
)
1111 (defvar message-checksum nil
)
1112 (defvar message-send-actions nil
1113 "A list of actions to be performed upon successful sending of a message.")
1114 (defvar message-exit-actions nil
1115 "A list of actions to be performed upon exiting after sending a message.")
1116 (defvar message-kill-actions nil
1117 "A list of actions to be performed before killing a message buffer.")
1118 (defvar message-postpone-actions nil
1119 "A list of actions to be performed after postponing a message.")
1121 (define-widget 'message-header-lines
'text
1122 "All header lines must be LFD terminated."
1123 :format
"%{%t%}:%n%v"
1124 :valid-regexp
"^\\'"
1125 :error
"All header lines must be newline terminated")
1127 (defcustom message-default-headers
""
1128 "*A string containing header lines to be inserted in outgoing messages.
1129 It is inserted before you edit the message, so you can edit or delete
1131 :group
'message-headers
1132 :link
'(custom-manual "(message)Message Headers")
1133 :type
'message-header-lines
)
1135 (defcustom message-default-mail-headers
""
1136 "*A string of header lines to be inserted in outgoing mails."
1137 :group
'message-headers
1138 :group
'message-mail
1139 :link
'(custom-manual "(message)Mail Headers")
1140 :type
'message-header-lines
)
1142 (defcustom message-default-news-headers
""
1143 "*A string of header lines to be inserted in outgoing news articles."
1144 :group
'message-headers
1145 :group
'message-news
1146 :link
'(custom-manual "(message)News Headers")
1147 :type
'message-header-lines
)
1149 ;; Note: could use /usr/ucb/mail instead of sendmail;
1150 ;; options -t, and -v if not interactive.
1151 (defcustom message-mailer-swallows-blank-line
1152 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1153 system-configuration
)
1154 (file-readable-p "/etc/sendmail.cf")
1155 (let ((buffer (get-buffer-create " *temp*")))
1157 (with-current-buffer buffer
1158 (insert-file-contents "/etc/sendmail.cf")
1159 (goto-char (point-min))
1160 (let ((case-fold-search nil
))
1161 (re-search-forward "^OR\\>" nil t
)))
1162 (kill-buffer buffer
))))
1163 ;; According to RFC822, "The field-name must be composed of printable
1164 ;; ASCII characters (i. e., characters that have decimal values between
1165 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1167 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1168 "*Set this non-nil if the system's mailer runs the header and body together.
1169 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1170 The value should be an expression to test whether the problem will
1172 :group
'message-sending
1173 :link
'(custom-manual "(message)Mail Variables")
1177 (define-mail-user-agent 'message-user-agent
1178 'message-mail
'message-send-and-exit
1179 'message-kill-buffer
'message-send-hook
)
1181 (defvar message-mh-deletable-headers
'(Message-ID Date Lines Sender
)
1182 "If non-nil, delete the deletable headers before feeding to mh.")
1184 (defvar message-send-method-alist
1185 '((news message-news-p message-send-via-news
)
1186 (mail message-mail-p message-send-via-mail
))
1187 "Alist of ways to send outgoing messages.
1188 Each element has the form
1190 \(TYPE PREDICATE FUNCTION)
1192 where TYPE is a symbol that names the method; PREDICATE is a function
1193 called without any parameters to determine whether the message is
1194 a message of type TYPE; and FUNCTION is a function to be called if
1195 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1198 (defcustom message-mail-alias-type
'abbrev
1199 "*What alias expansion type to use in Message buffers.
1200 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1201 an electric completion mode. nil switches mail aliases off.
1202 This can also be a list of values."
1204 :link
'(custom-manual "(message)Mail Aliases")
1205 :type
'(choice (const :tag
"Use Mailabbrev" abbrev
)
1206 (const :tag
"Use ecomplete" ecomplete
)
1207 (const :tag
"No expansion" nil
)))
1209 (defcustom message-self-insert-commands
'(self-insert-command)
1210 "List of `self-insert-command's used to trigger ecomplete.
1211 When one of those commands is invoked to enter a character in To or Cc
1212 header, ecomplete will suggest the candidates of recipients (see also
1213 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1214 text and it replaces `self-insert-command' with the other command, e.g.
1215 `egg-self-insert-command', you may want to add it to this list."
1216 :group
'message-various
1217 :type
'(repeat function
))
1219 (defcustom message-auto-save-directory
1220 (file-name-as-directory (nnheader-concat message-directory
"drafts"))
1221 "*Directory where Message auto-saves buffers if Gnus isn't running.
1222 If nil, Message won't auto-save."
1223 :group
'message-buffers
1224 :link
'(custom-manual "(message)Various Message Variables")
1225 :type
'(choice directory
(const :tag
"Don't auto-save" nil
)))
1227 (defcustom message-default-charset
1228 (and (not (mm-multibyte-p)) 'iso-8859-1
)
1229 "Default charset used in non-MULE Emacsen.
1230 If nil, you might be asked to input the charset."
1233 :link
'(custom-manual "(message)Various Message Variables")
1236 (defcustom message-dont-reply-to-names
1237 (and (boundp 'rmail-dont-reply-to-names
) rmail-dont-reply-to-names
)
1238 "*Addresses to prune when doing wide replies.
1239 This can be a regexp or a list of regexps. Also, a value of nil means
1240 exclude your own user name only."
1243 :link
'(custom-manual "(message)Wide Reply")
1244 :type
'(choice (const :tag
"Yourself" nil
)
1246 (repeat :tag
"Regexp List" regexp
)))
1248 (defsubst message-dont-reply-to-names
()
1249 (gmm-regexp-concat message-dont-reply-to-names
))
1251 (defvar message-shoot-gnksa-feet nil
1252 "*A list of GNKSA feet you are allowed to shoot.
1253 Gnus gives you all the opportunity you could possibly want for
1254 shooting yourself in the foot. Also, Gnus allows you to shoot the
1255 feet of Good Net-Keeping Seal of Approval. The following are foot
1257 `empty-article' Allow you to post an empty article;
1258 `quoted-text-only' Allow you to post quoted text only;
1259 `multiple-copies' Allow you to post multiple copies;
1260 `cancel-messages' Allow you to cancel or supersede messages from
1261 your other email addresses.")
1263 (defsubst message-gnksa-enable-p
(feature)
1264 (or (not (listp message-shoot-gnksa-feet
))
1265 (memq feature message-shoot-gnksa-feet
)))
1267 (defcustom message-hidden-headers
'("^References:" "^Face:" "^X-Face:"
1269 "Regexp of headers to be hidden when composing new messages.
1270 This can also be a list of regexps to match headers. Or a list
1271 starting with `not' and followed by regexps."
1274 :link
'(custom-manual "(message)Message Headers")
1276 :format
"%{%t%}: %[Value Type%] %v"
1277 (regexp :menu-tag
"regexp" :format
"regexp\n%t: %v")
1278 (repeat :menu-tag
"(regexp ...)" :format
"(regexp ...)\n%v%i"
1279 (regexp :format
"%t: %v"))
1280 (cons :menu-tag
"(not regexp ...)" :format
"(not regexp ...)\n%v"
1282 (repeat :format
"%v%i"
1283 (regexp :format
"%t: %v")))))
1285 (defcustom message-cite-articles-with-x-no-archive t
1286 "If non-nil, cite text from articles that has X-No-Archive set."
1290 ;;; Internal variables.
1291 ;;; Well, not really internal.
1293 (defvar message-mode-syntax-table
1294 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1295 (modify-syntax-entry ?%
". " table
)
1296 (modify-syntax-entry ?
> ". " table
)
1297 (modify-syntax-entry ?
< ". " table
)
1299 "Syntax table used while in Message mode.")
1301 (defface message-header-to
1304 (:foreground
"DarkOliveGreen1" :bold t
))
1307 (:foreground
"MidnightBlue" :bold t
))
1309 (:bold t
:italic t
)))
1310 "Face used for displaying From headers."
1311 :group
'message-faces
)
1312 ;; backward-compatibility alias
1313 (put 'message-header-to-face
'face-alias
'message-header-to
)
1315 (defface message-header-cc
1318 (:foreground
"chartreuse1" :bold t
))
1321 (:foreground
"MidnightBlue"))
1324 "Face used for displaying Cc headers."
1325 :group
'message-faces
)
1326 ;; backward-compatibility alias
1327 (put 'message-header-cc-face
'face-alias
'message-header-cc
)
1329 (defface message-header-subject
1332 (:foreground
"OliveDrab1"))
1335 (:foreground
"navy blue" :bold t
))
1338 "Face used for displaying subject headers."
1339 :group
'message-faces
)
1340 ;; backward-compatibility alias
1341 (put 'message-header-subject-face
'face-alias
'message-header-subject
)
1343 (defface message-header-newsgroups
1346 (:foreground
"yellow" :bold t
:italic t
))
1349 (:foreground
"blue4" :bold t
:italic t
))
1351 (:bold t
:italic t
)))
1352 "Face used for displaying newsgroups headers."
1353 :group
'message-faces
)
1354 ;; backward-compatibility alias
1355 (put 'message-header-newsgroups-face
'face-alias
'message-header-newsgroups
)
1357 (defface message-header-other
1360 (:foreground
"VioletRed1"))
1363 (:foreground
"steel blue"))
1365 (:bold t
:italic t
)))
1366 "Face used for displaying newsgroups headers."
1367 :group
'message-faces
)
1368 ;; backward-compatibility alias
1369 (put 'message-header-other-face
'face-alias
'message-header-other
)
1371 (defface message-header-name
1374 (:foreground
"green"))
1377 (:foreground
"cornflower blue"))
1380 "Face used for displaying header names."
1381 :group
'message-faces
)
1382 ;; backward-compatibility alias
1383 (put 'message-header-name-face
'face-alias
'message-header-name
)
1385 (defface message-header-xheader
1388 (:foreground
"DeepSkyBlue1"))
1391 (:foreground
"blue"))
1394 "Face used for displaying X-Header headers."
1395 :group
'message-faces
)
1396 ;; backward-compatibility alias
1397 (put 'message-header-xheader-face
'face-alias
'message-header-xheader
)
1399 (defface message-separator
1402 (:foreground
"LightSkyBlue1"))
1405 (:foreground
"brown"))
1408 "Face used for displaying the separator."
1409 :group
'message-faces
)
1410 ;; backward-compatibility alias
1411 (put 'message-separator-face
'face-alias
'message-separator
)
1413 (defface message-cited-text
1416 (:foreground
"LightPink1"))
1419 (:foreground
"red"))
1422 "Face used for displaying cited text names."
1423 :group
'message-faces
)
1424 ;; backward-compatibility alias
1425 (put 'message-cited-text-face
'face-alias
'message-cited-text
)
1427 (defface message-mml
1430 (:foreground
"MediumSpringGreen"))
1433 (:foreground
"ForestGreen"))
1436 "Face used for displaying MML."
1437 :group
'message-faces
)
1438 ;; backward-compatibility alias
1439 (put 'message-mml-face
'face-alias
'message-mml
)
1441 (defun message-font-lock-make-header-matcher (regexp)
1444 (let ((start (point)))
1447 (goto-char (point-min))
1448 (if (re-search-forward
1449 (concat "^" (regexp-quote mail-header-separator
) "$")
1451 (setq limit
(min limit
(match-beginning 0))))
1453 (and (< start limit
)
1454 (re-search-forward ,regexp limit t
))))))
1455 (if (featurep 'bytecomp
)
1459 (defvar message-font-lock-keywords
1460 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1461 `((,(message-font-lock-make-header-matcher
1462 (concat "^\\([Tt]o:\\)" content
))
1463 (1 'message-header-name
)
1464 (2 'message-header-to nil t
))
1465 (,(message-font-lock-make-header-matcher
1466 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content
))
1467 (1 'message-header-name
)
1468 (2 'message-header-cc nil t
))
1469 (,(message-font-lock-make-header-matcher
1470 (concat "^\\([Ss]ubject:\\)" content
))
1471 (1 'message-header-name
)
1472 (2 'message-header-subject nil t
))
1473 (,(message-font-lock-make-header-matcher
1474 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content
))
1475 (1 'message-header-name
)
1476 (2 'message-header-newsgroups nil t
))
1477 (,(message-font-lock-make-header-matcher
1478 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content
))
1479 (1 'message-header-name
)
1480 (2 'message-header-xheader
))
1481 (,(message-font-lock-make-header-matcher
1482 (concat "^\\([A-Z][^: \n\t]+:\\)" content
))
1483 (1 'message-header-name
)
1484 (2 'message-header-other nil t
))
1485 ,@(if (and mail-header-separator
1486 (not (equal mail-header-separator
"")))
1487 `((,(concat "^\\(" (regexp-quote mail-header-separator
) "\\)$")
1488 1 'message-separator
))
1491 (re-search-forward (concat "^\\("
1492 message-cite-prefix-regexp
1495 (0 'message-cited-text
))
1496 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1498 "Additional expressions to highlight in Message mode.")
1501 ;; XEmacs does it like this. For Emacs, we have to set the
1502 ;; `font-lock-defaults' buffer-local variable.
1503 (put 'message-mode
'font-lock-defaults
'(message-font-lock-keywords t
))
1505 (defvar message-face-alist
1506 '((bold . message-bold-region
)
1507 (underline . underline-region
)
1508 (default .
(lambda (b e
)
1509 (message-unbold-region b e
)
1510 (ununderline-region b e
))))
1511 "Alist of mail and news faces for facemenu.
1512 The cdr of each entry is a function for applying the face to a region.")
1514 (defcustom message-send-hook nil
1515 "Hook run before sending messages.
1516 This hook is run quite early when sending."
1517 :group
'message-various
1518 :options
'(ispell-message)
1519 :link
'(custom-manual "(message)Various Message Variables")
1522 (defcustom message-send-mail-hook nil
1523 "Hook run before sending mail messages.
1524 This hook is run very late -- just before the message is sent as
1526 :group
'message-various
1527 :link
'(custom-manual "(message)Various Message Variables")
1530 (defcustom message-send-news-hook nil
1531 "Hook run before sending news messages.
1532 This hook is run very late -- just before the message is sent as
1534 :group
'message-various
1535 :link
'(custom-manual "(message)Various Message Variables")
1538 (defcustom message-sent-hook nil
1539 "Hook run after sending messages."
1540 :group
'message-various
1543 (defvar message-send-coding-system
'binary
1544 "Coding system to encode outgoing mail.")
1546 (defvar message-draft-coding-system
1547 mm-auto-save-coding-system
1548 "*Coding system to compose mail.
1549 If you'd like to make it possible to share draft files between XEmacs
1550 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1551 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1553 (defcustom message-send-mail-partially-limit
1000000
1554 "The limitation of messages sent as message/partial.
1555 The lower bound of message size in characters, beyond which the message
1556 should be sent in several parts. If it is nil, the size is unlimited."
1558 :group
'message-buffers
1559 :link
'(custom-manual "(message)Mail Variables")
1560 :type
'(choice (const :tag
"unlimited" nil
)
1563 (defcustom message-alternative-emails nil
1564 "*Regexp matching alternative email addresses.
1565 The first address in the To, Cc or From headers of the original
1566 article matching this variable is used as the From field of
1569 This variable has precedence over posting styles and anything that runs
1570 off `message-setup-hook'."
1571 :group
'message-headers
1572 :link
'(custom-manual "(message)Message Headers")
1573 :type
'(choice (const :tag
"Always use primary" nil
)
1576 (defcustom message-hierarchical-addresses nil
1577 "A list of hierarchical mail address definitions.
1579 Inside each entry, the first address is the \"top\" address, and
1580 subsequent addresses are subaddresses; this is used to indicate that
1581 mail sent to the first address will automatically be delivered to the
1582 subaddresses. So if the first address appears in the recipient list
1583 for a message, the subaddresses will be removed (if present) before
1584 the mail is sent. All addresses in this structure should be
1587 :group
'message-headers
1588 :type
'(repeat (repeat string
)))
1590 (defcustom message-mail-user-agent nil
1591 "Like `mail-user-agent'.
1592 Except if it is nil, use Gnus native MUA; if it is t, use
1595 :type
'(radio (const :tag
"Gnus native"
1598 (const :tag
"`mail-user-agent'"
1601 (function-item :tag
"Default Emacs mail"
1603 sendmail-user-agent
)
1604 (function-item :tag
"Emacs interface to MH"
1607 (function :tag
"Other"))
1611 (defcustom message-wide-reply-confirm-recipients nil
1612 "Whether to confirm a wide reply to multiple email recipients.
1613 If this variable is nil, don't ask whether to reply to all recipients.
1614 If this variable is non-nil, pose the question \"Reply to all
1615 recipients?\" before a wide reply to multiple recipients. If the user
1616 answers yes, reply to all recipients as usual. If the user answers
1617 no, only reply back to the author."
1619 :group
'message-headers
1620 :link
'(custom-manual "(message)Wide Reply")
1623 (defcustom message-user-fqdn nil
1624 "*Domain part of Message-Ids."
1626 :group
'message-headers
1627 :link
'(custom-manual "(message)News Headers")
1628 :type
'(radio (const :format
"%v " nil
)
1629 (string :format
"FQDN: %v")))
1631 (defcustom message-use-idna
(and (condition-case nil
(require 'idna
)
1633 (mm-coding-system-p 'utf-8
)
1634 (executable-find idna-program
)
1635 (string= (idna-to-ascii "räksmörgås")
1636 "xn--rksmrgs-5wao1o")
1638 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1639 GNU Libidn, and in particular the elisp package \"idna.el\" and
1640 the external program \"idn\", must be installed for this
1641 functionality to work."
1643 :group
'message-headers
1644 :link
'(custom-manual "(message)IDNA")
1645 :type
'(choice (const :tag
"Ask" ask
)
1646 (const :tag
"Never" nil
)
1647 (const :tag
"Always" t
)))
1649 (defcustom message-generate-hashcash
(if (executable-find "hashcash") t
)
1650 "*Whether to generate X-Hashcash: headers.
1651 If t, always generate hashcash headers. If `opportunistic',
1652 only generate hashcash headers if it can be done without the user
1653 waiting (i.e., only asynchronously).
1655 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1656 :group
'message-headers
1657 :link
'(custom-manual "(message)Mail Headers")
1658 :type
'(choice (const :tag
"Always" t
)
1659 (const :tag
"Never" nil
)
1660 (const :tag
"Opportunistic" opportunistic
)))
1662 ;;; Internal variables.
1664 (defvar message-sending-message
"Sending...")
1665 (defvar message-buffer-list nil
)
1666 (defvar message-this-is-news nil
)
1667 (defvar message-this-is-mail nil
)
1668 (defvar message-draft-article nil
)
1669 (defvar message-mime-part nil
)
1670 (defvar message-posting-charset nil
)
1671 (defvar message-inserted-headers nil
)
1673 ;; Byte-compiler warning
1674 (defvar gnus-active-hashtb
)
1675 (defvar gnus-read-active-file
)
1677 ;;; Regexp matching the delimiter of messages in UNIX mail format
1678 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1679 ;;; of rmail.el's rmail-unix-mail-delimiter.
1680 (defvar message-unix-mail-delimiter
1681 (let ((time-zone-regexp
1682 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1683 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1689 ;; Many things can happen to an RFC 822 mailbox before it is put into
1690 ;; a `From' line. The leading phrase can be stripped, e.g.
1691 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1692 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1693 ;; can be removed, e.g.
1694 ;; From: joe@y.z (Joe K
1696 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1699 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1700 ;; The mailbox can be removed or be replaced by white space, e.g.
1701 ;; From: "Joe User"{space}{tab}
1703 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1704 ;; where {space} and {tab} represent the Ascii space and tab characters.
1705 ;; We want to match the results of any of these manglings.
1706 ;; The following regexp rejects names whose first characters are
1707 ;; obviously bogus, but after that anything goes.
1708 "\\([^\0-\b\n-\r\^?].*\\)?"
1710 ;; The time the message was sent.
1711 "\\([^\0-\r \^?]+\\) +" ; day of the week
1712 "\\([^\0-\r \^?]+\\) +" ; month
1713 "\\([0-3]?[0-9]\\) +" ; day of month
1714 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1716 ;; Perhaps a time zone, specified by an abbreviation, or by a
1721 " \\([0-9][0-9]+\\) *"
1723 ;; On some systems the time zone can appear after the year, too.
1727 "\\(remote from .*\\)?"
1730 "Regexp matching the delimiter of messages in UNIX mail format.")
1732 (defvar message-unsent-separator
1733 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1734 "^ *---+ +Returned message +---+ *$\\|"
1735 "^Start of returned message$\\|"
1736 "^ *---+ +Original message +---+ *$\\|"
1737 "^ *--+ +begin message +--+ *$\\|"
1738 "^ *---+ +Original message follows +---+ *$\\|"
1739 "^ *---+ +Undelivered message follows +---+ *$\\|"
1740 "^------ This is a copy of the message, including all the headers. ------ *$\\|"
1741 "^|? *---+ +Message text follows: +---+ *|?$")
1742 "A regexp that matches the separator before the text of a failed message.")
1744 (defvar message-field-fillers
1745 '((To message-fill-field-address
)
1746 (Cc message-fill-field-address
)
1747 (From message-fill-field-address
))
1748 "Alist of header names/filler functions.")
1750 (defvar message-header-format-alist
1765 (References . message-shorten-references
)
1767 "Alist used for formatting headers.")
1769 (defvar message-options nil
1770 "Some saved answers when sending message.")
1772 (defvar message-send-mail-real-function nil
1773 "Internal send mail function.")
1775 (defvar message-bogus-system-names
"^localhost\\.\\|\\.local$"
1776 "The regexp of bogus system names.")
1778 (defcustom message-valid-fqdn-regexp
1779 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1781 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1782 "aero\\|arpa\\|bitnet\\|biz\\|bofh\\|"
1783 "cat\\|com\\|coop\\|edu\\|gov\\|"
1784 "info\\|int\\|jobs\\|"
1785 "mil\\|mobi\\|museum\\|name\\|net\\|"
1786 "org\\|pro\\|travel\\|uucp\\)")
1787 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1788 ;; http://en.wikipedia.org/wiki/GTLD
1789 ;; `in the process of being approved': .asia .post .tel .sex
1790 ;; "dead" nato bitnet uucp
1791 "Regular expression that matches a valid FQDN."
1792 ;; see also: gnus-button-valid-fqdn-regexp
1794 :group
'message-headers
1798 (autoload 'gnus-alive-p
"gnus-util")
1799 (autoload 'gnus-delay-article
"gnus-delay")
1800 (autoload 'gnus-extract-address-components
"gnus-util")
1801 (autoload 'gnus-find-method-for-group
"gnus")
1802 (autoload 'gnus-group-decoded-name
"gnus-group")
1803 (autoload 'gnus-group-name-charset
"gnus-group")
1804 (autoload 'gnus-group-name-decode
"gnus-group")
1805 (autoload 'gnus-groups-from-server
"gnus")
1806 (autoload 'gnus-make-local-hook
"gnus-util")
1807 (autoload 'gnus-open-server
"gnus-int")
1808 (autoload 'gnus-output-to-mail
"gnus-util")
1809 (autoload 'gnus-output-to-rmail
"gnus-util")
1810 (autoload 'gnus-request-post
"gnus-int")
1811 (autoload 'gnus-select-frame-set-input-focus
"gnus-util")
1812 (autoload 'gnus-server-string
"gnus")
1813 (autoload 'idna-to-ascii
"idna")
1814 (autoload 'message-setup-toolbar
"messagexmas")
1815 (autoload 'mh-new-draft-name
"mh-comp")
1816 (autoload 'mh-send-letter
"mh-comp")
1817 (autoload 'nndraft-request-associate-buffer
"nndraft")
1818 (autoload 'nndraft-request-expire-articles
"nndraft")
1819 (autoload 'nnvirtual-find-group-art
"nnvirtual")
1820 (autoload 'rmail-dont-reply-to
"mail-utils")
1821 (autoload 'rmail-msg-is-pruned
"rmail")
1822 (autoload 'rmail-msg-restore-non-pruned-header
"rmail")
1823 (autoload 'rmail-output
"rmailout"))
1828 ;;; Utility functions.
1831 (defmacro message-y-or-n-p
(question show
&rest text
)
1832 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1833 `(message-talkative-question 'y-or-n-p
,question
,show
,@text
))
1835 (defmacro message-delete-line
(&optional n
)
1836 "Delete the current line (and the next N lines)."
1837 `(delete-region (progn (beginning-of-line) (point))
1838 (progn (forward-line ,(or n
1)) (point))))
1840 (defun message-mark-active-p ()
1841 "Non-nil means the mark and region are currently active in this buffer."
1844 (defun message-unquote-tokens (elems)
1845 "Remove double quotes (\") from strings in list ELEMS."
1846 (mapcar (lambda (item)
1847 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item
)
1848 (setq item
(concat (match-string 1 item
)
1849 (match-string 2 item
))))
1853 (defun message-tokenize-header (header &optional separator
)
1854 "Split HEADER into a list of header elements.
1855 SEPARATOR is a string of characters to be used as separators. \",\"
1856 is used by default."
1859 (let ((regexp (format "[%s]+" (or separator
",")))
1861 beg quoted elems paren
)
1863 (mm-enable-multibyte)
1864 (setq beg
(point-min))
1866 (goto-char (point-min))
1871 (cond ((and (> (point) beg
)
1873 (and (looking-at regexp
)
1876 (push (buffer-substring beg
(point)) elems
)
1877 (setq beg
(match-end 0)))
1878 ((eq (char-after) ?
\")
1879 (setq quoted
(not quoted
)))
1880 ((and (eq (char-after) ?\
()
1883 ((and (eq (char-after) ?\
))
1886 (nreverse elems
)))))
1888 (defun message-mail-file-mbox-p (file)
1889 "Say whether FILE looks like a Unix mbox file."
1890 (when (and (file-exists-p file
)
1891 (file-readable-p file
)
1892 (file-regular-p file
))
1894 (nnheader-insert-file-contents file
)
1895 (goto-char (point-min))
1896 (looking-at message-unix-mail-delimiter
))))
1898 (defun message-fetch-field (header &optional not-all
)
1899 "The same as `mail-fetch-field', only remove all newlines.
1900 The buffer is expected to be narrowed to just the header of the message;
1901 see `message-narrow-to-headers-or-head'."
1902 (let* ((inhibit-point-motion-hooks t
)
1903 (value (mail-fetch-field header nil
(not not-all
))))
1905 (while (string-match "\n[\t ]+" value
)
1906 (setq value
(replace-match " " t t value
)))
1909 (defun message-field-value (header &optional not-all
)
1910 "The same as `message-fetch-field', only narrow to the headers first."
1913 (message-narrow-to-headers-or-head)
1914 (message-fetch-field header not-all
))))
1916 (defun message-narrow-to-field ()
1917 "Narrow the buffer to the header on the current line."
1919 (while (looking-at "[ \t]")
1925 (if (re-search-forward "^[^ \n\t]" nil t
)
1928 (goto-char (point-min)))
1930 (defun message-add-header (&rest headers
)
1931 "Add the HEADERS to the message header, skipping those already present."
1934 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers
))
1935 (error "Invalid header `%s'" (car headers
)))
1936 (setq hclean
(match-string 1 (car headers
)))
1938 (message-narrow-to-headers)
1939 (unless (re-search-forward (concat "^" (regexp-quote hclean
) ":") nil t
)
1940 (goto-char (point-max))
1941 (if (string-match "\n$" (car headers
))
1942 (insert (car headers
))
1943 (insert (car headers
) ?
\n)))))
1944 (setq headers
(cdr headers
))))
1946 (defmacro message-with-reply-buffer
(&rest forms
)
1947 "Evaluate FORMS in the reply buffer, if it exists."
1948 `(when (and message-reply-buffer
1949 (buffer-name message-reply-buffer
))
1950 (with-current-buffer message-reply-buffer
1953 (put 'message-with-reply-buffer
'lisp-indent-function
0)
1954 (put 'message-with-reply-buffer
'edebug-form-spec
'(body))
1956 (defun message-fetch-reply-field (header)
1957 "Fetch field HEADER from the message we're replying to."
1958 (message-with-reply-buffer
1960 (mail-narrow-to-head)
1961 (message-fetch-field header
))))
1963 (defun message-strip-list-identifiers (subject)
1964 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
1965 (require 'gnus-sum
) ; for gnus-list-identifiers
1966 (let ((regexp (if (stringp gnus-list-identifiers
)
1967 gnus-list-identifiers
1968 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
1969 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
1970 " *\\)\\)+\\(Re: +\\)?\\)") subject
)
1971 (concat (substring subject
0 (match-beginning 1))
1972 (or (match-string 3 subject
)
1973 (match-string 5 subject
))
1978 (defun message-strip-subject-re (subject)
1979 "Remove \"Re:\" from subject lines in string SUBJECT."
1980 (if (string-match message-subject-re-regexp subject
)
1981 (substring subject
(match-end 0))
1984 (defcustom message-replacement-char
"."
1985 "Replacement character used instead of unprintable or not decodable chars."
1986 :group
'message-various
1987 :version
"22.1" ;; Gnus 5.10.9
1988 :type
'(choice string
1992 ;; FIXME: We also should call `message-strip-subject-encoded-words'
1993 ;; when forwarding. Probably in `message-make-forward-subject' and
1994 ;; `message-forward-make-body'.
1996 (defun message-strip-subject-encoded-words (subject)
1997 "Fix non-decodable words in SUBJECT."
1998 ;; Cf. `gnus-simplify-subject-fully'.
1999 (let* ((case-fold-search t
)
2000 (replacement-chars (format "[%s%s%s]"
2001 message-replacement-char
2002 message-replacement-char
2003 message-replacement-char
))
2004 (enc-word-re "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?\\([^?]+\\)\\(\\?=\\)")
2009 (goto-char (point-min))
2010 (when (re-search-forward enc-word-re nil t
)
2011 (setq cs-string
(match-string 1)))))
2012 cs-coding q-or-b word-beg word-end
)
2013 (if (or (not have-marker
) ;; No encoded word found...
2014 ;; ... or double encoding was correct:
2015 (and (stringp cs-string
)
2016 (setq cs-string
(downcase cs-string
))
2017 (mm-coding-system-p (intern cs-string
))
2021 Decoded Subject \"%s\"
2022 contains a valid encoded word. Decode again? "
2024 (setq cs-coding
(intern cs-string
))))))
2028 (goto-char (point-min))
2029 (while (re-search-forward enc-word-re nil t
)
2030 (setq cs-string
(downcase (match-string 1))
2031 q-or-b
(match-string 2)
2032 word-beg
(match-beginning 0)
2033 word-end
(match-end 0))
2035 (if (mm-coding-system-p (intern cs-string
))
2036 (setq cs-coding
(intern cs-string
))
2038 ;; No double encoded subject? => bogus charset.
2041 (mm-read-coding-system
2043 Decoded Subject \"%s\"
2044 contains an encoded word. The charset `%s' is unknown or invalid.
2045 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
2047 subject cs-string message-replacement-char
)))
2049 (replace-match (concat "=?" (symbol-name cs-coding
)
2052 (goto-char word-beg
)
2053 (re-search-forward "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?" word-end t
)
2056 (if (string-match "\\`Q\\'" q-or-b
)
2059 (message "Replacing non-decodable characters with \"%s\"."
2060 message-replacement-char
)
2061 (while (re-search-forward "\\(=[A-F0-9][A-F0-9]\\)+"
2063 (replace-match message-replacement-char
)))
2065 (message "Replacing non-decodable characters with \"%s\"."
2067 (re-search-forward "[^?]+" word-end t
)
2068 (replace-match replacement-chars
))
2069 (re-search-forward "\\?=")
2070 (replace-match "")))))
2071 (rfc2047-decode-region (point-min) (point-max))
2074 ;;; Start of functions adopted from `message-utils.el'.
2076 (defun message-strip-subject-trailing-was (subject)
2077 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
2078 Leading \"Re: \" is not stripped by this function. Use the function
2079 `message-strip-subject-re' for this."
2080 (let* ((query message-subject-trailing-was-query
)
2085 message-subject-trailing-was-ask-regexp
2086 message-subject-trailing-was-regexp
)
2089 (setq new
(substring subject
0 (match-beginning 0))))
2090 (if (or (not found
) (eq query nil
))
2093 (if (message-y-or-n-p
2094 "Strip `(was: <old subject>)' in subject? " t
2096 "Strip `(was: <old subject>)' in subject "
2097 "and use the new one instead?\n\n"
2098 "Current subject is: \""
2100 "New subject would be: \""
2102 "See the variable `message-subject-trailing-was-query' "
2103 "to get rid of this query."
2108 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
2110 (defun message-change-subject (new-subject)
2111 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
2112 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged>
2115 (read-from-minibuffer "New subject: ")))
2116 (cond ((and (not (or (null new-subject
) ; new subject not empty
2117 (zerop (string-width new-subject
))
2118 (string-match "^[ \t]*$" new-subject
))))
2122 (message-narrow-to-headers)
2123 (message-fetch-field "Subject"))))
2124 (cond ((not old-subject
)
2125 (error "No current subject"))
2128 (regexp-quote new-subject
)
2130 old-subject
)) ; yes, it really is a new subject
2131 ;; delete eventual Re: prefix
2133 (message-strip-subject-re old-subject
))
2134 (message-goto-subject)
2135 (message-delete-line)
2136 (insert (concat "Subject: "
2139 old-subject
")\n")))))))))
2141 (defun message-mark-inserted-region (beg end
&optional verbatim
)
2142 "Mark some region in the current article with enclosing tags.
2143 See `message-mark-insert-begin' and `message-mark-insert-end'.
2144 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2145 (interactive "r\nP")
2147 ;; add to the end of the region first, otherwise end would be invalid
2149 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2151 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2153 (defun message-mark-insert-file (file &optional verbatim
)
2154 "Insert FILE at point, marking it with enclosing tags.
2155 See `message-mark-insert-begin' and `message-mark-insert-end'.
2156 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2157 (interactive "fFile to insert: \nP")
2158 ;; reverse insertion to get correct result.
2160 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2162 (insert-file-contents file
)
2164 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2166 (defun message-add-archive-header ()
2167 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
2168 The note can be customized using `message-archive-note'. When called with a
2169 prefix argument, ask for a text to insert. If you don't want the note in the
2170 body, set `message-archive-note' to nil."
2172 (if current-prefix-arg
2173 (setq message-archive-note
2174 (read-from-minibuffer "Reason for No-Archive: "
2175 (cons message-archive-note
0))))
2177 (if (message-goto-signature)
2178 (re-search-backward message-signature-separator
))
2179 (when message-archive-note
2180 (insert message-archive-note
)
2182 (message-add-header message-archive-header
)
2183 (message-sort-headers)))
2185 (defun message-cross-post-followup-to-header (target-group)
2186 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2187 With prefix-argument just set Follow-Up, don't cross-post."
2189 (list ; Completion based on Gnus
2190 (completing-read "Followup To: "
2191 (if (boundp 'gnus-newsrc-alist
)
2193 nil nil
'("poster" .
0)
2194 (if (boundp 'gnus-group-history
)
2195 'gnus-group-history
))))
2196 (message-remove-header "Follow[Uu]p-[Tt]o" t
)
2197 (message-goto-newsgroups)
2199 ;; if we already did a crosspost before, kill old target
2200 (if (and message-cross-post-old-target
2202 (regexp-quote (concat "," message-cross-post-old-target
))
2205 ;; unless (followup is to poster or user explicitly asked not
2206 ;; to cross-post, or target-group is already in Newsgroups)
2207 ;; add target-group to Newsgroups line.
2209 ;; def: cross-post, req:no
2210 (and message-cross-post-default
(not current-prefix-arg
))
2211 ;; def: no-cross-post, req:yes
2212 (and (not message-cross-post-default
) current-prefix-arg
))
2213 (not (string-match "poster" target-group
))
2214 (not (string-match (regexp-quote target-group
)
2215 (message-fetch-field "Newsgroups"))))
2217 (insert (concat "," target-group
))))
2218 (end-of-line) ; ensure Followup: comes after Newsgroups:
2219 ;; unless new followup would be identical to Newsgroups line
2220 ;; make a new Followup-To line
2221 (if (not (string-match (concat "^[ \t]*"
2224 (message-fetch-field "Newsgroups")))
2225 (insert (concat "\nFollowup-To: " target-group
)))
2226 (setq message-cross-post-old-target target-group
))
2228 (defun message-cross-post-insert-note (target-group cross-post in-old
2230 "Insert a in message body note about a set Followup or Crosspost.
2231 If there have been previous notes, delete them. TARGET-GROUP specifies the
2232 group to Followup-To. When CROSS-POST is t, insert note about
2233 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2234 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2235 been made to before the user asked for a Crosspost."
2236 ;; start scanning body for previous uses
2237 (message-goto-signature)
2238 (let ((head (re-search-backward
2239 (concat "^" mail-header-separator
)
2240 nil t
))) ; just search in body
2241 (message-goto-signature)
2242 (while (re-search-backward
2243 (concat "^" (regexp-quote message-cross-post-note
) ".*")
2245 (message-delete-line))
2246 (message-goto-signature)
2247 (while (re-search-backward
2248 (concat "^" (regexp-quote message-followup-to-note
) ".*")
2250 (message-delete-line))
2252 (if (message-goto-signature)
2253 (re-search-backward message-signature-separator
))
2256 (string-match "^[ \t]*poster[ \t]*$" target-group
))
2257 (insert (concat message-followup-to-note target-group
"\n"))
2258 (insert (concat message-cross-post-note target-group
"\n")))))
2260 (defun message-cross-post-followup-to (target-group)
2261 "Crossposts message and set Followup-To to TARGET-GROUP.
2262 With prefix-argument just set Follow-Up, don't cross-post."
2264 (list ; Completion based on Gnus
2265 (completing-read "Followup To: "
2266 (if (boundp 'gnus-newsrc-alist
)
2268 nil nil
'("poster" .
0)
2269 (if (boundp 'gnus-group-history
)
2270 'gnus-group-history
))))
2271 (cond ((not (or (null target-group
) ; new subject not empty
2272 (zerop (string-width target-group
))
2273 (string-match "^[ \t]*$" target-group
)))
2275 (let* ((old-groups (message-fetch-field "Newsgroups"))
2276 (in-old (string-match
2277 (regexp-quote target-group
)
2278 (or old-groups
""))))
2279 ;; check whether target exactly matches old Newsgroups
2280 (cond ((not old-groups
)
2281 (error "No current newsgroup"))
2285 (regexp-quote target-group
)
2288 ;; yes, Newsgroups line must change
2289 (message-cross-post-followup-to-header target-group
)
2290 ;; insert note whether we do cross-post or followup-to
2291 (funcall message-cross-post-note-function
2293 (if (or (and message-cross-post-default
2294 (not current-prefix-arg
))
2295 (and (not message-cross-post-default
)
2296 current-prefix-arg
)) t
)
2297 in-old old-groups
))))))))
2299 ;;; Reduce To: to Cc: or Bcc: header
2301 (defun message-reduce-to-to-cc ()
2302 "Replace contents of To: header with contents of Cc: or Bcc: header."
2305 (save-restriction (message-narrow-to-headers)
2306 (message-fetch-field "cc")))
2308 (if (and (not cc-content
)
2311 (message-narrow-to-headers)
2312 (message-fetch-field "bcc"))))
2317 (message-delete-line)
2318 (insert (concat "To: " cc-content
"\n"))
2320 (message-narrow-to-headers)
2321 (message-remove-header (if bcc
2325 ;;; End of functions adopted from `message-utils.el'.
2327 (defun message-remove-header (header &optional is-regexp first reverse
)
2328 "Remove HEADER in the narrowed buffer.
2329 If IS-REGEXP, HEADER is a regular expression.
2330 If FIRST, only remove the first instance of the header.
2331 Return the number of headers removed."
2332 (goto-char (point-min))
2333 (let ((regexp (if is-regexp header
(concat "^" (regexp-quote header
) ":")))
2335 (case-fold-search t
)
2337 (while (and (not (eobp))
2340 (not (looking-at regexp
))
2341 (looking-at regexp
))
2348 ;; There might be a continuation header, so we have to search
2349 ;; until we find a new non-continuation line.
2352 (if (re-search-forward "^[^ \t]" nil t
)
2353 (goto-char (match-beginning 0))
2356 (if (re-search-forward "^[^ \t]" nil t
)
2357 (goto-char (match-beginning 0))
2358 (goto-char (point-max)))))
2361 (defun message-remove-first-header (header)
2362 "Remove the first instance of HEADER if there is more than one."
2364 (regexp (concat "^" (regexp-quote header
) ":")))
2366 (goto-char (point-min))
2367 (while (re-search-forward regexp nil t
)
2370 (message-remove-header header nil t
)
2373 (defun message-narrow-to-headers ()
2374 "Narrow the buffer to the head of the message."
2377 (goto-char (point-min))
2378 (if (re-search-forward
2379 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
)
2382 (goto-char (point-min)))
2384 (defun message-narrow-to-head-1 ()
2385 "Like `message-narrow-to-head'. Don't widen."
2387 (goto-char (point-min))
2388 (if (search-forward "\n\n" nil
1)
2391 (goto-char (point-min)))
2393 (defun message-narrow-to-head ()
2394 "Narrow the buffer to the head of the message.
2395 Point is left at the beginning of the narrowed-to region."
2397 (message-narrow-to-head-1))
2399 (defun message-narrow-to-headers-or-head ()
2400 "Narrow the buffer to the head of the message."
2403 (goto-char (point-min))
2404 (if (re-search-forward (concat "\\(\n\\)\n\\|^\\("
2405 (regexp-quote mail-header-separator
)
2408 (or (match-end 1) (match-beginning 2))
2410 (goto-char (point-min)))
2412 (defun message-news-p ()
2413 "Say whether the current buffer contains a news message."
2414 (and (not message-this-is-mail
)
2415 (or message-this-is-news
2418 (message-narrow-to-headers)
2419 (and (message-fetch-field "newsgroups")
2420 (not (message-fetch-field "posted-to"))))))))
2422 (defun message-mail-p ()
2423 "Say whether the current buffer contains a mail message."
2424 (and (not message-this-is-news
)
2425 (or message-this-is-mail
2428 (message-narrow-to-headers)
2429 (or (message-fetch-field "to")
2430 (message-fetch-field "cc")
2431 (message-fetch-field "bcc")))))))
2433 (defun message-subscribed-p ()
2434 "Say whether we need to insert a MFT header."
2435 (or message-subscribed-regexps
2436 message-subscribed-addresses
2437 message-subscribed-address-file
2438 message-subscribed-address-functions
))
2440 (defun message-next-header ()
2441 "Go to the beginning of the next header."
2443 (or (eobp) (forward-char 1))
2444 (not (if (re-search-forward "^[^ \t]" nil t
)
2446 (goto-char (point-max)))))
2448 (defun message-sort-headers-1 ()
2449 "Sort the buffer as headers using `message-rank' text props."
2450 (goto-char (point-min))
2453 nil
'message-next-header
2455 (message-next-header)
2459 (or (get-text-property (point) 'message-rank
)
2462 (defun message-sort-headers ()
2463 "Sort the headers of the current message according to `message-header-format-alist'."
2467 (let ((max (1+ (length message-header-format-alist
)))
2469 (message-narrow-to-headers)
2470 (while (re-search-forward "^[^ \n]+:" nil t
)
2472 (match-beginning 0) (1+ (match-beginning 0))
2474 (if (setq rank
(length (memq (assq (intern (buffer-substring
2476 (1- (match-end 0))))
2477 message-header-format-alist
)
2478 message-header-format-alist
)))
2481 (message-sort-headers-1))))
2483 (defun message-kill-address ()
2484 "Kill the address under point."
2486 (let ((start (point)))
2487 (message-skip-to-next-address)
2488 (kill-region start
(point))))
2491 (autoload 'Info-goto-node
"info")
2493 (defun message-info (&optional arg
)
2494 "Display the Message manual.
2496 Prefixed with one \\[universal-argument], display the Emacs MIME
2497 manual. With two \\[universal-argument]'s, display the EasyPG or
2498 PGG manual, depending on the value of `mml2015-use'."
2500 (Info-goto-node (format "(%s)Top"
2501 (cond ((eq arg
16) mml2015-use
)
2502 ((eq arg
4) 'emacs-mime
)
2503 ;; `booleanp' only available in Emacs 22+
2504 ((and (not (memq arg
'(nil t
)))
2518 (defvar message-mode-map nil
)
2520 (unless message-mode-map
2521 (setq message-mode-map
(make-keymap))
2522 (set-keymap-parent message-mode-map text-mode-map
)
2523 (define-key message-mode-map
"\C-c?" 'describe-mode
)
2525 (define-key message-mode-map
"\C-c\C-f\C-t" 'message-goto-to
)
2526 (define-key message-mode-map
"\C-c\C-f\C-o" 'message-goto-from
)
2527 (define-key message-mode-map
"\C-c\C-f\C-b" 'message-goto-bcc
)
2528 (define-key message-mode-map
"\C-c\C-f\C-w" 'message-goto-fcc
)
2529 (define-key message-mode-map
"\C-c\C-f\C-c" 'message-goto-cc
)
2530 (define-key message-mode-map
"\C-c\C-f\C-s" 'message-goto-subject
)
2531 (define-key message-mode-map
"\C-c\C-f\C-r" 'message-goto-reply-to
)
2532 (define-key message-mode-map
"\C-c\C-f\C-n" 'message-goto-newsgroups
)
2533 (define-key message-mode-map
"\C-c\C-f\C-d" 'message-goto-distribution
)
2534 (define-key message-mode-map
"\C-c\C-f\C-f" 'message-goto-followup-to
)
2535 (define-key message-mode-map
"\C-c\C-f\C-m" 'message-goto-mail-followup-to
)
2536 (define-key message-mode-map
"\C-c\C-f\C-k" 'message-goto-keywords
)
2537 (define-key message-mode-map
"\C-c\C-f\C-u" 'message-goto-summary
)
2538 (define-key message-mode-map
"\C-c\C-f\C-i"
2539 'message-insert-or-toggle-importance
)
2540 (define-key message-mode-map
"\C-c\C-f\C-a"
2541 'message-generate-unsubscribed-mail-followup-to
)
2543 ;; modify headers (and insert notes in body)
2544 (define-key message-mode-map
"\C-c\C-fs" 'message-change-subject
)
2546 (define-key message-mode-map
"\C-c\C-fx" 'message-cross-post-followup-to
)
2547 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2548 (define-key message-mode-map
"\C-c\C-ft" 'message-reduce-to-to-cc
)
2549 (define-key message-mode-map
"\C-c\C-fa" 'message-add-archive-header
)
2550 ;; mark inserted text
2551 (define-key message-mode-map
"\C-c\M-m" 'message-mark-inserted-region
)
2552 (define-key message-mode-map
"\C-c\M-f" 'message-mark-insert-file
)
2554 (define-key message-mode-map
"\C-c\C-b" 'message-goto-body
)
2555 (define-key message-mode-map
"\C-c\C-i" 'message-goto-signature
)
2557 (define-key message-mode-map
"\C-c\C-t" 'message-insert-to
)
2558 (define-key message-mode-map
"\C-c\C-fw" 'message-insert-wide-reply
)
2559 (define-key message-mode-map
"\C-c\C-n" 'message-insert-newsgroups
)
2560 (define-key message-mode-map
"\C-c\C-l" 'message-to-list-only
)
2561 (define-key message-mode-map
"\C-c\C-f\C-e" 'message-insert-expires
)
2563 (define-key message-mode-map
"\C-c\C-u" 'message-insert-or-toggle-importance
)
2564 (define-key message-mode-map
"\C-c\M-n"
2565 'message-insert-disposition-notification-to
)
2567 (define-key message-mode-map
"\C-c\C-y" 'message-yank-original
)
2568 (define-key message-mode-map
"\C-c\M-\C-y" 'message-yank-buffer
)
2569 (define-key message-mode-map
"\C-c\C-q" 'message-fill-yanked-message
)
2570 (define-key message-mode-map
"\C-c\C-w" 'message-insert-signature
)
2571 (define-key message-mode-map
"\C-c\M-h" 'message-insert-headers
)
2572 (define-key message-mode-map
"\C-c\C-r" 'message-caesar-buffer-body
)
2573 (define-key message-mode-map
"\C-c\C-o" 'message-sort-headers
)
2574 (define-key message-mode-map
"\C-c\M-r" 'message-rename-buffer
)
2576 (define-key message-mode-map
"\C-c\C-c" 'message-send-and-exit
)
2577 (define-key message-mode-map
"\C-c\C-s" 'message-send
)
2578 (define-key message-mode-map
"\C-c\C-k" 'message-kill-buffer
)
2579 (define-key message-mode-map
"\C-c\C-d" 'message-dont-send
)
2580 (define-key message-mode-map
"\C-c\n" 'gnus-delay-article
)
2582 (define-key message-mode-map
"\C-c\M-k" 'message-kill-address
)
2583 (define-key message-mode-map
"\C-c\C-e" 'message-elide-region
)
2584 (define-key message-mode-map
"\C-c\C-v" 'message-delete-not-region
)
2585 (define-key message-mode-map
"\C-c\C-z" 'message-kill-to-signature
)
2586 (define-key message-mode-map
"\M-\r" 'message-newline-and-reformat
)
2587 (define-key message-mode-map
[remap split-line
] 'message-split-line
)
2589 (define-key message-mode-map
"\C-c\C-a" 'mml-attach-file
)
2591 (define-key message-mode-map
"\C-a" 'message-beginning-of-line
)
2592 (define-key message-mode-map
"\t" 'message-tab
)
2593 (define-key message-mode-map
"\M-;" 'comment-region
)
2595 (define-key message-mode-map
"\M-n" 'message-display-abbrev
))
2598 message-mode-menu message-mode-map
"Message Menu."
2600 ["Yank Original" message-yank-original message-reply-buffer
]
2601 ["Fill Yanked Message" message-fill-yanked-message t
]
2602 ["Insert Signature" message-insert-signature t
]
2603 ["Caesar (rot13) Message" message-caesar-buffer-body t
]
2604 ["Caesar (rot13) Region" message-caesar-region
(message-mark-active-p)]
2605 ["Elide Region" message-elide-region
2606 :active
(message-mark-active-p)
2607 ,@(if (featurep 'xemacs
) nil
2608 '(:help
"Replace text in region with an ellipsis"))]
2609 ["Delete Outside Region" message-delete-not-region
2610 :active
(message-mark-active-p)
2611 ,@(if (featurep 'xemacs
) nil
2612 '(:help
"Delete all quoted text outside region"))]
2613 ["Kill To Signature" message-kill-to-signature t
]
2614 ["Newline and Reformat" message-newline-and-reformat t
]
2615 ["Rename buffer" message-rename-buffer t
]
2616 ["Spellcheck" ispell-message
2617 ,@(if (featurep 'xemacs
) '(t)
2618 '(:help
"Spellcheck this message"))]
2620 ["Insert Region Marked" message-mark-inserted-region
2621 :active
(message-mark-active-p)
2622 ,@(if (featurep 'xemacs
) nil
2623 '(:help
"Mark region with enclosing tags"))]
2624 ["Insert File Marked..." message-mark-insert-file
2625 ,@(if (featurep 'xemacs
) '(t)
2626 '(:help
"Insert file at point marked with enclosing tags"))]
2628 ["Send Message" message-send-and-exit
2629 ,@(if (featurep 'xemacs
) '(t)
2630 '(:help
"Send this message"))]
2631 ["Postpone Message" message-dont-send
2632 ,@(if (featurep 'xemacs
) '(t)
2633 '(:help
"File this draft message and exit"))]
2634 ["Send at Specific Time..." gnus-delay-article
2635 ,@(if (featurep 'xemacs
) '(t)
2636 '(:help
"Ask, then arrange to send message at that time"))]
2637 ["Kill Message" message-kill-buffer
2638 ,@(if (featurep 'xemacs
) '(t)
2639 '(:help
"Delete this message without sending"))]
2641 ["Message manual" message-info
2642 ,@(if (featurep 'xemacs
) '(t)
2643 '(:help
"Display the Message manual"))]))
2646 message-mode-field-menu message-mode-map
""
2648 ["To" message-goto-to t
]
2649 ["From" message-goto-from t
]
2650 ["Subject" message-goto-subject t
]
2651 ["Change subject..." message-change-subject t
]
2652 ["Cc" message-goto-cc t
]
2653 ["Bcc" message-goto-bcc t
]
2654 ["Fcc" message-goto-fcc t
]
2655 ["Reply-To" message-goto-reply-to t
]
2656 ["Flag As Important" message-insert-importance-high
2657 ,@(if (featurep 'xemacs
) '(t)
2658 '(:help
"Mark this message as important"))]
2659 ["Flag As Unimportant" message-insert-importance-low
2660 ,@(if (featurep 'xemacs
) '(t)
2661 '(:help
"Mark this message as unimportant"))]
2663 message-insert-disposition-notification-to
2664 ,@(if (featurep 'xemacs
) '(t)
2665 '(:help
"Request a receipt notification"))]
2667 ;; (typical) news stuff
2668 ["Summary" message-goto-summary t
]
2669 ["Keywords" message-goto-keywords t
]
2670 ["Newsgroups" message-goto-newsgroups t
]
2671 ["Fetch Newsgroups" message-insert-newsgroups t
]
2672 ["Followup-To" message-goto-followup-to t
]
2673 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2674 ["Crosspost / Followup-To..." message-cross-post-followup-to t
]
2675 ["Distribution" message-goto-distribution t
]
2676 ["Expires" message-insert-expires t
]
2677 ["X-No-Archive" message-add-archive-header t
]
2679 ;; (typical) mailing-lists stuff
2680 ["Fetch To" message-insert-to
2681 ,@(if (featurep 'xemacs
) '(t)
2682 '(:help
"Insert a To header that points to the author."))]
2683 ["Fetch To and Cc" message-insert-wide-reply
2684 ,@(if (featurep 'xemacs
) '(t)
2686 "Insert To and Cc headers as if you were doing a wide reply."))]
2688 ["Send to list only" message-to-list-only t
]
2689 ["Mail-Followup-To" message-goto-mail-followup-to t
]
2690 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2691 ,@(if (featurep 'xemacs
) '(t)
2692 '(:help
"Insert a reasonable `Mail-Followup-To:' header."))]
2693 ["Reduce To: to Cc:" message-reduce-to-to-cc t
]
2695 ["Sort Headers" message-sort-headers t
]
2696 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t
]
2697 ;; We hide `message-hidden-headers' by narrowing the buffer.
2698 ["Show Hidden Headers" widen t
]
2699 ["Goto Body" message-goto-body t
]
2700 ["Goto Signature" message-goto-signature t
]))
2702 (defvar message-tool-bar-map nil
)
2704 (defvar facemenu-add-face-function
)
2705 (defvar facemenu-remove-face-function
)
2707 ;;; Forbidden properties
2709 ;; We use `after-change-functions' to keep special text properties
2710 ;; that interfer with the normal function of message mode out of the
2713 (defcustom message-strip-special-text-properties t
2714 "Strip special properties from the message buffer.
2716 Emacs has a number of special text properties which can break message
2717 composing in various ways. If this option is set, message will strip
2718 these properties from the message composition buffer. However, some
2719 packages requires these properties to be present in order to work.
2720 If you use one of these packages, turn this option off, and hope the
2721 message composition doesn't break too bad."
2723 :group
'message-various
2724 :link
'(custom-manual "(message)Various Message Variables")
2727 (defconst message-forbidden-properties
2728 ;; No reason this should be clutter up customize. We make it a
2729 ;; property list (rather than a list of property symbols), to be
2730 ;; directly useful for `remove-text-properties'.
2731 '(field nil read-only nil invisible nil intangible nil
2732 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2733 insert-behind-hooks nil point-entered nil point-left nil
)
2734 ;; Other special properties:
2735 ;; category, face, display: probably doesn't do any harm.
2736 ;; fontified: is used by font-lock.
2737 ;; syntax-table, local-map: I dunno.
2738 ;; We need to add XEmacs names to the list.
2739 "Property list of with properties forbidden in message buffers.
2740 The values of the properties are ignored, only the property names are used.")
2742 (defun message-tamago-not-in-use-p (pos)
2743 "Return t when tamago version 4 is not in use at the cursor position.
2744 Tamago version 4 is a popular input method for writing Japanese text.
2745 It uses the properties `intangible', `invisible', `modification-hooks'
2746 and `read-only' when translating ascii or kana text to kanji text.
2747 These properties are essential to work, so we should never strip them."
2748 (not (and (boundp 'egg-modefull-mode
)
2749 (symbol-value 'egg-modefull-mode
)
2750 (or (memq (get-text-property pos
'intangible
)
2751 '(its-part-1 its-part-2
))
2752 (get-text-property pos
'egg-end
)
2753 (get-text-property pos
'egg-lang
)
2754 (get-text-property pos
'egg-start
)))))
2756 (defsubst message-mail-alias-type-p
(type)
2757 (if (atom message-mail-alias-type
)
2758 (eq message-mail-alias-type type
)
2759 (memq type message-mail-alias-type
)))
2761 (defun message-strip-forbidden-properties (begin end
&optional old-length
)
2762 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2763 This function is intended to be called from `after-change-functions'.
2764 See also `message-forbidden-properties'."
2765 (when (and (message-mail-alias-type-p 'ecomplete
)
2766 (memq this-command message-self-insert-commands
))
2767 (message-display-abbrev))
2768 (when (and message-strip-special-text-properties
2769 (message-tamago-not-in-use-p begin
))
2770 (let ((buffer-read-only nil
)
2771 (inhibit-read-only t
))
2772 (remove-text-properties begin end message-forbidden-properties
))))
2775 (define-derived-mode message-mode text-mode
"Message"
2776 "Major mode for editing mail and news to be sent.
2777 Like Text Mode but with these additional commands:\\<message-mode-map>
2778 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2779 C-c C-d Postpone sending the message C-c C-k Kill the message
2780 C-c C-f move to a header field (and create it if there isn't):
2781 C-c C-f C-t move to To C-c C-f C-s move to Subject
2782 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2783 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2784 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2785 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2786 C-c C-f C-o move to From (\"Originator\")
2787 C-c C-f C-f move to Followup-To
2788 C-c C-f C-m move to Mail-Followup-To
2789 C-c C-f C-e move to Expires
2790 C-c C-f C-i cycle through Importance values
2791 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2792 C-c C-f x crossposting with FollowUp-To header and note in body
2793 C-c C-f t replace To: header with contents of Cc: or Bcc:
2794 C-c C-f a Insert X-No-Archive: header and a note in the body
2795 C-c C-t `message-insert-to' (add a To header to a news followup)
2796 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2797 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2798 C-c C-b `message-goto-body' (move to beginning of message text).
2799 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2800 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2801 C-c C-y `message-yank-original' (insert current message, if any).
2802 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2803 C-c C-e `message-elide-region' (elide the text between point and mark).
2804 C-c C-v `message-delete-not-region' (remove the text outside the region).
2805 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2806 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2807 C-c C-a `mml-attach-file' (attach a file as MIME).
2808 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2809 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2810 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2811 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2812 M-RET `message-newline-and-reformat' (break the line and reformat)."
2813 (setq local-abbrev-table text-mode-abbrev-table
)
2814 (set (make-local-variable 'message-reply-buffer
) nil
)
2815 (set (make-local-variable 'message-inserted-headers
) nil
)
2816 (set (make-local-variable 'message-send-actions
) nil
)
2817 (set (make-local-variable 'message-exit-actions
) nil
)
2818 (set (make-local-variable 'message-kill-actions
) nil
)
2819 (set (make-local-variable 'message-postpone-actions
) nil
)
2820 (set (make-local-variable 'message-draft-article
) nil
)
2821 (setq buffer-offer-save t
)
2822 (set (make-local-variable 'facemenu-add-face-function
)
2824 (let ((face-fun (cdr (assq face message-face-alist
))))
2826 (funcall face-fun
(point) end
)
2827 (error "Face %s not configured for %s mode" face mode-name
)))
2829 (set (make-local-variable 'facemenu-remove-face-function
) t
)
2830 (set (make-local-variable 'message-reply-headers
) nil
)
2831 (make-local-variable 'message-newsreader
)
2832 (make-local-variable 'message-mailer
)
2833 (make-local-variable 'message-post-method
)
2834 (set (make-local-variable 'message-sent-message-via
) nil
)
2835 (set (make-local-variable 'message-checksum
) nil
)
2836 (set (make-local-variable 'message-mime-part
) 0)
2837 (message-setup-fill-variables)
2838 (when message-fill-column
2839 (setq fill-column message-fill-column
)
2840 (turn-on-auto-fill))
2841 ;; Allow using comment commands to add/remove quoting.
2842 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2843 (when message-yank-prefix
2844 (set (make-local-variable 'comment-start
) message-yank-prefix
)
2845 (set (make-local-variable 'comment-start-skip
)
2846 (concat "^" (regexp-quote message-yank-prefix
) "[ \t]*")))
2847 (if (featurep 'xemacs
)
2848 (message-setup-toolbar)
2849 (set (make-local-variable 'font-lock-defaults
)
2850 '(message-font-lock-keywords t
))
2851 (if (boundp 'tool-bar-map
)
2852 (set (make-local-variable 'tool-bar-map
) (message-make-tool-bar))))
2853 (easy-menu-add message-mode-menu message-mode-map
)
2854 (easy-menu-add message-mode-field-menu message-mode-map
)
2855 (gnus-make-local-hook 'after-change-functions
)
2856 ;; Mmmm... Forbidden properties...
2857 (add-hook 'after-change-functions
'message-strip-forbidden-properties
2859 ;; Allow mail alias things.
2861 ((message-mail-alias-type-p 'abbrev
)
2862 (if (fboundp 'mail-abbrevs-setup
)
2863 (mail-abbrevs-setup)
2864 (if (fboundp 'mail-aliases-setup
) ; warning avoidance
2865 (mail-aliases-setup))))
2866 ((message-mail-alias-type-p 'ecomplete
)
2868 (unless buffer-file-name
2869 (message-set-auto-save-file-name))
2870 (unless (buffer-base-buffer)
2871 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2872 ;; multibyte is not necessary at all. -- zsh
2873 (mm-enable-multibyte))
2874 (set (make-local-variable 'indent-tabs-mode
) nil
) ;No tabs for indentation.
2877 (defun message-setup-fill-variables ()
2878 "Setup message fill variables."
2879 (set (make-local-variable 'fill-paragraph-function
)
2880 'message-fill-paragraph
)
2881 (make-local-variable 'paragraph-separate
)
2882 (make-local-variable 'paragraph-start
)
2883 (make-local-variable 'adaptive-fill-regexp
)
2884 (unless (boundp 'adaptive-fill-first-line-regexp
)
2885 (setq adaptive-fill-first-line-regexp nil
))
2886 (make-local-variable 'adaptive-fill-first-line-regexp
)
2887 (let ((quote-prefix-regexp
2888 ;; User should change message-cite-prefix-regexp if
2889 ;; message-yank-prefix is set to an abnormal value.
2890 (concat "\\(" message-cite-prefix-regexp
"\\)[ \t]*")))
2891 (setq paragraph-start
2893 (regexp-quote mail-header-separator
) "$\\|"
2894 "[ \t]*$\\|" ; blank lines
2895 "-- $\\|" ; signature delimiter
2896 "---+$\\|" ; delimiters for forwarded messages
2897 page-delimiter
"$\\|" ; spoiler warnings
2898 ".*wrote:$\\|" ; attribution lines
2899 quote-prefix-regexp
"$\\|" ; empty lines in quoted text
2901 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
2902 (setq paragraph-separate paragraph-start
)
2903 (setq adaptive-fill-regexp
2904 (concat quote-prefix-regexp
"\\|" adaptive-fill-regexp
))
2905 (setq adaptive-fill-first-line-regexp
2906 (concat quote-prefix-regexp
"\\|"
2907 adaptive-fill-first-line-regexp
)))
2908 (make-local-variable 'auto-fill-inhibit-regexp
)
2909 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
2910 (setq auto-fill-inhibit-regexp nil
)
2911 (make-local-variable 'normal-auto-fill-function
)
2912 (setq normal-auto-fill-function
'message-do-auto-fill
)
2913 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
2914 ;; In that case, ensure that it uses the right function. The real
2915 ;; solution would be not to use `define-derived-mode', and run
2916 ;; `text-mode-hook' ourself at the end of the mode.
2917 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
2918 ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
2919 ;; now careful to run parent hooks after the body. --Stef
2920 (when auto-fill-function
2921 (setq auto-fill-function normal-auto-fill-function
)))
2926 ;;; Message mode commands
2929 ;;; Movement commands
2931 (defun message-goto-to ()
2932 "Move point to the To header."
2934 (message-position-on-field "To"))
2936 (defun message-goto-from ()
2937 "Move point to the From header."
2939 (message-position-on-field "From"))
2941 (defun message-goto-subject ()
2942 "Move point to the Subject header."
2944 (message-position-on-field "Subject"))
2946 (defun message-goto-cc ()
2947 "Move point to the Cc header."
2949 (message-position-on-field "Cc" "To"))
2951 (defun message-goto-bcc ()
2952 "Move point to the Bcc header."
2954 (message-position-on-field "Bcc" "Cc" "To"))
2956 (defun message-goto-fcc ()
2957 "Move point to the Fcc header."
2959 (message-position-on-field "Fcc" "To" "Newsgroups"))
2961 (defun message-goto-reply-to ()
2962 "Move point to the Reply-To header."
2964 (message-position-on-field "Reply-To" "Subject"))
2966 (defun message-goto-newsgroups ()
2967 "Move point to the Newsgroups header."
2969 (message-position-on-field "Newsgroups"))
2971 (defun message-goto-distribution ()
2972 "Move point to the Distribution header."
2974 (message-position-on-field "Distribution"))
2976 (defun message-goto-followup-to ()
2977 "Move point to the Followup-To header."
2979 (message-position-on-field "Followup-To" "Newsgroups"))
2981 (defun message-goto-mail-followup-to ()
2982 "Move point to the Mail-Followup-To header."
2984 (message-position-on-field "Mail-Followup-To" "To"))
2986 (defun message-goto-keywords ()
2987 "Move point to the Keywords header."
2989 (message-position-on-field "Keywords" "Subject"))
2991 (defun message-goto-summary ()
2992 "Move point to the Summary header."
2994 (message-position-on-field "Summary" "Subject"))
2996 (defun message-goto-body (&optional interactivep
)
2997 "Move point to the beginning of the message body."
2998 (interactive (list t
))
2999 (when (and interactivep
3000 (looking-at "[ \t]*\n"))
3002 (goto-char (point-min))
3003 (or (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3004 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t
)))
3006 (defun message-in-body-p ()
3007 "Return t if point is in the message body."
3008 (let ((body (save-excursion (message-goto-body) (point))))
3011 (defun message-goto-eoh ()
3012 "Move point to the end of the headers."
3017 (defun message-goto-signature ()
3018 "Move point to the beginning of the message signature.
3019 If there is no signature in the article, go to the end and
3022 (goto-char (point-min))
3023 (if (re-search-forward message-signature-separator nil t
)
3025 (goto-char (point-max))
3028 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc
)
3029 "Insert a reasonable MFT header in a post to an unsubscribed list.
3030 When making original posts to a mailing list you are not subscribed to,
3031 you have to type in a MFT header by hand. The contents, usually, are
3032 the addresses of the list and your own address. This function inserts
3033 such a header automatically. It fetches the contents of the To: header
3034 in the current mail buffer, and appends the current `user-mail-address'.
3036 If the optional argument INCLUDE-CC is non-nil, the addresses in the
3037 Cc: header are also put into the MFT."
3042 (message-narrow-to-headers)
3043 (message-remove-header "Mail-Followup-To")
3044 (setq cc
(and include-cc
(message-fetch-field "Cc")))
3046 (concat (message-fetch-field "To") "," cc
)
3047 (message-fetch-field "To"))))
3048 (message-goto-mail-followup-to)
3049 (insert (concat tos
", " user-mail-address
))))
3053 (defun message-insert-to (&optional force
)
3054 "Insert a To header that points to the author of the article being replied to.
3055 If the original author requested not to be sent mail, don't insert unless the
3056 prefix FORCE is given."
3058 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
3059 (dont (and mct
(or (equal (downcase mct
) "never")
3060 (equal (downcase mct
) "nobody"))))
3061 (to (or (message-fetch-reply-field "mail-reply-to")
3062 (message-fetch-reply-field "reply-to")
3063 (message-fetch-reply-field "from"))))
3067 "Ignoring the user request not to have copies sent via mail"
3068 "Complying with the user request not to have copies sent via mail")))
3069 (when (and force
(not to
))
3070 (error "No mail address in the article"))
3071 (when (and to
(or force
(not dont
)))
3072 (message-carefully-insert-headers (list (cons 'To to
))))))
3074 (defun message-insert-wide-reply ()
3075 "Insert To and Cc headers as if you were doing a wide reply."
3077 (let ((headers (message-with-reply-buffer
3078 (message-get-reply-headers t
))))
3079 (message-carefully-insert-headers headers
)))
3081 (defcustom message-header-synonyms
3084 "List of lists of header synonyms.
3085 E.g., if this list contains a member list with elements `Cc' and `To',
3086 then `message-carefully-insert-headers' will not insert a `To' header
3087 when the message is already `Cc'ed to the recipient."
3089 :group
'message-headers
3090 :link
'(custom-manual "(message)Message Headers")
3091 :type
'(repeat sexp
))
3093 (defun message-carefully-insert-headers (headers)
3094 "Insert the HEADERS, an alist, into the message buffer.
3095 Does not insert the headers when they are already present there
3096 or in the synonym headers, defined by `message-header-synonyms'."
3097 ;; FIXME: Should compare only the address and not the full name. Comparison
3098 ;; should be done case-folded (and with `string=' rather than
3100 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
3101 (dolist (header headers
)
3102 (let* ((header-name (symbol-name (car header
)))
3103 (new-header (cdr header
))
3104 (synonyms (loop for synonym in message-header-synonyms
3105 when
(memq (car header
) synonym
) return synonym
))
3107 (loop for synonym in synonyms
3108 for old-header
= (mail-fetch-field (symbol-name synonym
))
3109 when
(and old-header
(string-match new-header old-header
))
3112 (message "already have `%s' in `%s'" new-header old-header
)
3113 (when (and (message-position-on-field header-name
)
3114 (setq old-header
(mail-fetch-field header-name
))
3115 (not (string-match "\\` *\\'" old-header
)))
3117 (insert new-header
)))))
3119 (defun message-widen-reply ()
3120 "Widen the reply to include maximum recipients."
3123 (and message-reply-buffer
3124 (buffer-name message-reply-buffer
)
3125 (with-current-buffer message-reply-buffer
3126 (message-get-reply-headers t
)))))
3129 (message-narrow-to-headers)
3130 (dolist (elem follow-to
)
3131 (message-remove-header (symbol-name (car elem
)))
3132 (goto-char (point-min))
3133 (insert (symbol-name (car elem
)) ": "
3134 (cdr elem
) "\n"))))))
3136 (defun message-insert-newsgroups ()
3137 "Insert the Newsgroups header from the article being replied to."
3139 (when (and (message-position-on-field "Newsgroups")
3140 (mail-fetch-field "newsgroups")
3141 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
3143 (insert (or (message-fetch-reply-field "newsgroups") "")))
3147 ;;; Various commands
3149 (defun message-delete-not-region (beg end
)
3150 "Delete everything in the body of the current message outside of the region."
3155 ;; snarf citation prefix, if appropriate
3156 (unless (eq (point) (progn (beginning-of-line) (point)))
3157 (when (looking-at message-cite-prefix-regexp
)
3158 (setq citeprefix
(match-string 0))))
3160 (delete-region (point) (if (not (message-goto-signature))
3166 (delete-region beg
(progn (message-goto-body)
3170 (insert citeprefix
))))
3171 (when (message-goto-signature)
3174 (defun message-kill-to-signature (&optional arg
)
3175 "Kill all text up to the signature.
3176 If a numberic argument or prefix arg is given, leave that number
3177 of lines before the signature intact."
3181 (let ((point (point)))
3182 (narrow-to-region point
(point-max))
3183 (message-goto-signature)
3185 (if (and arg
(numberp arg
))
3186 (forward-line (- -
1 arg
))
3188 (unless (= point
(point))
3189 (kill-region point
(point))
3193 (defun message-newline-and-reformat (&optional arg not-break
)
3194 "Insert four newlines, and then reformat if inside quoted text.
3195 Prefix arg means justify as well."
3196 (interactive (list (if current-prefix-arg
'full
)))
3197 (let (quoted point beg end leading-space bolp fill-paragraph-function
)
3198 (setq point
(point))
3201 (setq bolp
(= beg point
))
3202 ;; Find first line of the paragraph.
3204 (while (and (not (eobp))
3205 (not (looking-at message-cite-prefix-regexp
))
3206 (looking-at paragraph-start
))
3209 (when (looking-at message-cite-prefix-regexp
)
3210 (setq quoted
(match-string 0))
3211 (goto-char (match-end 0))
3212 (looking-at "[ \t]*")
3213 (setq leading-space
(match-string 0)))
3217 (< (- point beg
) (length quoted
)))
3218 ;; break inside the cite prefix.
3224 (while (and (not (eobp))
3225 (not (looking-at paragraph-separate
))
3226 (looking-at message-cite-prefix-regexp
)
3227 (equal quoted
(match-string 0)))
3228 (goto-char (match-end 0))
3229 (looking-at "[ \t]*")
3230 (if (> (length leading-space
) (length (match-string 0)))
3231 (setq leading-space
(match-string 0)))
3235 (while (and (if (bobp) nil
(forward-line -
1) t
)
3236 (not (looking-at paragraph-start
))
3237 (looking-at message-cite-prefix-regexp
)
3238 (equal quoted
(match-string 0)))
3240 (goto-char (match-end 0))
3241 (looking-at "[ \t]*")
3242 (if (> (length leading-space
) (length (match-string 0)))
3243 (setq leading-space
(match-string 0)))))
3244 (while (and (not (eobp))
3245 (not (looking-at paragraph-separate
))
3246 (not (looking-at message-cite-prefix-regexp
)))
3250 (while (and (if (bobp) nil
(forward-line -
1) t
)
3251 (not (looking-at paragraph-start
))
3252 (not (looking-at message-cite-prefix-regexp
)))
3253 (setq beg
(point))))
3256 (narrow-to-region beg end
)
3263 (setq point
(point))
3264 ;; (newline 2) doesn't mark both newline's as hard, so call
3265 ;; newline twice. -jas
3268 (delete-region (point) (re-search-forward "[ \t]*"))
3269 (when (and quoted
(not bolp
))
3270 (insert quoted leading-space
)))
3273 (let* ((adaptive-fill-regexp
3274 (regexp-quote (concat quoted leading-space
)))
3275 (adaptive-fill-first-line-regexp
3276 adaptive-fill-regexp
))
3277 (fill-paragraph arg
))
3278 (fill-paragraph arg
))
3279 (if point
(goto-char point
)))))
3281 (defun message-fill-paragraph (&optional arg
)
3282 "Message specific function to fill a paragraph.
3283 This function is used as the value of `fill-paragraph-function' in
3284 Message buffers and is not meant to be called directly."
3285 (interactive (list (if current-prefix-arg
'full
)))
3286 (if (if (boundp 'filladapt-mode
) filladapt-mode
)
3288 (if (message-point-in-header-p)
3289 (message-fill-field)
3290 (message-newline-and-reformat arg t
))
3293 (defun message-point-in-header-p ()
3294 "Return t if point is in the header."
3296 (not (re-search-backward
3297 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
))))
3299 (defun message-do-auto-fill ()
3300 "Like `do-auto-fill', but don't fill in message header."
3301 (unless (message-point-in-header-p)
3304 (defun message-insert-signature (&optional force
)
3305 "Insert a signature. See documentation for variable `message-signature'."
3306 (interactive (list 0))
3309 ((and (null message-signature
)
3312 (goto-char (point-max))
3313 (not (re-search-backward message-signature-separator nil t
))))
3314 ((and (null message-signature
)
3317 ((functionp message-signature
)
3318 (funcall message-signature
))
3319 ((listp message-signature
)
3320 (eval message-signature
))
3321 (t message-signature
)))
3324 (cond ((stringp signature
)
3326 ((and (eq t signature
) message-signature-file
)
3327 (setq signature-file
3328 (if (and message-signature-directory
3329 ;; don't actually use the signature directory
3330 ;; if message-signature-file contains a path.
3331 (not (file-name-directory
3332 message-signature-file
)))
3333 (nnheader-concat message-signature-directory
3334 message-signature-file
)
3335 message-signature-file
))
3336 (file-exists-p signature-file
))))
3338 (goto-char (point-max))
3339 ;; Insert the signature.
3342 (when message-signature-insert-empty-line
3345 (if (eq signature t
)
3346 (insert-file-contents signature-file
)
3348 (goto-char (point-max))
3349 (or (bolp) (insert "\n")))))
3351 (defun message-insert-importance-high ()
3352 "Insert header to mark message as important."
3356 (message-narrow-to-headers)
3357 (message-remove-header "Importance"))
3359 (insert "Importance: high\n")))
3361 (defun message-insert-importance-low ()
3362 "Insert header to mark message as unimportant."
3366 (message-narrow-to-headers)
3367 (message-remove-header "Importance"))
3369 (insert "Importance: low\n")))
3371 (defun message-insert-or-toggle-importance ()
3372 "Insert a \"Importance: high\" header, or cycle through the header values.
3373 The three allowed values according to RFC 1327 are `high', `normal'
3380 (message-narrow-to-headers)
3381 (when (setq cur
(message-fetch-field "Importance"))
3382 (message-remove-header "Importance")
3383 (setq new
(cond ((string= cur
"high")
3385 ((string= cur
"low")
3390 (insert (format "Importance: %s\n" new
)))))
3392 (defun message-insert-disposition-notification-to ()
3393 "Request a disposition notification (return receipt) to this message.
3394 Note that this should not be used in newsgroups."
3398 (message-narrow-to-headers)
3399 (message-remove-header "Disposition-Notification-To"))
3401 (insert (format "Disposition-Notification-To: %s\n"
3402 (or (message-field-value "Reply-to")
3403 (message-field-value "From")
3404 (message-make-from))))))
3406 (defun message-elide-region (b e
)
3407 "Elide the text in the region.
3408 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3412 (insert message-elide-ellipsis
))
3414 (defvar message-caesar-translation-table nil
)
3416 (defun message-caesar-region (b e
&optional n
)
3417 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3420 (min (point) (or (mark t
) (point)))
3421 (max (point) (or (mark t
) (point)))
3422 (when current-prefix-arg
3423 (prefix-numeric-value current-prefix-arg
))))
3425 (setq n
(if (numberp n
) (mod n
26) 13)) ;canonize N
3426 (unless (or (zerop n
) ; no action needed for a rot of 0
3427 (= b e
)) ; no region to rotate
3428 ;; We build the table, if necessary.
3429 (when (or (not message-caesar-translation-table
)
3430 (/= (aref message-caesar-translation-table ?a
) (+ ?a n
)))
3431 (setq message-caesar-translation-table
3432 (message-make-caesar-translation-table n
)))
3433 (translate-region b e message-caesar-translation-table
)))
3435 (defun message-make-caesar-translation-table (n)
3436 "Create a rot table with offset N."
3438 (table (make-string 256 0)))
3439 (while (< (incf i
) 256)
3442 (substring table
0 ?A
)
3443 (substring table
(+ ?A n
) (+ ?A n
(- 26 n
)))
3444 (substring table ?A
(+ ?A n
))
3445 (substring table
(+ ?A
26) ?a
)
3446 (substring table
(+ ?a n
) (+ ?a n
(- 26 n
)))
3447 (substring table ?a
(+ ?a n
))
3448 (substring table
(+ ?a
26) 255))))
3450 (defun message-caesar-buffer-body (&optional rotnum wide
)
3451 "Caesar rotate all letters in the current buffer by 13 places.
3452 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3453 With prefix arg, specifies the number of places to rotate each letter forward.
3454 Mail and USENET news headers are not rotated unless WIDE is non-nil."
3455 (interactive (if current-prefix-arg
3456 (list (prefix-numeric-value current-prefix-arg
))
3460 (when (and (not wide
) (message-goto-body))
3461 (narrow-to-region (point) (point-max)))
3462 (message-caesar-region (point-min) (point-max) rotnum
))))
3464 (defun message-pipe-buffer-body (program)
3465 "Pipe the message body in the current buffer through PROGRAM."
3468 (when (message-goto-body)
3469 (narrow-to-region (point) (point-max)))
3470 (shell-command-on-region
3471 (point-min) (point-max) program nil t
))))
3473 (defun message-rename-buffer (&optional enter-string
)
3474 "Rename the *message* buffer to \"*message* RECIPIENT\".
3475 If the function is run with a prefix, it will ask for a new buffer
3476 name, rather than giving an automatic name."
3477 (interactive "Pbuffer name: ")
3480 (goto-char (point-min))
3481 (narrow-to-region (point)
3482 (search-forward mail-header-separator nil
'end
))
3484 (if (message-news-p) (message-fetch-field "Newsgroups")
3485 (message-fetch-field "To"))
3488 (if (string-match "," mail-to
)
3489 (concat (substring mail-to
0 (match-beginning 0)) ", ...")
3491 (name-default (concat "*message* " mail-trimmed-to
))
3492 (name (if enter-string
3493 (read-string "New buffer name: " name-default
)
3495 (rename-buffer name t
)))))
3497 (defun message-fill-yanked-message (&optional justifyp
)
3498 "Fill the paragraphs of a message yanked into this one.
3499 Numeric argument means justify as well."
3502 (goto-char (point-min))
3503 (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3504 (let ((fill-prefix message-yank-prefix
))
3505 (fill-individual-paragraphs (point) (point-max) justifyp
))))
3507 (defun message-indent-citation (&optional start end yank-only
)
3508 "Modify text just inserted from a message to be cited.
3509 The inserted text should be the region.
3510 When this function returns, the region is again around the modified text.
3512 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3513 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3514 (unless start
(setq start
(point)))
3516 ;; Remove unwanted headers.
3517 (when message-ignored-cited-headers
3522 (if (search-forward "\n\n" nil t
)
3525 (message-remove-header message-ignored-cited-headers t
)
3526 (when (= (point-min) (point-max))
3527 (setq all-removed t
))
3528 (goto-char (point-max)))
3532 ;; Delete blank lines at the start of the buffer.
3533 (while (and (point-min)
3536 (message-delete-line))
3537 ;; Delete blank lines at the end of the buffer.
3538 (goto-char (point-max))
3541 (while (and (zerop (forward-line -
1))
3543 (message-delete-line)))
3544 ;; Do the indentation.
3545 (if (null message-yank-prefix
)
3546 (indent-rigidly start
(or end
(mark t
)) message-indentation-spaces
)
3549 (while (< (point) (or end
(mark t
)))
3550 (cond ((looking-at ">")
3551 (insert message-yank-cited-prefix
))
3553 (insert message-yank-empty-prefix
))
3555 (insert message-yank-prefix
)))
3559 (defun message-remove-blank-cited-lines (&optional remove
)
3560 "Remove cited lines containing only blanks.
3561 If REMOVE is non-nil, remove newlines, too.
3563 To use this automatically, you may add this function to
3564 `gnus-message-setup-hook'."
3569 (when (boundp 'message-yank-cited-prefix
)
3570 (concat message-yank-cited-prefix
"\\|"))
3574 (gnus-message 8 "removing `%s'" citexp
)
3577 (while (re-search-forward citexp nil t
)
3578 (replace-match (if remove
"" "\n"))))))
3580 (defvar message-cite-reply-above nil
3581 "If non-nil, start own text above the quote.
3583 Note: Top posting is bad netiquette. Don't use it unless you
3584 really must. You probably want to set variable only for specific
3585 groups, e.g. using `gnus-posting-styles':
3587 (eval (set (make-local-variable 'message-cite-reply-above) t))
3589 This variable has no effect in news postings.")
3591 (defun message-yank-original (&optional arg
)
3592 "Insert the message being replied to, if any.
3593 Puts point before the text and mark after.
3594 Normally indents each nonblank line ARG spaces (default 3). However,
3595 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3597 This function uses `message-cite-function' to do the actual citing.
3599 Just \\[universal-argument] as argument means don't indent, insert no
3600 prefix, and don't delete any headers."
3602 (let ((modified (buffer-modified-p))
3604 (when (and message-reply-buffer
3605 message-cite-function
)
3606 (when message-cite-reply-above
3607 (if (and (not (message-news-p))
3608 (or (eq message-cite-reply-above
'is-evil
)
3610 Top posting is bad netiquette. Please don't top post unless you really must.
3611 Really top post? ")))
3614 (buffer-substring (message-goto-body)
3616 (delete-region (message-goto-body) (point-max)))
3617 (set (make-local-variable 'message-cite-reply-above
) nil
)))
3618 (delete-windows-on message-reply-buffer t
)
3619 (push-mark (save-excursion
3620 (insert-buffer-substring message-reply-buffer
)
3625 (funcall message-cite-function
)
3626 (unless (eq (char-before (mark t
)) ?
\n)
3628 (goto-char (mark t
))
3629 (insert-before-markers ?
\n)
3631 (when message-cite-reply-above
3634 (insert (if (bolp) "\n" "\n\n"))
3635 (message-goto-body))
3636 ;; Add a `message-setup-very-last-hook' here?
3637 ;; Add `gnus-article-highlight-citation' here?
3639 (setq message-checksum
(message-checksum))))))
3641 (defun message-yank-buffer (buffer)
3642 "Insert BUFFER into the current buffer and quote it."
3643 (interactive "bYank buffer: ")
3644 (let ((message-reply-buffer (get-buffer buffer
)))
3645 (save-window-excursion
3646 (message-yank-original))))
3648 (defun message-buffers ()
3649 "Return a list of active message buffers."
3651 (save-current-buffer
3652 (dolist (buffer (buffer-list t
))
3654 (when (and (eq major-mode
'message-mode
)
3655 (null message-sent-message-via
))
3656 (push (buffer-name buffer
) buffers
))))
3657 (nreverse buffers
)))
3659 (defun message-cite-original-1 (strip-signature)
3660 "Cite an original message.
3661 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3664 This function uses `mail-citation-hook' if that is non-nil."
3665 (if (and (boundp 'mail-citation-hook
)
3667 (run-hooks 'mail-citation-hook
)
3668 (let* ((start (point))
3672 (when message-indent-citation-function
3673 (if (listp message-indent-citation-function
)
3674 message-indent-citation-function
3675 (list message-indent-citation-function
))))
3676 ;; This function may be called by `gnus-summary-yank-message' and
3677 ;; may insert a different article from the original. So, we will
3678 ;; modify the value of `message-reply-headers' with that article.
3679 (message-reply-headers
3681 (narrow-to-region start end
)
3682 (message-narrow-to-head-1)
3683 (setq x-no-archive
(message-fetch-field "x-no-archive"))
3685 (or (message-fetch-field "subject") "none")
3686 (or (message-fetch-field "from") "nobody")
3687 (message-fetch-field "date")
3688 (message-fetch-field "message-id" t
)
3689 (message-fetch-field "references")
3691 (mml-quote-region start end
)
3692 (when strip-signature
3696 (when (re-search-backward message-signature-separator start t
)
3697 ;; Also peel off any blank lines before the signature.
3699 (while (looking-at "^[ \t]*$")
3702 (delete-region (point) end
)
3703 (unless (search-backward "\n\n" start t
)
3704 ;; Insert a blank line if it is peeled off.
3707 (mapc 'funcall functions
)
3708 (when message-citation-line-function
3711 (funcall message-citation-line-function
))
3712 (when (and x-no-archive
3713 (not message-cite-articles-with-x-no-archive
)
3714 (string-match "yes" x-no-archive
))
3716 (delete-region (point) (mark t
))
3717 (insert "> [Quoted text removed due to X-No-Archive]\n")
3719 (forward-line -
1)))))
3721 (defun message-cite-original ()
3722 "Cite function in the standard Message manner."
3723 (message-cite-original-1 nil
))
3725 (defvar gnus-extract-address-components
)
3727 (autoload 'format-spec
"format-spec")
3729 (defun message-insert-formatted-citation-line (&optional from date
)
3730 "Function that inserts a formatted citation line.
3732 See `message-citation-line-format'."
3733 ;; The optional args are for testing/debugging. They will disappear later.
3735 ;; (with-temp-buffer
3736 ;; (message-insert-formatted-citation-line
3737 ;; "John Doe <john.doe@example.invalid>"
3740 (when (or message-reply-headers
(and from date
))
3742 (setq from
(mail-header-from message-reply-headers
)))
3743 (let* ((data (condition-case ()
3744 (funcall (if (boundp gnus-extract-address-components
)
3745 gnus-extract-address-components
3746 'mail-extract-address-components
)
3752 (net (car (cdr data
)))
3753 (name-or-net (or (car data
)
3754 (car (cdr data
)) from
))
3758 ;; We need Gnus functionality if the user wants date or time from
3759 ;; the original article:
3760 (when (string-match "%[^fnNFL]" message-citation-line-format
)
3761 (autoload 'gnus-date-get-time
"gnus-util")
3762 (gnus-date-get-time (mail-header-date message-reply-headers
)))))
3765 (when (stringp name
)
3766 ;; Guess first name and last name:
3767 (cond ((string-match
3768 "\\`\\(\\w\\|[-.]\\)+ \\(\\w\\|[-.]\\)+\\'" name
)
3769 (setq fname
(nth 0 (split-string name
"[ \t]+"))
3770 lname
(nth 1 (split-string name
"[ \t]+"))))
3772 "\\`\\(\\w\\|[-.]\\)+, \\(\\w\\|[-.]\\)+\\'" name
)
3773 (setq fname
(nth 1 (split-string name
"[ \t,]+"))
3774 lname
(nth 0 (split-string name
"[ \t,]+"))))
3776 "\\`\\(\\w\\|[-.]\\)+\\'" name
)
3779 ;; The following letters are not used in `format-time-string':
3780 (push ?E lst
) (push "<E>" lst
)
3781 (push ?F lst
) (push fname lst
)
3782 ;; We might want to use "" instead of "<X>" later.
3783 (push ?J lst
) (push "<J>" lst
)
3784 (push ?K lst
) (push "<K>" lst
)
3785 (push ?L lst
) (push lname lst
)
3786 (push ?N lst
) (push name-or-net lst
)
3787 (push ?O lst
) (push "<O>" lst
)
3788 (push ?P lst
) (push "<P>" lst
)
3789 (push ?Q lst
) (push "<Q>" lst
)
3790 (push ?f lst
) (push from lst
)
3791 (push ?i lst
) (push "<i>" lst
)
3792 (push ?n lst
) (push net lst
)
3793 (push ?o lst
) (push "<o>" lst
)
3794 (push ?q lst
) (push "<q>" lst
)
3795 (push ?t lst
) (push "<t>" lst
)
3796 (push ?v lst
) (push "<v>" lst
)
3797 ;; Delegate the rest to `format-time-string':
3799 (when (and (not (memq i lst
))
3804 (push (condition-case nil
3805 (progn (format-time-string (format "%%%c" i
)
3811 (spec (apply 'format-spec-make flist
)))
3812 (insert (format-spec message-citation-line-format spec
)))
3815 (defun message-cite-original-without-signature ()
3816 "Cite function in the standard Message manner.
3817 This function strips off the signature from the original message."
3818 (message-cite-original-1 t
))
3820 (defun message-insert-citation-line ()
3821 "Insert a simple citation line."
3822 (when message-reply-headers
3823 (insert (mail-header-from message-reply-headers
) " writes:")
3827 (defun message-position-on-field (header &rest afters
)
3828 (let ((case-fold-search t
))
3831 (goto-char (point-min))
3834 (concat "^" (regexp-quote mail-header-separator
) "$"))
3835 (match-beginning 0)))
3836 (goto-char (point-min))
3837 (if (re-search-forward (concat "^" (regexp-quote header
) ":") nil t
)
3839 (re-search-forward "^[^ \t]" nil
'move
)
3841 (skip-chars-backward "\n")
3844 (not (re-search-forward
3845 (concat "^" (regexp-quote (car afters
)) ":")
3849 (re-search-forward "^[^ \t]" nil
'move
)
3850 (beginning-of-line))
3851 (insert header
": \n")
3855 (defun message-remove-signature ()
3856 "Remove the signature from the text between point and mark.
3857 The text will also be indented the normal way."
3859 (let ((start (point))
3861 (if (not (re-search-forward message-signature-separator
(mark t
) t
))
3862 ;; No signature here, so we just indent the cited text.
3863 (message-indent-citation)
3864 ;; Find the last non-empty line.
3866 (while (looking-at "[ \t]*$")
3869 (setq mark
(set-marker (make-marker) (point)))
3871 (message-indent-citation)
3872 ;; Enable undoing the deletion.
3874 (delete-region mark
(mark t
))
3875 (set-marker mark nil
)))))
3880 ;;; Sending messages
3883 (defun message-send-and-exit (&optional arg
)
3884 "Send message like `message-send', then, if no errors, exit from mail buffer."
3886 (let ((buf (current-buffer))
3887 (actions message-exit-actions
))
3888 (when (and (message-send arg
)
3890 (if message-kill-buffer-on-exit
3893 (when (eq buf
(current-buffer))
3894 (message-bury buf
)))
3895 (message-do-actions actions
)
3898 (defun message-dont-send ()
3899 "Don't send the message you have been editing.
3900 Instead, just auto-save the buffer and then bury it."
3902 (set-buffer-modified-p t
)
3904 (let ((actions message-postpone-actions
))
3905 (message-bury (current-buffer))
3906 (message-do-actions actions
)))
3908 (defun message-kill-buffer ()
3909 "Kill the current buffer."
3911 (when (or (not (buffer-modified-p))
3912 (not message-kill-buffer-query
)
3913 (yes-or-no-p "Message modified; kill anyway? "))
3914 (let ((actions message-kill-actions
)
3915 (draft-article message-draft-article
)
3916 (auto-save-file-name buffer-auto-save-file-name
)
3917 (file-name buffer-file-name
)
3918 (modified (buffer-modified-p)))
3919 (setq buffer-file-name nil
)
3920 (kill-buffer (current-buffer))
3921 (when (and (or (and auto-save-file-name
3922 (file-exists-p auto-save-file-name
))
3924 (file-exists-p file-name
)))
3926 ;; If the message buffer has lived in a dedicated window,
3927 ;; `kill-buffer' has killed the frame. Thus the
3928 ;; `yes-or-no-p' may show up in a lowered frame. Make sure
3929 ;; that the user can see the question by raising the
3932 (yes-or-no-p (format "Remove the backup file%s? "
3933 (if modified
" too" "")))))
3935 (delete-file auto-save-file-name
))
3936 (let ((message-draft-article draft-article
))
3937 (message-disassociate-draft)))
3938 (message-do-actions actions
))))
3940 (defun message-bury (buffer)
3941 "Bury this mail BUFFER."
3942 (let ((newbuf (other-buffer buffer
)))
3943 (bury-buffer buffer
)
3944 (if (and (window-dedicated-p (selected-window))
3945 (not (null (delq (selected-frame) (visible-frame-list)))))
3946 (delete-frame (selected-frame))
3947 (switch-to-buffer newbuf
))))
3949 (defun message-send (&optional arg
)
3950 "Send the message in the current buffer.
3951 If `message-interactive' is non-nil, wait for success indication or
3952 error messages, and inform user.
3953 Otherwise any failure is reported in a message back to the user from
3955 The usage of ARG is defined by the instance that called Message.
3956 It should typically alter the sending method in some way or other."
3958 ;; Make it possible to undo the coming changes.
3960 (let ((inhibit-read-only t
))
3961 (put-text-property (point-min) (point-max) 'read-only nil
))
3962 (message-fix-before-sending)
3963 (run-hooks 'message-send-hook
)
3964 (message message-sending-message
)
3965 (let ((alist message-send-method-alist
)
3967 elem sent dont-barf-on-no-method
3968 (message-options message-options
))
3969 (message-options-set-recipient)
3971 (setq elem
(pop alist
)))
3972 (when (funcall (cadr elem
))
3973 (when (and (or (not (memq (car elem
)
3974 message-sent-message-via
))
3975 (message-fetch-field "supersedes")
3976 (if (or (message-gnksa-enable-p 'multiple-copies
)
3977 (not (eq (car elem
) 'news
)))
3980 "Already sent message via %s; resend? "
3982 (error "Denied posting -- multiple copies")))
3983 (setq success
(funcall (caddr elem
) arg
)))
3987 (let ((fcc (message-fetch-field "Fcc"))
3988 (gcc (message-fetch-field "Gcc")))
3990 (or (eq message-allow-no-recipients
'always
)
3991 (and (not (eq message-allow-no-recipients
'never
))
3992 (setq dont-barf-on-no-method
3994 (format "No receiver, perform %s anyway? "
3995 (cond ((and fcc gcc
) "Fcc and Gcc")
3998 (error "No methods specified to send by"))
3999 (when (or dont-barf-on-no-method
4003 (run-hooks 'message-sent-hook
))
4004 (message "Sending...done")
4005 ;; Do ecomplete address snarfing.
4006 (when (message-mail-alias-type-p 'ecomplete
)
4007 (message-put-addresses-in-ecomplete))
4008 ;; Mark the buffer as unmodified and delete auto-save.
4009 (set-buffer-modified-p nil
)
4010 (delete-auto-save-file-if-necessary t
)
4011 (message-disassociate-draft)
4012 ;; Delete other mail buffers and stuff.
4013 (message-do-send-housekeeping)
4014 (message-do-actions message-send-actions
)
4018 (defun message-send-via-mail (arg)
4019 "Send the current message via mail."
4020 (message-send-mail arg
))
4022 (defun message-send-via-news (arg)
4023 "Send the current message via news."
4024 (funcall message-send-news-function arg
))
4026 (defmacro message-check
(type &rest forms
)
4027 "Eval FORMS if TYPE is to be checked."
4028 `(or (message-check-element ,type
)
4032 (put 'message-check
'lisp-indent-function
1)
4033 (put 'message-check
'edebug-form-spec
'(form body
))
4035 (defun message-text-with-property (prop &optional start end reverse
)
4036 "Return a list of start and end positions where the text has PROP.
4037 START and END bound the search, they default to `point-min' and
4038 `point-max' respectively. If REVERSE is non-nil, find text which does
4041 (setq start
(point-min)))
4043 (setq end
(point-max)))
4047 (setq start
(text-property-any start end prop nil
)))
4048 (setq next
(next-single-property-change start prop nil end
))
4049 (push (cons start
(or next end
)) regions
)
4052 (or (get-text-property start prop
)
4053 (and (setq start
(next-single-property-change
4054 start prop nil end
))
4055 (get-text-property start prop
))))
4056 (setq next
(text-property-any start end prop nil
))
4057 (push (cons start
(or next end
)) regions
)
4059 (nreverse regions
)))
4061 (defcustom message-bogus-address-regexp nil
;; "noreply\\|nospam\\|invalid"
4062 "Regexp of potentially bogus mail addresses."
4063 :version
"23.1" ;; No Gnus
4064 :group
'message-headers
4067 (defun message-fix-before-sending ()
4068 "Do various things to make the message nice before sending it."
4069 ;; Make sure there's a newline at the end of the message.
4070 (goto-char (point-max))
4073 ;; Make the hidden headers visible.
4075 ;; Sort headers before sending the message.
4076 (message-sort-headers)
4077 ;; Make invisible text visible.
4078 ;; It doesn't seem as if this is useful, since the invisible property
4079 ;; is clobbered by an after-change hook anyhow.
4080 (message-check 'invisible-text
4081 (let ((regions (message-text-with-property 'invisible
))
4085 (setq from
(caar regions
)
4087 regions
(cdr regions
))
4088 (put-text-property from to
'invisible nil
)
4089 (message-overlay-put (message-make-overlay from to
)
4091 (unless (yes-or-no-p
4092 "Invisible text found and made visible; continue sending? ")
4093 (error "Invisible text found and made visible")))))
4094 (message-check 'illegible-text
4095 (let (char found choice
)
4098 (skip-chars-forward mm-7bit-chars
)
4099 (when (get-text-property (point) 'no-illegible-text
)
4100 ;; There is a signed or encrypted raw message part
4101 ;; that is considered to be safe.
4102 (goto-char (or (next-single-property-change
4103 (point) 'no-illegible-text
)
4105 (setq char
(char-after)))
4106 (when (or (< (mm-char-int char
) 128)
4107 (and (mm-multibyte-p)
4108 (memq (char-charset char
)
4109 '(eight-bit-control eight-bit-graphic
4111 (not (get-text-property
4112 (point) 'untranslated-utf-8
))))
4113 (message-overlay-put (message-make-overlay (point) (1+ (point)))
4119 (gnus-multiple-choice
4120 "Non-printable characters found. Continue sending?"
4121 `((?d
"Remove non-printable characters and send")
4123 "Replace non-printable characters with \"%s\" and send"
4124 message-replacement-char
))
4125 (?i
"Ignore non-printable characters and send")
4126 (?e
"Continue editing"))))
4128 (error "Non-printable characters"))
4130 (skip-chars-forward mm-7bit-chars
)
4132 (when (let ((char (char-after)))
4133 (or (< (mm-char-int char
) 128)
4134 (and (mm-multibyte-p)
4135 ;; FIXME: Wrong for Emacs 23 (unicode) and for
4136 ;; things like undecable utf-8. Should at least
4137 ;; use find-coding-systems-region.
4138 (memq (char-charset char
)
4139 '(eight-bit-control eight-bit-graphic
4141 (not (get-text-property
4142 (point) 'untranslated-utf-8
)))))
4144 (message-kill-all-overlays)
4146 (when (eq choice ?r
)
4147 (insert message-replacement-char
))))
4149 (skip-chars-forward mm-7bit-chars
)))))
4150 (message-check 'bogus-recipient
4151 ;; Warn before composing or sending a mail to an invalid address.
4152 (message-check-recipients)))
4154 (defun message-bogus-recipient-p (recipients)
4155 "Check if a mail address in RECIPIENTS looks bogus.
4157 RECIPIENTS is a mail header. Return a list of potentially bogus
4158 addresses. If none is found, return nil.
4160 An addresses might be bogus if the domain part is not fully
4161 qualified, see `message-valid-fqdn-regexp', or if it matches
4162 `message-bogus-address-regexp'."
4163 ;; FIXME: How about "foo@subdomain", when the MTA adds ".domain.tld"?
4165 (mapc (lambda (address)
4166 (setq address
(cadr address
))
4170 (not (string-match "@" address
))
4173 message-valid-fqdn-regexp
"\\)\\'") address
)))
4174 (and (stringp message-bogus-address-regexp
)
4175 (string-match message-bogus-address-regexp address
)))
4176 (push address found
)))
4178 (mail-extract-address-components recipients t
))
4181 (defun message-check-recipients ()
4182 "Warn before composing or sending a mail to an invalid address.
4184 This function could be useful in `message-setup-hook'."
4187 (message-narrow-to-headers)
4188 (dolist (hdr '("To" "Cc" "Bcc"))
4189 (let ((addr (message-fetch-field hdr
)))
4190 (when (stringp addr
)
4191 (dolist (bog (message-bogus-recipient-p addr
))
4195 "Address `%s' might be bogus. Continue? " bog
)))
4196 (error "Bogus address."))))))))
4198 (defun message-add-action (action &rest types
)
4199 "Add ACTION to be performed when doing an exit of type TYPES."
4201 (add-to-list (intern (format "message-%s-actions" (pop types
)))
4204 (defun message-delete-action (action &rest types
)
4205 "Delete ACTION from lists of actions performed when doing an exit of type TYPES."
4208 (set (setq var
(intern (format "message-%s-actions" (pop types
))))
4209 (delq action
(symbol-value var
))))))
4211 (defun message-do-actions (actions)
4212 "Perform all actions in ACTIONS."
4213 ;; Now perform actions on successful sending.
4214 (dolist (action actions
)
4217 ;; A simple function.
4220 ;; Something to be evaled.
4224 (defun message-send-mail-partially ()
4225 "Send mail as message/partial."
4226 ;; replace the header delimiter with a blank line
4227 (goto-char (point-min))
4229 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4230 (replace-match "\n")
4231 (run-hooks 'message-send-mail-hook
)
4232 (let ((p (goto-char (point-min)))
4233 (tembuf (message-generate-new-buffer-clone-locals " message temp"))
4234 (curbuf (current-buffer))
4235 (id (message-make-message-id)) (n 1)
4236 plist total header required-mail-headers
)
4238 (if (< (point-max) (+ p message-send-mail-partially-limit
))
4239 (goto-char (point-max))
4240 (goto-char (+ p message-send-mail-partially-limit
))
4242 (if (<= (point) p
) (forward-line 1))) ;; In case of bad message.
4245 (setq total
(length plist
))
4246 (push (point-max) plist
)
4247 (setq plist
(nreverse plist
))
4250 (setq p
(pop plist
))
4253 (copy-to-buffer tembuf p
(car plist
))
4255 (goto-char (point-min))
4258 (goto-char (point-min))
4259 (narrow-to-region (point) (point))
4262 (setq header
(buffer-substring (point-min) (point)))
4263 (goto-char (point-min))
4264 (narrow-to-region (point) (point))
4266 (message-remove-header "Mime-Version")
4267 (message-remove-header "Content-Type")
4268 (message-remove-header "Content-Transfer-Encoding")
4269 (message-remove-header "Message-ID")
4270 (message-remove-header "Lines")
4271 (goto-char (point-max))
4272 (insert "Mime-Version: 1.0\n")
4273 (setq header
(buffer-string)))
4274 (goto-char (point-max))
4275 (insert (format "Content-Type: message/partial; id=\"%s\"; number=%d; total=%d\n\n"
4278 (let ((mail-header-separator ""))
4279 (when (memq 'Message-ID message-required-mail-headers
)
4280 (insert "Message-ID: " (message-make-message-id) "\n"))
4281 (when (memq 'Lines message-required-mail-headers
)
4282 (insert "Lines: " (message-make-lines) "\n"))
4283 (message-goto-subject)
4285 (insert (format " (%d/%d)" n total
))
4287 (mm-with-unibyte-current-buffer
4288 (funcall (or message-send-mail-real-function
4289 message-send-mail-function
))))
4291 (setq p
(pop plist
))
4293 (kill-buffer tembuf
))))
4295 (defun message-send-mail (&optional arg
)
4296 (require 'mail-utils
)
4297 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
4298 (case-fold-search nil
)
4299 (news (message-news-p))
4300 (mailbuf (current-buffer))
4301 (message-this-is-mail t
)
4302 (message-posting-charset
4303 (if (fboundp 'gnus-setup-posting-charset
)
4304 (gnus-setup-posting-charset nil
)
4305 message-posting-charset
))
4306 (headers message-required-mail-headers
))
4307 (when (and message-generate-hashcash
4308 (not (eq message-generate-hashcash
'opportunistic
)))
4309 (message "Generating hashcash...")
4310 ;; Wait for calculations already started to finish...
4311 (hashcash-wait-async)
4312 ;; ...and do calculations not already done. mail-add-payment
4313 ;; will leave existing X-Hashcash headers alone.
4315 (message "Generating hashcash...done"))
4317 (message-narrow-to-headers)
4318 ;; Generate the Mail-Followup-To header if the header is not there...
4319 (if (and (message-subscribed-p)
4320 (not (mail-fetch-field "mail-followup-to")))
4323 (cons "Mail-Followup-To" (message-make-mail-followup-to))
4324 message-required-mail-headers
))
4325 ;; otherwise, delete the MFT header if the field is empty
4326 (when (equal "" (mail-fetch-field "mail-followup-to"))
4327 (message-remove-header "^Mail-Followup-To:")))
4328 ;; Insert some headers.
4329 (let ((message-deletable-headers
4330 (if news nil message-deletable-headers
)))
4331 (message-generate-headers headers
))
4332 ;; Check continuation headers.
4333 (message-check 'continuation-headers
4334 (goto-char (point-min))
4335 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4336 (goto-char (match-beginning 0))
4337 (if (y-or-n-p "Fix continuation lines? ")
4340 (unless (y-or-n-p "Send anyway? ")
4341 (error "Failed to send the message")))))
4342 ;; Let the user do all of the above.
4343 (run-hooks 'message-header-hook
))
4345 (with-current-buffer tembuf
4347 ;; Avoid copying text props (except hard newlines).
4348 (insert (with-current-buffer mailbuf
4349 (mml-buffer-substring-no-properties-except-hard-newlines
4350 (point-min) (point-max))))
4351 ;; Remove some headers.
4352 (message-encode-message-body)
4354 (message-narrow-to-headers)
4355 ;; We (re)generate the Lines header.
4356 (when (memq 'Lines message-required-mail-headers
)
4357 (message-generate-headers '(Lines)))
4358 ;; Remove some headers.
4359 (message-remove-header message-ignored-mail-headers t
)
4360 (let ((mail-parse-charset message-default-charset
))
4361 (mail-encode-encoded-word-buffer)))
4362 (goto-char (point-max))
4363 ;; require one newline at the end.
4364 (or (= (preceding-char) ?
\n)
4366 (message-cleanup-headers)
4367 ;; FIXME: we're inserting the courtesy copy after encoding.
4368 ;; This is wrong if the courtesy copy string contains
4369 ;; non-ASCII characters. -- jh
4372 (message-narrow-to-headers)
4374 (or (message-fetch-field "cc")
4375 (message-fetch-field "bcc")
4376 (message-fetch-field "to"))
4377 (let ((content-type (message-fetch-field
4382 (string= "text/plain"
4384 (mail-header-parse-content-type
4388 (message-fetch-field
4389 "content-transfer-encoding")))))))
4390 (message-insert-courtesy-copy))
4391 (if (or (not message-send-mail-partially-limit
)
4392 (< (buffer-size) message-send-mail-partially-limit
)
4393 (not (message-y-or-n-p
4394 "The message size is too large, split? "
4398 (/ (buffer-size) 1000) "KB, is too large.
4400 Some mail gateways (MTA's) bounce large messages. To avoid the
4401 problem, answer `y', and the message will be split into several
4402 smaller pieces, the size of each is about "
4403 (/ message-send-mail-partially-limit
1000)
4407 However, some mail readers (MUA's) can't read split messages, i.e.,
4408 mails in message/partially format. Answer `n', and the message will be
4411 The size limit is controlled by `message-send-mail-partially-limit'.
4412 If you always want Gnus to send messages in one piece, set
4413 `message-send-mail-partially-limit' to nil.
4415 (mm-with-unibyte-current-buffer
4416 (message "Sending via mail...")
4417 (funcall (or message-send-mail-real-function
4418 message-send-mail-function
)))
4419 (message-send-mail-partially)))
4420 (kill-buffer tembuf
))
4421 (set-buffer mailbuf
)
4422 (push 'mail message-sent-message-via
)))
4424 (defun message-send-mail-with-sendmail ()
4425 "Send off the prepared buffer with sendmail."
4426 (let ((errbuf (if message-interactive
4427 (message-generate-new-buffer-clone-locals
4430 resend-to-addresses delimline
)
4433 (let ((case-fold-search t
))
4435 (message-narrow-to-headers)
4436 (setq resend-to-addresses
(message-fetch-field "resent-to")))
4437 ;; Change header-delimiter to be what sendmail expects.
4438 (goto-char (point-min))
4440 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4441 (replace-match "\n")
4443 (setq delimline
(point-marker))
4444 (run-hooks 'message-send-mail-hook
)
4445 ;; Insert an extra newline if we need it to work around
4446 ;; Sun's bug that swallows newlines.
4447 (goto-char (1+ delimline
))
4448 (when (eval message-mailer-swallows-blank-line
)
4450 (when message-interactive
4451 (with-current-buffer errbuf
4453 (let* ((default-directory "/")
4454 (coding-system-for-write message-send-coding-system
)
4456 'call-process-region
4458 (list (point-min) (point-max)
4459 (cond ((boundp 'sendmail-program
)
4461 ((file-exists-p "/usr/sbin/sendmail")
4462 "/usr/sbin/sendmail")
4463 ((file-exists-p "/usr/lib/sendmail")
4464 "/usr/lib/sendmail")
4465 ((file-exists-p "/usr/ucblib/sendmail")
4466 "/usr/ucblib/sendmail")
4468 nil errbuf nil
"-oi")
4469 message-sendmail-extra-arguments
4470 ;; Always specify who from,
4471 ;; since some systems have broken sendmails.
4472 ;; But some systems are more broken with -f, so
4473 ;; we'll let users override this.
4474 (if (null message-sendmail-f-is-evil
)
4475 (list "-f" (message-sendmail-envelope-from)))
4476 ;; These mean "report errors by mail"
4477 ;; and "deliver in background".
4478 (if (null message-interactive
) '("-oem" "-odb"))
4479 ;; Get the addresses from the message
4480 ;; unless this is a resend.
4481 ;; We must not do that for a resend
4482 ;; because we would find the original addresses.
4483 ;; For a resend, include the specific addresses.
4484 (if resend-to-addresses
4485 (list resend-to-addresses
)
4487 (unless (or (null cpr
) (and (numberp cpr
) (zerop cpr
)))
4488 (error "Sending...failed with exit value %d" cpr
)))
4489 (when message-interactive
4490 (with-current-buffer errbuf
4491 (goto-char (point-min))
4492 (while (re-search-forward "\n+ *" nil t
)
4493 (replace-match "; "))
4494 (if (not (zerop (buffer-size)))
4495 (error "Sending...failed to %s"
4496 (buffer-string))))))
4497 (when (bufferp errbuf
)
4498 (kill-buffer errbuf
)))))
4500 (defun message-send-mail-with-qmail ()
4501 "Pass the prepared message buffer to qmail-inject.
4502 Refer to the documentation for the variable `message-send-mail-function'
4503 to find out how to use this."
4504 ;; replace the header delimiter with a blank line
4505 (goto-char (point-min))
4507 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4508 (replace-match "\n")
4509 (run-hooks 'message-send-mail-hook
)
4512 (let ((coding-system-for-write message-send-coding-system
))
4514 'call-process-region
(point-min) (point-max)
4515 message-qmail-inject-program nil nil nil
4516 ;; qmail-inject's default behaviour is to look for addresses on the
4517 ;; command line; if there're none, it scans the headers.
4518 ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
4520 ;; in general, ALL of qmail-inject's defaults are perfect for simply
4521 ;; reading a formatted (i. e., at least a To: or Resent-To header)
4522 ;; message from stdin.
4524 ;; qmail also has the advantage of not having been raped by
4525 ;; various vendors, so we don't have to allow for that, either --
4526 ;; compare this with message-send-mail-with-sendmail and weep
4527 ;; for sendmail's lost innocence.
4529 ;; all this is way cool coz it lets us keep the arguments entirely
4530 ;; free for -inject-arguments -- a big win for the user and for us
4531 ;; since we don't have to play that double-guessing game and the user
4532 ;; gets full control (no gestapo'ish -f's, for instance). --sj
4533 (if (functionp message-qmail-inject-args
)
4534 (funcall message-qmail-inject-args
)
4535 message-qmail-inject-args
)))
4536 ;; qmail-inject doesn't say anything on it's stdout/stderr,
4537 ;; we have to look at the retval instead
4539 (100 (error "qmail-inject reported permanent failure"))
4540 (111 (error "qmail-inject reported transient failure"))
4541 ;; should never happen
4542 (t (error "qmail-inject reported unknown failure"))))
4544 (defun message-send-mail-with-mh ()
4545 "Send the prepared message buffer with mh."
4546 (let ((mh-previous-window-config nil
)
4547 (name (mh-new-draft-name)))
4548 (setq buffer-file-name name
)
4549 ;; MH wants to generate these headers itself.
4550 (when message-mh-deletable-headers
4551 (let ((headers message-mh-deletable-headers
))
4553 (goto-char (point-min))
4554 (and (re-search-forward
4555 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
4556 (message-delete-line))
4558 (run-hooks 'message-send-mail-hook
)
4559 ;; Pass it on to mh.
4562 (defun message-smtpmail-send-it ()
4563 "Send the prepared message buffer with `smtpmail-send-it'.
4564 This only differs from `smtpmail-send-it' that this command evaluates
4565 `message-send-mail-hook' just before sending a message. It is useful
4566 if your ISP requires the POP-before-SMTP authentication. See the Gnus
4567 manual for details."
4568 (run-hooks 'message-send-mail-hook
)
4571 (defun message-send-mail-with-mailclient ()
4572 "Send the prepared message buffer with `mailclient-send-it'.
4573 This only differs from `smtpmail-send-it' that this command evaluates
4574 `message-send-mail-hook' just before sending a message."
4575 (run-hooks 'message-send-mail-hook
)
4576 (mailclient-send-it))
4578 (defun message-canlock-generate ()
4579 "Return a string that is non-trivial to guess.
4580 Do not use this for anything important, it is cryptographically weak."
4582 (let (sha1-maximum-internal-length)
4583 (sha1 (concat (message-unique-id)
4584 (format "%x%x%x" (random) (random t
) (random))
4585 (prin1-to-string (recent-keys))
4586 (prin1-to-string (garbage-collect))))))
4588 (defun message-canlock-password ()
4589 "The password used by message for cancel locks.
4590 This is the value of `canlock-password', if that option is non-nil.
4591 Otherwise, generate and save a value for `canlock-password' first."
4592 (unless canlock-password
4593 (customize-save-variable 'canlock-password
(message-canlock-generate))
4594 (setq canlock-password-for-verify canlock-password
))
4597 (defun message-insert-canlock ()
4598 (when message-insert-canlock
4599 (message-canlock-password)
4600 (canlock-insert-header)))
4602 (defun message-send-news (&optional arg
)
4603 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*"))
4604 (case-fold-search nil
)
4605 (method (if (functionp message-post-method
)
4606 (funcall message-post-method arg
)
4607 message-post-method
))
4608 (newsgroups-field (save-restriction
4609 (message-narrow-to-headers-or-head)
4610 (message-fetch-field "Newsgroups")))
4611 (followup-field (save-restriction
4612 (message-narrow-to-headers-or-head)
4613 (message-fetch-field "Followup-To")))
4614 ;; BUG: We really need to get the charset for each name in the
4615 ;; Newsgroups and Followup-To lines to allow crossposting
4616 ;; between group namess with incompatible character sets.
4617 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
4618 (group-field-charset
4619 (gnus-group-name-charset method newsgroups-field
))
4620 (followup-field-charset
4621 (gnus-group-name-charset method
(or followup-field
"")))
4622 (rfc2047-header-encoding-alist
4623 (append (when group-field-charset
4624 (list (cons "Newsgroups" group-field-charset
)))
4625 (when followup-field-charset
4626 (list (cons "Followup-To" followup-field-charset
)))
4627 rfc2047-header-encoding-alist
))
4628 (messbuf (current-buffer))
4629 (message-syntax-checks
4631 (listp message-syntax-checks
))
4632 (cons '(existing-newsgroups . disabled
)
4633 message-syntax-checks
)
4634 message-syntax-checks
))
4635 (message-this-is-news t
)
4636 (message-posting-charset
4637 (gnus-setup-posting-charset newsgroups-field
))
4639 (if (not (message-check-news-body-syntax))
4642 (message-narrow-to-headers)
4643 ;; Insert some headers.
4644 (message-generate-headers message-required-news-headers
)
4645 (message-insert-canlock)
4646 ;; Let the user do all of the above.
4647 (run-hooks 'message-header-hook
))
4648 ;; Note: This check will be disabled by the ".*" default value for
4649 ;; gnus-group-name-charset-group-alist. -- Pa 2001-10-07.
4650 (when (and group-field-charset
4651 (listp message-syntax-checks
))
4652 (setq message-syntax-checks
4653 (cons '(valid-newsgroups . disabled
)
4654 message-syntax-checks
)))
4655 (message-cleanup-headers)
4656 (if (not (let ((message-post-method method
))
4657 (message-check-news-syntax)))
4660 (with-current-buffer tembuf
4661 (buffer-disable-undo)
4663 ;; Avoid copying text props (except hard newlines).
4665 (with-current-buffer messbuf
4666 (mml-buffer-substring-no-properties-except-hard-newlines
4667 (point-min) (point-max))))
4668 (message-encode-message-body)
4669 ;; Remove some headers.
4671 (message-narrow-to-headers)
4672 ;; We (re)generate the Lines header.
4673 (when (memq 'Lines message-required-mail-headers
)
4674 (message-generate-headers '(Lines)))
4675 ;; Remove some headers.
4676 (message-remove-header message-ignored-news-headers t
)
4677 (let ((mail-parse-charset message-default-charset
))
4678 (mail-encode-encoded-word-buffer)))
4679 (goto-char (point-max))
4680 ;; require one newline at the end.
4681 (or (= (preceding-char) ?
\n)
4683 (let ((case-fold-search t
))
4684 ;; Remove the delimiter.
4685 (goto-char (point-min))
4687 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4688 (replace-match "\n")
4690 (run-hooks 'message-send-news-hook
)
4691 (gnus-open-server method
)
4692 (message "Sending news via %s..." (gnus-server-string method
))
4693 (setq result
(let ((mail-header-separator ""))
4694 (gnus-request-post method
))))
4695 (kill-buffer tembuf
))
4696 (set-buffer messbuf
)
4698 (push 'news message-sent-message-via
)
4699 (message "Couldn't send message via news: %s"
4700 (nnheader-get-report (car method
)))
4704 ;;; Header generation & syntax checking.
4707 (defun message-check-element (type)
4708 "Return non-nil if this TYPE is not to be checked."
4709 (if (eq message-syntax-checks
'dont-check-for-anything-just-trust-me
)
4711 (let ((able (assq type message-syntax-checks
)))
4713 (eq (cdr able
) 'disabled
)))))
4715 (defun message-check-news-syntax ()
4716 "Check the syntax of the message."
4720 ;; We narrow to the headers and check them first.
4723 (message-narrow-to-headers)
4724 (message-check-news-header-syntax))))))
4726 (defun message-check-news-header-syntax ()
4728 ;; Check Newsgroups header.
4729 (message-check 'newsgroups
4730 (let ((group (message-fetch-field "newsgroups")))
4733 (not (string-match "\\`[ \t]*\\'" group
)))
4736 "The newsgroups field is empty or missing. Posting is denied.")))))
4737 ;; Check the Subject header.
4738 (message-check 'subject
4739 (let* ((case-fold-search t
)
4740 (subject (message-fetch-field "subject")))
4743 (not (string-match "\\`[ \t]*\\'" subject
)))
4746 "The subject field is empty or missing. Posting is denied.")))))
4747 ;; Check for commands in Subject.
4748 (message-check 'subject-cmsg
4749 (if (string-match "^cmsg " (message-fetch-field "subject"))
4751 "The control code \"cmsg\" is in the subject. Really post? ")
4753 ;; Check long header lines.
4754 (message-check 'long-header-lines
4755 (let ((start (point))
4759 (while (and (not found
)
4760 (re-search-forward "^\\([^ \t:]+\\): " nil t
))
4761 (if (> (- (point) (match-beginning 0)) 998)
4763 length
(- (point) (match-beginning 0)))
4764 (setq header
(match-string-no-properties 1)))
4765 (setq start
(match-beginning 0))
4768 (y-or-n-p (format "Your %s header is too long (%d). Really post? "
4771 ;; Check for multiple identical headers.
4772 (message-check 'multiple-headers
4774 (while (and (not found
)
4775 (re-search-forward "^[^ \t:]+: " nil t
))
4777 (or (re-search-forward
4782 (match-beginning 0) (- (match-end 0) 2))))
4787 (y-or-n-p (format "Multiple %s headers. Really post? " found
))
4789 ;; Check for Version and Sendsys.
4790 (message-check 'sendsys
4791 (if (re-search-forward "^Sendsys:\\|^Version:" nil t
)
4793 (format "The article contains a %s command. Really post? "
4794 (buffer-substring (match-beginning 0)
4795 (1- (match-end 0)))))
4797 ;; See whether we can shorten Followup-To.
4798 (message-check 'shorten-followup-to
4799 (let ((newsgroups (message-fetch-field "newsgroups"))
4800 (followup-to (message-fetch-field "followup-to"))
4802 (when (and newsgroups
4803 (string-match "," newsgroups
)
4808 (setq to
(completing-read
4809 "Followups to (default no Followup-To header): "
4812 (message-tokenize-header
4814 (goto-char (point-min))
4815 (insert "Followup-To: " to
"\n"))
4817 ;; Check "Shoot me".
4818 (message-check 'shoot
4819 (if (re-search-forward
4820 "Message-ID.*.i-did-not-set--mail-host-address--so-tickle-me" nil t
)
4821 (y-or-n-p "You appear to have a misconfigured system. Really post? ")
4823 ;; Check for Approved.
4824 (message-check 'approved
4825 (if (re-search-forward "^Approved:" nil t
)
4826 (y-or-n-p "The article contains an Approved header. Really post? ")
4828 ;; Check the Message-ID header.
4829 (message-check 'message-id
4830 (let* ((case-fold-search t
)
4831 (message-id (message-fetch-field "message-id" t
)))
4832 (or (not message-id
)
4833 ;; Is there an @ in the ID?
4834 (and (string-match "@" message-id
)
4835 ;; Is there a dot in the ID?
4836 (string-match "@[^.]*\\." message-id
)
4837 ;; Does the ID end with a dot?
4838 (not (string-match "\\.>" message-id
)))
4840 (format "The Message-ID looks strange: \"%s\". Really post? "
4842 ;; Check the Newsgroups & Followup-To headers.
4843 (message-check 'existing-newsgroups
4844 (let* ((case-fold-search t
)
4845 (newsgroups (message-fetch-field "newsgroups"))
4846 (followup-to (message-fetch-field "followup-to"))
4847 (groups (message-tokenize-header
4849 (concat newsgroups
"," followup-to
)
4851 (post-method (if (functionp message-post-method
)
4852 (funcall message-post-method
)
4853 message-post-method
))
4854 ;; KLUDGE to handle nnvirtual groups. Doing this right
4855 ;; would probably involve a new nnoo function.
4856 ;; -- Per Abrahamsen <abraham@dina.kvl.dk>, 2001-10-17.
4857 (method (if (and (consp post-method
)
4858 (eq (car post-method
) 'nnvirtual
)
4859 gnus-message-group-art
)
4860 (let ((group (car (nnvirtual-find-group-art
4861 (car gnus-message-group-art
)
4862 (cdr gnus-message-group-art
)))))
4863 (gnus-find-method-for-group group
))
4867 (gnus-group-name-decode
4868 (gnus-group-real-name n
)
4869 (gnus-group-name-charset method n
)))
4870 (gnus-groups-from-server method
)))
4873 (when (and (not (equal (car groups
) "poster"))
4874 (not (member (car groups
) known-groups
))
4875 (not (member (car groups
) errors
)))
4876 (push (car groups
) errors
))
4879 ;; Gnus is not running.
4880 ((or (not (and (boundp 'gnus-active-hashtb
)
4881 gnus-active-hashtb
))
4882 (not (boundp 'gnus-read-active-file
)))
4884 ;; We don't have all the group names.
4885 ((and (or (not gnus-read-active-file
)
4886 (eq gnus-read-active-file
'some
))
4890 "Really use %s possibly unknown group%s: %s? "
4891 (if (= (length errors
) 1) "this" "these")
4892 (if (= (length errors
) 1) "" "s")
4893 (mapconcat 'identity errors
", "))))
4894 ;; There were no errors.
4897 ;; There are unknown groups.
4901 "Really post to %s unknown group%s: %s? "
4902 (if (= (length errors
) 1) "this" "these")
4903 (if (= (length errors
) 1) "" "s")
4904 (mapconcat 'identity errors
", ")))))))
4905 ;; Check continuation headers.
4906 (message-check 'continuation-headers
4907 (goto-char (point-min))
4908 (let ((do-posting t
))
4909 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4910 (goto-char (match-beginning 0))
4911 (if (y-or-n-p "Fix continuation lines? ")
4914 (unless (y-or-n-p "Send anyway? ")
4915 (setq do-posting nil
))))
4917 ;; Check the Newsgroups & Followup-To headers for syntax errors.
4918 (message-check 'valid-newsgroups
4919 (let ((case-fold-search t
)
4920 (headers '("Newsgroups" "Followup-To"))
4922 (while (and headers
(not error
))
4923 (when (setq header
(mail-fetch-field (car headers
)))
4927 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-+_&.a-zA-Z0-9]+\\)*\\'"
4932 (not (string-match "\\.\\'\\|\\.\\." g
)))
4933 (message-tokenize-header header
","))))
4940 (format "The %s header looks odd: \"%s\". Really post? "
4941 (car headers
) header
)))))
4942 (message-check 'repeated-newsgroups
4943 (let ((case-fold-search t
)
4944 (headers '("Newsgroups" "Followup-To"))
4945 header error groups group
)
4948 (when (setq header
(mail-fetch-field (pop headers
)))
4949 (setq groups
(message-tokenize-header header
","))
4950 (while (setq group
(pop groups
))
4951 (when (member group groups
)
4957 (format "Group %s is repeated in headers. Really post? " error
)))))
4958 ;; Check the From header.
4959 (message-check 'from
4960 (let* ((case-fold-search t
)
4961 (from (message-fetch-field "from"))
4965 (message "There is no From line. Posting is denied.")
4967 ((or (not (string-match
4969 (setq ad
(nth 1 (mail-extract-address-components
4970 from
))))) ;larsi@ifi
4971 (string-match "\\.\\." ad
) ;larsi@ifi..uio
4972 (string-match "@\\." ad
) ;larsi@.ifi.uio
4973 (string-match "\\.$" ad
) ;larsi@ifi.uio.
4974 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
4975 (string-match "(.*).*(.*)" from
)) ;(lars) (lars)
4977 "Denied posting -- the From looks strange: \"%s\"." from
)
4979 ((let ((addresses (rfc822-addresses from
)))
4980 (while (and addresses
4981 (not (eq (string-to-char (car addresses
)) ?\
()))
4982 (setq addresses
(cdr addresses
)))
4985 "Denied posting -- bad From address: \"%s\"." from
)
4988 ;; Check the Reply-To header.
4989 (message-check 'reply-to
4990 (let* ((case-fold-search t
)
4991 (reply-to (message-fetch-field "reply-to"))
4996 ((string-match "," reply-to
)
4998 (format "Multiple Reply-To addresses: \"%s\". Really post? "
5000 ((or (not (string-match
5002 (setq ad
(nth 1 (mail-extract-address-components
5003 reply-to
))))) ;larsi@ifi
5004 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5005 (string-match "@\\." ad
) ;larsi@.ifi.uio
5006 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5007 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5008 (string-match "(.*).*(.*)" reply-to
)) ;(lars) (lars)
5011 "The Reply-To looks strange: \"%s\". Really post? "
5015 (defun message-check-news-body-syntax ()
5017 ;; Check for long lines.
5018 (message-check 'long-lines
5019 (goto-char (point-min))
5021 (concat "^" (regexp-quote mail-header-separator
) "$"))
5025 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)")
5028 (< (- (point) p
) 80)))
5029 (zerop (forward-line 1))))
5033 "You have lines longer than 79 characters. Really post? ")))
5034 ;; Check whether the article is empty.
5035 (message-check 'empty
5036 (goto-char (point-min))
5038 (concat "^" (regexp-quote mail-header-separator
) "$"))
5041 (goto-char (point-max))
5042 (re-search-backward message-signature-separator nil t
)
5044 (or (re-search-backward "[^ \n\t]" b t
)
5045 (if (message-gnksa-enable-p 'empty-article
)
5046 (y-or-n-p "Empty article. Really post? ")
5047 (message "Denied posting -- Empty article.")
5049 ;; Check for control characters.
5050 (message-check 'control-chars
5051 (if (re-search-forward
5052 (mm-string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
5055 "The article contains control characters. Really post? ")
5057 ;; Check excessive size.
5058 (message-check 'size
5059 (if (> (buffer-size) 60000)
5061 (format "The article is %d octets long. Really post? "
5064 ;; Check whether any new text has been added.
5065 (message-check 'new-text
5067 (not message-checksum
)
5068 (not (eq (message-checksum) message-checksum
))
5069 (if (message-gnksa-enable-p 'quoted-text-only
)
5071 "It looks like no new text has been added. Really post? ")
5072 (message "Denied posting -- no new text has been added.")
5074 ;; Check the length of the signature.
5075 (message-check 'signature
5076 (goto-char (point-max))
5077 (if (not (re-search-backward message-signature-separator nil t
))
5079 (if (>= (count-lines (1+ (point-at-eol)) (point-max)) 5)
5080 (if (message-gnksa-enable-p 'signature
)
5082 (format "Signature is excessively long (%d lines). Really post? "
5083 (count-lines (1+ (point-at-eol)) (point-max))))
5084 (message "Denied posting -- Excessive signature.")
5087 ;; Ensure that text follows last quoted portion.
5088 (message-check 'quoting-style
5089 (goto-char (point-max))
5090 (let ((no-problem t
))
5091 (when (search-backward-regexp "^>[^\n]*\n" nil t
)
5092 (setq no-problem
(search-forward-regexp "^[ \t]*[^>\n]" nil t
)))
5095 (if (message-gnksa-enable-p 'quoted-text-only
)
5096 (y-or-n-p "Your text should follow quoted text. Really post? ")
5098 (goto-char (point-min))
5100 (concat "^" (regexp-quote mail-header-separator
) "$"))
5101 (if (search-forward-regexp "^[ \t]*[^>\n]" nil t
)
5102 (y-or-n-p "Your text should follow quoted text. Really post? ")
5103 (message "Denied posting -- only quoted text.")
5106 (defun message-checksum ()
5107 "Return a \"checksum\" for the current buffer."
5110 (goto-char (point-min))
5112 (concat "^" (regexp-quote mail-header-separator
) "$"))
5114 (when (not (looking-at "[ \t\n]"))
5115 (setq sum
(logxor (ash sum
1) (if (natnump sum
) 0 1)
5120 (defun message-do-fcc ()
5121 "Process Fcc headers in the current buffer."
5122 (let ((case-fold-search t
)
5123 (buf (current-buffer))
5125 (mml-externalize-attachments message-fcc-externalize-attachments
))
5128 (message-narrow-to-headers)
5129 (setq file
(message-fetch-field "fcc" t
)))
5131 (set-buffer (get-buffer-create " *message temp*"))
5133 (insert-buffer-substring buf
)
5134 (message-encode-message-body)
5136 (message-narrow-to-headers)
5137 (while (setq file
(message-fetch-field "fcc" t
))
5139 (message-remove-header "fcc" nil t
))
5140 (let ((mail-parse-charset message-default-charset
)
5141 (rfc2047-header-encoding-alist
5142 (cons '("Newsgroups" . default
)
5143 rfc2047-header-encoding-alist
)))
5144 (mail-encode-encoded-word-buffer)))
5145 (goto-char (point-min))
5146 (when (re-search-forward
5147 (concat "^" (regexp-quote mail-header-separator
) "$")
5149 (replace-match "" t t
))
5150 ;; Process FCC operations.
5152 (setq file
(pop list
))
5153 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file
)
5154 ;; Pipe the article to the program in question.
5155 (call-process-region (point-min) (point-max) shell-file-name
5156 nil nil nil shell-command-switch
5157 (match-string 1 file
))
5158 ;; Save the article.
5159 (setq file
(expand-file-name file
))
5160 (unless (file-exists-p (file-name-directory file
))
5161 (make-directory (file-name-directory file
) t
))
5162 (if (and message-fcc-handler-function
5163 (not (eq message-fcc-handler-function
'rmail-output
)))
5164 (funcall message-fcc-handler-function file
)
5165 (if (and (file-readable-p file
) (mail-file-babyl-p file
))
5166 (rmail-output file
1 nil t
)
5167 (let ((mail-use-rfc822 t
))
5168 (rmail-output file
1 t t
))))))
5169 (kill-buffer (current-buffer))))))
5171 (defun message-output (filename)
5172 "Append this article to Unix/babyl mail file FILENAME."
5173 (if (and (file-readable-p filename
)
5174 (mail-file-babyl-p filename
))
5175 (gnus-output-to-rmail filename t
)
5176 (gnus-output-to-mail filename t
)))
5178 (defun message-cleanup-headers ()
5179 "Do various automatic cleanups of the headers."
5180 ;; Remove empty lines in the header.
5182 (message-narrow-to-headers)
5183 ;; Remove blank lines.
5184 (while (re-search-forward "^[ \t]*\n" nil t
)
5185 (replace-match "" t t
))
5187 ;; Correct Newsgroups and Followup-To headers: Change sequence of
5188 ;; spaces to comma and eliminate spaces around commas. Eliminate
5189 ;; embedded line breaks.
5190 (goto-char (point-min))
5191 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t
)
5195 (if (re-search-forward "^[^ \t]" nil t
)
5199 (goto-char (point-min))
5200 (while (re-search-forward "\n[ \t]+" nil t
)
5201 (replace-match " " t t
)) ;No line breaks (too confusing)
5202 (goto-char (point-min))
5203 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t
)
5204 (replace-match "," t t
))
5205 (goto-char (point-min))
5206 ;; Remove trailing commas.
5207 (when (re-search-forward ",+$" nil t
)
5208 (replace-match "" t t
))))))
5210 (defun message-make-date (&optional now
)
5211 "Make a valid data header.
5212 If NOW, use that time instead."
5213 (let ((system-time-locale "C"))
5214 (format-time-string "%a, %d %b %Y %T %z" now
)))
5216 (defun message-insert-expires (days)
5217 "Insert the Expires header. Expiry in DAYS days."
5218 (interactive "NExpire article in how many days? ")
5220 (message-position-on-field "Expires" "X-Draft-From")
5221 (insert (message-make-expires-date days
))))
5223 (defun message-make-expires-date (days)
5224 "Make date string for the Expires header. Expiry in DAYS days.
5226 In posting styles use `(\"Expires\" (make-expires-date 30))'."
5227 (let* ((cur (decode-time (current-time)))
5228 (nday (+ days
(nth 3 cur
))))
5229 (setf (nth 3 cur
) nday
)
5230 (message-make-date (apply 'encode-time cur
))))
5232 (defun message-make-message-id ()
5233 "Make a unique Message-ID."
5234 (concat "<" (message-unique-id)
5235 (let ((psubject (save-excursion (message-fetch-field "subject")))
5237 (save-excursion (message-fetch-field "supersedes"))))
5239 (and message-reply-headers
5240 (mail-header-references message-reply-headers
)
5241 (mail-header-subject message-reply-headers
)
5244 (message-strip-subject-re
5245 (mail-header-subject message-reply-headers
))
5246 (message-strip-subject-re psubject
))))
5248 (string-match "_-_@" psupersedes
)))
5250 "@" (message-make-fqdn) ">"))
5252 (defvar message-unique-id-char nil
)
5254 ;; If you ever change this function, make sure the new version
5255 ;; cannot generate IDs that the old version could.
5256 ;; You might for example insert a "." somewhere (not next to another dot
5257 ;; or string boundary), or modify the "fsf" string.
5258 (defun message-unique-id ()
5259 ;; Don't use microseconds from (current-time), they may be unsupported.
5260 ;; Instead we use this randomly inited counter.
5261 (setq message-unique-id-char
5262 (%
(1+ (or message-unique-id-char
(logand (random t
) (1- (lsh 1 20)))))
5263 ;; (current-time) returns 16-bit ints,
5264 ;; and 2^16*25 just fits into 4 digits i base 36.
5266 (let ((tm (current-time)))
5268 (if (or (memq system-type
'(ms-dos emx vax-vms
))
5269 ;; message-number-base36 doesn't handle bigints.
5270 (floatp (user-uid)))
5271 (let ((user (downcase (user-login-name))))
5272 (while (string-match "[^a-z0-9_]" user
)
5273 (aset user
(match-beginning 0) ?_
))
5275 (message-number-base36 (user-uid) -
1))
5276 (message-number-base36 (+ (car tm
)
5277 (lsh (% message-unique-id-char
25) 16)) 4)
5278 (message-number-base36 (+ (nth 1 tm
)
5279 (lsh (/ message-unique-id-char
25) 16)) 4)
5280 ;; Append a given name, because while the generated ID is unique
5281 ;; to this newsreader, other newsreaders might otherwise generate
5282 ;; the same ID via another algorithm.
5285 (defun message-number-base36 (num len
)
5290 (concat (message-number-base36 (/ num
36) (1- len
))
5291 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
5294 (defun message-make-organization ()
5295 "Make an Organization header."
5296 (let* ((organization
5297 (when message-user-organization
5298 (if (functionp message-user-organization
)
5299 (funcall message-user-organization
)
5300 message-user-organization
))))
5302 (mm-enable-multibyte)
5303 (cond ((stringp organization
)
5304 (insert organization
))
5305 ((and (eq t organization
)
5306 message-user-organization-file
5307 (file-exists-p message-user-organization-file
))
5308 (insert-file-contents message-user-organization-file
)))
5309 (goto-char (point-min))
5310 (while (re-search-forward "[\t\n]+" nil t
)
5311 (replace-match "" t t
))
5312 (unless (zerop (buffer-size))
5315 (defun message-make-lines ()
5316 "Count the number of lines and return numeric string."
5321 (int-to-string (count-lines (point) (point-max))))))
5323 (defun message-make-references ()
5324 "Return the References header for this message."
5325 (when message-reply-headers
5326 (let ((message-id (mail-header-message-id message-reply-headers
))
5327 (references (mail-header-references message-reply-headers
)))
5328 (if (or references message-id
)
5329 (concat (or references
"") (and references
" ")
5333 (defun message-make-in-reply-to ()
5334 "Return the In-Reply-To header for this message."
5335 (when message-reply-headers
5336 (let ((from (mail-header-from message-reply-headers
))
5337 (date (mail-header-date message-reply-headers
))
5338 (msg-id (mail-header-message-id message-reply-headers
)))
5340 (let ((name (mail-extract-address-components from
)))
5342 msg-id
(if msg-id
" (")
5344 (if (string-match "[^\000-\177]" (car name
))
5345 ;; Quote a string containing non-ASCII characters.
5346 ;; It will make the RFC2047 encoder cause an error
5347 ;; if there are special characters.
5348 (let ((default-enable-multibyte-characters t
))
5351 (goto-char (point-min))
5352 (while (search-forward "\"" nil t
)
5355 (zerop (%
(skip-chars-backward "\\\\") 2))
5356 (goto-char (match-beginning 0)))
5359 ;; Those quotes will be removed by the RFC2047 encoder.
5360 (concat "\"" (buffer-string) "\"")))
5364 (if (or (not date
) (string= date
""))
5365 "(unknown date)" date
)
5366 "\"" (if msg-id
")")))))))
5368 (defun message-make-distribution ()
5369 "Make a Distribution header."
5370 (let ((orig-distribution (message-fetch-reply-field "distribution")))
5371 (cond ((functionp message-distribution-function
)
5372 (funcall message-distribution-function
))
5373 (t orig-distribution
))))
5375 (defun message-make-expires ()
5376 "Return an Expires header based on `message-expires'."
5377 (let ((current (current-time))
5378 (future (* 1.0 message-expires
60 60 24)))
5379 ;; Add the future to current.
5380 (setcar current
(+ (car current
) (round (/ future
(expt 2 16)))))
5381 (setcar (cdr current
) (+ (nth 1 current
) (%
(round future
) (expt 2 16))))
5382 (message-make-date current
)))
5384 (defun message-make-path ()
5386 (let ((login-name (user-login-name)))
5387 (cond ((null message-user-path
)
5388 (concat (system-name) "!" login-name
))
5389 ((stringp message-user-path
)
5390 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
5391 (concat message-user-path
"!" login-name
))
5394 (defun message-make-from (&optional name address
)
5395 "Make a From header."
5396 (let* ((style message-from-style
)
5397 (login (or address
(message-make-address)))
5399 (and (boundp 'user-full-name
)
5402 (when (string= fullname
"&")
5403 (setq fullname
(user-login-name)))
5405 (mm-enable-multibyte)
5408 (equal fullname
""))
5410 ((or (eq style
'angles
)
5411 (and (not (eq style
'parens
))
5412 ;; Use angles if no quoting is needed, or if parens would
5413 ;; need quoting too.
5414 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname
))
5415 (let ((tmp (concat fullname nil
)))
5416 (while (string-match "([^()]*)" tmp
)
5417 (aset tmp
(match-beginning 0) ?-
)
5418 (aset tmp
(1- (match-end 0)) ?-
))
5419 (string-match "[\\()]" tmp
)))))
5421 (goto-char (point-min))
5422 ;; Look for a character that cannot appear unquoted
5423 ;; according to RFC 822.
5424 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil
1)
5425 ;; Quote fullname, escaping specials.
5426 (goto-char (point-min))
5428 (while (re-search-forward "[\"\\]" nil
1)
5429 (replace-match "\\\\\\&" t
))
5431 (insert " <" login
">"))
5432 (t ; 'parens or default
5434 (let ((fullname-start (point)))
5436 (goto-char fullname-start
)
5437 ;; RFC 822 says \ and nonmatching parentheses
5438 ;; must be escaped in comments.
5439 ;; Escape every instance of ()\ ...
5440 (while (re-search-forward "[()\\]" nil
1)
5441 (replace-match "\\\\\\&" t
))
5442 ;; ... then undo escaping of matching parentheses,
5443 ;; including matching nested parentheses.
5444 (goto-char fullname-start
)
5445 (while (re-search-forward
5446 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
5448 (replace-match "\\1(\\3)" t
)
5449 (goto-char fullname-start
)))
5453 (defun message-make-sender ()
5454 "Return the \"real\" user address.
5455 This function tries to ignore all user modifications, and
5456 give as trustworthy answer as possible."
5457 (concat (user-login-name) "@" (system-name)))
5459 (defun message-make-address ()
5460 "Make the address of the user."
5461 (or (message-user-mail-address)
5462 (concat (user-login-name) "@" (message-make-domain))))
5464 (defun message-user-mail-address ()
5465 "Return the pertinent part of `user-mail-address'."
5466 (when (and user-mail-address
5467 (string-match "@.*\\." user-mail-address
))
5468 (if (string-match " " user-mail-address
)
5469 (nth 1 (mail-extract-address-components user-mail-address
))
5470 user-mail-address
)))
5472 (defun message-sendmail-envelope-from ()
5473 "Return the envelope from."
5474 (cond ((eq message-sendmail-envelope-from
'header
)
5475 (nth 1 (mail-extract-address-components
5476 (message-fetch-field "from"))))
5477 ((stringp message-sendmail-envelope-from
)
5478 message-sendmail-envelope-from
)
5480 (message-make-address))))
5482 (defun message-make-fqdn ()
5483 "Return user's fully qualified domain name."
5484 (let* ((system-name (system-name))
5485 (user-mail (message-user-mail-address))
5488 (string-match "@\\(.*\\)\\'" user-mail
))
5489 (match-string 1 user-mail
)))
5490 (case-fold-search t
))
5492 ((and message-user-fqdn
5493 (stringp message-user-fqdn
)
5494 (string-match message-valid-fqdn-regexp message-user-fqdn
)
5495 (not (string-match message-bogus-system-names message-user-fqdn
)))
5496 ;; `message-user-fqdn' seems to be valid
5498 ((and (string-match message-valid-fqdn-regexp system-name
)
5499 (not (string-match message-bogus-system-names system-name
)))
5500 ;; `system-name' returned the right result.
5502 ;; Try `mail-host-address'.
5503 ((and (boundp 'mail-host-address
)
5504 (stringp mail-host-address
)
5505 (string-match message-valid-fqdn-regexp mail-host-address
)
5506 (not (string-match message-bogus-system-names mail-host-address
)))
5508 ;; We try `user-mail-address' as a backup.
5510 (stringp user-domain
)
5511 (string-match message-valid-fqdn-regexp user-domain
)
5512 (not (string-match message-bogus-system-names user-domain
)))
5514 ;; Default to this bogus thing.
5517 ".i-did-not-set--mail-host-address--so-tickle-me")))))
5519 (defun message-make-host-name ()
5520 "Return the name of the host."
5521 (let ((fqdn (message-make-fqdn)))
5522 (string-match "^[^.]+\\." fqdn
)
5523 (substring fqdn
0 (1- (match-end 0)))))
5525 (defun message-make-domain ()
5526 "Return the domain name."
5527 (or mail-host-address
5528 (message-make-fqdn)))
5530 (defun message-to-list-only ()
5531 "Send a message to the list only.
5532 Remove all addresses but the list address from To and Cc headers."
5534 (let ((listaddr (message-make-mail-followup-to t
)))
5537 (message-remove-header "to")
5538 (message-remove-header "cc")
5539 (message-position-on-field "To" "X-Draft-From")
5540 (insert listaddr
)))))
5542 (defun message-make-mail-followup-to (&optional only-show-subscribed
)
5543 "Return the Mail-Followup-To header.
5544 If passed the optional argument ONLY-SHOW-SUBSCRIBED only return the
5545 subscribed address (and not the additional To and Cc header contents)."
5546 (let* ((case-fold-search t
)
5547 (to (message-fetch-field "To"))
5548 (cc (message-fetch-field "cc"))
5549 (msg-recipients (concat to
(and to cc
", ") cc
))
5551 (mapcar 'mail-strip-quoted-names
5552 (message-tokenize-header msg-recipients
)))
5554 (if message-subscribed-address-file
5555 (let (begin end item re
)
5558 (insert-file-contents message-subscribed-address-file
)
5560 (setq begin
(point))
5563 (if (bolp) (setq end
(1- end
)))
5564 (setq item
(regexp-quote (buffer-substring begin end
)))
5565 (if re
(setq re
(concat re
"\\|" item
))
5566 (setq re
(concat "\\`\\(" item
))))
5567 (and re
(list (concat re
"\\)\\'"))))))))
5568 (mft-regexps (apply 'append message-subscribed-regexps
5569 (mapcar 'regexp-quote
5570 message-subscribed-addresses
)
5573 message-subscribed-address-functions
))))
5576 (loop for recipient in recipients
5577 when
(loop for regexp in mft-regexps
5578 when
(string-match regexp recipient
) return t
)
5581 (if only-show-subscribed
5583 msg-recipients
))))))
5585 (defun message-idna-to-ascii-rhs-1 (header)
5586 "Interactively potentially IDNA encode domain names in HEADER."
5587 (let ((field (message-fetch-field header
))
5591 (mm-delete-duplicates
5592 (mapcar (lambda (rhs) (or (cadr (split-string rhs
"@")) ""))
5595 'car
(mail-header-parse-addresses field
))))))
5596 (setq ace
(if (string-match "\\`[[:ascii:]]+\\'" rhs
)
5598 (downcase (idna-to-ascii rhs
))))
5599 (when (and (not (equal rhs ace
))
5600 (or (not (eq message-use-idna
'ask
))
5601 (y-or-n-p (format "Replace %s with %s in %s:? "
5603 (goto-char (point-min))
5604 (while (re-search-forward (concat "^" header
":") nil t
)
5605 (message-narrow-to-field)
5606 (while (search-forward (concat "@" rhs
) nil t
)
5607 (replace-match (concat "@" ace
) t t
))
5608 (goto-char (point-max))
5611 (defun message-idna-to-ascii-rhs ()
5612 "Possibly IDNA encode non-ASCII domain names in From:, To: and Cc: headers.
5613 See `message-idna-encode'."
5615 (when message-use-idna
5618 (message-narrow-to-head)
5619 (message-idna-to-ascii-rhs-1 "From")
5620 (message-idna-to-ascii-rhs-1 "To")
5621 (message-idna-to-ascii-rhs-1 "Reply-To")
5622 (message-idna-to-ascii-rhs-1 "Mail-Reply-To")
5623 (message-idna-to-ascii-rhs-1 "Mail-Followup-To")
5624 (message-idna-to-ascii-rhs-1 "Cc")))))
5626 (defun message-generate-headers (headers)
5627 "Prepare article HEADERS.
5628 Headers already prepared in the buffer are not modified."
5629 (setq headers
(append headers message-required-headers
))
5631 (message-narrow-to-headers)
5632 (let* ((Date (message-make-date))
5633 (Message-ID (message-make-message-id))
5634 (Organization (message-make-organization))
5635 (From (message-make-from))
5636 (Path (message-make-path))
5639 (In-Reply-To (message-make-in-reply-to))
5640 (References (message-make-references))
5642 (Distribution (message-make-distribution))
5643 (Lines (message-make-lines))
5644 (User-Agent message-newsreader
)
5645 (Expires (message-make-expires))
5646 (case-fold-search t
)
5648 header value elem header-string
)
5649 ;; First we remove any old generated headers.
5650 (let ((headers message-deletable-headers
))
5651 (unless (buffer-modified-p)
5652 (setq headers
(delq 'Message-ID
(copy-sequence headers
))))
5654 (goto-char (point-min))
5655 (and (re-search-forward
5656 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
5657 (get-text-property (1+ (match-beginning 0)) 'message-deletable
)
5658 (message-delete-line))
5660 ;; Go through all the required headers and see if they are in the
5661 ;; articles already. If they are not, or are empty, they are
5662 ;; inserted automatically - except for Subject, Newsgroups and
5665 (goto-char (point-min))
5666 (setq elem
(pop headers
))
5668 (if (eq (car elem
) 'optional
)
5669 (setq header
(cdr elem
)
5671 (setq header
(car elem
)))
5673 (setq header-string
(if (stringp header
)
5675 (symbol-name header
)))
5676 (when (or (not (re-search-forward
5678 (regexp-quote (downcase header-string
))
5682 ;; The header was found. We insert a space after the
5683 ;; colon, if there is none.
5684 (if (/= (char-after) ?
) (insert " ") (forward-char 1))
5685 ;; Find out whether the header is empty.
5686 (looking-at "[ \t]*\n[^ \t]")))
5687 ;; So we find out what value we should insert.
5691 (eq (car elem
) 'optional
)
5692 (not (member header-string message-inserted-headers
)))
5693 ;; This is an optional header. If the cdr of this
5694 ;; is something that is nil, then we do not insert
5696 (setq header
(cdr elem
))
5697 (or (and (functionp (cdr elem
))
5698 (funcall (cdr elem
)))
5699 (and (boundp (cdr elem
))
5700 (symbol-value (cdr elem
)))))
5702 ;; The element is a cons. Either the cdr is a
5703 ;; string to be inserted verbatim, or it is a
5704 ;; function, and we insert the value returned from
5706 (or (and (stringp (cdr elem
))
5708 (and (functionp (cdr elem
))
5709 (funcall (cdr elem
)))))
5710 ((and (boundp header
)
5711 (symbol-value header
))
5712 ;; The element is a symbol. We insert the value
5713 ;; of this symbol, if any.
5714 (symbol-value header
))
5715 ((not (message-check-element
5716 (intern (downcase (symbol-name header
)))))
5717 ;; We couldn't generate a value for this header,
5718 ;; so we just ask the user.
5719 (read-from-minibuffer
5720 (format "Empty header for %s; enter value: " header
)))))
5721 ;; Finally insert the header.
5723 (not (equal value
"")))
5727 ;; This header didn't exist, so we insert it.
5728 (goto-char (point-max))
5730 (cdr (assq header message-header-format-alist
))))
5732 (funcall formatter header value
)
5733 (insert header-string
": " value
))
5734 (goto-char (message-fill-field))
5735 ;; We check whether the value was ended by a
5736 ;; newline. If not, we insert one.
5740 ;; The value of this header was empty, so we clear
5741 ;; totally and insert the new value.
5742 (delete-region (point) (point-at-eol))
5743 ;; If the header is optional, and the header was
5744 ;; empty, we can't insert it anyway.
5746 (push header-string message-inserted-headers
)
5748 (message-fill-field)))
5749 ;; Add the deletable property to the headers that require it.
5750 (and (memq header message-deletable-headers
)
5751 (progn (beginning-of-line) (looking-at "[^:]+: "))
5752 (add-text-properties
5753 (point) (match-end 0)
5754 '(message-deletable t face italic
) (current-buffer)))))))
5755 ;; Insert new Sender if the From is strange.
5756 (let ((from (message-fetch-field "from"))
5757 (sender (message-fetch-field "sender"))
5758 (secure-sender (message-make-sender)))
5760 (not (message-check-element 'sender
))
5763 (cadr (mail-extract-address-components from
)))
5764 (downcase secure-sender
)))
5769 (cadr (mail-extract-address-components sender
)))
5770 (downcase secure-sender
)))))
5771 (goto-char (point-min))
5772 ;; Rename any old Sender headers to Original-Sender.
5773 (when (re-search-forward "^\\(Original-\\)*Sender:" nil t
)
5775 (insert "Original-")
5776 (beginning-of-line))
5777 (when (or (message-news-p)
5778 (string-match "@.+\\.." secure-sender
))
5779 (insert "Sender: " secure-sender
"\n"))))
5781 (message-idna-to-ascii-rhs))))
5783 (defun message-insert-courtesy-copy ()
5784 "Insert a courtesy message in mail copies of combined messages."
5788 (message-narrow-to-headers)
5789 (when (setq newsgroups
(message-fetch-field "newsgroups"))
5790 (goto-char (point-max))
5791 (insert "Posted-To: " newsgroups
"\n")))
5793 (when message-courtesy-message
5795 ((string-match "%s" message-courtesy-message
)
5796 (insert (format message-courtesy-message newsgroups
)))
5798 (insert message-courtesy-message
)))))))
5801 ;;; Setting up a message buffer
5804 (defun message-skip-to-next-address ()
5805 (let ((end (save-excursion
5806 (message-next-header)
5809 (when (looking-at ",")
5811 (while (and (not (= (point) end
))
5812 (or (not (eq char ?
,))
5814 (skip-chars-forward "^,\"" (point-max))
5815 (when (eq (setq char
(following-char)) ?
\")
5816 (setq quoted
(not quoted
)))
5817 (unless (= (point) end
)
5819 (skip-chars-forward " \t\n")))
5821 (defun message-fill-address (header value
)
5822 (insert (capitalize (symbol-name header
))
5824 (if (consp value
) (car value
) value
)
5826 (message-fill-field-address))
5828 (defun message-split-line ()
5829 "Split current line, moving portion beyond point vertically down.
5830 If the current line has `message-yank-prefix', insert it on the new line."
5833 (split-line message-yank-prefix
) ;; Emacs 22.1+ supports arg.
5837 (defun message-insert-header (header value
)
5838 (insert (capitalize (symbol-name header
))
5840 (if (consp value
) (car value
) value
)))
5842 (defun message-field-name ()
5844 (goto-char (point-min))
5845 (when (looking-at "\\([^:]+\\):")
5846 (intern (capitalize (match-string 1))))))
5848 (defun message-fill-field ()
5851 (message-narrow-to-field)
5852 (let ((field-name (message-field-name)))
5853 (funcall (or (cadr (assq field-name message-field-fillers
))
5854 'message-fill-field-general
)))
5857 (defun message-fill-field-address ()
5859 (message-skip-to-next-address)
5861 (if (and (> (current-column) 78)
5867 (setq last
(1+ (point))))
5868 (setq last
(1+ (point)))))))
5870 (defun message-fill-field-general ()
5871 (let ((begin (point))
5874 (while (and (search-forward "\n" nil t
)
5876 (replace-match " " t t
))
5877 (fill-region-as-paragraph begin
(point-max))
5878 ;; Tapdance around looong Message-IDs.
5880 (when (looking-at "[ \t]*$")
5881 (message-delete-line))
5883 (search-forward ":" nil t
)
5884 (when (looking-at "\n[ \t]+")
5885 (replace-match " " t t
))
5886 (goto-char (point-max))))
5888 (defun message-shorten-1 (list cut surplus
)
5889 "Cut SURPLUS elements out of LIST, beginning with CUTth one."
5890 (setcdr (nthcdr (- cut
2) list
)
5891 (nthcdr (+ (- cut
2) surplus
1) list
)))
5893 (defun message-shorten-references (header references
)
5894 "Trim REFERENCES to be 21 Message-ID long or less, and fold them.
5895 When sending via news, also check that the REFERENCES are less
5896 than 988 characters long, and if they are not, trim them until
5904 (goto-char (point-min))
5905 ;; Cons a list of valid references. GNKSA says we must not include MIDs
5906 ;; with whitespace or missing brackets (7.a "Does not propagate broken
5907 ;; Message-IDs in original References").
5908 (while (re-search-forward "<[^ <]+@[^ <]+>" nil t
)
5909 (push (match-string 0) refs
))
5910 (setq refs
(nreverse refs
)
5911 count
(length refs
)))
5913 ;; If the list has more than MAXCOUNT elements, trim it by
5914 ;; removing the CUTth element and the required number of
5915 ;; elements that follow.
5916 (when (> count maxcount
)
5917 (let ((surplus (- count maxcount
)))
5918 (message-shorten-1 refs cut surplus
)
5919 (decf count surplus
)))
5921 ;; When sending via news, make sure the total folded length will
5922 ;; be less than 998 characters. This is to cater to broken INN
5923 ;; 2.3 which counts the total number of characters in a header
5924 ;; rather than the physical line length of each line, as it should.
5926 ;; This hack should be removed when it's believed than INN 2.3 is
5927 ;; no longer widely used.
5929 ;; At this point the headers have not been generated, thus we use
5930 ;; message-this-is-news directly.
5931 (when message-this-is-news
5934 (message-insert-header
5935 header
(mapconcat #'identity refs
" "))
5937 (message-shorten-1 refs cut
1)))
5938 ;; Finally, collect the references back into a string and insert
5939 ;; it into the buffer.
5940 (message-insert-header header
(mapconcat #'identity refs
" "))))
5942 (defun message-position-point ()
5943 "Move point to where the user probably wants to find it."
5944 (message-narrow-to-headers)
5946 ((re-search-forward "^[^:]+:[ \t]*$" nil t
)
5947 (search-backward ":" )
5950 (if (eq (char-after) ?
)
5954 (goto-char (point-max))
5957 (unless (looking-at "$")
5961 (defcustom message-beginning-of-line t
5962 "Whether \\<message-mode-map>\\[message-beginning-of-line]\
5963 goes to beginning of header values."
5965 :group
'message-buffers
5966 :link
'(custom-manual "(message)Movement")
5969 (defun message-beginning-of-line (&optional n
)
5970 "Move point to beginning of header value or to beginning of line.
5971 The prefix argument N is passed directly to `beginning-of-line'.
5973 This command is identical to `beginning-of-line' if point is
5974 outside the message header or if the option `message-beginning-of-line'
5977 If point is in the message header and on a (non-continued) header
5978 line, move point to the beginning of the header value or the beginning of line,
5979 whichever is closer. If point is already at beginning of line, move point to
5980 beginning of header value. Therefore, repeated calls will toggle point
5981 between beginning of field and beginning of line."
5983 (let ((zrs 'zmacs-region-stays
))
5984 (when (and (featurep 'xemacs
) (interactive-p) (boundp zrs
))
5986 (if (and message-beginning-of-line
5987 (message-point-in-header-p))
5988 (let* ((here (point))
5989 (bol (progn (beginning-of-line n
) (point)))
5990 (eol (point-at-eol))
5991 (eoh (re-search-forward ": *" eol t
)))
5993 (if (and eoh
(or (< eoh here
) (= bol here
)))
5995 (beginning-of-line n
)))
5997 (defun message-buffer-name (type &optional to group
)
5998 "Return a new (unique) buffer name based on TYPE and TO."
6000 ;; Generate a new buffer name The Message Way.
6001 ((memq message-generate-new-buffers
'(unique t
))
6002 (generate-new-buffer-name
6006 (or (car (mail-extract-address-components to
))
6009 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6011 ;; Check whether `message-generate-new-buffers' is a function,
6012 ;; and if so, call it.
6013 ((functionp message-generate-new-buffers
)
6014 (funcall message-generate-new-buffers type to group
))
6015 ((eq message-generate-new-buffers
'unsent
)
6016 (generate-new-buffer-name
6017 (concat "*unsent " type
6020 (or (car (mail-extract-address-components to
))
6023 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6025 ;; Search for the existing message buffer with the specified name.
6027 (let* ((new (if (eq message-generate-new-buffers
'standard
)
6028 (generate-new-buffer-name (concat "*" type
" message*"))
6029 (let ((message-generate-new-buffers 'unique
))
6030 (message-buffer-name type to group
))))
6031 (regexp (concat "\\`"
6033 (if (string-match "<[0-9]+>\\'" new
)
6034 (substring new
0 (match-beginning 0))
6036 "\\(?:<\\([0-9]+\\)>\\)?\\'"))
6037 (case-fold-search nil
))
6044 (when (and (string-match regexp
(setq b
(buffer-name b
)))
6045 (eq (with-current-buffer b major-mode
)
6047 (cons (string-to-number (or (match-string 1 b
) "1"))
6050 'car-less-than-car
)))
6053 (defun message-pop-to-buffer (name &optional switch-function
)
6054 "Pop to buffer NAME, and warn if it already exists and is modified."
6055 (let ((buffer (get-buffer name
)))
6057 (buffer-name buffer
))
6058 (let ((window (get-buffer-window buffer
0)))
6060 ;; Raise the frame already displaying the message buffer.
6062 (gnus-select-frame-set-input-focus (window-frame window
))
6063 (select-window window
))
6064 (funcall (or switch-function
'pop-to-buffer
) buffer
)
6065 (set-buffer buffer
))
6066 (when (and (buffer-modified-p)
6069 "Message already being composed; erase? ")
6071 (error "Message being composed")))
6072 (funcall (or switch-function
'pop-to-buffer
) name
)
6077 (defun message-do-send-housekeeping ()
6078 "Kill old message buffers."
6079 ;; We might have sent this buffer already. Delete it from the
6081 (setq message-buffer-list
(delq (current-buffer) message-buffer-list
))
6082 (while (and message-max-buffers
6084 (>= (length message-buffer-list
) message-max-buffers
))
6085 ;; Kill the oldest buffer -- unless it has been changed.
6086 (let ((buffer (pop message-buffer-list
)))
6087 (when (and (buffer-name buffer
)
6088 (not (buffer-modified-p buffer
)))
6089 (kill-buffer buffer
))))
6090 ;; Rename the buffer.
6091 (if message-send-rename-function
6092 (funcall message-send-rename-function
)
6093 ;; Note: mail-abbrevs of XEmacs renames buffer name behind Gnus.
6095 "\\`\\*\\(sent \\|unsent \\)?\\(.+\\)\\*[^\\*]*\\|\\`mail to "
6097 (let ((name (match-string 2 (buffer-name)))
6099 (if (not (or (null name
)
6100 (string-equal name
"mail")
6101 (string-equal name
"posting")))
6102 (setq name
(concat "*sent " name
"*"))
6103 (message-narrow-to-headers)
6104 (setq to
(message-fetch-field "to"))
6105 (setq group
(message-fetch-field "newsgroups"))
6109 (to (concat "*sent mail to "
6110 (or (car (mail-extract-address-components to
))
6112 ((and group
(not (string= group
"")))
6113 (concat "*sent posting on " group
"*"))
6114 (t "*sent mail*"))))
6115 (unless (string-equal name
(buffer-name))
6116 (rename-buffer name t
)))))
6117 ;; Push the current buffer onto the list.
6118 (when message-max-buffers
6119 (setq message-buffer-list
6120 (nconc message-buffer-list
(list (current-buffer))))))
6122 (defun message-mail-user-agent ()
6124 ((not message-mail-user-agent
) nil
)
6125 ((eq message-mail-user-agent t
) mail-user-agent
)
6126 (t message-mail-user-agent
))))
6127 (if (memq mua
'(message-user-agent gnus-user-agent
))
6131 (defun message-setup (headers &optional replybuffer actions
6132 continue switch-function
)
6133 (let ((mua (message-mail-user-agent))
6134 subject to field yank-action
)
6135 (if (not (and message-this-is-mail mua
))
6136 (message-setup-1 headers replybuffer actions
)
6138 (setq yank-action
(list 'insert-buffer replybuffer
)))
6139 (setq headers
(copy-sequence headers
))
6140 (setq field
(assq 'Subject headers
))
6142 (setq subject
(cdr field
))
6143 (setq headers
(delq field headers
)))
6144 (setq field
(assq 'To headers
))
6146 (setq to
(cdr field
))
6147 (setq headers
(delq field headers
)))
6148 (let ((mail-user-agent mua
))
6149 (compose-mail to subject
6150 (mapcar (lambda (item)
6152 (format "%s" (car item
))
6155 continue switch-function yank-action actions
)))))
6157 (defun message-headers-to-generate (headers included-headers excluded-headers
)
6158 "Return a list that includes all headers from HEADERS.
6159 If INCLUDED-HEADERS is a list, just include those headers. If it is
6160 t, include all headers. In any case, headers from EXCLUDED-HEADERS
6164 (dolist (header headers
)
6165 (setq header-name
(cond
6166 ((and (consp header
)
6167 (eq (car header
) 'optional
))
6168 ;; On the form (optional . Header)
6171 ;; On the form (Header . function)
6176 (when (and (not (memq header-name excluded-headers
))
6177 (or (eq included-headers t
)
6178 (memq header-name included-headers
)))
6179 (push header result
)))
6182 (defun message-setup-1 (headers &optional replybuffer actions
)
6183 (dolist (action actions
)
6185 (add-to-list 'message-send-actions
6186 `(apply ',(car action
) ',(cdr action
)))))
6187 (setq message-reply-buffer replybuffer
)
6188 (goto-char (point-min))
6189 ;; Insert all the headers.
6192 (alist message-header-format-alist
))
6194 (unless (assq (caar h
) message-header-format-alist
)
6195 (push (list (caar h
)) alist
))
6199 (delete-region (point) (progn (forward-line -
1) (point)))
6200 (when message-default-headers
6201 (insert message-default-headers
)
6202 (or (bolp) (insert ?
\n)))
6203 (insert mail-header-separator
"\n")
6205 (when (message-news-p)
6206 (when message-default-news-headers
6207 (insert message-default-news-headers
)
6208 (or (bolp) (insert ?
\n)))
6209 (when message-generate-headers-first
6210 (message-generate-headers
6211 (message-headers-to-generate
6212 (append message-required-news-headers
6213 message-required-headers
)
6214 message-generate-headers-first
6215 '(Lines Subject
)))))
6216 (when (message-mail-p)
6217 (when message-default-mail-headers
6218 (insert message-default-mail-headers
)
6219 (or (bolp) (insert ?
\n)))
6220 (when message-generate-headers-first
6221 (message-generate-headers
6222 (message-headers-to-generate
6223 (append message-required-mail-headers
6224 message-required-headers
)
6225 message-generate-headers-first
6226 '(Lines Subject
)))))
6227 (run-hooks 'message-signature-setup-hook
)
6228 (message-insert-signature)
6230 (message-narrow-to-headers)
6231 (run-hooks 'message-header-setup-hook
))
6232 (setq buffer-undo-list nil
)
6233 (when message-generate-hashcash
6234 ;; Generate hashcash headers for recipients already known
6235 (mail-add-payment-async))
6236 ;; Gnus posting styles are applied via buffer-local `message-setup-hook'
6238 (run-hooks 'message-setup-hook
)
6239 ;; Do this last to give it precedence over posting styles, etc.
6240 (when (message-mail-p)
6242 (message-narrow-to-headers)
6243 (if message-alternative-emails
6244 (message-use-alternative-email-as-from))))
6245 (message-position-point)
6246 ;; Allow correct handling of `message-checksum' in `message-yank-original':
6247 (set-buffer-modified-p nil
)
6250 (defun message-set-auto-save-file-name ()
6251 "Associate the message buffer with a file in the drafts directory."
6252 (when message-auto-save-directory
6253 (unless (file-directory-p
6254 (directory-file-name message-auto-save-directory
))
6255 (make-directory message-auto-save-directory t
))
6257 (setq message-draft-article
6258 (nndraft-request-associate-buffer "drafts"))
6259 (setq buffer-file-name
(expand-file-name
6260 (if (memq system-type
6261 '(ms-dos ms-windows windows-nt
6262 cygwin cygwin32 win32 w32
6266 message-auto-save-directory
))
6267 (setq buffer-auto-save-file-name
(make-auto-save-file-name)))
6268 (clear-visited-file-modtime)
6269 (setq buffer-file-coding-system message-draft-coding-system
)))
6271 (defun message-disassociate-draft ()
6272 "Disassociate the message buffer from the drafts directory."
6273 (when message-draft-article
6274 (nndraft-request-expire-articles
6275 (list message-draft-article
) "nndraft:drafts" nil t
)))
6277 (defun message-insert-headers ()
6278 "Generate the headers for the article."
6282 (message-narrow-to-headers)
6283 (when (message-news-p)
6284 (message-generate-headers
6287 (copy-sequence message-required-news-headers
)))))
6288 (when (message-mail-p)
6289 (message-generate-headers
6292 (copy-sequence message-required-mail-headers
))))))))
6297 ;;; Commands for interfacing with message
6301 (defun message-mail (&optional to subject
6302 other-headers continue switch-function
6303 yank-action send-actions
)
6304 "Start editing a mail message to be sent.
6305 OTHER-HEADERS is an alist of header/value pairs. CONTINUE says whether
6306 to continue editing a message already being composed. SWITCH-FUNCTION
6307 is a function used to switch to and display the mail buffer."
6309 (let ((message-this-is-mail t
) replybuffer
)
6310 (unless (message-mail-user-agent)
6311 (message-pop-to-buffer
6312 ;; Search for the existing message buffer if `continue' is non-nil.
6313 (let ((message-generate-new-buffers
6314 (when (or (not continue
)
6315 (eq message-generate-new-buffers
'standard
)
6316 (functionp message-generate-new-buffers
))
6317 message-generate-new-buffers
)))
6318 (message-buffer-name "mail" to
))
6320 ;; FIXME: message-mail should do something if YANK-ACTION is not
6322 (and (consp yank-action
) (eq (car yank-action
) 'insert-buffer
)
6323 (setq replybuffer
(nth 1 yank-action
)))
6326 `((To .
,(or to
"")) (Subject .
,(or subject
"")))
6327 (when other-headers other-headers
))
6328 replybuffer send-actions continue switch-function
)
6329 ;; FIXME: Should return nil if failure.
6333 (defun message-news (&optional newsgroups subject
)
6334 "Start editing a news article to be sent."
6336 (let ((message-this-is-news t
))
6337 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
))
6338 (message-setup `((Newsgroups .
,(or newsgroups
""))
6339 (Subject .
,(or subject
""))))))
6341 (defun message-alter-recipients-discard-bogus-full-name (addrcell)
6342 "Discard mail address in full names.
6343 When the full name in reply headers contains the mail
6344 address (e.g. \"foo@bar <foo@bar>\"), discard full name.
6345 ADDRCELL is a cons cell where the car is the mail address and the
6346 cdr is the complete address (full name and mail address)."
6347 (if (string-match (concat (regexp-quote (car addrcell
)) ".*"
6348 (regexp-quote (car addrcell
)))
6350 (cons (car addrcell
) (car addrcell
))
6353 (defcustom message-alter-recipients-function nil
6354 "Function called to allow alteration of reply header structures.
6355 It is called in `message-get-reply-headers' for each recipient.
6356 The function is called with one parameter, a cons cell ..."
6357 :type
'(choice (const :tag
"None" nil
)
6358 (const :tag
"Discard bogus full name"
6359 message-alter-recipients-discard-bogus-full-name
)
6361 :version
"23.1" ;; No Gnus
6362 :group
'message-headers
)
6364 (defun message-get-reply-headers (wide &optional to-address address-headers
)
6365 (let (follow-to mct never-mct to cc author mft recipients extra
)
6366 ;; Find all relevant headers we need.
6368 (message-narrow-to-headers-or-head)
6369 ;; Gmane renames "To". Look at "Original-To", too, if it is present in
6370 ;; message-header-synonyms.
6371 (setq to
(or (message-fetch-field "to")
6372 (and (loop for synonym in message-header-synonyms
6373 when
(memq 'Original-To synonym
)
6375 (message-fetch-field "original-to")))
6376 cc
(message-fetch-field "cc")
6377 extra
(when message-extra-wide-headers
6378 (mapconcat 'identity
6379 (mapcar 'message-fetch-field
6380 message-extra-wide-headers
)
6382 mct
(message-fetch-field "mail-copies-to")
6383 author
(or (message-fetch-field "mail-reply-to")
6384 (message-fetch-field "reply-to")
6385 (message-fetch-field "from")
6387 mft
(and message-use-mail-followup-to
6388 (message-fetch-field "mail-followup-to"))))
6390 ;; Handle special values of Mail-Copies-To.
6392 (cond ((or (equal (downcase mct
) "never")
6393 (equal (downcase mct
) "nobody"))
6396 ((or (equal (downcase mct
) "always")
6397 (equal (downcase mct
) "poster"))
6398 (setq mct author
))))
6401 ;; Build (textual) list of new recipient addresses.
6404 (setq recipients
(concat ", " author
)))
6406 (dolist (header address-headers
)
6407 (let ((value (message-fetch-field header
)))
6409 (setq recipients
(concat recipients
", " value
))))))
6411 (string-match "[^ \t,]" mft
)
6412 (or (not (eq message-use-mail-followup-to
'ask
))
6413 (message-y-or-n-p "Obey Mail-Followup-To? " t
"\
6414 You should normally obey the Mail-Followup-To: header. In this
6415 article, it has the value of
6419 which directs your response to " (if (string-match "," mft
)
6420 "the specified addresses"
6421 "that address only") ".
6423 Most commonly, Mail-Followup-To is used by a mailing list poster to
6424 express that responses should be sent to just the list, and not the
6427 If a message is posted to several mailing lists, Mail-Followup-To may
6428 also be used to direct the following discussion to one list only,
6429 because discussions that are spread over several lists tend to be
6430 fragmented and very difficult to follow.
6432 Also, some source/announcement lists are not intended for discussion;
6433 responses here are directed to other addresses.
6435 You may customize the variable `message-use-mail-followup-to', if you
6436 want to get rid of this query permanently.")))
6437 (setq recipients
(concat ", " mft
)))
6439 (setq recipients
(concat ", " to-address
))
6440 ;; If the author explicitly asked for a copy, we don't deny it to them.
6441 (if mct
(setq recipients
(concat recipients
", " mct
))))
6443 (setq recipients
(if never-mct
"" (concat ", " author
)))
6444 (if to
(setq recipients
(concat recipients
", " to
)))
6445 (if cc
(setq recipients
(concat recipients
", " cc
)))
6446 (if extra
(setq recipients
(concat recipients
", " extra
)))
6447 (if mct
(setq recipients
(concat recipients
", " mct
)))))
6448 (if (>= (length recipients
) 2)
6449 ;; Strip the leading ", ".
6450 (setq recipients
(substring recipients
2)))
6451 ;; Squeeze whitespace.
6452 (while (string-match "[ \t][ \t]+" recipients
)
6453 (setq recipients
(replace-match " " t t recipients
)))
6454 ;; Remove addresses that match `rmail-dont-reply-to-names'.
6455 (let ((rmail-dont-reply-to-names (message-dont-reply-to-names)))
6456 (setq recipients
(rmail-dont-reply-to recipients
)))
6457 ;; Perhaps "Mail-Copies-To: never" removed the only address?
6458 (if (string-equal recipients
"")
6459 (setq recipients author
))
6460 ;; Convert string to a list of (("foo@bar" . "Name <Foo@BAR>") ...).
6464 (if message-alter-recipients-function
6465 (funcall message-alter-recipients-function
6466 (cons (downcase (mail-strip-quoted-names addr
))
6468 (cons (downcase (mail-strip-quoted-names addr
)) addr
)))
6469 (message-tokenize-header recipients
)))
6470 ;; Remove first duplicates. (Why not all duplicates? Is this a bug?)
6471 (let ((s recipients
))
6473 (setq recipients
(delq (assoc (car (pop s
)) s
) recipients
))))
6475 ;; Remove hierarchical lists that are contained within each other,
6476 ;; if message-hierarchical-addresses is defined.
6477 (when message-hierarchical-addresses
6478 (let ((plain-addrs (mapcar 'car recipients
))
6481 (setq subaddrs
(assoc (car plain-addrs
)
6482 message-hierarchical-addresses
)
6483 plain-addrs
(cdr plain-addrs
))
6485 (setq subaddrs
(cdr subaddrs
))
6487 (setq recip
(assoc (car subaddrs
) recipients
)
6488 subaddrs
(cdr subaddrs
))
6490 (setq recipients
(delq recip recipients
))))))))
6492 ;; Build the header alist. Allow the user to be asked whether
6493 ;; or not to reply to all recipients in a wide reply.
6494 (setq follow-to
(list (cons 'To
(cdr (pop recipients
)))))
6495 (when (and recipients
6496 (or (not message-wide-reply-confirm-recipients
)
6497 (y-or-n-p "Reply to all recipients? ")))
6498 (setq recipients
(mapconcat
6499 (lambda (addr) (cdr addr
)) recipients
", "))
6500 (if (string-match "^ +" recipients
)
6501 (setq recipients
(substring recipients
(match-end 0))))
6502 (push (cons 'Cc recipients
) follow-to
)))
6505 (defcustom message-simplify-subject-functions
6506 '(message-strip-list-identifiers
6507 message-strip-subject-re
6508 message-strip-subject-trailing-was
6509 message-strip-subject-encoded-words
)
6510 "List of functions taking a string argument that simplify subjects.
6511 The functions are applied when replying to a message.
6513 Useful functions to put in this list include:
6514 `message-strip-list-identifiers', `message-strip-subject-re',
6515 `message-strip-subject-trailing-was', and
6516 `message-strip-subject-encoded-words'."
6517 :version
"22.1" ;; Gnus 5.10.9
6518 :group
'message-various
6519 :type
'(repeat function
))
6521 (defun message-simplify-subject (subject &optional functions
)
6522 "Return simplified SUBJECT."
6525 (setq functions message-simplify-subject-functions
))
6526 (when (and (memq 'message-strip-list-identifiers functions
)
6527 gnus-list-identifiers
)
6528 (setq subject
(message-strip-list-identifiers subject
)))
6529 (when (memq 'message-strip-subject-re functions
)
6530 (setq subject
(concat "Re: " (message-strip-subject-re subject
))))
6531 (when (and (memq 'message-strip-subject-trailing-was functions
)
6532 message-subject-trailing-was-query
)
6533 (setq subject
(message-strip-subject-trailing-was subject
)))
6534 (when (memq 'message-strip-subject-encoded-words functions
)
6535 (setq subject
(message-strip-subject-encoded-words subject
)))
6539 (defun message-reply (&optional to-address wide
)
6540 "Start editing a reply to the article in the current buffer."
6542 (require 'gnus-sum
) ; for gnus-list-identifiers
6543 (let ((cur (current-buffer))
6544 from subject date reply-to to cc
6545 references message-id follow-to
6546 (inhibit-point-motion-hooks t
)
6547 (message-this-is-mail t
)
6550 (message-narrow-to-head-1)
6551 ;; Allow customizations to have their say.
6553 ;; This is a regular reply.
6554 (when (functionp message-reply-to-function
)
6556 (setq follow-to
(funcall message-reply-to-function
))))
6557 ;; This is a followup.
6558 (when (functionp message-wide-reply-to-function
)
6561 (funcall message-wide-reply-to-function
)))))
6562 (setq message-id
(message-fetch-field "message-id" t
)
6563 references
(message-fetch-field "references")
6564 date
(message-fetch-field "date")
6565 from
(or (message-fetch-field "from") "nobody")
6566 subject
(or (message-fetch-field "subject") "none"))
6568 ;; Strip list identifiers, "Re: ", and "was:"
6569 (setq subject
(message-simplify-subject subject
))
6571 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6572 (string-match "<[^>]+>" gnus-warning
))
6573 (setq message-id
(match-string 0 gnus-warning
)))
6576 (setq follow-to
(message-get-reply-headers wide to-address
))))
6578 (unless (message-mail-user-agent)
6579 (message-pop-to-buffer
6580 (message-buffer-name
6581 (if wide
"wide reply" "reply") from
6582 (if wide to-address nil
))))
6584 (setq message-reply-headers
6585 (vector 0 subject from date message-id references
0 0 ""))
6588 `((Subject .
,subject
)
6593 (defun message-wide-reply (&optional to-address
)
6594 "Make a \"wide\" reply to the message in the current buffer."
6596 (message-reply to-address t
))
6599 (defun message-followup (&optional to-newsgroups
)
6600 "Follow up to the message in the current buffer.
6601 If TO-NEWSGROUPS, use that as the new Newsgroups line."
6603 (require 'gnus-sum
) ; for gnus-list-identifiers
6604 (let ((cur (current-buffer))
6605 from subject date reply-to mrt mct
6606 references message-id follow-to
6607 (inhibit-point-motion-hooks t
)
6608 (message-this-is-news t
)
6609 followup-to distribution newsgroups gnus-warning posted-to
)
6612 (goto-char (point-min))
6613 (if (search-forward "\n\n" nil t
)
6616 (when (functionp message-followup-to-function
)
6618 (funcall message-followup-to-function
)))
6619 (setq from
(message-fetch-field "from")
6620 date
(message-fetch-field "date")
6621 subject
(or (message-fetch-field "subject") "none")
6622 references
(message-fetch-field "references")
6623 message-id
(message-fetch-field "message-id" t
)
6624 followup-to
(message-fetch-field "followup-to")
6625 newsgroups
(message-fetch-field "newsgroups")
6626 posted-to
(message-fetch-field "posted-to")
6627 reply-to
(message-fetch-field "reply-to")
6628 mrt
(message-fetch-field "mail-reply-to")
6629 distribution
(message-fetch-field "distribution")
6630 mct
(message-fetch-field "mail-copies-to"))
6631 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6632 (string-match "<[^>]+>" gnus-warning
))
6633 (setq message-id
(match-string 0 gnus-warning
)))
6634 ;; Remove bogus distribution.
6635 (when (and (stringp distribution
)
6636 (let ((case-fold-search t
))
6637 (string-match "world" distribution
)))
6638 (setq distribution nil
))
6639 ;; Strip list identifiers, "Re: ", and "was:"
6640 (setq subject
(message-simplify-subject subject
))
6643 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups
))
6645 (setq message-reply-headers
6646 (vector 0 subject from date message-id references
0 0 ""))
6649 `((Subject .
,subject
)
6652 (list (cons 'Newsgroups to-newsgroups
)))
6653 (follow-to follow-to
)
6654 ((and followup-to message-use-followup-to
)
6657 ((equal (downcase followup-to
) "poster")
6658 (if (or (eq message-use-followup-to
'use
)
6659 (message-y-or-n-p "Obey Followup-To: poster? " t
"\
6660 You should normally obey the Followup-To: header.
6662 `Followup-To: poster' sends your response via e-mail instead of news.
6664 A typical situation where `Followup-To: poster' is used is when the poster
6665 does not read the newsgroup, so he wouldn't see any replies sent to it.
6667 You may customize the variable `message-use-followup-to', if you
6668 want to get rid of this query permanently."))
6670 (setq message-this-is-news nil
)
6671 (cons 'To
(or mrt reply-to from
"")))
6672 (cons 'Newsgroups newsgroups
)))
6674 (if (or (equal followup-to newsgroups
)
6675 (not (eq message-use-followup-to
'ask
))
6677 (concat "Obey Followup-To: " followup-to
"? ") t
"\
6678 You should normally obey the Followup-To: header.
6680 `Followup-To: " followup-to
"'
6681 directs your response to " (if (string-match "," followup-to
)
6682 "the specified newsgroups"
6683 "that newsgroup only") ".
6685 If a message is posted to several newsgroups, Followup-To is often
6686 used to direct the following discussion to one newsgroup only,
6687 because discussions that are spread over several newsgroup tend to
6688 be fragmented and very difficult to follow.
6690 Also, some source/announcement newsgroups are not intended for discussion;
6691 responses here are directed to other newsgroups.
6693 You may customize the variable `message-use-followup-to', if you
6694 want to get rid of this query permanently."))
6695 (cons 'Newsgroups followup-to
)
6696 (cons 'Newsgroups newsgroups
))))))
6698 `((Newsgroups .
,posted-to
)))
6700 `((Newsgroups .
,newsgroups
))))
6701 ,@(and distribution
(list (cons 'Distribution distribution
)))
6703 (not (or (equal (downcase mct
) "never")
6704 (equal (downcase mct
) "nobody"))))
6705 (list (cons 'Cc
(if (or (equal (downcase mct
) "always")
6706 (equal (downcase mct
) "poster"))
6707 (or mrt reply-to from
"")
6712 (defun message-is-yours-p ()
6713 "Non-nil means current article is yours.
6714 If you have added 'cancel-messages to `message-shoot-gnksa-feet', all articles
6715 are yours except those that have Cancel-Lock header not belonging to you.
6716 Instead of shooting GNKSA feet, you should modify `message-alternative-emails'
6717 regexp to match all of yours addresses."
6718 ;; Canlock-logic as suggested by Per Abrahamsen
6719 ;; <abraham@dina.kvl.dk>
6721 ;; IF article has cancel-lock THEN
6722 ;; IF we can verify it THEN
6725 ;; error: cancellock: article is not yours
6727 ;; Use old rules, comparing sender...
6730 (message-narrow-to-head-1)
6731 (if (message-fetch-field "Cancel-Lock")
6732 (if (null (canlock-verify))
6734 (error "Failed to verify Cancel-lock: This article is not yours"))
6737 (message-gnksa-enable-p 'cancel-messages
)
6738 (and (setq sender
(message-fetch-field "sender"))
6739 (string-equal (downcase sender
)
6740 (downcase (message-make-sender))))
6741 ;; Email address in From field equals to our address
6742 (and (setq from
(message-fetch-field "from"))
6744 (downcase (car (mail-header-parse-address from
)))
6745 (downcase (car (mail-header-parse-address
6746 (message-make-from))))))
6747 ;; Email address in From field matches
6748 ;; 'message-alternative-emails' regexp
6750 message-alternative-emails
6752 message-alternative-emails
6753 (car (mail-header-parse-address from
))))))))))
6756 (defun message-cancel-news (&optional arg
)
6757 "Cancel an article you posted.
6758 If ARG, allow editing of the cancellation message."
6760 (unless (message-news-p)
6761 (error "This is not a news article; canceling is impossible"))
6762 (let (from newsgroups message-id distribution buf
)
6764 ;; Get header info from original article.
6766 (message-narrow-to-head-1)
6767 (setq from
(message-fetch-field "from")
6768 newsgroups
(message-fetch-field "newsgroups")
6769 message-id
(message-fetch-field "message-id" t
)
6770 distribution
(message-fetch-field "distribution")))
6771 ;; Make sure that this article was written by the user.
6772 (unless (message-is-yours-p)
6773 (error "This article is not yours"))
6774 (when (yes-or-no-p "Do you really want to cancel this article? ")
6775 ;; Make control message.
6778 (setq buf
(set-buffer (get-buffer-create " *message cancel*"))))
6780 (insert "Newsgroups: " newsgroups
"\n"
6782 "Subject: cmsg cancel " message-id
"\n"
6783 "Control: cancel " message-id
"\n"
6785 (concat "Distribution: " distribution
"\n")
6787 mail-header-separator
"\n"
6788 message-cancel-message
)
6789 (run-hooks 'message-cancel-hook
)
6791 (message "Canceling your article...")
6792 (if (let ((message-syntax-checks
6793 'dont-check-for-anything-just-trust-me
))
6794 (funcall message-send-news-function
))
6795 (message "Canceling your article...done"))
6796 (kill-buffer buf
))))))
6799 (defun message-supersede ()
6800 "Start composing a message to supersede the current message.
6801 This is done simply by taking the old article and adding a Supersedes
6802 header line with the old Message-ID."
6804 (let ((cur (current-buffer)))
6805 ;; Check whether the user owns the article that is to be superseded.
6806 (unless (message-is-yours-p)
6807 (error "This article is not yours"))
6808 ;; Get a normal message buffer.
6809 (message-pop-to-buffer (message-buffer-name "supersede"))
6810 (insert-buffer-substring cur
)
6812 (message-narrow-to-head-1)
6813 ;; Remove unwanted headers.
6814 (when message-ignored-supersedes-headers
6815 (message-remove-header message-ignored-supersedes-headers t
))
6816 (goto-char (point-min))
6817 (if (not (re-search-forward "^Message-ID: " nil t
))
6818 (error "No Message-ID in this article")
6819 (replace-match "Supersedes: " t t
))
6820 (goto-char (point-max))
6821 (insert mail-header-separator
)
6826 (defun message-recover ()
6827 "Reread contents of current buffer from its last auto-save file."
6829 (let ((file-name (make-auto-save-file-name)))
6830 (cond ((save-window-excursion
6831 (if (not (eq system-type
'vax-vms
))
6832 (with-output-to-temp-buffer "*Directory*"
6833 (with-current-buffer standard-output
6834 (fundamental-mode)) ; for Emacs 20.4+
6835 (buffer-disable-undo standard-output
)
6836 (let ((default-directory "/"))
6838 "ls" nil standard-output nil
"-l" file-name
))))
6839 (yes-or-no-p (format "Recover auto save file %s? " file-name
)))
6840 (let ((buffer-read-only nil
))
6842 (insert-file-contents file-name nil
)))
6843 (t (error "message-recover cancelled")))))
6845 ;;; Washing Subject:
6847 (defun message-wash-subject (subject)
6848 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT.
6849 Previous forwarders, replyers, etc. may add it."
6852 (goto-char (point-min))
6853 ;; strip Re/Fwd stuff off the beginning
6854 (while (re-search-forward
6855 "\\([Rr][Ee]:\\|[Ff][Ww][Dd]\\(\\[[0-9]*\\]\\)?:\\|[Ff][Ww]:\\)" nil t
)
6858 ;; and gnus-style forwards [foo@bar.com] subject
6859 (goto-char (point-min))
6860 (while (re-search-forward "\\[[^ \t]*\\(@\\|\\.\\)[^ \t]*\\]" nil t
)
6864 (goto-char (point-max))
6865 (while (re-search-backward "([Ff][Ww][Dd])" nil t
)
6868 ;; and finally, any whitespace that was left-over
6869 (goto-char (point-min))
6870 (while (re-search-forward "^[ \t]+" nil t
)
6872 (goto-char (point-max))
6873 (while (re-search-backward "[ \t]+$" nil t
)
6878 ;;; Forwarding messages.
6880 (defvar message-forward-decoded-p nil
6881 "Non-nil means the original message is decoded.")
6883 (defun message-forward-subject-name-subject (subject)
6884 "Generate a SUBJECT for a forwarded message.
6885 The form is: [Source] Subject, where if the original message was mail,
6886 Source is the name of the sender, and if the original message was
6887 news, Source is the list of newsgroups is was posted to."
6888 (let* ((group (message-fetch-field "newsgroups"))
6889 (from (message-fetch-field "from"))
6892 (gnus-group-decoded-name group
)
6894 (car (gnus-extract-address-components from
))
6895 (cadr (gnus-extract-address-components from
))))
6898 (if message-forward-decoded-p
6900 (mail-decode-encoded-word-string prefix
))
6903 (defun message-forward-subject-author-subject (subject)
6904 "Generate a SUBJECT for a forwarded message.
6905 The form is: [Source] Subject, where if the original message was mail,
6906 Source is the sender, and if the original message was news, Source is
6907 the list of newsgroups is was posted to."
6908 (let* ((group (message-fetch-field "newsgroups"))
6911 (gnus-group-decoded-name group
)
6912 (or (message-fetch-field "from")
6915 (if message-forward-decoded-p
6917 (mail-decode-encoded-word-string prefix
))
6920 (defun message-forward-subject-fwd (subject)
6921 "Generate a SUBJECT for a forwarded message.
6922 The form is: Fwd: Subject, where Subject is the original subject of
6924 (if (string-match "^Fwd: " subject
)
6926 (concat "Fwd: " subject
)))
6928 (defun message-make-forward-subject ()
6929 "Return a Subject header suitable for the message in the current buffer."
6932 (message-narrow-to-head-1)
6933 (let ((funcs message-make-forward-subject-function
)
6934 (subject (message-fetch-field "Subject")))
6937 (if message-forward-decoded-p
6939 (mail-decode-encoded-word-string subject
))
6941 (when message-wash-forwarded-subjects
6942 (setq subject
(message-wash-subject subject
)))
6943 ;; Make sure funcs is a list.
6946 (setq funcs
(list funcs
)))
6947 ;; Apply funcs in order, passing subject generated by previous
6948 ;; func to the next one.
6949 (dolist (func funcs
)
6950 (when (functionp func
)
6951 (setq subject
(funcall func subject
))))
6954 (defvar gnus-article-decoded-p
)
6958 (defun message-forward (&optional news digest
)
6959 "Forward the current message via mail.
6960 Optional NEWS will use news to forward instead of mail.
6961 Optional DIGEST will use digest to forward."
6963 (let* ((cur (current-buffer))
6964 (message-forward-decoded-p
6965 (if (local-variable-p 'gnus-article-decoded-p
(current-buffer))
6966 gnus-article-decoded-p
;; In an article buffer.
6967 message-forward-decoded-p
))
6968 (subject (message-make-forward-subject)))
6970 (message-news nil subject
)
6971 (message-mail nil subject
))
6972 (message-forward-make-body cur digest
)))
6974 (defun message-forward-make-body-plain (forward-buffer)
6976 "\n-------------------- Start of forwarded message --------------------\n")
6977 (let ((b (point)) e
)
6980 (mm-disable-multibyte)
6982 (with-current-buffer forward-buffer
6983 (mm-with-unibyte-current-buffer (buffer-string))))
6984 (mm-enable-multibyte)
6986 (goto-char (point-min))
6987 (when (looking-at "From ")
6988 (replace-match "X-From-Line: "))
6992 "\n-------------------- End of forwarded message --------------------\n")
6993 (message-remove-ignored-headers b e
)))
6995 (defun message-remove-ignored-headers (b e
)
6996 (when message-forward-ignored-headers
6998 (narrow-to-region b e
)
7000 (narrow-to-region (point)
7001 (or (search-forward "\n\n" nil t
) (point)))
7002 (let ((ignored (if (stringp message-forward-ignored-headers
)
7003 (list message-forward-ignored-headers
)
7004 message-forward-ignored-headers
)))
7005 (dolist (elem ignored
)
7006 (message-remove-header elem t
))))))
7008 (defun message-forward-make-body-mime (forward-buffer)
7010 (insert "\n\n<#part type=message/rfc822 disposition=inline raw=t>\n")
7012 (narrow-to-region (point) (point))
7013 (mml-insert-buffer forward-buffer
)
7014 (goto-char (point-min))
7015 (when (looking-at "From ")
7016 (replace-match "X-From-Line: "))
7017 (goto-char (point-max)))
7018 (insert "<#/part>\n")
7019 ;; Consider there is no illegible text.
7020 (add-text-properties
7022 `(no-illegible-text t rear-nonsticky t start-open t
))))
7024 (defun message-forward-make-body-mml (forward-buffer)
7025 (insert "\n\n<#mml type=message/rfc822 disposition=inline>\n")
7026 (let ((b (point)) e
)
7027 (if (not message-forward-decoded-p
)
7030 (mm-disable-multibyte)
7032 (with-current-buffer forward-buffer
7033 (mm-with-unibyte-current-buffer (buffer-string))))
7034 (mm-enable-multibyte)
7036 (goto-char (point-min))
7037 (when (looking-at "From ")
7038 (replace-match "X-From-Line: "))
7041 (narrow-to-region (point) (point))
7042 (mml-insert-buffer forward-buffer
)
7043 (goto-char (point-min))
7044 (when (looking-at "From ")
7045 (replace-match "X-From-Line: "))
7046 (goto-char (point-max))))
7048 (insert "<#/mml>\n")
7049 (when (and (not message-forward-decoded-p
)
7050 message-forward-ignored-headers
)
7051 (message-remove-ignored-headers b e
))))
7053 (defun message-forward-make-body-digest-plain (forward-buffer)
7055 "\n-------------------- Start of forwarded message --------------------\n")
7056 (let ((b (point)) e
)
7057 (mml-insert-buffer forward-buffer
)
7060 "\n-------------------- End of forwarded message --------------------\n")))
7062 (defun message-forward-make-body-digest-mime (forward-buffer)
7063 (insert "\n<#multipart type=digest>\n")
7064 (let ((b (point)) e
)
7065 (insert-buffer-substring forward-buffer
)
7067 (insert "<#/multipart>\n")
7069 (narrow-to-region b e
)
7071 (narrow-to-region (point)
7072 (or (search-forward "\n\n" nil t
) (point)))
7073 (delete-region (point-min) (point-max)))))
7075 (defun message-forward-make-body-digest (forward-buffer)
7076 (if message-forward-as-mime
7077 (message-forward-make-body-digest-mime forward-buffer
)
7078 (message-forward-make-body-digest-plain forward-buffer
)))
7081 (autoload 'mm-uu-dissect-text-parts
"mm-uu")
7082 (autoload 'mm-uu-dissect
"mm-uu"))
7084 (defun message-signed-or-encrypted-p (&optional dont-emulate-mime handles
)
7085 "Say whether the current buffer contains signed or encrypted message.
7086 If DONT-EMULATE-MIME is nil, this function does the MIME emulation on
7087 messages that don't conform to PGP/MIME described in RFC2015. HANDLES
7088 is for the internal use."
7090 (let ((mm-decrypt-option 'never
)
7091 (mm-verify-option 'never
))
7092 (if (setq handles
(mm-dissect-buffer nil t
))
7093 (unless dont-emulate-mime
7094 (mm-uu-dissect-text-parts handles
))
7095 (unless dont-emulate-mime
7096 (setq handles
(mm-uu-dissect))))))
7097 ;; Check text/plain message in which there is a signed or encrypted
7098 ;; body that has been encoded by B or Q.
7099 (unless (or handles dont-emulate-mime
)
7100 (let ((cur (current-buffer))
7101 (mm-decrypt-option 'never
)
7102 (mm-verify-option 'never
))
7104 (insert-buffer-substring cur
)
7105 (when (setq handles
(mm-dissect-buffer t t
))
7107 (bufferp (car handles
))
7108 (mm-destroy-parts handles
))
7109 (equal (mm-handle-media-type handles
) "text/plain"))
7111 (mm-decode-content-transfer-encoding
7112 (mm-handle-encoding handles
))
7113 (setq handles
(mm-uu-dissect)))
7114 (setq handles nil
))))))
7118 (dolist (handle (if (stringp (car handles
))
7119 (if (member (car handles
)
7120 '("multipart/signed"
7121 "multipart/encrypted"))
7125 (if (stringp (car handle
))
7126 (when (message-signed-or-encrypted-p dont-emulate-mime handle
)
7128 (when (and (bufferp (car handle
))
7129 (equal (mm-handle-media-type handle
)
7131 (with-current-buffer (mm-handle-buffer handle
)
7132 (when (message-signed-or-encrypted-p dont-emulate-mime
)
7133 (throw 'found t
)))))))
7134 (mm-destroy-parts handles
))))
7137 (defun message-forward-make-body (forward-buffer &optional digest
)
7138 ;; Put point where we want it before inserting the forwarded
7140 (if message-forward-before-signature
7142 (goto-char (point-max)))
7144 (message-forward-make-body-digest forward-buffer
)
7145 (if message-forward-as-mime
7146 (if (and message-forward-show-mml
7147 (not (and (eq message-forward-show-mml
'best
)
7148 ;; Use the raw form in the body if it contains
7149 ;; signed or encrypted message so as not to be
7150 ;; destroyed by re-encoding.
7151 (with-current-buffer forward-buffer
7153 (message-signed-or-encrypted-p)
7155 (message-forward-make-body-mml forward-buffer
)
7156 (message-forward-make-body-mime forward-buffer
))
7157 (message-forward-make-body-plain forward-buffer
)))
7158 (message-position-point))
7161 (defun message-forward-rmail-make-body (forward-buffer)
7162 (save-window-excursion
7163 (set-buffer forward-buffer
)
7164 (if (rmail-msg-is-pruned)
7165 (rmail-msg-restore-non-pruned-header)))
7166 (message-forward-make-body forward-buffer
))
7168 ;; Fixme: Should have defcustom.
7170 (defun message-insinuate-rmail ()
7171 "Let RMAIL use message to forward."
7173 (setq rmail-enable-mime-composing t
)
7174 (setq rmail-insert-mime-forwarded-message-function
7175 'message-forward-rmail-make-body
))
7178 (defun message-resend (address)
7179 "Resend the current article to ADDRESS."
7181 (list (message-read-from-minibuffer "Resend message to: ")))
7182 (message "Resending message to %s..." address
)
7184 (let ((cur (current-buffer))
7186 ;; We first set up a normal mail buffer.
7187 (unless (message-mail-user-agent)
7188 (set-buffer (get-buffer-create " *message resend*"))
7190 (let ((message-this-is-mail t
)
7191 message-generate-hashcash
7193 (message-setup `((To .
,address
))))
7194 ;; Insert our usual headers.
7195 (message-generate-headers '(From Date To Message-ID
))
7196 (message-narrow-to-headers)
7197 ;; Remove X-Draft-From header etc.
7198 (message-remove-header message-ignored-mail-headers t
)
7199 ;; Rename them all to "Resent-*".
7200 (goto-char (point-min))
7201 (while (re-search-forward "^[A-Za-z]" nil t
)
7206 (delete-region (point) (point-max))
7208 ;; Insert the message to be resent.
7209 (insert-buffer-substring cur
)
7210 (goto-char (point-min))
7211 (search-forward "\n\n")
7214 (narrow-to-region beg
(point))
7215 (message-remove-header message-ignored-resent-headers t
)
7216 (goto-char (point-max)))
7217 (insert mail-header-separator
)
7218 ;; Rename all old ("Also-")Resent headers.
7219 (while (re-search-backward "^\\(Also-\\)*Resent-" beg t
)
7222 ;; Quote any "From " lines at the beginning.
7224 (when (looking-at "From ")
7225 (replace-match "X-From-Line: "))
7227 (let ((message-inhibit-body-encoding t
)
7228 message-required-mail-headers
7229 message-generate-hashcash
7230 rfc2047-encode-encoded-words
)
7231 (message-send-mail))
7232 (kill-buffer (current-buffer)))
7233 (message "Resending message to %s...done" address
)))
7236 (defun message-bounce ()
7237 "Re-mail the current message.
7238 This only makes sense if the current message is a bounce message that
7239 contains some mail you have written which has been bounced back to
7242 (let ((handles (mm-dissect-buffer t
))
7244 (message-pop-to-buffer (message-buffer-name "bounce"))
7245 (if (stringp (car handles
))
7246 ;; This is a MIME bounce.
7247 (mm-insert-part (car (last handles
)))
7248 ;; This is a non-MIME bounce, so we try to remove things
7250 (mm-insert-part handles
)
7252 (goto-char (point-min))
7253 (re-search-forward "\n\n+" nil t
)
7254 (setq boundary
(point))
7255 ;; We remove everything before the bounced mail.
7256 (if (or (re-search-forward message-unsent-separator nil t
)
7258 (search-forward "\n\n" nil
'move
)
7259 (re-search-backward "^Return-Path:.*\n" boundary t
)))
7262 (delete-region (point-min)
7263 (if (re-search-forward "^[^ \n\t]+:" nil t
)
7266 (goto-char boundary
)
7267 (when (re-search-backward "^.?From .*\n" nil t
)
7268 (delete-region (match-beginning 0) (match-end 0)))))
7271 (message-narrow-to-head-1)
7272 (message-remove-header message-ignored-bounced-headers t
)
7273 (goto-char (point-max))
7274 (insert mail-header-separator
))
7275 (message-position-point)))
7278 ;;; Interactive entry points for new message buffers.
7282 (defun message-mail-other-window (&optional to subject
)
7283 "Like `message-mail' command, but display mail buffer in another window."
7285 (unless (message-mail-user-agent)
7286 (let ((pop-up-windows t
)
7287 (special-display-buffer-names nil
)
7288 (special-display-regexps nil
)
7289 (same-window-buffer-names nil
)
7290 (same-window-regexps nil
))
7291 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7292 (let ((message-this-is-mail t
))
7293 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7294 nil nil nil
'switch-to-buffer-other-window
)))
7297 (defun message-mail-other-frame (&optional to subject
)
7298 "Like `message-mail' command, but display mail buffer in another frame."
7300 (unless (message-mail-user-agent)
7301 (let ((pop-up-frames t
)
7302 (special-display-buffer-names nil
)
7303 (special-display-regexps nil
)
7304 (same-window-buffer-names nil
)
7305 (same-window-regexps nil
))
7306 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7307 (let ((message-this-is-mail t
))
7308 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7309 nil nil nil
'switch-to-buffer-other-frame
)))
7312 (defun message-news-other-window (&optional newsgroups subject
)
7313 "Start editing a news article to be sent."
7315 (let ((pop-up-windows t
)
7316 (special-display-buffer-names nil
)
7317 (special-display-regexps nil
)
7318 (same-window-buffer-names nil
)
7319 (same-window-regexps nil
))
7320 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7321 (let ((message-this-is-news t
))
7322 (message-setup `((Newsgroups .
,(or newsgroups
""))
7323 (Subject .
,(or subject
""))))))
7326 (defun message-news-other-frame (&optional newsgroups subject
)
7327 "Start editing a news article to be sent."
7329 (let ((pop-up-frames t
)
7330 (special-display-buffer-names nil
)
7331 (special-display-regexps nil
)
7332 (same-window-buffer-names nil
)
7333 (same-window-regexps nil
))
7334 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7335 (let ((message-this-is-news t
))
7336 (message-setup `((Newsgroups .
,(or newsgroups
""))
7337 (Subject .
,(or subject
""))))))
7341 ;; This code should be moved to underline.el (from which it is stolen).
7344 (defun message-bold-region (start end
)
7345 "Bold all nonblank characters in the region.
7346 Works by overstriking characters.
7347 Called from program, takes two arguments START and END
7348 which specify the range to operate on."
7351 (let ((end1 (make-marker)))
7352 (move-marker end1
(max start end
))
7353 (goto-char (min start end
))
7354 (while (< (point) end1
)
7355 (or (looking-at "[_\^@- ]")
7356 (insert (char-after) "\b"))
7357 (forward-char 1)))))
7360 (defun message-unbold-region (start end
)
7361 "Remove all boldness (overstruck characters) in the region.
7362 Called from program, takes two arguments START and END
7363 which specify the range to operate on."
7366 (let ((end1 (make-marker)))
7367 (move-marker end1
(max start end
))
7368 (goto-char (min start end
))
7369 (while (search-forward "\b" end1 t
)
7370 (if (eq (char-after) (char-after (- (point) 2)))
7371 (delete-char -
2))))))
7373 (defun message-exchange-point-and-mark ()
7374 "Exchange point and mark, but don't activate region if it was inactive."
7376 (message-mark-active-p)
7377 (exchange-point-and-mark))
7378 (setq mark-active nil
)))
7380 (defalias 'message-make-overlay
'make-overlay
)
7381 (defalias 'message-delete-overlay
'delete-overlay
)
7382 (defalias 'message-overlay-put
'overlay-put
)
7383 (defun message-kill-all-overlays ()
7384 (if (featurep 'xemacs
)
7385 (map-extents (lambda (extent ignore
) (delete-extent extent
)))
7386 (mapcar #'delete-overlay
(overlays-in (point-min) (point-max)))))
7388 ;; Support for toolbar
7389 (defvar tool-bar-mode
)
7391 ;; Note: The :set function in the `message-tool-bar*' variables will only
7392 ;; affect _new_ message buffers. We might add a function that walks thru all
7393 ;; message-mode buffers and force the update.
7394 (defun message-tool-bar-update (&optional symbol value
)
7395 "Update message mode toolbar.
7396 Setter function for custom variables."
7397 (setq-default message-tool-bar-map nil
)
7399 ;; When used as ":set" function:
7400 (set-default symbol value
)))
7402 (defcustom message-tool-bar
(if (eq gmm-tool-bar-style
'gnome
)
7403 'message-tool-bar-gnome
7404 'message-tool-bar-retro
)
7405 "Specifies the message mode tool bar.
7407 It can be either a list or a symbol refering to a list. See
7408 `gmm-tool-bar-from-list' for the format of the list. The
7409 default key map is `message-mode-map'.
7411 Pre-defined symbols include `message-tool-bar-gnome' and
7412 `message-tool-bar-retro'."
7413 :type
'(repeat gmm-tool-bar-list-item
)
7414 :type
'(choice (const :tag
"GNOME style" message-tool-bar-gnome
)
7415 (const :tag
"Retro look" message-tool-bar-retro
)
7416 (repeat :tag
"User defined list" gmm-tool-bar-item
)
7418 :version
"23.1" ;; No Gnus
7419 :initialize
'custom-initialize-default
7420 :set
'message-tool-bar-update
7423 (defcustom message-tool-bar-gnome
7424 '((ispell-message "spell" nil
7425 :visible
(or (not (boundp 'flyspell-mode
))
7426 (not flyspell-mode
)))
7427 (flyspell-buffer "spell" t
7428 :visible
(and (boundp 'flyspell-mode
)
7430 :help
"Flyspell whole buffer")
7431 (gmm-ignore "separator")
7432 (message-send-and-exit "mail/send")
7433 (message-dont-send "mail/save-draft")
7434 (message-kill-buffer "close") ;; stock_cancel
7435 (mml-attach-file "attach" mml-mode-map
)
7436 (mml-preview "mail/preview" mml-mode-map
)
7437 (mml-secure-message-sign-encrypt "lock" mml-mode-map
:visible nil
)
7438 (message-insert-importance-high "important" nil
:visible nil
)
7439 (message-insert-importance-low "unimportant" nil
:visible nil
)
7440 (message-insert-disposition-notification-to "receipt" nil
:visible nil
)
7441 (gmm-customize-mode "preferences" t
:help
"Edit mode preferences")
7442 (message-info "help" t
:help
"Message manual"))
7443 "List of items for the message tool bar (GNOME style).
7445 See `gmm-tool-bar-from-list' for details on the format of the list."
7446 :type
'(repeat gmm-tool-bar-item
)
7447 :version
"23.1" ;; No Gnus
7448 :initialize
'custom-initialize-default
7449 :set
'message-tool-bar-update
7452 (defcustom message-tool-bar-retro
7453 '(;; Old Emacs 21 icon for consistency.
7454 (message-send-and-exit "gnus/mail-send")
7455 (message-kill-buffer "close")
7456 (message-dont-send "cancel")
7457 (mml-attach-file "attach" mml-mode-map
)
7458 (ispell-message "spell")
7459 (mml-preview "preview" mml-mode-map
)
7460 (message-insert-importance-high "gnus/important")
7461 (message-insert-importance-low "gnus/unimportant")
7462 (message-insert-disposition-notification-to "gnus/receipt"))
7463 "List of items for the message tool bar (retro style).
7465 See `gmm-tool-bar-from-list' for details on the format of the list."
7466 :type
'(repeat gmm-tool-bar-item
)
7467 :version
"23.1" ;; No Gnus
7468 :initialize
'custom-initialize-default
7469 :set
'message-tool-bar-update
7472 (defcustom message-tool-bar-zap-list
7473 '(new-file open-file dired kill-buffer write-file
7474 print-buffer customize help
)
7475 "List of icon items from the global tool bar.
7476 These items are not displayed on the message mode tool bar.
7478 See `gmm-tool-bar-from-list' for the format of the list."
7479 :type
'gmm-tool-bar-zap-list
7480 :version
"23.1" ;; No Gnus
7481 :initialize
'custom-initialize-default
7482 :set
'message-tool-bar-update
7485 (defvar image-load-path
)
7487 (defun message-make-tool-bar (&optional force
)
7488 "Make a message mode tool bar from `message-tool-bar-list'.
7489 When FORCE, rebuild the tool bar."
7490 (when (and (not (featurep 'xemacs
))
7491 (boundp 'tool-bar-mode
)
7493 (or (not message-tool-bar-map
) force
))
7494 (setq message-tool-bar-map
7496 (gmm-image-load-path-for-library "message"
7497 "mail/save-draft.xpm"
7499 (image-load-path (cons (car load-path
)
7500 (when (boundp 'image-load-path
)
7502 (gmm-tool-bar-from-list message-tool-bar
7503 message-tool-bar-zap-list
7504 'message-mode-map
))))
7505 message-tool-bar-map
)
7507 ;;; Group name completion.
7509 (defcustom message-newgroups-header-regexp
7510 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
7511 "Regexp that match headers that lists groups."
7515 (defcustom message-completion-alist
7516 (list (cons message-newgroups-header-regexp
'message-expand-group
)
7517 '("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . message-expand-name
)
7518 '("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
7519 . message-expand-name
)
7520 '("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):"
7521 . message-expand-name
))
7522 "Alist of (RE . FUN). Use FUN for completion on header lines matching RE."
7525 :type
'(alist :key-type regexp
:value-type function
))
7527 (defcustom message-expand-name-databases
7529 "List of databases to try for name completion (`message-expand-name').
7530 Each element is a symbol and can be `bbdb' or `eudc'."
7532 :type
'(set (const bbdb
) (const eudc
)))
7534 (defcustom message-tab-body-function nil
7535 "*Function to execute when `message-tab' (TAB) is executed in the body.
7536 If nil, the function bound in `text-mode-map' or `global-map' is executed."
7539 :link
'(custom-manual "(message)Various Commands")
7540 :type
'(choice (const nil
)
7543 (declare-function mail-abbrev-in-expansion-header-p
"mailabbrev" ())
7545 (defun message-tab ()
7546 "Complete names according to `message-completion-alist'.
7547 Execute function specified by `message-tab-body-function' when not in
7550 (let ((alist message-completion-alist
))
7552 (let ((mail-abbrev-mode-regexp (caar alist
)))
7553 (not (mail-abbrev-in-expansion-header-p))))
7554 (setq alist
(cdr alist
)))
7555 (funcall (or (cdar alist
) message-tab-body-function
7556 (lookup-key text-mode-map
"\t")
7557 (lookup-key global-map
"\t")
7558 'indent-relative
))))
7563 (let ((standard-output (current-buffer)))
7564 (eval '(display-completion-list nil
"")))
7565 (defalias 'message-display-completion-list
'display-completion-list
))
7566 (error ;; Don't use `wrong-number-of-arguments' here because of XEmacs.
7567 (defun message-display-completion-list (completions &optional ignore
)
7568 "Display the list of completions, COMPLETIONS, using `standard-output'."
7569 (display-completion-list completions
)))))
7571 (defun message-expand-group ()
7572 "Expand the group name under point."
7573 (let* ((b (save-excursion
7578 (skip-chars-forward "^:")
7581 (skip-chars-backward "^, \t\n") (point))))
7582 (completion-ignore-case t
)
7583 (string (buffer-substring b
(progn (skip-chars-forward "^,\t\n ")
7585 (hashtb (and (boundp 'gnus-active-hashtb
) gnus-active-hashtb
))
7586 (completions (all-completions string hashtb
))
7588 (delete-region b
(point))
7590 ((= (length completions
) 1)
7591 (if (string= (car completions
) string
)
7594 (message "Only matching group"))
7595 (insert (car completions
))))
7596 ((and (setq comp
(try-completion string hashtb
))
7597 (not (string= comp string
)))
7602 (message "No matching groups")
7603 (save-selected-window
7604 (pop-to-buffer "*Completions*")
7605 (buffer-disable-undo)
7606 (let ((buffer-read-only nil
))
7608 (let ((standard-output (current-buffer)))
7609 (message-display-completion-list (sort completions
'string
<)
7611 (setq buffer-read-only nil
)
7612 (goto-char (point-min))
7613 (delete-region (point) (progn (forward-line 3) (point))))))))))
7615 (defun message-expand-name ()
7616 (cond ((and (memq 'eudc message-expand-name-databases
)
7617 (boundp 'eudc-protocol
)
7619 (eudc-expand-inline))
7620 ((and (memq 'bbdb message-expand-name-databases
)
7621 (fboundp 'bbdb-complete-name
))
7622 (bbdb-complete-name))
7628 (defun message-talkative-question (ask question show
&rest text
)
7629 "Call FUNCTION with argument QUESTION; optionally display TEXT... args.
7630 If SHOW is non-nil, the arguments TEXT... are displayed in a temp buffer.
7631 The following arguments may contain lists of values."
7633 (setq text
(message-flatten-list text
)))
7634 (save-window-excursion
7635 (with-output-to-temp-buffer " *MESSAGE information message*"
7636 (with-current-buffer " *MESSAGE information message*"
7637 (fundamental-mode) ; for Emacs 20.4+
7639 (goto-char (point-min))))
7640 (funcall ask question
))
7641 (funcall ask question
)))
7643 (defun message-flatten-list (list)
7644 "Return a new, flat list that contains all elements of LIST.
7646 \(message-flatten-list '(1 (2 3 (4 5 (6))) 7))
7649 (apply 'append
(mapcar 'message-flatten-list list
)))
7653 (defun message-generate-new-buffer-clone-locals (name &optional varstr
)
7654 "Create and return a buffer with name based on NAME using `generate-new-buffer'.
7655 Then clone the local variables and values from the old buffer to the
7656 new one, cloning only the locals having a substring matching the
7658 (let ((oldbuf (current-buffer)))
7659 (with-current-buffer (generate-new-buffer name
)
7660 (message-clone-locals oldbuf varstr
)
7663 (defun message-clone-locals (buffer &optional varstr
)
7664 "Clone the local variables from BUFFER to the current buffer."
7665 (let ((locals (with-current-buffer buffer
(buffer-local-variables)))
7666 (regexp "^gnus\\|^nn\\|^message\\|^sendmail\\|^smtp\\|^user-mail-address"))
7669 (when (and (consp local
)
7671 (string-match regexp
(symbol-name (car local
)))
7673 (string-match varstr
(symbol-name (car local
)))))
7675 (set (make-local-variable (car local
))
7683 (defvar message-inhibit-body-encoding nil
)
7685 (defun message-encode-message-body ()
7686 (unless message-inhibit-body-encoding
7687 (let ((mail-parse-charset (or mail-parse-charset
7688 message-default-charset
))
7689 (case-fold-search t
)
7690 lines content-type-p
)
7693 (narrow-to-region (point) (point-max))
7694 (let ((new (mml-generate-mime)))
7696 (delete-region (point-min) (point-max))
7698 (goto-char (point-min))
7699 (if (eq (aref new
0) ?
\n)
7701 (search-forward "\n\n")
7702 (setq lines
(buffer-substring (point-min) (1- (point))))
7703 (delete-region (point-min) (point))))))
7705 (message-narrow-to-headers-or-head)
7706 (message-remove-header "Mime-Version")
7707 (goto-char (point-max))
7708 (insert "MIME-Version: 1.0\n")
7711 (setq content-type-p
7713 (re-search-backward "^Content-Type:" nil t
))))
7715 (message-narrow-to-headers-or-head)
7716 (message-remove-first-header "Content-Type")
7717 (message-remove-first-header "Content-Transfer-Encoding"))
7718 ;; We always make sure that the message has a Content-Type
7719 ;; header. This is because some broken MTAs and MUAs get
7720 ;; awfully confused when confronted with a message with a
7721 ;; MIME-Version header and without a Content-Type header. For
7722 ;; instance, Solaris' /usr/bin/mail.
7723 (unless content-type-p
7724 (goto-char (point-min))
7725 ;; For unknown reason, MIME-Version doesn't exist.
7726 (when (re-search-forward "^MIME-Version:" nil t
)
7728 (insert "Content-Type: text/plain; charset=us-ascii\n"))))))
7730 (defun message-read-from-minibuffer (prompt &optional initial-contents
)
7731 "Read from the minibuffer while providing abbrev expansion."
7732 (if (fboundp 'mail-abbrevs-setup
)
7733 (let ((mail-abbrev-mode-regexp "")
7734 (minibuffer-setup-hook 'mail-abbrevs-setup
)
7735 (minibuffer-local-map message-minibuffer-local-map
))
7736 (read-from-minibuffer prompt initial-contents
))
7737 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook
)
7738 (minibuffer-local-map message-minibuffer-local-map
))
7739 (read-string prompt initial-contents
))))
7741 (defun message-use-alternative-email-as-from ()
7742 "Set From field of the outgoing message to the first matching
7743 address in `message-alternative-emails', looking at To, Cc and
7744 From headers in the original article."
7745 (require 'mail-utils
)
7746 (let* ((fields '("To" "Cc" "From"))
7749 (mail-strip-quoted-names
7750 (mapconcat 'message-fetch-reply-field fields
","))
7754 (if (string-match message-alternative-emails
(car emails
))
7755 (setq email
(car emails
)
7758 (unless (or (not email
) (equal email user-mail-address
))
7759 (message-remove-header "From")
7760 (goto-char (point-max))
7761 (insert "From: " (let ((user-mail-address email
)) (message-make-from))
7764 (defun message-options-get (symbol)
7765 (cdr (assq symbol message-options
)))
7767 (defun message-options-set (symbol value
)
7768 (let ((the-cons (assq symbol message-options
)))
7771 (setcdr the-cons value
)
7772 (setq message-options
(delq the-cons message-options
)))
7774 (push (cons symbol value
) message-options
))))
7777 (defun message-options-set-recipient ()
7779 (message-narrow-to-headers-or-head)
7780 (message-options-set 'message-sender
7781 (mail-strip-quoted-names
7782 (message-fetch-field "from")))
7783 (message-options-set 'message-recipients
7784 (mail-strip-quoted-names
7785 (let ((to (message-fetch-field "to"))
7786 (cc (message-fetch-field "cc"))
7787 (bcc (message-fetch-field "bcc")))
7790 (if (and to cc
) ", ")
7792 (if (and (or to cc
) bcc
) ", ")
7795 (defun message-hide-headers ()
7796 "Hide headers based on the `message-hidden-headers' variable."
7797 (let ((regexps (if (stringp message-hidden-headers
)
7798 (list message-hidden-headers
)
7799 message-hidden-headers
))
7800 (inhibit-point-motion-hooks t
)
7801 (after-change-functions nil
)
7802 (end-of-headers (point-min)))
7806 (message-narrow-to-headers)
7807 (goto-char (point-min))
7809 (if (not (message-hide-header-p regexps
))
7810 (message-next-header)
7811 (let ((begin (point))
7813 (message-next-header)
7814 (setq header
(buffer-substring begin
(point))
7815 header-len
(- (point) begin
))
7816 (delete-region begin
(point))
7817 (goto-char end-of-headers
)
7819 (setq end-of-headers
7820 (+ end-of-headers header-len
))))))))
7821 (narrow-to-region end-of-headers
(point-max))))
7823 (defun message-hide-header-p (regexps)
7826 (when (eq (car regexps
) 'not
)
7829 (dolist (regexp regexps
)
7830 (setq result
(or result
(looking-at regexp
))))
7835 (defun message-put-addresses-in-ecomplete ()
7836 (dolist (header '("to" "cc" "from" "reply-to"))
7837 (let ((value (message-field-value header
)))
7838 (dolist (string (mail-header-parse-addresses value
'raw
))
7840 (gnus-replace-in-string
7841 (gnus-replace-in-string string
"^ +\\| +$" "") "\n" ""))
7842 (ecomplete-add-item 'mail
(car (mail-header-parse-address string
))
7846 (defun message-display-abbrev (&optional choose
)
7847 "Display the next possible abbrev for the text before point."
7848 (interactive (list t
))
7849 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?
\t ?
))
7850 (message-point-in-header-p)
7853 (while (and (memq (char-after) '(?
\t ?
))
7854 (zerop (forward-line -
1))))
7855 (looking-at "To:\\|Cc:")))
7856 (let* ((end (point))
7857 (start (save-excursion
7858 (and (re-search-backward "[\n\t ]" nil t
)
7860 (word (when start
(buffer-substring start end
)))
7861 (match (when (and word
7862 (not (zerop (length word
))))
7863 (ecomplete-display-matches 'mail word choose
))))
7864 (when (and choose match
)
7865 (delete-region start end
)
7868 ;; To send pre-formatted letters like the example below, you can use
7869 ;; `message-send-form-letter':
7870 ;; --8<---------------cut here---------------start------------->8---
7871 ;; To: alice@invalid.invalid
7872 ;; Subject: Verification of your contact information
7873 ;; From: Contact verification <admin@foo.invalid>
7874 ;; --text follows this line--
7876 ;; please verify that your contact information is still valid:
7877 ;; Alice A, A avenue 11, 1111 A town, Austria
7878 ;; ----------next form letter message follows this line----------
7879 ;; To: bob@invalid.invalid
7880 ;; Subject: Verification of your contact information
7881 ;; From: Contact verification <admin@foo.invalid>
7882 ;; --text follows this line--
7884 ;; please verify that your contact information is still valid:
7885 ;; Bob, B street 22, 22222 Be town, Belgium
7886 ;; ----------next form letter message follows this line----------
7887 ;; To: charlie@invalid.invalid
7888 ;; Subject: Verification of your contact information
7889 ;; From: Contact verification <admin@foo.invalid>
7890 ;; --text follows this line--
7892 ;; please verify that your contact information is still valid:
7893 ;; Charlie Chaplin, C plaza 33, 33333 C town, Chile
7894 ;; --8<---------------cut here---------------end--------------->8---
7896 ;; FIXME: What is the most common term (circular letter, form letter, serial
7897 ;; letter, standard letter) for such kind of letter? See also
7898 ;; <http://en.wikipedia.org/wiki/Form_letter>
7900 ;; FIXME: Maybe extent message-mode's font-lock support to recognize
7901 ;; `message-form-letter-separator', i.e. highlight each message like a single
7904 (defcustom message-form-letter-separator
7905 "\n----------next form letter message follows this line----------\n"
7906 "Separator for `message-send-form-letter'."
7907 ;; :group 'message-form-letter
7908 :group
'message-various
7909 :version
"23.1" ;; No Gnus
7912 (defcustom message-send-form-letter-delay
1
7913 "Delay in seconds when sending a message with `message-send-form-letter'.
7914 Only used when `message-send-form-letter' is called with non-nil
7916 ;; :group 'message-form-letter
7917 :group
'message-various
7918 :version
"23.1" ;; No Gnus
7921 (defun message-send-form-letter (&optional force
)
7922 "Sent all form letter messages from current buffer.
7923 Unless FORCE, prompt before sending.
7925 The messages are separated by `message-form-letter-separator'.
7926 Header and body are separated by `mail-header-separator'."
7928 (let ((sent 0) (skipped 0)
7932 (goto-char (point-min))
7935 end
(if (search-forward message-form-letter-separator nil t
)
7936 (- (point) (length message-form-letter-separator
) -
1)
7940 (buffer-substring-no-properties start end
))
7941 (setq buff
(generate-new-buffer "*mail - form letter*"))
7942 (with-current-buffer buff
7945 (setq to
(message-fetch-field "To"))
7946 (switch-to-buffer buff
)
7948 (sit-for message-send-form-letter-delay
))
7950 (y-or-n-p (format "Send message to `%s'? " to
)))
7952 (setq sent
(1+ sent
))
7953 (message-send-and-exit))
7954 (message (format "Message to `%s' skipped." to
))
7955 (setq skipped
(1+ skipped
)))
7956 (when (buffer-live-p buff
)
7957 (kill-buffer buff
))))
7958 (message "%s message(s) sent, %s skipped." sent skipped
)))
7960 (defun message-replace-header (header new-value
&optional after force
)
7961 "Remove HEADER and insert the NEW-VALUE.
7962 If AFTER, insert after this header. If FORCE, insert new field
7963 even if NEW-VALUE is empty."
7964 ;; Similar to `nnheader-replace-header' but for message buffers.
7967 (message-narrow-to-headers)
7968 (message-remove-header header
))
7969 (when (or force
(> (length new-value
) 0))
7971 (message-position-on-field header after
)
7972 (message-position-on-field header
))
7973 (insert new-value
))))
7975 (defcustom message-recipients-without-full-name
7976 (list "ding@gnus.org"
7978 "emacs-devel@gnu.org"
7979 "emacs-pretest-bug@gnu.org"
7980 "bug-gnu-emacs@gnu.org")
7981 "Mail addresses that have no full name.
7982 Used in `message-simplify-recipients'."
7983 ;; Maybe the addresses could be extracted from
7984 ;; `gnus-parameter-to-list-alist'?
7985 :type
'(choice (const :tag
"None" nil
)
7987 :version
"23.1" ;; No Gnus
7988 :group
'message-headers
)
7990 (defun message-simplify-recipients ()
7992 (dolist (hdr '("Cc" "To"))
7993 (message-replace-header
7997 (if (and message-recipients-without-full-name
7999 (regexp-opt message-recipients-without-full-name
)
8003 (message-make-from (car addrcomp
) (cadr addrcomp
))
8005 (when (message-fetch-field hdr
)
8006 (mail-extract-address-components
8007 (message-fetch-field hdr
) t
))
8010 (when (featurep 'xemacs
)
8011 (require 'messagexmas
)
8012 (message-xmas-redefine))
8016 (run-hooks 'message-load-hook
)
8019 ;; coding: iso-8859-1
8022 ;; arch-tag: 94b32cac-4504-4b6c-8181-030ebf380ee0
8023 ;;; message.el ends here