1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This mode provides mail-sending facilities from within Emacs. It
27 ;; consists mainly of large chunks of code from the sendmail.el,
28 ;; gnus-msg.el and rnewspost.el files.
32 ;; For Emacs <22.2 and XEmacs.
34 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
41 ;; Only for the trivial macros mail-header-from, mail-header-date
42 ;; mail-header-references, mail-header-subject, mail-header-id
43 (eval-when-compile (require 'nnheader
))
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
))
54 (autoload 'mailclient-send-it
"mailclient") ;; Emacs 22 or contrib/
56 (defvar gnus-message-group-art
)
57 (defvar gnus-list-identifiers
) ; gnus-sum is required where necessary
58 (defvar rmail-enable-mime-composing
)
60 (defgroup message
'((user-mail-address custom-variable
)
61 (user-full-name custom-variable
))
62 "Mail and news message composing."
63 :link
'(custom-manual "(message)Top")
67 (put 'user-mail-address
'custom-type
'string
)
68 (put 'user-full-name
'custom-type
'string
)
70 (defgroup message-various nil
71 "Various Message Variables."
72 :link
'(custom-manual "(message)Various Message Variables")
75 (defgroup message-buffers nil
77 :link
'(custom-manual "(message)Message Buffers")
80 (defgroup message-sending nil
82 :link
'(custom-manual "(message)Sending Variables")
85 (defgroup message-interface nil
87 :link
'(custom-manual "(message)Interface")
90 (defgroup message-forwarding nil
92 :link
'(custom-manual "(message)Forwarding")
93 :group
'message-interface
)
95 (defgroup message-insertion nil
97 :link
'(custom-manual "(message)Insertion")
100 (defgroup message-headers nil
102 :link
'(custom-manual "(message)Message Headers")
105 (defgroup message-news nil
106 "Composing News Messages."
109 (defgroup message-mail nil
110 "Composing Mail Messages."
113 (defgroup message-faces nil
114 "Faces used for message composing."
118 (defcustom message-directory
"~/Mail/"
119 "*Directory from which all other mail file variables are derived."
120 :group
'message-various
123 (defcustom message-max-buffers
10
124 "*How many buffers to keep before starting to kill them off."
125 :group
'message-buffers
128 (defcustom message-send-rename-function nil
129 "Function called to rename the buffer after sending it."
130 :group
'message-buffers
131 :type
'(choice function
(const nil
)))
133 (defcustom message-fcc-handler-function
'message-output
134 "*A function called to save outgoing articles.
135 This function will be called with the name of the file to store the
136 article in. The default function is `message-output' which saves in Unix
138 :type
'(radio (function-item message-output
)
139 (function :tag
"Other"))
140 :group
'message-sending
)
142 (defcustom message-fcc-externalize-attachments nil
143 "If non-nil, attachments are included as external parts in Fcc copies."
146 :group
'message-sending
)
148 (defcustom message-courtesy-message
149 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
150 "*This is inserted at the start of a mailed copy of a posted message.
151 If the string contains the format spec \"%s\", the Newsgroups
152 the article has been posted to will be inserted there.
153 If this variable is nil, no such courtesy message will be added."
154 :group
'message-sending
155 :type
'(radio string
(const nil
)))
157 (defcustom message-ignored-bounced-headers
158 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
159 "*Regexp that matches headers to be removed in resent bounced mail."
160 :group
'message-interface
163 (defcustom message-from-style
'default
164 ;; In Emacs 24.1 this defaults to the value of `mail-from-style'
166 ;; `angles' in Emacs 22.1~23.1, XEmacs 21.4, 21.5, and SXEmacs 22.1;
167 ;; `default' in Emacs 23.2, and 24.1
168 "*Specifies how \"From\" headers look.
170 If nil, they contain just the return address like:
172 If `parens', they look like:
173 king@grassland.com (Elvis Parsley)
174 If `angles', they look like:
175 Elvis Parsley <king@grassland.com>
177 Otherwise, most addresses look like `angles', but they look like
178 `parens' if `angles' would need quoting and `parens' would not."
180 :type
'(choice (const :tag
"simple" nil
)
184 :group
'message-headers
)
186 (defcustom message-insert-canlock t
187 "Whether to insert a Cancel-Lock header in news postings."
189 :group
'message-headers
192 (defcustom message-syntax-checks
193 (if message-insert-canlock
'((sender . disabled
)) nil
)
194 ;; Guess this one shouldn't be easy to customize...
195 "*Controls what syntax checks should not be performed on outgoing posts.
196 To disable checking of long signatures, for instance, add
197 `(signature . disabled)' to this list.
199 Don't touch this variable unless you really know what you're doing.
201 Checks include `approved', `bogus-recipient', `continuation-headers',
202 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
203 `invisible-text', `long-header-lines', `long-lines', `message-id',
204 `multiple-headers', `new-text', `newsgroups', `quoting-style',
205 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
206 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
207 and `valid-newsgroups'."
209 :type
'(repeat sexp
)) ; Fixme: improve this
211 (defcustom message-required-headers
'((optional . References
)
213 "*Headers to be generated or prompted for when sending a message.
214 Also see `message-required-news-headers' and
215 `message-required-mail-headers'."
218 :group
'message-headers
219 :link
'(custom-manual "(message)Message Headers")
220 :type
'(repeat sexp
))
222 (defcustom message-draft-headers
'(References From Date
)
223 "*Headers to be generated when saving a draft message."
226 :group
'message-headers
227 :link
'(custom-manual "(message)Message Headers")
228 :type
'(repeat sexp
))
230 (defcustom message-required-news-headers
231 '(From Newsgroups Subject Date Message-ID
232 (optional . Organization
)
233 (optional . User-Agent
))
234 "*Headers to be generated or prompted for when posting an article.
235 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
236 Message-ID. Organization, Lines, In-Reply-To, Expires, and
237 User-Agent are optional. If you don't want message to insert some
238 header, remove it from this list."
240 :group
'message-headers
241 :link
'(custom-manual "(message)Message Headers")
242 :type
'(repeat sexp
))
244 (defcustom message-required-mail-headers
245 '(From Subject Date
(optional . In-Reply-To
) Message-ID
246 (optional . User-Agent
))
247 "*Headers to be generated or prompted for when mailing a message.
248 It is recommended that From, Date, To, Subject and Message-ID be
249 included. Organization and User-Agent are optional."
251 :group
'message-headers
252 :link
'(custom-manual "(message)Message Headers")
253 :type
'(repeat sexp
))
255 (defcustom message-prune-recipient-rules nil
256 "Rules for how to prune the list of recipients when doing wide replies.
257 This is a list of regexps and regexp matches."
260 :group
'message-headers
261 :link
'(custom-manual "(message)Wide Reply")
262 :type
'(repeat regexp
))
264 (defcustom message-deletable-headers
'(Message-ID Date Lines
)
265 "Headers to be deleted if they already exist and were generated by message previously."
266 :group
'message-headers
267 :link
'(custom-manual "(message)Message Headers")
270 (defcustom message-ignored-news-headers
271 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
272 "*Regexp of headers to be removed unconditionally before posting."
274 :group
'message-headers
275 :link
'(custom-manual "(message)Message Headers")
276 :type
'(repeat :value-to-internal
(lambda (widget value
)
277 (custom-split-regexp-maybe value
))
278 :match
(lambda (widget value
)
280 (widget-editable-list-match widget value
)))
283 (defcustom message-ignored-mail-headers
284 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
285 "*Regexp of headers to be removed unconditionally before mailing."
287 :group
'message-headers
288 :link
'(custom-manual "(message)Mail Headers")
291 (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:\\|^Injection-Date:\\|^Injection-Info:"
292 "*Header lines matching this regexp will be deleted before posting.
293 It's best to delete old Path and Date headers before posting to avoid
295 :group
'message-interface
296 :link
'(custom-manual "(message)Superseding")
297 :type
'(repeat :value-to-internal
(lambda (widget value
)
298 (custom-split-regexp-maybe value
))
299 :match
(lambda (widget value
)
301 (widget-editable-list-match widget value
)))
304 (defcustom message-subject-re-regexp
305 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
306 "*Regexp matching \"Re: \" in the subject line."
307 :group
'message-various
308 :link
'(custom-manual "(message)Message Headers")
311 ;;; Start of variables adopted from `message-utils.el'.
313 (defcustom message-subject-trailing-was-query t
314 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
315 If nil, leave the subject unchanged. If it is the symbol `ask', query
316 the user what do do. In this case, the subject is matched against
317 `message-subject-trailing-was-ask-regexp'. If
318 `message-subject-trailing-was-query' is t, always strip the trailing
319 old subject. In this case, `message-subject-trailing-was-regexp' is
322 :type
'(choice (const :tag
"never" nil
)
323 (const :tag
"always strip" t
)
325 :link
'(custom-manual "(message)Message Headers")
326 :group
'message-various
)
328 (defcustom message-subject-trailing-was-ask-regexp
329 "[ \t]*\\([[(]+[Ww][Aa][Ss]:?[ \t]*.*[])]+\\)"
330 "*Regexp matching \"(was: <old subject>)\" in the subject line.
332 The function `message-strip-subject-trailing-was' uses this regexp if
333 `message-subject-trailing-was-query' is set to the symbol `ask'. If
334 the variable is t instead of `ask', use
335 `message-subject-trailing-was-regexp' instead.
337 It is okay to create some false positives here, as the user is asked."
339 :group
'message-various
340 :link
'(custom-manual "(message)Message Headers")
343 (defcustom message-subject-trailing-was-regexp
344 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
345 "*Regexp matching \"(was: <old subject>)\" in the subject line.
347 If `message-subject-trailing-was-query' is set to t, the subject is
348 matched against `message-subject-trailing-was-regexp' in
349 `message-strip-subject-trailing-was'. You should use a regexp creating very
350 few false positives here."
352 :group
'message-various
353 :link
'(custom-manual "(message)Message Headers")
356 ;;; marking inserted text
358 (defcustom message-mark-insert-begin
359 "--8<---------------cut here---------------start------------->8---\n"
360 "How to mark the beginning of some inserted text."
363 :link
'(custom-manual "(message)Insertion Variables")
364 :group
'message-various
)
366 (defcustom message-mark-insert-end
367 "--8<---------------cut here---------------end--------------->8---\n"
368 "How to mark the end of some inserted text."
371 :link
'(custom-manual "(message)Insertion Variables")
372 :group
'message-various
)
374 (defcustom message-archive-header
"X-No-Archive: Yes\n"
375 "Header to insert when you don't want your article to be archived.
376 Archives \(such as groups.google.com\) respect this header."
379 :link
'(custom-manual "(message)Header Commands")
380 :group
'message-various
)
382 (defcustom message-archive-note
383 "X-No-Archive: Yes - save http://groups.google.com/"
384 "Note to insert why you wouldn't want this posting archived.
385 If nil, don't insert any text in the body."
387 :type
'(radio string
(const nil
))
388 :link
'(custom-manual "(message)Header Commands")
389 :group
'message-various
)
391 ;;; Crossposts and Followups
392 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
393 ;; new suggestions by R. Weikusat <rw at another.de>
395 (defvar message-cross-post-old-target nil
396 "Old target for cross-posts or follow-ups.")
397 (make-variable-buffer-local 'message-cross-post-old-target
)
399 (defcustom message-cross-post-default t
400 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
401 If nil, `message-cross-post-followup-to' will only do a followup. Note that
402 you can explicitly override this setting by calling
403 `message-cross-post-followup-to' with a prefix."
406 :group
'message-various
)
408 (defcustom message-cross-post-note
"Crosspost & Followup-To: "
409 "Note to insert before signature to notify of cross-post and follow-up."
412 :group
'message-various
)
414 (defcustom message-followup-to-note
"Followup-To: "
415 "Note to insert before signature to notify of follow-up only."
418 :group
'message-various
)
420 (defcustom message-cross-post-note-function
'message-cross-post-insert-note
421 "Function to use to insert note about Crosspost or Followup-To.
422 The function will be called with four arguments. The function should not only
423 insert a note, but also ensure old notes are deleted. See the documentation
424 for `message-cross-post-insert-note'."
427 :group
'message-various
)
429 ;;; End of variables adopted from `message-utils.el'.
431 (defcustom message-signature-separator
"^-- $"
432 "Regexp matching the signature separator.
433 This variable is used to strip off the signature from quoted text
434 when `message-cite-function' is
435 `message-cite-original-without-signature'. Most useful values
436 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
438 :type
'(choice (const :tag
"strict" "^-- $")
439 (const :tag
"loose" "^-- *$")
441 :version
"22.3" ;; Gnus 5.10.12 (changed default)
442 :link
'(custom-manual "(message)Various Message Variables")
443 :group
'message-various
)
445 (defcustom message-elide-ellipsis
"\n[...]\n\n"
446 "*The string which is inserted for elided text."
448 :link
'(custom-manual "(message)Various Commands")
449 :group
'message-various
)
451 (defcustom message-interactive t
452 ;; In Emacs 24.1 this defaults to the value of `mail-interactive'
454 ;; `nil' in Emacs 22.1~22.3, XEmacs 21.4, 21.5, and SXEmacs 22.1;
455 ;; `t' in Emacs 23.1~24.1
456 "Non-nil means when sending a message wait for and display errors.
457 A value of nil means let mailer mail back a message to report errors."
459 :group
'message-sending
461 :link
'(custom-manual "(message)Sending Variables")
464 (defcustom message-confirm-send nil
465 "When non-nil, ask for confirmation when sending a message."
466 :group
'message-sending
468 :version
"23.1" ;; No Gnus
469 :link
'(custom-manual "(message)Sending Variables")
472 (defcustom message-generate-new-buffers
'unsent
473 "*Say whether to create a new message buffer to compose a message.
474 Valid values include:
477 Generate the buffer name in the Message way (e.g., *mail*, *news*,
478 *mail to whom*, *news on group*, etc.) and continue editing in the
479 existing buffer of that name. If there is no such buffer, it will
483 Create the new buffer with the name generated in the Message way.
486 Similar to `unique' but the buffer name begins with \"*unsent \".
489 Similar to nil but the buffer name is simpler like *mail message*.
492 If this is a function, call that function with three parameters:
493 The type, the To address and the group name (any of these may be nil).
494 The function should return the new buffer name."
496 :group
'message-buffers
497 :link
'(custom-manual "(message)Message Buffers")
498 :type
'(choice (const nil
)
499 (sexp :tag
"unique" :format
"unique\n" :value unique
500 :match
(lambda (widget value
) (memq value
'(unique t
))))
503 (function :format
"\n %{%t%}: %v")))
505 (defcustom message-kill-buffer-on-exit nil
506 "*Non-nil means that the message buffer will be killed after sending a message."
507 :group
'message-buffers
508 :link
'(custom-manual "(message)Message Buffers")
511 (defcustom message-kill-buffer-query t
512 "*Non-nil means that killing a modified message buffer has to be confirmed.
513 This is used by `message-kill-buffer'."
514 :version
"23.1" ;; No Gnus
515 :group
'message-buffers
518 (defvar gnus-local-organization
)
519 (defcustom message-user-organization
520 (or (and (boundp 'gnus-local-organization
)
521 (stringp gnus-local-organization
)
522 gnus-local-organization
)
523 (getenv "ORGANIZATION")
525 "*String to be used as an Organization header.
526 If t, use `message-user-organization-file'."
527 :group
'message-headers
528 :type
'(choice string
529 (const :tag
"consult file" t
)))
531 (defcustom message-user-organization-file
533 (dolist (f (list "/etc/organization"
534 "/etc/news/organization"
535 "/usr/lib/news/organization"))
536 (when (file-readable-p f
)
539 "*Local news organization file."
541 :link
'(custom-manual "(message)News Headers")
542 :group
'message-headers
)
544 (defcustom message-make-forward-subject-function
545 #'message-forward-subject-name-subject
546 "*List of functions called to generate subject headers for forwarded messages.
547 The subject generated by the previous function is passed into each
550 The provided functions are:
552 * `message-forward-subject-author-subject' Source of article (author or
553 newsgroup), in brackets followed by the subject
554 * `message-forward-subject-name-subject' Source of article (name of author
555 or newsgroup), in brackets followed by the subject
556 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
558 :group
'message-forwarding
559 :link
'(custom-manual "(message)Forwarding")
560 :type
'(radio (function-item message-forward-subject-author-subject
)
561 (function-item message-forward-subject-fwd
)
562 (function-item message-forward-subject-name-subject
)
563 (repeat :tag
"List of functions" function
)))
565 (defcustom message-forward-as-mime t
566 "*Non-nil means forward messages as an inline/rfc822 MIME section.
567 Otherwise, directly inline the old message in the forwarded message."
569 :group
'message-forwarding
570 :link
'(custom-manual "(message)Forwarding")
573 (defcustom message-forward-show-mml
'best
574 "*Non-nil means show forwarded messages as MML (decoded from MIME).
575 Otherwise, forwarded messages are unchanged.
576 Can also be the symbol `best' to indicate that MML should be
577 used, except when it is a bad idea to use MML. One example where
578 it is a bad idea is when forwarding a signed or encrypted
579 message, because converting MIME to MML would invalidate the
582 :group
'message-forwarding
583 :type
'(choice (const :tag
"use MML" t
)
584 (const :tag
"don't use MML " nil
)
585 (const :tag
"use MML when appropriate" best
)))
587 (defcustom message-forward-before-signature t
588 "*Non-nil means put forwarded message before signature, else after."
589 :group
'message-forwarding
592 (defcustom message-wash-forwarded-subjects nil
593 "*Non-nil means try to remove as much cruft as possible from the subject.
594 Done before generating the new subject of a forward."
595 :group
'message-forwarding
596 :link
'(custom-manual "(message)Forwarding")
599 (defcustom message-ignored-resent-headers
600 ;; `Delivered-To' needs to be removed because some mailers use it to
601 ;; detect loops, so if you resend a message to an address that ultimately
602 ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
603 ;; case you may be removed from the list on the grounds that mail to you
604 ;; bounced with a "mailing loop" error).
605 "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
606 "*All headers that match this regexp will be deleted when resending a message."
607 :group
'message-interface
608 :link
'(custom-manual "(message)Resending")
609 :type
'(repeat :value-to-internal
(lambda (widget value
)
610 (custom-split-regexp-maybe value
))
611 :match
(lambda (widget value
)
613 (widget-editable-list-match widget value
)))
616 (defcustom message-forward-ignored-headers
"^Content-Transfer-Encoding:\\|^X-Gnus"
617 "*All headers that match this regexp will be deleted when forwarding a message."
619 :group
'message-forwarding
620 :type
'(repeat :value-to-internal
(lambda (widget value
)
621 (custom-split-regexp-maybe value
))
622 :match
(lambda (widget value
)
624 (widget-editable-list-match widget value
)))
627 (defcustom message-ignored-cited-headers
"."
628 "*Delete these headers from the messages you yank."
629 :group
'message-insertion
630 :link
'(custom-manual "(message)Insertion Variables")
633 (defcustom message-cite-prefix-regexp
634 ;; In Emacs 24.1 this defaults to the value of
635 ;; `mail-citation-prefix-regexp'; the default value varies according
636 ;; to the Emacs version. In XEmacs 21.4 and 21.5, sendmail.el
638 (if (string-match "[[:digit:]]" "1")
639 ;; Support POSIX? XEmacs 21.5.27 doesn't.
640 "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|]\\)+"
641 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
642 (let (non-word-constituents)
643 (with-syntax-table text-mode-syntax-table
644 (setq non-word-constituents
646 (if (string-match "\\w" "_") "" "_")
647 (if (string-match "\\w" ".") "" "."))))
648 (if (equal non-word-constituents
"")
649 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|]\\)+"
650 (concat "\\([ \t]*\\(\\w\\|["
651 non-word-constituents
652 "]\\)+>+\\|[ \t]*[]>|]\\)+"))))
653 "*Regexp matching the longest possible citation prefix on a line."
655 :group
'message-insertion
656 :link
'(custom-manual "(message)Insertion Variables")
658 :set
(lambda (symbol value
)
660 (custom-set-default symbol value
)
661 (if (boundp 'gnus-message-cite-prefix-regexp
)
662 (setq gnus-message-cite-prefix-regexp
663 (concat "^\\(?:" value
"\\)"))))))
665 (defcustom message-cancel-message
"I am canceling my own article.\n"
666 "Message to be inserted in the cancel message."
667 :group
'message-interface
668 :link
'(custom-manual "(message)Canceling News")
671 (defun message-send-mail-function ()
672 "Return suitable value for the variable `message-send-mail-function'."
673 (cond ((and (require 'sendmail
)
674 (boundp 'sendmail-program
)
676 (executable-find sendmail-program
))
677 'message-send-mail-with-sendmail
)
678 ((and (locate-library "smtpmail")
679 (boundp 'smtpmail-default-smtp-server
)
680 smtpmail-default-smtp-server
)
681 'message-smtpmail-send-it
)
682 ((locate-library "mailclient")
683 'message-send-mail-with-mailclient
)
685 (error "Don't know how to send mail. Please customize `message-send-mail-function'"))))
687 ;; Useful to set in site-init.el
688 (defcustom message-send-mail-function
689 (cond ((eq send-mail-function
'smtpmail-send-it
) 'message-smtpmail-send-it
)
690 ((eq send-mail-function
'feedmail-send-it
) 'feedmail-send-it
)
691 ((eq send-mail-function
'mailclient-send-it
)
692 'message-send-mail-with-mailclient
)
693 (t (message-send-mail-function)))
694 "Function to call to send the current buffer as mail.
695 The headers should be delimited by a line whose contents match the
696 variable `mail-header-separator'.
698 Valid values include `message-send-mail-with-sendmail'
699 `message-send-mail-with-mh', `message-send-mail-with-qmail',
700 `message-smtpmail-send-it', `smtpmail-send-it',
701 `feedmail-send-it' and `message-send-mail-with-mailclient'. The
702 default is system dependent and determined by the function
703 `message-send-mail-function'.
705 See also `send-mail-function'."
706 :type
'(radio (function-item message-send-mail-with-sendmail
)
707 (function-item message-send-mail-with-mh
)
708 (function-item message-send-mail-with-qmail
)
709 (function-item message-smtpmail-send-it
)
710 (function-item smtpmail-send-it
)
711 (function-item feedmail-send-it
)
712 (function-item message-send-mail-with-mailclient
713 :tag
"Use Mailclient package")
714 (function :tag
"Other"))
715 :group
'message-sending
717 :initialize
'custom-initialize-default
718 :link
'(custom-manual "(message)Mail Variables")
719 :group
'message-mail
)
721 (defcustom message-send-news-function
'message-send-news
722 "Function to call to send the current buffer as news.
723 The headers should be delimited by a line whose contents match the
724 variable `mail-header-separator'."
725 :group
'message-sending
727 :link
'(custom-manual "(message)News Variables")
730 (defcustom message-reply-to-function nil
731 "If non-nil, function that should return a list of headers.
732 This function should pick out addresses from the To, Cc, and From headers
733 and respond with new To and Cc headers."
734 :group
'message-interface
735 :link
'(custom-manual "(message)Reply")
736 :type
'(choice function
(const nil
)))
738 (defcustom message-wide-reply-to-function nil
739 "If non-nil, function that should return a list of headers.
740 This function should pick out addresses from the To, Cc, and From headers
741 and respond with new To and Cc headers."
742 :group
'message-interface
743 :link
'(custom-manual "(message)Wide Reply")
744 :type
'(choice function
(const nil
)))
746 (defcustom message-followup-to-function nil
747 "If non-nil, function that should return a list of headers.
748 This function should pick out addresses from the To, Cc, and From headers
749 and respond with new To and Cc headers."
750 :group
'message-interface
751 :link
'(custom-manual "(message)Followup")
752 :type
'(choice function
(const nil
)))
754 (defcustom message-extra-wide-headers nil
755 "If non-nil, a list of additional address headers.
756 These are used when composing a wide reply."
757 :group
'message-sending
758 :type
'(repeat string
))
760 (defcustom message-use-followup-to
'ask
761 "*Specifies what to do with Followup-To header.
762 If nil, always ignore the header. If it is t, use its value, but
763 query before using the \"poster\" value. If it is the symbol `ask',
764 always query the user whether to use the value. If it is the symbol
765 `use', always use the value."
766 :group
'message-interface
767 :link
'(custom-manual "(message)Followup")
768 :type
'(choice (const :tag
"ignore" nil
)
769 (const :tag
"use & query" t
)
773 (defcustom message-use-mail-followup-to
'use
774 "*Specifies what to do with Mail-Followup-To header.
775 If nil, always ignore the header. If it is the symbol `ask', always
776 query the user whether to use the value. If it is the symbol `use',
777 always use the value."
779 :group
'message-interface
780 :link
'(custom-manual "(message)Mailing Lists")
781 :type
'(choice (const :tag
"ignore" nil
)
785 (defcustom message-subscribed-address-functions nil
786 "*Specifies functions for determining list subscription.
787 If nil, do not attempt to determine list subscription with functions.
788 If non-nil, this variable contains a list of functions which return
789 regular expressions to match lists. These functions can be used in
790 conjunction with `message-subscribed-regexps' and
791 `message-subscribed-addresses'."
793 :group
'message-interface
794 :link
'(custom-manual "(message)Mailing Lists")
795 :type
'(repeat sexp
))
797 (defcustom message-subscribed-address-file nil
798 "*A file containing addresses the user is subscribed to.
799 If nil, do not look at any files to determine list subscriptions. If
800 non-nil, each line of this file should be a mailing list address."
802 :group
'message-interface
803 :link
'(custom-manual "(message)Mailing Lists")
804 :type
'(radio file
(const nil
)))
806 (defcustom message-subscribed-addresses nil
807 "*Specifies a list of addresses the user is subscribed to.
808 If nil, do not use any predefined list subscriptions. This list of
809 addresses can be used in conjunction with
810 `message-subscribed-address-functions' and `message-subscribed-regexps'."
812 :group
'message-interface
813 :link
'(custom-manual "(message)Mailing Lists")
814 :type
'(repeat string
))
816 (defcustom message-subscribed-regexps nil
817 "*Specifies a list of addresses the user is subscribed to.
818 If nil, do not use any predefined list subscriptions. This list of
819 regular expressions can be used in conjunction with
820 `message-subscribed-address-functions' and `message-subscribed-addresses'."
822 :group
'message-interface
823 :link
'(custom-manual "(message)Mailing Lists")
824 :type
'(repeat regexp
))
826 (defcustom message-allow-no-recipients
'ask
827 "Specifies what to do when there are no recipients other than Gcc/Fcc.
828 If it is the symbol `always', the posting is allowed. If it is the
829 symbol `never', the posting is not allowed. If it is the symbol
830 `ask', you are prompted."
832 :group
'message-interface
833 :link
'(custom-manual "(message)Message Headers")
834 :type
'(choice (const always
)
838 (defcustom message-sendmail-f-is-evil nil
839 "*Non-nil means don't add \"-f username\" to the sendmail command line.
840 Doing so would be even more evil than leaving it out."
841 :group
'message-sending
842 :link
'(custom-manual "(message)Mail Variables")
845 (defcustom message-sendmail-envelope-from nil
846 ;; In Emacs 24.1 this defaults to the value of `mail-envelope-from'
847 ;; if it is available, or defaults to nil. sendmail.el provides it;
848 ;; the default value is nil in all (X)Emacsen that Gnus supports.
849 "*Envelope-from when sending mail with sendmail.
850 If this is nil, use `user-mail-address'. If it is the symbol
851 `header', use the From: header of the message."
853 :type
'(choice (string :tag
"From name")
854 (const :tag
"Use From: header from message" header
)
855 (const :tag
"Use `user-mail-address'" nil
))
856 :link
'(custom-manual "(message)Mail Variables")
857 :group
'message-sending
)
859 (defcustom message-sendmail-extra-arguments nil
860 "Additional arguments to `sendmail-program'."
861 ;; E.g. '("-a" "account") for msmtp
862 :version
"23.1" ;; No Gnus
863 :type
'(repeat string
)
864 ;; :link '(custom-manual "(message)Mail Variables")
865 :group
'message-sending
)
867 ;; qmail-related stuff
868 (defcustom message-qmail-inject-program
"/var/qmail/bin/qmail-inject"
869 "Location of the qmail-inject program."
870 :group
'message-sending
871 :link
'(custom-manual "(message)Mail Variables")
874 (defcustom message-qmail-inject-args nil
875 "Arguments passed to qmail-inject programs.
876 This should be a list of strings, one string for each argument.
877 It may also be a function.
879 For e.g., if you wish to set the envelope sender address so that bounces
880 go to the right place or to deal with listserv's usage of that address, you
881 might set this variable to '(\"-f\" \"you@some.where\")."
882 :group
'message-sending
883 :link
'(custom-manual "(message)Mail Variables")
884 :type
'(choice (function)
887 (defvar gnus-post-method
)
888 (defvar gnus-select-method
)
889 (defcustom message-post-method
890 (cond ((and (boundp 'gnus-post-method
)
891 (listp gnus-post-method
)
894 ((boundp 'gnus-select-method
)
897 "*Method used to post news.
898 Note that when posting from inside Gnus, for instance, this
899 variable isn't used."
901 :group
'message-sending
902 ;; This should be the `gnus-select-method' widget, but that might
903 ;; create a dependence to `gnus.el'.
906 ;; FIXME: This should be a temporary workaround until someone implements a
907 ;; proper solution. If a crash happens while replying, the auto-save file
908 ;; will *not* have a `References:' header if `message-generate-headers-first'
909 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
910 (defcustom message-generate-headers-first
'(references)
911 "Which headers should be generated before starting to compose a message.
912 If t, generate all required headers. This can also be a list of headers to
913 generate. The variables `message-required-news-headers' and
914 `message-required-mail-headers' specify which headers to generate.
916 Note that the variable `message-deletable-headers' specifies headers which
917 are to be deleted and then re-generated before sending, so this variable
918 will not have a visible effect for those headers."
919 :group
'message-headers
920 :link
'(custom-manual "(message)Message Headers")
921 :type
'(choice (const :tag
"None" nil
)
922 (const :tag
"References" '(references))
924 (repeat (sexp :tag
"Header"))))
926 (defcustom message-fill-column
72
927 "Column beyond which automatic line-wrapping should happen.
928 Local value for message buffers. If non-nil, also turn on
929 auto-fill in message buffers."
930 :group
'message-various
931 ;; :link '(custom-manual "(message)Message Headers")
932 :type
'(choice (const :tag
"Don't turn on auto fill" nil
)
935 (defcustom message-setup-hook nil
936 "Normal hook, run each time a new outgoing message is initialized.
937 The function `message-setup' runs this hook."
938 :group
'message-various
939 :link
'(custom-manual "(message)Various Message Variables")
942 (defcustom message-cancel-hook nil
943 "Hook run when cancelling articles."
944 :group
'message-various
945 :link
'(custom-manual "(message)Various Message Variables")
948 (defcustom message-signature-setup-hook nil
949 "Normal hook, run each time a new outgoing message is initialized.
950 It is run after the headers have been inserted and before
951 the signature is inserted."
952 :group
'message-various
953 :link
'(custom-manual "(message)Various Message Variables")
956 (defcustom message-mode-hook nil
957 "Hook run in message mode buffers."
958 :group
'message-various
961 (defcustom message-header-hook nil
962 "Hook run in a message mode buffer narrowed to the headers."
963 :group
'message-various
966 (defcustom message-header-setup-hook nil
967 "Hook called narrowed to the headers when setting up a message buffer."
968 :group
'message-various
969 :link
'(custom-manual "(message)Various Message Variables")
972 (defcustom message-minibuffer-local-map
973 (let ((map (make-sparse-keymap 'message-minibuffer-local-map
)))
974 (set-keymap-parent map minibuffer-local-map
)
976 "Keymap for `message-read-from-minibuffer'."
978 :group
'message-various
)
980 (defcustom message-citation-line-function
'message-insert-citation-line
981 "*Function called to insert the \"Whomever writes:\" line.
983 Predefined functions include `message-insert-citation-line' and
984 `message-insert-formatted-citation-line' (see the variable
985 `message-citation-line-format').
987 Note that Gnus provides a feature where the reader can click on
988 `writes:' to hide the cited text. If you change this line too much,
989 people who read your message will have to change their Gnus
990 configuration. See the variable `gnus-cite-attribution-suffix'."
992 (function-item :tag
"plain" message-insert-citation-line
)
993 (function-item :tag
"formatted" message-insert-formatted-citation-line
)
994 (function :tag
"Other"))
995 :link
'(custom-manual "(message)Insertion Variables")
996 :group
'message-insertion
)
998 (defcustom message-citation-line-format
"On %a, %b %d %Y, %N wrote:\n"
999 "Format of the \"Whomever writes:\" line.
1001 The string is formatted using `format-spec'. The following
1002 constructs are replaced:
1004 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
1005 %n The mail address, e.g. \"john.doe@example.invalid\".
1006 %N The real name if present, e.g.: \"John Doe\", else fall
1007 back to the mail address.
1008 %F The first name if present, e.g.: \"John\".
1009 %L The last name if present, e.g.: \"Doe\".
1011 All other format specifiers are passed to `format-time-string'
1012 which is called using the date from the article your replying to.
1013 Extracting the first (%F) and last name (%L) is done
1014 heuristically, so you should always check it yourself.
1016 Please also read the note in the documentation of
1017 `message-citation-line-function'."
1018 :type
'(choice (const :tag
"Plain" "%f writes:")
1019 (const :tag
"Include date" "On %a, %b %d %Y, %n wrote:")
1021 :link
'(custom-manual "(message)Insertion Variables")
1022 :version
"23.1" ;; No Gnus
1023 :group
'message-insertion
)
1025 (defcustom message-yank-prefix
"> "
1026 ;; In Emacs 24.1 this defaults to the value of `mail-yank-prefix'
1027 ;; that defaults to:
1028 ;; `nil' in Emacs 22.1~23.1;
1029 ;; "> " in Emacs 23.2, 24.1, XEmacs 21.4, 21.5, and SXEmacs 22.1
1030 "*Prefix inserted on the lines of yanked messages.
1031 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1032 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
1035 :link
'(custom-manual "(message)Insertion Variables")
1036 :group
'message-insertion
)
1038 (defcustom message-yank-cited-prefix
">"
1039 "*Prefix inserted on cited lines of yanked messages.
1040 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1041 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1044 :link
'(custom-manual "(message)Insertion Variables")
1045 :group
'message-insertion
)
1047 (defcustom message-yank-empty-prefix
">"
1048 "*Prefix inserted on empty lines of yanked messages.
1049 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1052 :link
'(custom-manual "(message)Insertion Variables")
1053 :group
'message-insertion
)
1055 (defcustom message-indentation-spaces
3
1056 ;; In Emacs 24.1 this defaults to the value of
1057 ;; `mail-indentation-spaces' that defaults to `3' in Emacs 22.1~24.1,
1058 ;; and SXEmacs 22.1. In XEmacs 21.4 and 21.5, sendmail.el provides
1059 ;; it; the defalut value is `3'.
1060 "*Number of spaces to insert at the beginning of each cited line.
1061 Used by `message-yank-original' via `message-yank-cite'."
1063 :group
'message-insertion
1064 :link
'(custom-manual "(message)Insertion Variables")
1067 (defcustom message-cite-function
'message-cite-original-without-signature
1068 "*Function for citing an original message.
1069 Predefined functions include `message-cite-original' and
1070 `message-cite-original-without-signature'.
1071 Note that these functions use `mail-citation-hook' if that is non-nil."
1072 :type
'(radio (function-item message-cite-original
)
1073 (function-item message-cite-original-without-signature
)
1074 (function-item sc-cite-original
)
1075 (function :tag
"Other"))
1076 :link
'(custom-manual "(message)Insertion Variables")
1077 :version
"22.3" ;; Gnus 5.10.12 (changed default)
1078 :group
'message-insertion
)
1080 (defcustom message-indent-citation-function
'message-indent-citation
1081 "*Function for modifying a citation just inserted in the mail buffer.
1082 This can also be a list of functions. Each function can find the
1083 citation between (point) and (mark t). And each function should leave
1084 point and mark around the citation text as modified."
1086 :link
'(custom-manual "(message)Insertion Variables")
1087 :group
'message-insertion
)
1089 (defcustom message-signature t
1090 ;; In Emacs 24.1 this defaults to the value of `mail-signature' that
1092 ;; `nil' in Emacs 22.1~23.1, XEmacs 21.4, 21.5, and SXEmacs 22.1;
1093 ;; `t' in Emacs 23.2, and 24.1
1094 "*String to be inserted at the end of the message buffer.
1095 If t, the `message-signature-file' file will be inserted instead.
1096 If a function, the result from the function will be used instead.
1097 If a form, the result from the form will be used instead."
1100 :link
'(custom-manual "(message)Insertion Variables")
1101 :group
'message-insertion
)
1103 (defcustom message-signature-file
"~/.signature"
1104 ;; In Emacs 24.1 this defaults to the value of `mail-signature-file'
1105 ;; that defaults to "~/.signature" in Emacs 22.1~24.1, and SXEmacs
1106 ;; 22.1. In XEmacs 21.4 and 21.5, sendmail.el provides it;
1107 ;; the defalut value is "~/.signature".
1108 "*Name of file containing the text inserted at end of message buffer.
1109 Ignored if the named file doesn't exist.
1110 If nil, don't insert a signature.
1111 If a path is specified, the value of `message-signature-directory' is ignored,
1114 :type
'(choice file
(const :tags
"None" nil
))
1115 :link
'(custom-manual "(message)Insertion Variables")
1116 :group
'message-insertion
)
1118 (defcustom message-signature-directory nil
1119 "*Name of directory containing signature files.
1120 Comes in handy if you have many such files, handled via posting styles for
1122 If nil, `message-signature-file' is expected to specify the directory if
1124 :type
'(choice string
(const :tags
"None" nil
))
1125 :link
'(custom-manual "(message)Insertion Variables")
1126 :group
'message-insertion
)
1128 (defcustom message-signature-insert-empty-line t
1129 "*If non-nil, insert an empty line before the signature separator."
1132 :link
'(custom-manual "(message)Insertion Variables")
1133 :group
'message-insertion
)
1135 (defcustom message-distribution-function nil
1136 "*Function called to return a Distribution header."
1137 :group
'message-news
1138 :group
'message-headers
1139 :link
'(custom-manual "(message)News Headers")
1140 :type
'(choice function
(const nil
)))
1142 (defcustom message-expires
14
1143 "Number of days before your article expires."
1144 :group
'message-news
1145 :group
'message-headers
1146 :link
'(custom-manual "(message)News Headers")
1149 (defcustom message-user-path nil
1150 "If nil, use the NNTP server name in the Path header.
1151 If stringp, use this; if non-nil, use no host name (user name only)."
1152 :group
'message-news
1153 :group
'message-headers
1154 :link
'(custom-manual "(message)News Headers")
1155 :type
'(choice (const :tag
"nntp" nil
)
1156 (string :tag
"name")
1157 (sexp :tag
"none" :format
"%t" t
)))
1159 ;; This can be the name of a buffer, or a cons cell (FUNCTION . ARGS)
1160 ;; for yanking the original buffer.
1161 (defvar message-reply-buffer nil
)
1162 (defvar message-reply-headers nil
1163 "The headers of the current replied article.
1164 It is a vector of the following headers:
1165 \[number subject from date id references chars lines xref extra].")
1166 (defvar message-newsreader nil
)
1167 (defvar message-mailer nil
)
1168 (defvar message-sent-message-via nil
)
1169 (defvar message-checksum nil
)
1170 (defvar message-send-actions nil
1171 "A list of actions to be performed upon successful sending of a message.")
1172 (defvar message-exit-actions nil
1173 "A list of actions to be performed upon exiting after sending a message.")
1174 (defvar message-kill-actions nil
1175 "A list of actions to be performed before killing a message buffer.")
1176 (defvar message-postpone-actions nil
1177 "A list of actions to be performed after postponing a message.")
1179 (define-widget 'message-header-lines
'text
1180 "All header lines must be LFD terminated."
1181 :format
"%{%t%}:%n%v"
1182 :valid-regexp
"^\\'"
1183 :error
"All header lines must be newline terminated")
1185 (defcustom message-default-headers
""
1186 "Header lines to be inserted in outgoing messages.
1187 This can be set to a string containing or a function returning
1188 header lines to be inserted before you edit the message, so you
1189 can edit or delete these lines. If set to a function, it is
1190 called and its result is inserted."
1192 :group
'message-headers
1193 :link
'(custom-manual "(message)Message Headers")
1195 (message-header-lines :tag
"String")
1196 (function :tag
"Function")))
1198 (defcustom message-default-mail-headers
1199 ;; Ease the transition from mail-mode to message-mode. See bugs#4431, 5555.
1200 (concat (if (and (boundp 'mail-default-reply-to
)
1201 (stringp mail-default-reply-to
))
1202 (format "Reply-to: %s\n" mail-default-reply-to
))
1203 (if (and (boundp 'mail-self-blind
)
1205 (format "BCC: %s\n" user-mail-address
))
1206 (if (and (boundp 'mail-archive-file-name
)
1207 (stringp mail-archive-file-name
))
1208 (format "FCC: %s\n" mail-archive-file-name
))
1209 ;; Use the value of `mail-default-headers' if available.
1210 ;; Note: as for XEmacs 21.4 and 21.5, it is unavailable
1211 ;; unless sendmail.el is loaded.
1212 (if (boundp 'mail-default-headers
)
1213 mail-default-headers
))
1214 "*A string of header lines to be inserted in outgoing mails."
1216 :group
'message-headers
1217 :group
'message-mail
1218 :link
'(custom-manual "(message)Mail Headers")
1219 :type
'message-header-lines
)
1221 (defcustom message-default-news-headers
""
1222 "*A string of header lines to be inserted in outgoing news articles."
1223 :group
'message-headers
1224 :group
'message-news
1225 :link
'(custom-manual "(message)News Headers")
1226 :type
'message-header-lines
)
1228 ;; Note: could use /usr/ucb/mail instead of sendmail;
1229 ;; options -t, and -v if not interactive.
1230 (defcustom message-mailer-swallows-blank-line
1231 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1232 system-configuration
)
1233 (file-readable-p "/etc/sendmail.cf")
1234 (let ((buffer (get-buffer-create " *temp*")))
1236 (with-current-buffer buffer
1237 (insert-file-contents "/etc/sendmail.cf")
1238 (goto-char (point-min))
1239 (let ((case-fold-search nil
))
1240 (re-search-forward "^OR\\>" nil t
)))
1241 (kill-buffer buffer
))))
1242 ;; According to RFC822, "The field-name must be composed of printable
1243 ;; ASCII characters (i. e., characters that have decimal values between
1244 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1246 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1247 "*Set this non-nil if the system's mailer runs the header and body together.
1248 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1249 The value should be an expression to test whether the problem will
1251 :group
'message-sending
1252 :link
'(custom-manual "(message)Mail Variables")
1256 (define-mail-user-agent 'message-user-agent
1257 'message-mail
'message-send-and-exit
1258 'message-kill-buffer
'message-send-hook
)
1260 (defvar message-mh-deletable-headers
'(Message-ID Date Lines Sender
)
1261 "If non-nil, delete the deletable headers before feeding to mh.")
1263 (defvar message-send-method-alist
1264 '((news message-news-p message-send-via-news
)
1265 (mail message-mail-p message-send-via-mail
))
1266 "Alist of ways to send outgoing messages.
1267 Each element has the form
1269 \(TYPE PREDICATE FUNCTION)
1271 where TYPE is a symbol that names the method; PREDICATE is a function
1272 called without any parameters to determine whether the message is
1273 a message of type TYPE; and FUNCTION is a function to be called if
1274 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1277 (defcustom message-mail-alias-type
'abbrev
1278 "*What alias expansion type to use in Message buffers.
1279 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1280 an electric completion mode. nil switches mail aliases off.
1281 This can also be a list of values."
1283 :link
'(custom-manual "(message)Mail Aliases")
1284 :type
'(choice (const :tag
"Use Mailabbrev" abbrev
)
1285 (const :tag
"Use ecomplete" ecomplete
)
1286 (const :tag
"No expansion" nil
)))
1288 (defcustom message-self-insert-commands
'(self-insert-command)
1289 "List of `self-insert-command's used to trigger ecomplete.
1290 When one of those commands is invoked to enter a character in To or Cc
1291 header, ecomplete will suggest the candidates of recipients (see also
1292 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1293 text and it replaces `self-insert-command' with the other command, e.g.
1294 `egg-self-insert-command', you may want to add it to this list."
1295 :group
'message-various
1296 :type
'(repeat function
))
1298 (defcustom message-auto-save-directory
1299 (file-name-as-directory (expand-file-name "drafts" message-directory
))
1300 "*Directory where Message auto-saves buffers if Gnus isn't running.
1301 If nil, Message won't auto-save."
1302 :group
'message-buffers
1303 :link
'(custom-manual "(message)Various Message Variables")
1304 :type
'(choice directory
(const :tag
"Don't auto-save" nil
)))
1306 (defcustom message-default-charset
1307 (and (not (mm-multibyte-p)) 'iso-8859-1
)
1308 "Default charset used in non-MULE Emacsen.
1309 If nil, you might be asked to input the charset."
1312 :link
'(custom-manual "(message)Various Message Variables")
1315 (defcustom message-dont-reply-to-names
1316 (and (boundp 'rmail-dont-reply-to-names
) rmail-dont-reply-to-names
)
1317 "*Addresses to prune when doing wide replies.
1318 This can be a regexp or a list of regexps. Also, a value of nil means
1319 exclude your own user name only."
1322 :link
'(custom-manual "(message)Wide Reply")
1323 :type
'(choice (const :tag
"Yourself" nil
)
1325 (repeat :tag
"Regexp List" regexp
)))
1327 (defsubst message-dont-reply-to-names
()
1328 (gmm-regexp-concat message-dont-reply-to-names
))
1330 (defvar message-shoot-gnksa-feet nil
1331 "*A list of GNKSA feet you are allowed to shoot.
1332 Gnus gives you all the opportunity you could possibly want for
1333 shooting yourself in the foot. Also, Gnus allows you to shoot the
1334 feet of Good Net-Keeping Seal of Approval. The following are foot
1336 `empty-article' Allow you to post an empty article;
1337 `quoted-text-only' Allow you to post quoted text only;
1338 `multiple-copies' Allow you to post multiple copies;
1339 `cancel-messages' Allow you to cancel or supersede messages from
1340 your other email addresses.")
1342 (defsubst message-gnksa-enable-p
(feature)
1343 (or (not (listp message-shoot-gnksa-feet
))
1344 (memq feature message-shoot-gnksa-feet
)))
1346 (defcustom message-hidden-headers
'("^References:" "^Face:" "^X-Face:"
1348 "Regexp of headers to be hidden when composing new messages.
1349 This can also be a list of regexps to match headers. Or a list
1350 starting with `not' and followed by regexps."
1353 :link
'(custom-manual "(message)Message Headers")
1355 :format
"%{%t%}: %[Value Type%] %v"
1356 (regexp :menu-tag
"regexp" :format
"regexp\n%t: %v")
1357 (repeat :menu-tag
"(regexp ...)" :format
"(regexp ...)\n%v%i"
1358 (regexp :format
"%t: %v"))
1359 (cons :menu-tag
"(not regexp ...)" :format
"(not regexp ...)\n%v"
1361 (repeat :format
"%v%i"
1362 (regexp :format
"%t: %v")))))
1364 (defcustom message-cite-articles-with-x-no-archive t
1365 "If non-nil, cite text from articles that has X-No-Archive set."
1369 ;;; Internal variables.
1370 ;;; Well, not really internal.
1372 (defvar message-mode-syntax-table
1373 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1374 (modify-syntax-entry ?%
". " table
)
1375 (modify-syntax-entry ?
> ". " table
)
1376 (modify-syntax-entry ?
< ". " table
)
1378 "Syntax table used while in Message mode.")
1380 (defface message-header-to
1383 (:foreground
"DarkOliveGreen1" :bold t
))
1386 (:foreground
"MidnightBlue" :bold t
))
1388 (:bold t
:italic t
)))
1389 "Face used for displaying From headers."
1390 :group
'message-faces
)
1391 ;; backward-compatibility alias
1392 (put 'message-header-to-face
'face-alias
'message-header-to
)
1393 (put 'message-header-to-face
'obsolete-face
"22.1")
1395 (defface message-header-cc
1398 (:foreground
"chartreuse1" :bold t
))
1401 (:foreground
"MidnightBlue"))
1404 "Face used for displaying Cc headers."
1405 :group
'message-faces
)
1406 ;; backward-compatibility alias
1407 (put 'message-header-cc-face
'face-alias
'message-header-cc
)
1408 (put 'message-header-cc-face
'obsolete-face
"22.1")
1410 (defface message-header-subject
1413 (:foreground
"OliveDrab1"))
1416 (:foreground
"navy blue" :bold t
))
1419 "Face used for displaying subject headers."
1420 :group
'message-faces
)
1421 ;; backward-compatibility alias
1422 (put 'message-header-subject-face
'face-alias
'message-header-subject
)
1423 (put 'message-header-subject-face
'obsolete-face
"22.1")
1425 (defface message-header-newsgroups
1428 (:foreground
"yellow" :bold t
:italic t
))
1431 (:foreground
"blue4" :bold t
:italic t
))
1433 (:bold t
:italic t
)))
1434 "Face used for displaying newsgroups headers."
1435 :group
'message-faces
)
1436 ;; backward-compatibility alias
1437 (put 'message-header-newsgroups-face
'face-alias
'message-header-newsgroups
)
1438 (put 'message-header-newsgroups-face
'obsolete-face
"22.1")
1440 (defface message-header-other
1443 (:foreground
"VioletRed1"))
1446 (:foreground
"steel blue"))
1448 (:bold t
:italic t
)))
1449 "Face used for displaying newsgroups headers."
1450 :group
'message-faces
)
1451 ;; backward-compatibility alias
1452 (put 'message-header-other-face
'face-alias
'message-header-other
)
1453 (put 'message-header-other-face
'obsolete-face
"22.1")
1455 (defface message-header-name
1458 (:foreground
"green"))
1461 (:foreground
"cornflower blue"))
1464 "Face used for displaying header names."
1465 :group
'message-faces
)
1466 ;; backward-compatibility alias
1467 (put 'message-header-name-face
'face-alias
'message-header-name
)
1468 (put 'message-header-name-face
'obsolete-face
"22.1")
1470 (defface message-header-xheader
1473 (:foreground
"DeepSkyBlue1"))
1476 (:foreground
"blue"))
1479 "Face used for displaying X-Header headers."
1480 :group
'message-faces
)
1481 ;; backward-compatibility alias
1482 (put 'message-header-xheader-face
'face-alias
'message-header-xheader
)
1483 (put 'message-header-xheader-face
'obsolete-face
"22.1")
1485 (defface message-separator
1488 (:foreground
"LightSkyBlue1"))
1491 (:foreground
"brown"))
1494 "Face used for displaying the separator."
1495 :group
'message-faces
)
1496 ;; backward-compatibility alias
1497 (put 'message-separator-face
'face-alias
'message-separator
)
1498 (put 'message-separator-face
'obsolete-face
"22.1")
1500 (defface message-cited-text
1503 (:foreground
"LightPink1"))
1506 (:foreground
"red"))
1509 "Face used for displaying cited text names."
1510 :group
'message-faces
)
1511 ;; backward-compatibility alias
1512 (put 'message-cited-text-face
'face-alias
'message-cited-text
)
1513 (put 'message-cited-text-face
'obsolete-face
"22.1")
1515 (defface message-mml
1518 (:foreground
"MediumSpringGreen"))
1521 (:foreground
"ForestGreen"))
1524 "Face used for displaying MML."
1525 :group
'message-faces
)
1526 ;; backward-compatibility alias
1527 (put 'message-mml-face
'face-alias
'message-mml
)
1528 (put 'message-mml-face
'obsolete-face
"22.1")
1530 (defun message-font-lock-make-header-matcher (regexp)
1533 (let ((start (point)))
1536 (goto-char (point-min))
1537 (if (re-search-forward
1538 (concat "^" (regexp-quote mail-header-separator
) "$")
1540 (setq limit
(min limit
(match-beginning 0))))
1542 (and (< start limit
)
1543 (re-search-forward ,regexp limit t
))))))
1544 (if (featurep 'bytecomp
)
1548 (defvar message-font-lock-keywords
1549 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1550 `((,(message-font-lock-make-header-matcher
1551 (concat "^\\([Tt]o:\\)" content
))
1552 (1 'message-header-name
)
1553 (2 'message-header-to nil t
))
1554 (,(message-font-lock-make-header-matcher
1555 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content
))
1556 (1 'message-header-name
)
1557 (2 'message-header-cc nil t
))
1558 (,(message-font-lock-make-header-matcher
1559 (concat "^\\([Ss]ubject:\\)" content
))
1560 (1 'message-header-name
)
1561 (2 'message-header-subject nil t
))
1562 (,(message-font-lock-make-header-matcher
1563 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content
))
1564 (1 'message-header-name
)
1565 (2 'message-header-newsgroups nil t
))
1566 (,(message-font-lock-make-header-matcher
1567 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content
))
1568 (1 'message-header-name
)
1569 (2 'message-header-xheader
))
1570 (,(message-font-lock-make-header-matcher
1571 (concat "^\\([A-Z][^: \n\t]+:\\)" content
))
1572 (1 'message-header-name
)
1573 (2 'message-header-other nil t
))
1574 ,@(if (and mail-header-separator
1575 (not (equal mail-header-separator
"")))
1576 `((,(concat "^\\(" (regexp-quote mail-header-separator
) "\\)$")
1577 1 'message-separator
))
1580 (re-search-forward (concat "^\\("
1581 message-cite-prefix-regexp
1584 (0 'message-cited-text
))
1585 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1587 "Additional expressions to highlight in Message mode.")
1590 ;; XEmacs does it like this. For Emacs, we have to set the
1591 ;; `font-lock-defaults' buffer-local variable.
1592 (put 'message-mode
'font-lock-defaults
'(message-font-lock-keywords t
))
1594 (defvar message-face-alist
1595 '((bold . message-bold-region
)
1596 (underline . underline-region
)
1597 (default .
(lambda (b e
)
1598 (message-unbold-region b e
)
1599 (ununderline-region b e
))))
1600 "Alist of mail and news faces for facemenu.
1601 The cdr of each entry is a function for applying the face to a region.")
1603 (defcustom message-send-hook nil
1604 "Hook run before sending messages.
1605 This hook is run quite early when sending."
1606 :group
'message-various
1607 :options
'(ispell-message)
1608 :link
'(custom-manual "(message)Various Message Variables")
1611 (defcustom message-send-mail-hook nil
1612 "Hook run before sending mail messages.
1613 This hook is run very late -- just before the message is sent as
1615 :group
'message-various
1616 :link
'(custom-manual "(message)Various Message Variables")
1619 (defcustom message-send-news-hook nil
1620 "Hook run before sending news messages.
1621 This hook is run very late -- just before the message is sent as
1623 :group
'message-various
1624 :link
'(custom-manual "(message)Various Message Variables")
1627 (defcustom message-sent-hook nil
1628 "Hook run after sending messages."
1629 :group
'message-various
1632 (defvar message-send-coding-system
'binary
1633 "Coding system to encode outgoing mail.")
1635 (defvar message-draft-coding-system
1636 mm-auto-save-coding-system
1637 "*Coding system to compose mail.
1638 If you'd like to make it possible to share draft files between XEmacs
1639 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1640 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1642 (defcustom message-send-mail-partially-limit nil
1643 "The limitation of messages sent as message/partial.
1644 The lower bound of message size in characters, beyond which the message
1645 should be sent in several parts. If it is nil, the size is unlimited."
1647 :group
'message-buffers
1648 :link
'(custom-manual "(message)Mail Variables")
1649 :type
'(choice (const :tag
"unlimited" nil
)
1652 (defcustom message-alternative-emails nil
1653 "*Regexp matching alternative email addresses.
1654 The first address in the To, Cc or From headers of the original
1655 article matching this variable is used as the From field of
1658 This variable has precedence over posting styles and anything that runs
1659 off `message-setup-hook'."
1660 :group
'message-headers
1661 :link
'(custom-manual "(message)Message Headers")
1662 :type
'(choice (const :tag
"Always use primary" nil
)
1665 (defcustom message-hierarchical-addresses nil
1666 "A list of hierarchical mail address definitions.
1668 Inside each entry, the first address is the \"top\" address, and
1669 subsequent addresses are subaddresses; this is used to indicate that
1670 mail sent to the first address will automatically be delivered to the
1671 subaddresses. So if the first address appears in the recipient list
1672 for a message, the subaddresses will be removed (if present) before
1673 the mail is sent. All addresses in this structure should be
1676 :group
'message-headers
1677 :type
'(repeat (repeat string
)))
1679 (defcustom message-mail-user-agent nil
1680 "Like `mail-user-agent'.
1681 Except if it is nil, use Gnus native MUA; if it is t, use
1684 :type
'(radio (const :tag
"Gnus native"
1687 (const :tag
"`mail-user-agent'"
1690 (function-item :tag
"Default Emacs mail"
1692 sendmail-user-agent
)
1693 (function-item :tag
"Emacs interface to MH"
1696 (function :tag
"Other"))
1700 (defcustom message-wide-reply-confirm-recipients nil
1701 "Whether to confirm a wide reply to multiple email recipients.
1702 If this variable is nil, don't ask whether to reply to all recipients.
1703 If this variable is non-nil, pose the question \"Reply to all
1704 recipients?\" before a wide reply to multiple recipients. If the user
1705 answers yes, reply to all recipients as usual. If the user answers
1706 no, only reply back to the author."
1708 :group
'message-headers
1709 :link
'(custom-manual "(message)Wide Reply")
1712 (defcustom message-user-fqdn nil
1713 "*Domain part of Message-Ids."
1715 :group
'message-headers
1716 :link
'(custom-manual "(message)News Headers")
1717 :type
'(radio (const :format
"%v " nil
)
1718 (string :format
"FQDN: %v")))
1720 (defcustom message-use-idna
(and (condition-case nil
(require 'idna
)
1722 (mm-coding-system-p 'utf-8
)
1723 (executable-find idna-program
)
1724 (string= (idna-to-ascii "räksmörgås")
1725 "xn--rksmrgs-5wao1o")
1727 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1728 GNU Libidn, and in particular the elisp package \"idna.el\" and
1729 the external program \"idn\", must be installed for this
1730 functionality to work."
1732 :group
'message-headers
1733 :link
'(custom-manual "(message)IDNA")
1734 :type
'(choice (const :tag
"Ask" ask
)
1735 (const :tag
"Never" nil
)
1736 (const :tag
"Always" t
)))
1738 (defcustom message-generate-hashcash
(if (executable-find "hashcash") 'opportunistic
)
1739 "*Whether to generate X-Hashcash: headers.
1740 If t, always generate hashcash headers. If `opportunistic',
1741 only generate hashcash headers if it can be done without the user
1742 waiting (i.e., only asynchronously).
1744 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1746 :group
'message-headers
1747 :link
'(custom-manual "(message)Mail Headers")
1748 :type
'(choice (const :tag
"Always" t
)
1749 (const :tag
"Never" nil
)
1750 (const :tag
"Opportunistic" opportunistic
)))
1752 ;;; Internal variables.
1754 (defvar message-sending-message
"Sending...")
1755 (defvar message-buffer-list nil
)
1756 (defvar message-this-is-news nil
)
1757 (defvar message-this-is-mail nil
)
1758 (defvar message-draft-article nil
)
1759 (defvar message-mime-part nil
)
1760 (defvar message-posting-charset nil
)
1761 (defvar message-inserted-headers nil
)
1762 (defvar message-inhibit-ecomplete nil
)
1764 ;; Byte-compiler warning
1765 (defvar gnus-active-hashtb
)
1766 (defvar gnus-read-active-file
)
1768 ;;; Regexp matching the delimiter of messages in UNIX mail format
1769 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1770 ;;; of rmail.el's rmail-unix-mail-delimiter.
1771 (defvar message-unix-mail-delimiter
1772 (let ((time-zone-regexp
1773 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1774 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1780 ;; Many things can happen to an RFC 822 mailbox before it is put into
1781 ;; a `From' line. The leading phrase can be stripped, e.g.
1782 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1783 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1784 ;; can be removed, e.g.
1785 ;; From: joe@y.z (Joe K
1787 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1790 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1791 ;; The mailbox can be removed or be replaced by white space, e.g.
1792 ;; From: "Joe User"{space}{tab}
1794 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1795 ;; where {space} and {tab} represent the Ascii space and tab characters.
1796 ;; We want to match the results of any of these manglings.
1797 ;; The following regexp rejects names whose first characters are
1798 ;; obviously bogus, but after that anything goes.
1799 "\\([^\0-\b\n-\r\^?].*\\)?"
1801 ;; The time the message was sent.
1802 "\\([^\0-\r \^?]+\\) +" ; day of the week
1803 "\\([^\0-\r \^?]+\\) +" ; month
1804 "\\([0-3]?[0-9]\\) +" ; day of month
1805 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1807 ;; Perhaps a time zone, specified by an abbreviation, or by a
1812 " \\([0-9][0-9]+\\) *"
1814 ;; On some systems the time zone can appear after the year, too.
1818 "\\(remote from .*\\)?"
1821 "Regexp matching the delimiter of messages in UNIX mail format.")
1823 (defvar message-unsent-separator
1824 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1825 "^ *---+ +Returned message +---+ *$\\|"
1826 "^Start of returned message$\\|"
1827 "^ *---+ +Original message +---+ *$\\|"
1828 "^ *--+ +begin message +--+ *$\\|"
1829 "^ *---+ +Original message follows +---+ *$\\|"
1830 "^ *---+ +Undelivered message follows +---+ *$\\|"
1831 "^------ This is a copy of the message, including all the headers. ------ *$\\|"
1832 "^|? *---+ +Message text follows: +---+ *|?$")
1833 "A regexp that matches the separator before the text of a failed message.")
1835 (defvar message-field-fillers
1836 '((To message-fill-field-address
)
1837 (Cc message-fill-field-address
)
1838 (From message-fill-field-address
))
1839 "Alist of header names/filler functions.")
1841 (defvar message-header-format-alist
1856 (References . message-shorten-references
)
1858 "Alist used for formatting headers.")
1860 (defvar message-options nil
1861 "Some saved answers when sending message.")
1863 (defvar message-send-mail-real-function nil
1864 "Internal send mail function.")
1866 (defvar message-bogus-system-names
"^localhost\\.\\|\\.local$"
1867 "The regexp of bogus system names.")
1869 (defcustom message-valid-fqdn-regexp
1870 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1872 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1873 "aero\\|arpa\\|bitnet\\|biz\\|bofh\\|"
1874 "cat\\|com\\|coop\\|edu\\|gov\\|"
1875 "info\\|int\\|jobs\\|"
1876 "mil\\|mobi\\|museum\\|name\\|net\\|"
1877 "org\\|pro\\|travel\\|uucp\\)")
1878 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1879 ;; http://en.wikipedia.org/wiki/GTLD
1880 ;; `in the process of being approved': .asia .post .tel .sex
1881 ;; "dead" nato bitnet uucp
1882 "Regular expression that matches a valid FQDN."
1883 ;; see also: gnus-button-valid-fqdn-regexp
1885 :group
'message-headers
1888 (autoload 'gnus-alive-p
"gnus-util")
1889 (autoload 'gnus-delay-article
"gnus-delay")
1890 (autoload 'gnus-extract-address-components
"gnus-util")
1891 (autoload 'gnus-find-method-for-group
"gnus")
1892 (autoload 'gnus-group-decoded-name
"gnus-group")
1893 (autoload 'gnus-group-name-charset
"gnus-group")
1894 (autoload 'gnus-group-name-decode
"gnus-group")
1895 (autoload 'gnus-groups-from-server
"gnus")
1896 (autoload 'gnus-make-local-hook
"gnus-util")
1897 (autoload 'gnus-open-server
"gnus-int")
1898 (autoload 'gnus-output-to-mail
"gnus-util")
1899 (autoload 'gnus-output-to-rmail
"gnus-util")
1900 (autoload 'gnus-request-post
"gnus-int")
1901 (autoload 'gnus-select-frame-set-input-focus
"gnus-util")
1902 (autoload 'gnus-server-string
"gnus")
1903 (autoload 'idna-to-ascii
"idna")
1904 (autoload 'message-setup-toolbar
"messagexmas")
1905 (autoload 'mh-new-draft-name
"mh-comp")
1906 (autoload 'mh-send-letter
"mh-comp")
1907 (autoload 'nndraft-request-associate-buffer
"nndraft")
1908 (autoload 'nndraft-request-expire-articles
"nndraft")
1909 (autoload 'nnvirtual-find-group-art
"nnvirtual")
1910 (autoload 'rmail-dont-reply-to
"mail-utils")
1911 (autoload 'rmail-msg-is-pruned
"rmail")
1912 (autoload 'rmail-output
"rmailout")
1917 ;;; Utility functions.
1920 (defmacro message-y-or-n-p
(question show
&rest text
)
1921 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1922 `(message-talkative-question 'y-or-n-p
,question
,show
,@text
))
1924 (defmacro message-delete-line
(&optional n
)
1925 "Delete the current line (and the next N lines)."
1926 `(delete-region (progn (beginning-of-line) (point))
1927 (progn (forward-line ,(or n
1)) (point))))
1929 (defun message-mark-active-p ()
1930 "Non-nil means the mark and region are currently active in this buffer."
1933 (defun message-unquote-tokens (elems)
1934 "Remove double quotes (\") from strings in list ELEMS."
1935 (mapcar (lambda (item)
1936 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item
)
1937 (setq item
(concat (match-string 1 item
)
1938 (match-string 2 item
))))
1942 (defun message-tokenize-header (header &optional separator
)
1943 "Split HEADER into a list of header elements.
1944 SEPARATOR is a string of characters to be used as separators. \",\"
1945 is used by default."
1948 (let ((regexp (format "[%s]+" (or separator
",")))
1950 beg quoted elems paren
)
1952 (mm-enable-multibyte)
1953 (setq beg
(point-min))
1955 (goto-char (point-min))
1960 (cond ((and (> (point) beg
)
1962 (and (looking-at regexp
)
1965 (push (buffer-substring beg
(point)) elems
)
1966 (setq beg
(match-end 0)))
1967 ((eq (char-after) ?
\")
1968 (setq quoted
(not quoted
)))
1969 ((and (eq (char-after) ?\
()
1972 ((and (eq (char-after) ?\
))
1975 (nreverse elems
)))))
1977 (autoload 'nnheader-insert-file-contents
"nnheader")
1979 (defun message-mail-file-mbox-p (file)
1980 "Say whether FILE looks like a Unix mbox file."
1981 (when (and (file-exists-p file
)
1982 (file-readable-p file
)
1983 (file-regular-p file
))
1985 (nnheader-insert-file-contents file
)
1986 (goto-char (point-min))
1987 (looking-at message-unix-mail-delimiter
))))
1989 (defun message-fetch-field (header &optional not-all
)
1990 "The same as `mail-fetch-field', only remove all newlines.
1991 The buffer is expected to be narrowed to just the header of the message;
1992 see `message-narrow-to-headers-or-head'."
1993 (let* ((inhibit-point-motion-hooks t
)
1994 (value (mail-fetch-field header nil
(not not-all
))))
1996 (while (string-match "\n[\t ]+" value
)
1997 (setq value
(replace-match " " t t value
)))
2000 (defun message-field-value (header &optional not-all
)
2001 "The same as `message-fetch-field', only narrow to the headers first."
2004 (message-narrow-to-headers-or-head)
2005 (message-fetch-field header not-all
))))
2007 (defun message-narrow-to-field ()
2008 "Narrow the buffer to the header on the current line."
2010 (while (looking-at "[ \t]")
2016 (if (re-search-forward "^[^ \n\t]" nil t
)
2019 (goto-char (point-min)))
2021 (defun message-add-header (&rest headers
)
2022 "Add the HEADERS to the message header, skipping those already present."
2025 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers
))
2026 (error "Invalid header `%s'" (car headers
)))
2027 (setq hclean
(match-string 1 (car headers
)))
2029 (message-narrow-to-headers)
2030 (unless (re-search-forward (concat "^" (regexp-quote hclean
) ":") nil t
)
2031 (goto-char (point-max))
2032 (if (string-match "\n$" (car headers
))
2033 (insert (car headers
))
2034 (insert (car headers
) ?
\n)))))
2035 (setq headers
(cdr headers
))))
2037 (defmacro message-with-reply-buffer
(&rest forms
)
2038 "Evaluate FORMS in the reply buffer, if it exists."
2039 `(when (and (bufferp message-reply-buffer
)
2040 (buffer-name message-reply-buffer
))
2041 (with-current-buffer message-reply-buffer
2044 (put 'message-with-reply-buffer
'lisp-indent-function
0)
2045 (put 'message-with-reply-buffer
'edebug-form-spec
'(body))
2047 (defun message-fetch-reply-field (header)
2048 "Fetch field HEADER from the message we're replying to."
2049 (message-with-reply-buffer
2051 (mail-narrow-to-head)
2052 (message-fetch-field header
))))
2054 (defun message-strip-list-identifiers (subject)
2055 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
2056 (require 'gnus-sum
) ; for gnus-list-identifiers
2057 (let ((regexp (if (stringp gnus-list-identifiers
)
2058 gnus-list-identifiers
2059 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
2060 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
2061 " *\\)\\)+\\(Re: +\\)?\\)") subject
)
2062 (concat (substring subject
0 (match-beginning 1))
2063 (or (match-string 3 subject
)
2064 (match-string 5 subject
))
2069 (defun message-strip-subject-re (subject)
2070 "Remove \"Re:\" from subject lines in string SUBJECT."
2071 (if (string-match message-subject-re-regexp subject
)
2072 (substring subject
(match-end 0))
2075 (defcustom message-replacement-char
"."
2076 "Replacement character used instead of unprintable or not decodable chars."
2077 :group
'message-various
2078 :version
"22.1" ;; Gnus 5.10.9
2079 :type
'(choice string
2083 ;; FIXME: We also should call `message-strip-subject-encoded-words'
2084 ;; when forwarding. Probably in `message-make-forward-subject' and
2085 ;; `message-forward-make-body'.
2087 (defun message-strip-subject-encoded-words (subject)
2088 "Fix non-decodable words in SUBJECT."
2089 ;; Cf. `gnus-simplify-subject-fully'.
2090 (let* ((case-fold-search t
)
2091 (replacement-chars (format "[%s%s%s]"
2092 message-replacement-char
2093 message-replacement-char
2094 message-replacement-char
))
2095 (enc-word-re "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?\\([^?]+\\)\\(\\?=\\)")
2100 (goto-char (point-min))
2101 (when (re-search-forward enc-word-re nil t
)
2102 (setq cs-string
(match-string 1)))))
2103 cs-coding q-or-b word-beg word-end
)
2104 (if (or (not have-marker
) ;; No encoded word found...
2105 ;; ... or double encoding was correct:
2106 (and (stringp cs-string
)
2107 (setq cs-string
(downcase cs-string
))
2108 (mm-coding-system-p (intern cs-string
))
2112 Decoded Subject \"%s\"
2113 contains a valid encoded word. Decode again? "
2115 (setq cs-coding
(intern cs-string
))))))
2119 (goto-char (point-min))
2120 (while (re-search-forward enc-word-re nil t
)
2121 (setq cs-string
(downcase (match-string 1))
2122 q-or-b
(match-string 2)
2123 word-beg
(match-beginning 0)
2124 word-end
(match-end 0))
2126 (if (mm-coding-system-p (intern cs-string
))
2127 (setq cs-coding
(intern cs-string
))
2129 ;; No double encoded subject? => bogus charset.
2132 (mm-read-coding-system
2134 Decoded Subject \"%s\"
2135 contains an encoded word. The charset `%s' is unknown or invalid.
2136 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
2138 subject cs-string message-replacement-char
)))
2140 (replace-match (concat "=?" (symbol-name cs-coding
)
2143 (goto-char word-beg
)
2144 (re-search-forward "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?" word-end t
)
2147 (if (string-match "\\`Q\\'" q-or-b
)
2150 (message "Replacing non-decodable characters with \"%s\"."
2151 message-replacement-char
)
2152 (while (re-search-forward "\\(=[A-F0-9][A-F0-9]\\)+"
2154 (replace-match message-replacement-char
)))
2156 (message "Replacing non-decodable characters with \"%s\"."
2158 (re-search-forward "[^?]+" word-end t
)
2159 (replace-match replacement-chars
))
2160 (re-search-forward "\\?=")
2161 (replace-match "")))))
2162 (rfc2047-decode-region (point-min) (point-max))
2165 ;;; Start of functions adopted from `message-utils.el'.
2167 (defun message-strip-subject-trailing-was (subject)
2168 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
2169 Leading \"Re: \" is not stripped by this function. Use the function
2170 `message-strip-subject-re' for this."
2171 (let* ((query message-subject-trailing-was-query
)
2176 message-subject-trailing-was-ask-regexp
2177 message-subject-trailing-was-regexp
)
2180 (setq new
(substring subject
0 (match-beginning 0))))
2181 (if (or (not found
) (eq query nil
))
2184 (if (message-y-or-n-p
2185 "Strip `(was: <old subject>)' in subject? " t
2187 "Strip `(was: <old subject>)' in subject "
2188 "and use the new one instead?\n\n"
2189 "Current subject is: \""
2191 "New subject would be: \""
2193 "See the variable `message-subject-trailing-was-query' "
2194 "to get rid of this query."
2199 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
2201 (defun message-change-subject (new-subject)
2202 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
2205 (read-from-minibuffer "New subject: ")))
2206 (cond ((and (not (or (null new-subject
) ; new subject not empty
2207 (zerop (string-width new-subject
))
2208 (string-match "^[ \t]*$" new-subject
))))
2212 (message-narrow-to-headers)
2213 (message-fetch-field "Subject"))))
2214 (cond ((not old-subject
)
2215 (error "No current subject"))
2218 (regexp-quote new-subject
)
2220 old-subject
)) ; yes, it really is a new subject
2221 ;; delete eventual Re: prefix
2223 (message-strip-subject-re old-subject
))
2224 (message-goto-subject)
2225 (message-delete-line)
2226 (insert (concat "Subject: "
2229 old-subject
")\n")))))))))
2231 (defun message-mark-inserted-region (beg end
&optional verbatim
)
2232 "Mark some region in the current article with enclosing tags.
2233 See `message-mark-insert-begin' and `message-mark-insert-end'.
2234 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2235 (interactive "r\nP")
2237 ;; add to the end of the region first, otherwise end would be invalid
2239 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2241 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2243 (defun message-mark-insert-file (file &optional verbatim
)
2244 "Insert FILE at point, marking it with enclosing tags.
2245 See `message-mark-insert-begin' and `message-mark-insert-end'.
2246 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2247 (interactive "fFile to insert: \nP")
2248 ;; reverse insertion to get correct result.
2250 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2252 (insert-file-contents file
)
2254 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2256 (defun message-add-archive-header ()
2257 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
2258 The note can be customized using `message-archive-note'. When called with a
2259 prefix argument, ask for a text to insert. If you don't want the note in the
2260 body, set `message-archive-note' to nil."
2262 (if current-prefix-arg
2263 (setq message-archive-note
2264 (read-from-minibuffer "Reason for No-Archive: "
2265 (cons message-archive-note
0))))
2267 (if (message-goto-signature)
2268 (re-search-backward message-signature-separator
))
2269 (when message-archive-note
2270 (insert message-archive-note
)
2272 (message-add-header message-archive-header
)
2273 (message-sort-headers)))
2275 (defun message-cross-post-followup-to-header (target-group)
2276 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2277 With prefix-argument just set Follow-Up, don't cross-post."
2279 (list ; Completion based on Gnus
2280 (completing-read "Followup To: "
2281 (if (boundp 'gnus-newsrc-alist
)
2283 nil nil
'("poster" .
0)
2284 (if (boundp 'gnus-group-history
)
2285 'gnus-group-history
))))
2286 (message-remove-header "Follow[Uu]p-[Tt]o" t
)
2287 (message-goto-newsgroups)
2289 ;; if we already did a crosspost before, kill old target
2290 (if (and message-cross-post-old-target
2292 (regexp-quote (concat "," message-cross-post-old-target
))
2295 ;; unless (followup is to poster or user explicitly asked not
2296 ;; to cross-post, or target-group is already in Newsgroups)
2297 ;; add target-group to Newsgroups line.
2299 ;; def: cross-post, req:no
2300 (and message-cross-post-default
(not current-prefix-arg
))
2301 ;; def: no-cross-post, req:yes
2302 (and (not message-cross-post-default
) current-prefix-arg
))
2303 (not (string-match "poster" target-group
))
2304 (not (string-match (regexp-quote target-group
)
2305 (message-fetch-field "Newsgroups"))))
2307 (insert (concat "," target-group
))))
2308 (end-of-line) ; ensure Followup: comes after Newsgroups:
2309 ;; unless new followup would be identical to Newsgroups line
2310 ;; make a new Followup-To line
2311 (if (not (string-match (concat "^[ \t]*"
2314 (message-fetch-field "Newsgroups")))
2315 (insert (concat "\nFollowup-To: " target-group
)))
2316 (setq message-cross-post-old-target target-group
))
2318 (defun message-cross-post-insert-note (target-group cross-post in-old
2320 "Insert a in message body note about a set Followup or Crosspost.
2321 If there have been previous notes, delete them. TARGET-GROUP specifies the
2322 group to Followup-To. When CROSS-POST is t, insert note about
2323 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2324 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2325 been made to before the user asked for a Crosspost."
2326 ;; start scanning body for previous uses
2327 (message-goto-signature)
2328 (let ((head (re-search-backward
2329 (concat "^" mail-header-separator
)
2330 nil t
))) ; just search in body
2331 (message-goto-signature)
2332 (while (re-search-backward
2333 (concat "^" (regexp-quote message-cross-post-note
) ".*")
2335 (message-delete-line))
2336 (message-goto-signature)
2337 (while (re-search-backward
2338 (concat "^" (regexp-quote message-followup-to-note
) ".*")
2340 (message-delete-line))
2342 (if (message-goto-signature)
2343 (re-search-backward message-signature-separator
))
2346 (string-match "^[ \t]*poster[ \t]*$" target-group
))
2347 (insert (concat message-followup-to-note target-group
"\n"))
2348 (insert (concat message-cross-post-note target-group
"\n")))))
2350 (defun message-cross-post-followup-to (target-group)
2351 "Crossposts message and set Followup-To to TARGET-GROUP.
2352 With prefix-argument just set Follow-Up, don't cross-post."
2354 (list ; Completion based on Gnus
2355 (completing-read "Followup To: "
2356 (if (boundp 'gnus-newsrc-alist
)
2358 nil nil
'("poster" .
0)
2359 (if (boundp 'gnus-group-history
)
2360 'gnus-group-history
))))
2361 (cond ((not (or (null target-group
) ; new subject not empty
2362 (zerop (string-width target-group
))
2363 (string-match "^[ \t]*$" target-group
)))
2365 (let* ((old-groups (message-fetch-field "Newsgroups"))
2366 (in-old (string-match
2367 (regexp-quote target-group
)
2368 (or old-groups
""))))
2369 ;; check whether target exactly matches old Newsgroups
2370 (cond ((not old-groups
)
2371 (error "No current newsgroup"))
2375 (regexp-quote target-group
)
2378 ;; yes, Newsgroups line must change
2379 (message-cross-post-followup-to-header target-group
)
2380 ;; insert note whether we do cross-post or followup-to
2381 (funcall message-cross-post-note-function
2383 (if (or (and message-cross-post-default
2384 (not current-prefix-arg
))
2385 (and (not message-cross-post-default
)
2386 current-prefix-arg
)) t
)
2387 in-old old-groups
))))))))
2389 ;;; Reduce To: to Cc: or Bcc: header
2391 (defun message-reduce-to-to-cc ()
2392 "Replace contents of To: header with contents of Cc: or Bcc: header."
2395 (save-restriction (message-narrow-to-headers)
2396 (message-fetch-field "cc")))
2398 (if (and (not cc-content
)
2401 (message-narrow-to-headers)
2402 (message-fetch-field "bcc"))))
2407 (message-delete-line)
2408 (insert (concat "To: " cc-content
"\n"))
2410 (message-narrow-to-headers)
2411 (message-remove-header (if bcc
2415 ;;; End of functions adopted from `message-utils.el'.
2417 (defun message-remove-header (header &optional is-regexp first reverse
)
2418 "Remove HEADER in the narrowed buffer.
2419 If IS-REGEXP, HEADER is a regular expression.
2420 If FIRST, only remove the first instance of the header.
2421 Return the number of headers removed."
2422 (goto-char (point-min))
2423 (let ((regexp (if is-regexp header
(concat "^" (regexp-quote header
) ":")))
2425 (case-fold-search t
)
2427 (while (and (not (eobp))
2430 (not (looking-at regexp
))
2431 (looking-at regexp
))
2438 ;; There might be a continuation header, so we have to search
2439 ;; until we find a new non-continuation line.
2442 (if (re-search-forward "^[^ \t]" nil t
)
2443 (goto-char (match-beginning 0))
2446 (if (re-search-forward "^[^ \t]" nil t
)
2447 (goto-char (match-beginning 0))
2448 (goto-char (point-max)))))
2451 (defun message-remove-first-header (header)
2452 "Remove the first instance of HEADER if there is more than one."
2454 (regexp (concat "^" (regexp-quote header
) ":")))
2456 (goto-char (point-min))
2457 (while (re-search-forward regexp nil t
)
2460 (message-remove-header header nil t
)
2463 (defun message-narrow-to-headers ()
2464 "Narrow the buffer to the head of the message."
2467 (goto-char (point-min))
2468 (if (re-search-forward
2469 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
)
2472 (goto-char (point-min)))
2474 (defun message-narrow-to-head-1 ()
2475 "Like `message-narrow-to-head'. Don't widen."
2477 (goto-char (point-min))
2478 (if (search-forward "\n\n" nil
1)
2481 (goto-char (point-min)))
2483 ;; FIXME: clarify diffference: message-narrow-to-head,
2484 ;; message-narrow-to-headers-or-head, message-narrow-to-headers
2485 (defun message-narrow-to-head ()
2486 "Narrow the buffer to the head of the message.
2487 Point is left at the beginning of the narrowed-to region."
2489 (message-narrow-to-head-1))
2491 (defun message-narrow-to-headers-or-head ()
2492 "Narrow the buffer to the head of the message."
2495 (goto-char (point-min))
2496 (if (re-search-forward (concat "\\(\n\\)\n\\|^\\("
2497 (regexp-quote mail-header-separator
)
2500 (or (match-end 1) (match-beginning 2))
2502 (goto-char (point-min)))
2504 (defun message-news-p ()
2505 "Say whether the current buffer contains a news message."
2506 (and (not message-this-is-mail
)
2507 (or message-this-is-news
2510 (message-narrow-to-headers)
2511 (and (message-fetch-field "newsgroups")
2512 (not (message-fetch-field "posted-to"))))))))
2514 (defun message-mail-p ()
2515 "Say whether the current buffer contains a mail message."
2516 (and (not message-this-is-news
)
2517 (or message-this-is-mail
2520 (message-narrow-to-headers)
2521 (or (message-fetch-field "to")
2522 (message-fetch-field "cc")
2523 (message-fetch-field "bcc")))))))
2525 (defun message-subscribed-p ()
2526 "Say whether we need to insert a MFT header."
2527 (or message-subscribed-regexps
2528 message-subscribed-addresses
2529 message-subscribed-address-file
2530 message-subscribed-address-functions
))
2532 (defun message-next-header ()
2533 "Go to the beginning of the next header."
2535 (or (eobp) (forward-char 1))
2536 (not (if (re-search-forward "^[^ \t]" nil t
)
2538 (goto-char (point-max)))))
2540 (defun message-sort-headers-1 ()
2541 "Sort the buffer as headers using `message-rank' text props."
2542 (goto-char (point-min))
2545 nil
'message-next-header
2547 (message-next-header)
2551 (or (get-text-property (point) 'message-rank
)
2554 (defun message-sort-headers ()
2555 "Sort the headers of the current message according to `message-header-format-alist'."
2559 (let ((max (1+ (length message-header-format-alist
)))
2561 (message-narrow-to-headers)
2562 (while (re-search-forward "^[^ \n]+:" nil t
)
2564 (match-beginning 0) (1+ (match-beginning 0))
2566 (if (setq rank
(length (memq (assq (intern (buffer-substring
2568 (1- (match-end 0))))
2569 message-header-format-alist
)
2570 message-header-format-alist
)))
2573 (message-sort-headers-1))))
2575 (defun message-kill-address ()
2576 "Kill the address under point."
2578 (let ((start (point)))
2579 (message-skip-to-next-address)
2580 (kill-region start
(point))))
2583 (autoload 'Info-goto-node
"info")
2584 (defvar mml2015-use
)
2586 (defun message-info (&optional arg
)
2587 "Display the Message manual.
2589 Prefixed with one \\[universal-argument], display the Emacs MIME
2590 manual. With two \\[universal-argument]'s, display the EasyPG or
2591 PGG manual, depending on the value of `mml2015-use'."
2593 ;; Don't use `info' because support for `(filename)nodename' is not
2594 ;; available in XEmacs < 21.5.12.
2595 (Info-goto-node (format "(%s)Top"
2599 ((eq arg
4) 'emacs-mime
)
2600 ;; `booleanp' only available in Emacs 22+
2601 ((and (not (memq arg
'(nil t
)))
2615 (defvar message-mode-map nil
)
2617 (unless message-mode-map
2618 (setq message-mode-map
(make-keymap))
2619 (set-keymap-parent message-mode-map text-mode-map
)
2620 (define-key message-mode-map
"\C-c?" 'describe-mode
)
2622 (define-key message-mode-map
"\C-c\C-f\C-t" 'message-goto-to
)
2623 (define-key message-mode-map
"\C-c\C-f\C-o" 'message-goto-from
)
2624 (define-key message-mode-map
"\C-c\C-f\C-b" 'message-goto-bcc
)
2625 (define-key message-mode-map
"\C-c\C-f\C-w" 'message-goto-fcc
)
2626 (define-key message-mode-map
"\C-c\C-f\C-c" 'message-goto-cc
)
2627 (define-key message-mode-map
"\C-c\C-f\C-s" 'message-goto-subject
)
2628 (define-key message-mode-map
"\C-c\C-f\C-r" 'message-goto-reply-to
)
2629 (define-key message-mode-map
"\C-c\C-f\C-n" 'message-goto-newsgroups
)
2630 (define-key message-mode-map
"\C-c\C-f\C-d" 'message-goto-distribution
)
2631 (define-key message-mode-map
"\C-c\C-f\C-f" 'message-goto-followup-to
)
2632 (define-key message-mode-map
"\C-c\C-f\C-m" 'message-goto-mail-followup-to
)
2633 (define-key message-mode-map
"\C-c\C-f\C-k" 'message-goto-keywords
)
2634 (define-key message-mode-map
"\C-c\C-f\C-u" 'message-goto-summary
)
2635 (define-key message-mode-map
"\C-c\C-f\C-i"
2636 'message-insert-or-toggle-importance
)
2637 (define-key message-mode-map
"\C-c\C-f\C-a"
2638 'message-generate-unsubscribed-mail-followup-to
)
2640 ;; modify headers (and insert notes in body)
2641 (define-key message-mode-map
"\C-c\C-fs" 'message-change-subject
)
2643 (define-key message-mode-map
"\C-c\C-fx" 'message-cross-post-followup-to
)
2644 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2645 (define-key message-mode-map
"\C-c\C-ft" 'message-reduce-to-to-cc
)
2646 (define-key message-mode-map
"\C-c\C-fa" 'message-add-archive-header
)
2647 ;; mark inserted text
2648 (define-key message-mode-map
"\C-c\M-m" 'message-mark-inserted-region
)
2649 (define-key message-mode-map
"\C-c\M-f" 'message-mark-insert-file
)
2651 (define-key message-mode-map
"\C-c\C-b" 'message-goto-body
)
2652 (define-key message-mode-map
"\C-c\C-i" 'message-goto-signature
)
2654 (define-key message-mode-map
"\C-c\C-t" 'message-insert-to
)
2655 (define-key message-mode-map
"\C-c\C-fw" 'message-insert-wide-reply
)
2656 (define-key message-mode-map
"\C-c\C-n" 'message-insert-newsgroups
)
2657 (define-key message-mode-map
"\C-c\C-l" 'message-to-list-only
)
2658 (define-key message-mode-map
"\C-c\C-f\C-e" 'message-insert-expires
)
2660 (define-key message-mode-map
"\C-c\C-u" 'message-insert-or-toggle-importance
)
2661 (define-key message-mode-map
"\C-c\M-n"
2662 'message-insert-disposition-notification-to
)
2664 (define-key message-mode-map
"\C-c\C-y" 'message-yank-original
)
2665 (define-key message-mode-map
"\C-c\M-\C-y" 'message-yank-buffer
)
2666 (define-key message-mode-map
"\C-c\C-q" 'message-fill-yanked-message
)
2667 (define-key message-mode-map
"\C-c\C-w" 'message-insert-signature
)
2668 (define-key message-mode-map
"\C-c\M-h" 'message-insert-headers
)
2669 (define-key message-mode-map
"\C-c\C-r" 'message-caesar-buffer-body
)
2670 (define-key message-mode-map
"\C-c\C-o" 'message-sort-headers
)
2671 (define-key message-mode-map
"\C-c\M-r" 'message-rename-buffer
)
2673 (define-key message-mode-map
"\C-c\C-c" 'message-send-and-exit
)
2674 (define-key message-mode-map
"\C-c\C-s" 'message-send
)
2675 (define-key message-mode-map
"\C-c\C-k" 'message-kill-buffer
)
2676 (define-key message-mode-map
"\C-c\C-d" 'message-dont-send
)
2677 (define-key message-mode-map
"\C-c\n" 'gnus-delay-article
)
2679 (define-key message-mode-map
"\C-c\M-k" 'message-kill-address
)
2680 (define-key message-mode-map
"\C-c\C-e" 'message-elide-region
)
2681 (define-key message-mode-map
"\C-c\C-v" 'message-delete-not-region
)
2682 (define-key message-mode-map
"\C-c\C-z" 'message-kill-to-signature
)
2683 (define-key message-mode-map
"\M-\r" 'message-newline-and-reformat
)
2684 (define-key message-mode-map
[remap split-line
] 'message-split-line
)
2686 (define-key message-mode-map
"\C-c\C-a" 'mml-attach-file
)
2688 (define-key message-mode-map
"\C-a" 'message-beginning-of-line
)
2689 (define-key message-mode-map
"\t" 'message-tab
)
2691 (define-key message-mode-map
"\M-n" 'message-display-abbrev
))
2694 message-mode-menu message-mode-map
"Message Menu."
2696 ["Yank Original" message-yank-original message-reply-buffer
]
2697 ["Fill Yanked Message" message-fill-yanked-message t
]
2698 ["Insert Signature" message-insert-signature t
]
2699 ["Caesar (rot13) Message" message-caesar-buffer-body t
]
2700 ["Caesar (rot13) Region" message-caesar-region
(message-mark-active-p)]
2701 ["Elide Region" message-elide-region
2702 :active
(message-mark-active-p)
2703 ,@(if (featurep 'xemacs
) nil
2704 '(:help
"Replace text in region with an ellipsis"))]
2705 ["Delete Outside Region" message-delete-not-region
2706 :active
(message-mark-active-p)
2707 ,@(if (featurep 'xemacs
) nil
2708 '(:help
"Delete all quoted text outside region"))]
2709 ["Kill To Signature" message-kill-to-signature t
]
2710 ["Newline and Reformat" message-newline-and-reformat t
]
2711 ["Rename buffer" message-rename-buffer t
]
2712 ["Spellcheck" ispell-message
2713 ,@(if (featurep 'xemacs
) '(t)
2714 '(:help
"Spellcheck this message"))]
2716 ["Insert Region Marked" message-mark-inserted-region
2717 :active
(message-mark-active-p)
2718 ,@(if (featurep 'xemacs
) nil
2719 '(:help
"Mark region with enclosing tags"))]
2720 ["Insert File Marked..." message-mark-insert-file
2721 ,@(if (featurep 'xemacs
) '(t)
2722 '(:help
"Insert file at point marked with enclosing tags"))]
2724 ["Send Message" message-send-and-exit
2725 ,@(if (featurep 'xemacs
) '(t)
2726 '(:help
"Send this message"))]
2727 ["Postpone Message" message-dont-send
2728 ,@(if (featurep 'xemacs
) '(t)
2729 '(:help
"File this draft message and exit"))]
2730 ["Send at Specific Time..." gnus-delay-article
2731 ,@(if (featurep 'xemacs
) '(t)
2732 '(:help
"Ask, then arrange to send message at that time"))]
2733 ["Kill Message" message-kill-buffer
2734 ,@(if (featurep 'xemacs
) '(t)
2735 '(:help
"Delete this message without sending"))]
2737 ["Message manual" message-info
2738 ,@(if (featurep 'xemacs
) '(t)
2739 '(:help
"Display the Message manual"))]))
2742 message-mode-field-menu message-mode-map
""
2744 ["To" message-goto-to t
]
2745 ["From" message-goto-from t
]
2746 ["Subject" message-goto-subject t
]
2747 ["Change subject..." message-change-subject t
]
2748 ["Cc" message-goto-cc t
]
2749 ["Bcc" message-goto-bcc t
]
2750 ["Fcc" message-goto-fcc t
]
2751 ["Reply-To" message-goto-reply-to t
]
2752 ["Flag As Important" message-insert-importance-high
2753 ,@(if (featurep 'xemacs
) '(t)
2754 '(:help
"Mark this message as important"))]
2755 ["Flag As Unimportant" message-insert-importance-low
2756 ,@(if (featurep 'xemacs
) '(t)
2757 '(:help
"Mark this message as unimportant"))]
2759 message-insert-disposition-notification-to
2760 ,@(if (featurep 'xemacs
) '(t)
2761 '(:help
"Request a receipt notification"))]
2763 ;; (typical) news stuff
2764 ["Summary" message-goto-summary t
]
2765 ["Keywords" message-goto-keywords t
]
2766 ["Newsgroups" message-goto-newsgroups t
]
2767 ["Fetch Newsgroups" message-insert-newsgroups t
]
2768 ["Followup-To" message-goto-followup-to t
]
2769 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2770 ["Crosspost / Followup-To..." message-cross-post-followup-to t
]
2771 ["Distribution" message-goto-distribution t
]
2772 ["Expires" message-insert-expires t
]
2773 ["X-No-Archive" message-add-archive-header t
]
2775 ;; (typical) mailing-lists stuff
2776 ["Fetch To" message-insert-to
2777 ,@(if (featurep 'xemacs
) '(t)
2778 '(:help
"Insert a To header that points to the author."))]
2779 ["Fetch To and Cc" message-insert-wide-reply
2780 ,@(if (featurep 'xemacs
) '(t)
2782 "Insert To and Cc headers as if you were doing a wide reply."))]
2784 ["Send to list only" message-to-list-only t
]
2785 ["Mail-Followup-To" message-goto-mail-followup-to t
]
2786 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2787 ,@(if (featurep 'xemacs
) '(t)
2788 '(:help
"Insert a reasonable `Mail-Followup-To:' header."))]
2789 ["Reduce To: to Cc:" message-reduce-to-to-cc t
]
2791 ["Sort Headers" message-sort-headers t
]
2792 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t
]
2793 ;; We hide `message-hidden-headers' by narrowing the buffer.
2794 ["Show Hidden Headers" widen t
]
2795 ["Goto Body" message-goto-body t
]
2796 ["Goto Signature" message-goto-signature t
]))
2798 (defvar message-tool-bar-map nil
)
2800 (defvar facemenu-add-face-function
)
2801 (defvar facemenu-remove-face-function
)
2803 ;;; Forbidden properties
2805 ;; We use `after-change-functions' to keep special text properties
2806 ;; that interfere with the normal function of message mode out of the
2809 (defcustom message-strip-special-text-properties t
2810 "Strip special properties from the message buffer.
2812 Emacs has a number of special text properties which can break message
2813 composing in various ways. If this option is set, message will strip
2814 these properties from the message composition buffer. However, some
2815 packages requires these properties to be present in order to work.
2816 If you use one of these packages, turn this option off, and hope the
2817 message composition doesn't break too bad."
2819 :group
'message-various
2820 :link
'(custom-manual "(message)Various Message Variables")
2823 (defconst message-forbidden-properties
2824 ;; No reason this should be clutter up customize. We make it a
2825 ;; property list (rather than a list of property symbols), to be
2826 ;; directly useful for `remove-text-properties'.
2827 '(field nil read-only nil invisible nil intangible nil
2828 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2829 insert-behind-hooks nil point-entered nil point-left nil
)
2830 ;; Other special properties:
2831 ;; category, face, display: probably doesn't do any harm.
2832 ;; fontified: is used by font-lock.
2833 ;; syntax-table, local-map: I dunno.
2834 ;; We need to add XEmacs names to the list.
2835 "Property list of with properties forbidden in message buffers.
2836 The values of the properties are ignored, only the property names are used.")
2838 (defun message-tamago-not-in-use-p (pos)
2839 "Return t when tamago version 4 is not in use at the cursor position.
2840 Tamago version 4 is a popular input method for writing Japanese text.
2841 It uses the properties `intangible', `invisible', `modification-hooks'
2842 and `read-only' when translating ascii or kana text to kanji text.
2843 These properties are essential to work, so we should never strip them."
2844 (not (and (boundp 'egg-modefull-mode
)
2845 (symbol-value 'egg-modefull-mode
)
2846 (or (memq (get-text-property pos
'intangible
)
2847 '(its-part-1 its-part-2
))
2848 (get-text-property pos
'egg-end
)
2849 (get-text-property pos
'egg-lang
)
2850 (get-text-property pos
'egg-start
)))))
2852 (defsubst message-mail-alias-type-p
(type)
2853 (if (atom message-mail-alias-type
)
2854 (eq message-mail-alias-type type
)
2855 (memq type message-mail-alias-type
)))
2857 (defun message-strip-forbidden-properties (begin end
&optional old-length
)
2858 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2859 This function is intended to be called from `after-change-functions'.
2860 See also `message-forbidden-properties'."
2861 (when (and (message-mail-alias-type-p 'ecomplete
)
2862 (memq this-command message-self-insert-commands
))
2863 (message-display-abbrev))
2864 (when (and message-strip-special-text-properties
2865 (message-tamago-not-in-use-p begin
))
2866 (let ((buffer-read-only nil
)
2867 (inhibit-read-only t
))
2868 (remove-text-properties begin end message-forbidden-properties
))))
2870 (autoload 'ecomplete-setup
"ecomplete") ;; for Emacs <23.
2873 (define-derived-mode message-mode text-mode
"Message"
2874 "Major mode for editing mail and news to be sent.
2875 Like Text Mode but with these additional commands:\\<message-mode-map>
2876 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2877 C-c C-d Postpone sending the message C-c C-k Kill the message
2878 C-c C-f move to a header field (and create it if there isn't):
2879 C-c C-f C-t move to To C-c C-f C-s move to Subject
2880 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2881 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2882 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2883 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2884 C-c C-f C-o move to From (\"Originator\")
2885 C-c C-f C-f move to Followup-To
2886 C-c C-f C-m move to Mail-Followup-To
2887 C-c C-f C-e move to Expires
2888 C-c C-f C-i cycle through Importance values
2889 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2890 C-c C-f x crossposting with FollowUp-To header and note in body
2891 C-c C-f t replace To: header with contents of Cc: or Bcc:
2892 C-c C-f a Insert X-No-Archive: header and a note in the body
2893 C-c C-t `message-insert-to' (add a To header to a news followup)
2894 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2895 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2896 C-c C-b `message-goto-body' (move to beginning of message text).
2897 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2898 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2899 C-c C-y `message-yank-original' (insert current message, if any).
2900 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2901 C-c C-e `message-elide-region' (elide the text between point and mark).
2902 C-c C-v `message-delete-not-region' (remove the text outside the region).
2903 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2904 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2905 C-c C-a `mml-attach-file' (attach a file as MIME).
2906 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2907 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2908 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2909 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2910 M-RET `message-newline-and-reformat' (break the line and reformat)."
2911 (setq local-abbrev-table text-mode-abbrev-table
)
2912 (set (make-local-variable 'message-reply-buffer
) nil
)
2913 (set (make-local-variable 'message-inserted-headers
) nil
)
2914 (set (make-local-variable 'message-send-actions
) nil
)
2915 (set (make-local-variable 'message-exit-actions
) nil
)
2916 (set (make-local-variable 'message-kill-actions
) nil
)
2917 (set (make-local-variable 'message-postpone-actions
) nil
)
2918 (set (make-local-variable 'message-draft-article
) nil
)
2919 (setq buffer-offer-save t
)
2920 (set (make-local-variable 'facemenu-add-face-function
)
2922 (let ((face-fun (cdr (assq face message-face-alist
))))
2924 (funcall face-fun
(point) end
)
2925 (error "Face %s not configured for %s mode" face mode-name
)))
2927 (set (make-local-variable 'facemenu-remove-face-function
) t
)
2928 (set (make-local-variable 'message-reply-headers
) nil
)
2929 (make-local-variable 'message-newsreader
)
2930 (make-local-variable 'message-mailer
)
2931 (make-local-variable 'message-post-method
)
2932 (set (make-local-variable 'message-sent-message-via
) nil
)
2933 (set (make-local-variable 'message-checksum
) nil
)
2934 (set (make-local-variable 'message-mime-part
) 0)
2935 (message-setup-fill-variables)
2936 (when message-fill-column
2937 (setq fill-column message-fill-column
)
2938 (turn-on-auto-fill))
2939 ;; Allow using comment commands to add/remove quoting.
2940 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2941 (when message-yank-prefix
2942 (set (make-local-variable 'comment-start
) message-yank-prefix
)
2943 (set (make-local-variable 'comment-start-skip
)
2944 (concat "^" (regexp-quote message-yank-prefix
) "[ \t]*")))
2945 (if (featurep 'xemacs
)
2946 (message-setup-toolbar)
2947 (set (make-local-variable 'font-lock-defaults
)
2948 '(message-font-lock-keywords t
))
2949 (if (boundp 'tool-bar-map
)
2950 (set (make-local-variable 'tool-bar-map
) (message-make-tool-bar))))
2951 (easy-menu-add message-mode-menu message-mode-map
)
2952 (easy-menu-add message-mode-field-menu message-mode-map
)
2953 (gnus-make-local-hook 'after-change-functions
)
2954 ;; Mmmm... Forbidden properties...
2955 (add-hook 'after-change-functions
'message-strip-forbidden-properties
2957 ;; Allow mail alias things.
2959 ((message-mail-alias-type-p 'abbrev
)
2960 (if (fboundp 'mail-abbrevs-setup
)
2961 (mail-abbrevs-setup)
2962 (if (fboundp 'mail-aliases-setup
) ; warning avoidance
2963 (mail-aliases-setup))))
2964 ((message-mail-alias-type-p 'ecomplete
)
2966 (unless buffer-file-name
2967 (message-set-auto-save-file-name))
2968 (unless (buffer-base-buffer)
2969 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2970 ;; multibyte is not necessary at all. -- zsh
2971 (mm-enable-multibyte))
2972 (set (make-local-variable 'indent-tabs-mode
) nil
) ;No tabs for indentation.
2975 (defun message-setup-fill-variables ()
2976 "Setup message fill variables."
2977 (set (make-local-variable 'fill-paragraph-function
)
2978 'message-fill-paragraph
)
2979 (make-local-variable 'paragraph-separate
)
2980 (make-local-variable 'paragraph-start
)
2981 (make-local-variable 'adaptive-fill-regexp
)
2982 (unless (boundp 'adaptive-fill-first-line-regexp
)
2983 (setq adaptive-fill-first-line-regexp nil
))
2984 (make-local-variable 'adaptive-fill-first-line-regexp
)
2985 (let ((quote-prefix-regexp
2986 ;; User should change message-cite-prefix-regexp if
2987 ;; message-yank-prefix is set to an abnormal value.
2988 (concat "\\(" message-cite-prefix-regexp
"\\)[ \t]*")))
2989 (setq paragraph-start
2991 (regexp-quote mail-header-separator
) "$\\|"
2992 "[ \t]*$\\|" ; blank lines
2993 "-- $\\|" ; signature delimiter
2994 "---+$\\|" ; delimiters for forwarded messages
2995 page-delimiter
"$\\|" ; spoiler warnings
2996 ".*wrote:$\\|" ; attribution lines
2997 quote-prefix-regexp
"$\\|" ; empty lines in quoted text
2999 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
3000 (setq paragraph-separate paragraph-start
)
3001 (setq adaptive-fill-regexp
3002 (concat quote-prefix-regexp
"\\|" adaptive-fill-regexp
))
3003 (setq adaptive-fill-first-line-regexp
3004 (concat quote-prefix-regexp
"\\|"
3005 adaptive-fill-first-line-regexp
)))
3006 (make-local-variable 'auto-fill-inhibit-regexp
)
3007 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
3008 (setq auto-fill-inhibit-regexp nil
)
3009 (make-local-variable 'normal-auto-fill-function
)
3010 (setq normal-auto-fill-function
'message-do-auto-fill
)
3011 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
3012 ;; In that case, ensure that it uses the right function. The real
3013 ;; solution would be not to use `define-derived-mode', and run
3014 ;; `text-mode-hook' ourself at the end of the mode.
3015 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
3016 ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
3017 ;; now careful to run parent hooks after the body. --Stef
3018 (when auto-fill-function
3019 (setq auto-fill-function normal-auto-fill-function
)))
3024 ;;; Message mode commands
3027 ;;; Movement commands
3029 (defun message-goto-to ()
3030 "Move point to the To header."
3032 (message-position-on-field "To"))
3034 (defun message-goto-from ()
3035 "Move point to the From header."
3037 (message-position-on-field "From"))
3039 (defun message-goto-subject ()
3040 "Move point to the Subject header."
3042 (message-position-on-field "Subject"))
3044 (defun message-goto-cc ()
3045 "Move point to the Cc header."
3047 (message-position-on-field "Cc" "To"))
3049 (defun message-goto-bcc ()
3050 "Move point to the Bcc header."
3052 (message-position-on-field "Bcc" "Cc" "To"))
3054 (defun message-goto-fcc ()
3055 "Move point to the Fcc header."
3057 (message-position-on-field "Fcc" "To" "Newsgroups"))
3059 (defun message-goto-reply-to ()
3060 "Move point to the Reply-To header."
3062 (message-position-on-field "Reply-To" "Subject"))
3064 (defun message-goto-newsgroups ()
3065 "Move point to the Newsgroups header."
3067 (message-position-on-field "Newsgroups"))
3069 (defun message-goto-distribution ()
3070 "Move point to the Distribution header."
3072 (message-position-on-field "Distribution"))
3074 (defun message-goto-followup-to ()
3075 "Move point to the Followup-To header."
3077 (message-position-on-field "Followup-To" "Newsgroups"))
3079 (defun message-goto-mail-followup-to ()
3080 "Move point to the Mail-Followup-To header."
3082 (message-position-on-field "Mail-Followup-To" "To"))
3084 (defun message-goto-keywords ()
3085 "Move point to the Keywords header."
3087 (message-position-on-field "Keywords" "Subject"))
3089 (defun message-goto-summary ()
3090 "Move point to the Summary header."
3092 (message-position-on-field "Summary" "Subject"))
3095 (defmacro message-called-interactively-p
(kind)
3098 (eval '(called-interactively-p 'any
))
3100 `(called-interactively-p ,kind
))
3102 (wrong-number-of-arguments '(called-interactively-p))
3104 (void-function '(interactive-p)))))
3106 (defun message-goto-body ()
3107 "Move point to the beginning of the message body."
3109 (when (and (message-called-interactively-p 'any
)
3110 (looking-at "[ \t]*\n"))
3112 (goto-char (point-min))
3113 (or (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3114 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t
)))
3116 (defun message-in-body-p ()
3117 "Return t if point is in the message body."
3118 (let ((body (save-excursion (message-goto-body))))
3121 (defun message-goto-eoh ()
3122 "Move point to the end of the headers."
3127 (defun message-goto-signature ()
3128 "Move point to the beginning of the message signature.
3129 If there is no signature in the article, go to the end and
3132 (goto-char (point-min))
3133 (if (re-search-forward message-signature-separator nil t
)
3135 (goto-char (point-max))
3138 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc
)
3139 "Insert a reasonable MFT header in a post to an unsubscribed list.
3140 When making original posts to a mailing list you are not subscribed to,
3141 you have to type in a MFT header by hand. The contents, usually, are
3142 the addresses of the list and your own address. This function inserts
3143 such a header automatically. It fetches the contents of the To: header
3144 in the current mail buffer, and appends the current `user-mail-address'.
3146 If the optional argument INCLUDE-CC is non-nil, the addresses in the
3147 Cc: header are also put into the MFT."
3152 (message-narrow-to-headers)
3153 (message-remove-header "Mail-Followup-To")
3154 (setq cc
(and include-cc
(message-fetch-field "Cc")))
3156 (concat (message-fetch-field "To") "," cc
)
3157 (message-fetch-field "To"))))
3158 (message-goto-mail-followup-to)
3159 (insert (concat tos
", " user-mail-address
))))
3163 (defun message-insert-to (&optional force
)
3164 "Insert a To header that points to the author of the article being replied to.
3165 If the original author requested not to be sent mail, don't insert unless the
3166 prefix FORCE is given."
3168 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
3169 (dont (and mct
(or (equal (downcase mct
) "never")
3170 (equal (downcase mct
) "nobody"))))
3171 (to (or (message-fetch-reply-field "mail-reply-to")
3172 (message-fetch-reply-field "reply-to")
3173 (message-fetch-reply-field "from"))))
3177 "Ignoring the user request not to have copies sent via mail"
3178 "Complying with the user request not to have copies sent via mail")))
3179 (when (and force
(not to
))
3180 (error "No mail address in the article"))
3181 (when (and to
(or force
(not dont
)))
3182 (message-carefully-insert-headers (list (cons 'To to
))))))
3184 (defun message-insert-wide-reply ()
3185 "Insert To and Cc headers as if you were doing a wide reply."
3187 (let ((headers (message-with-reply-buffer
3188 (message-get-reply-headers t
))))
3189 (message-carefully-insert-headers headers
)))
3191 (defcustom message-header-synonyms
3194 "List of lists of header synonyms.
3195 E.g., if this list contains a member list with elements `Cc' and `To',
3196 then `message-carefully-insert-headers' will not insert a `To' header
3197 when the message is already `Cc'ed to the recipient."
3199 :group
'message-headers
3200 :link
'(custom-manual "(message)Message Headers")
3201 :type
'(repeat sexp
))
3203 (defun message-carefully-insert-headers (headers)
3204 "Insert the HEADERS, an alist, into the message buffer.
3205 Does not insert the headers when they are already present there
3206 or in the synonym headers, defined by `message-header-synonyms'."
3207 ;; FIXME: Should compare only the address and not the full name. Comparison
3208 ;; should be done case-folded (and with `string=' rather than
3210 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
3211 (dolist (header headers
)
3212 (let* ((header-name (symbol-name (car header
)))
3213 (new-header (cdr header
))
3214 (synonyms (loop for synonym in message-header-synonyms
3215 when
(memq (car header
) synonym
) return synonym
))
3217 (loop for synonym in synonyms
3218 for old-header
= (mail-fetch-field (symbol-name synonym
))
3219 when
(and old-header
(string-match new-header old-header
))
3222 (message "already have `%s' in `%s'" new-header old-header
)
3223 (when (and (message-position-on-field header-name
)
3224 (setq old-header
(mail-fetch-field header-name
))
3225 (not (string-match "\\` *\\'" old-header
)))
3227 (insert new-header
)))))
3229 (defun message-widen-reply ()
3230 "Widen the reply to include maximum recipients."
3233 (and (bufferp message-reply-buffer
)
3234 (buffer-name message-reply-buffer
)
3235 (with-current-buffer message-reply-buffer
3236 (message-get-reply-headers t
)))))
3239 (message-narrow-to-headers)
3240 (dolist (elem follow-to
)
3241 (message-remove-header (symbol-name (car elem
)))
3242 (goto-char (point-min))
3243 (insert (symbol-name (car elem
)) ": "
3244 (cdr elem
) "\n"))))))
3246 (defun message-insert-newsgroups ()
3247 "Insert the Newsgroups header from the article being replied to."
3249 (when (and (message-position-on-field "Newsgroups")
3250 (mail-fetch-field "newsgroups")
3251 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
3253 (insert (or (message-fetch-reply-field "newsgroups") "")))
3257 ;;; Various commands
3259 (defun message-delete-not-region (beg end
)
3260 "Delete everything in the body of the current message outside of the region."
3265 ;; snarf citation prefix, if appropriate
3266 (unless (eq (point) (progn (beginning-of-line) (point)))
3267 (when (looking-at message-cite-prefix-regexp
)
3268 (setq citeprefix
(match-string 0))))
3270 (delete-region (point) (if (not (message-goto-signature))
3276 (delete-region beg
(progn (message-goto-body)
3280 (insert citeprefix
))))
3281 (when (message-goto-signature)
3284 (defun message-kill-to-signature (&optional arg
)
3285 "Kill all text up to the signature.
3286 If a numeric argument or prefix arg is given, leave that number
3287 of lines before the signature intact."
3291 (let ((point (point)))
3292 (narrow-to-region point
(point-max))
3293 (message-goto-signature)
3295 (if (and arg
(numberp arg
))
3296 (forward-line (- -
1 arg
))
3298 (unless (= point
(point))
3299 (kill-region point
(point))
3303 (defun message-newline-and-reformat (&optional arg not-break
)
3304 "Insert four newlines, and then reformat if inside quoted text.
3305 Prefix arg means justify as well."
3306 (interactive (list (if current-prefix-arg
'full
)))
3307 (let (quoted point beg end leading-space bolp fill-paragraph-function
)
3308 (setq point
(point))
3311 (setq bolp
(= beg point
))
3312 ;; Find first line of the paragraph.
3314 (while (and (not (eobp))
3315 (not (looking-at message-cite-prefix-regexp
))
3316 (looking-at paragraph-start
))
3319 (when (looking-at message-cite-prefix-regexp
)
3320 (setq quoted
(match-string 0))
3321 (goto-char (match-end 0))
3322 (looking-at "[ \t]*")
3323 (setq leading-space
(match-string 0)))
3327 (< (- point beg
) (length quoted
)))
3328 ;; break inside the cite prefix.
3334 (while (and (not (eobp))
3335 (not (looking-at paragraph-separate
))
3336 (looking-at message-cite-prefix-regexp
)
3337 (equal quoted
(match-string 0)))
3338 (goto-char (match-end 0))
3339 (looking-at "[ \t]*")
3340 (if (> (length leading-space
) (length (match-string 0)))
3341 (setq leading-space
(match-string 0)))
3345 (while (and (if (bobp) nil
(forward-line -
1) t
)
3346 (not (looking-at paragraph-start
))
3347 (looking-at message-cite-prefix-regexp
)
3348 (equal quoted
(match-string 0)))
3350 (goto-char (match-end 0))
3351 (looking-at "[ \t]*")
3352 (if (> (length leading-space
) (length (match-string 0)))
3353 (setq leading-space
(match-string 0)))))
3354 (while (and (not (eobp))
3355 (not (looking-at paragraph-separate
))
3356 (not (looking-at message-cite-prefix-regexp
)))
3360 (while (and (if (bobp) nil
(forward-line -
1) t
)
3361 (not (looking-at paragraph-start
))
3362 (not (looking-at message-cite-prefix-regexp
)))
3363 (setq beg
(point))))
3366 (narrow-to-region beg end
)
3373 (setq point
(point))
3374 ;; (newline 2) doesn't mark both newline's as hard, so call
3375 ;; newline twice. -jas
3378 (delete-region (point) (re-search-forward "[ \t]*"))
3379 (when (and quoted
(not bolp
))
3380 (insert quoted leading-space
)))
3383 (let* ((adaptive-fill-regexp
3384 (regexp-quote (concat quoted leading-space
)))
3385 (adaptive-fill-first-line-regexp
3386 adaptive-fill-regexp
))
3387 (fill-paragraph arg
))
3388 (fill-paragraph arg
))
3389 (if point
(goto-char point
)))))
3391 (defun message-fill-paragraph (&optional arg
)
3392 "Message specific function to fill a paragraph.
3393 This function is used as the value of `fill-paragraph-function' in
3394 Message buffers and is not meant to be called directly."
3395 (interactive (list (if current-prefix-arg
'full
)))
3396 (if (if (boundp 'filladapt-mode
) filladapt-mode
)
3398 (if (message-point-in-header-p)
3399 (message-fill-field)
3400 (message-newline-and-reformat arg t
))
3403 (defun message-point-in-header-p ()
3404 "Return t if point is in the header."
3406 (not (re-search-backward
3407 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
))))
3409 (defun message-do-auto-fill ()
3410 "Like `do-auto-fill', but don't fill in message header."
3411 (unless (message-point-in-header-p)
3414 (defun message-insert-signature (&optional force
)
3415 "Insert a signature. See documentation for variable `message-signature'."
3416 (interactive (list 0))
3419 ((and (null message-signature
)
3422 (goto-char (point-max))
3423 (not (re-search-backward message-signature-separator nil t
))))
3424 ((and (null message-signature
)
3427 ((functionp message-signature
)
3428 (funcall message-signature
))
3429 ((listp message-signature
)
3430 (eval message-signature
))
3431 (t message-signature
)))
3434 (cond ((stringp signature
)
3436 ((and (eq t signature
) message-signature-file
)
3437 (setq signature-file
3438 (if (and message-signature-directory
3439 ;; don't actually use the signature directory
3440 ;; if message-signature-file contains a path.
3441 (not (file-name-directory
3442 message-signature-file
)))
3443 (expand-file-name message-signature-file
3444 message-signature-directory
)
3445 message-signature-file
))
3446 (file-exists-p signature-file
))))
3448 (goto-char (point-max))
3449 ;; Insert the signature.
3452 (when message-signature-insert-empty-line
3455 (if (eq signature t
)
3456 (insert-file-contents signature-file
)
3458 (goto-char (point-max))
3459 (or (bolp) (insert "\n")))))
3461 (defun message-insert-importance-high ()
3462 "Insert header to mark message as important."
3466 (message-narrow-to-headers)
3467 (message-remove-header "Importance"))
3469 (insert "Importance: high\n")))
3471 (defun message-insert-importance-low ()
3472 "Insert header to mark message as unimportant."
3476 (message-narrow-to-headers)
3477 (message-remove-header "Importance"))
3479 (insert "Importance: low\n")))
3481 (defun message-insert-or-toggle-importance ()
3482 "Insert a \"Importance: high\" header, or cycle through the header values.
3483 The three allowed values according to RFC 1327 are `high', `normal'
3490 (message-narrow-to-headers)
3491 (when (setq cur
(message-fetch-field "Importance"))
3492 (message-remove-header "Importance")
3493 (setq new
(cond ((string= cur
"high")
3495 ((string= cur
"low")
3500 (insert (format "Importance: %s\n" new
)))))
3502 (defun message-insert-disposition-notification-to ()
3503 "Request a disposition notification (return receipt) to this message.
3504 Note that this should not be used in newsgroups."
3508 (message-narrow-to-headers)
3509 (message-remove-header "Disposition-Notification-To"))
3511 (insert (format "Disposition-Notification-To: %s\n"
3512 (or (message-field-value "Reply-to")
3513 (message-field-value "From")
3514 (message-make-from))))))
3516 (defun message-elide-region (b e
)
3517 "Elide the text in the region.
3518 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3522 (insert message-elide-ellipsis
))
3524 (defvar message-caesar-translation-table nil
)
3526 (defun message-caesar-region (b e
&optional n
)
3527 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3530 (min (point) (or (mark t
) (point)))
3531 (max (point) (or (mark t
) (point)))
3532 (when current-prefix-arg
3533 (prefix-numeric-value current-prefix-arg
))))
3535 (setq n
(if (numberp n
) (mod n
26) 13)) ;canonize N
3536 (unless (or (zerop n
) ; no action needed for a rot of 0
3537 (= b e
)) ; no region to rotate
3538 ;; We build the table, if necessary.
3539 (when (or (not message-caesar-translation-table
)
3540 (/= (aref message-caesar-translation-table ?a
) (+ ?a n
)))
3541 (setq message-caesar-translation-table
3542 (message-make-caesar-translation-table n
)))
3543 (translate-region b e message-caesar-translation-table
)))
3545 (defun message-make-caesar-translation-table (n)
3546 "Create a rot table with offset N."
3548 (table (make-string 256 0)))
3549 (while (< (incf i
) 256)
3552 (substring table
0 ?A
)
3553 (substring table
(+ ?A n
) (+ ?A n
(- 26 n
)))
3554 (substring table ?A
(+ ?A n
))
3555 (substring table
(+ ?A
26) ?a
)
3556 (substring table
(+ ?a n
) (+ ?a n
(- 26 n
)))
3557 (substring table ?a
(+ ?a n
))
3558 (substring table
(+ ?a
26) 255))))
3560 (defun message-caesar-buffer-body (&optional rotnum wide
)
3561 "Caesar rotate all letters in the current buffer by 13 places.
3562 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3563 With prefix arg, specifies the number of places to rotate each letter forward.
3564 Mail and USENET news headers are not rotated unless WIDE is non-nil."
3565 (interactive (if current-prefix-arg
3566 (list (prefix-numeric-value current-prefix-arg
))
3570 (when (and (not wide
) (message-goto-body))
3571 (narrow-to-region (point) (point-max)))
3572 (message-caesar-region (point-min) (point-max) rotnum
))))
3574 (defun message-pipe-buffer-body (program)
3575 "Pipe the message body in the current buffer through PROGRAM."
3578 (when (message-goto-body)
3579 (narrow-to-region (point) (point-max)))
3580 (shell-command-on-region
3581 (point-min) (point-max) program nil t
))))
3583 (defun message-rename-buffer (&optional enter-string
)
3584 "Rename the *message* buffer to \"*message* RECIPIENT\".
3585 If the function is run with a prefix, it will ask for a new buffer
3586 name, rather than giving an automatic name."
3587 (interactive "Pbuffer name: ")
3590 (goto-char (point-min))
3591 (narrow-to-region (point)
3592 (search-forward mail-header-separator nil
'end
))
3594 (if (message-news-p) (message-fetch-field "Newsgroups")
3595 (message-fetch-field "To"))
3598 (if (string-match "," mail-to
)
3599 (concat (substring mail-to
0 (match-beginning 0)) ", ...")
3601 (name-default (concat "*message* " mail-trimmed-to
))
3602 (name (if enter-string
3603 (read-string "New buffer name: " name-default
)
3605 (rename-buffer name t
)))))
3607 (defun message-fill-yanked-message (&optional justifyp
)
3608 "Fill the paragraphs of a message yanked into this one.
3609 Numeric argument means justify as well."
3612 (goto-char (point-min))
3613 (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3614 (let ((fill-prefix message-yank-prefix
))
3615 (fill-individual-paragraphs (point) (point-max) justifyp
))))
3617 (defun message-indent-citation (&optional start end yank-only
)
3618 "Modify text just inserted from a message to be cited.
3619 The inserted text should be the region.
3620 When this function returns, the region is again around the modified text.
3622 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3623 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3624 (unless start
(setq start
(point)))
3626 ;; Remove unwanted headers.
3627 (when message-ignored-cited-headers
3632 (if (search-forward "\n\n" nil t
)
3635 (message-remove-header message-ignored-cited-headers t
)
3636 (when (= (point-min) (point-max))
3637 (setq all-removed t
))
3638 (goto-char (point-max)))
3642 ;; Delete blank lines at the start of the buffer.
3643 (while (and (point-min)
3646 (message-delete-line))
3647 ;; Delete blank lines at the end of the buffer.
3648 (goto-char (point-max))
3651 (while (and (zerop (forward-line -
1))
3653 (message-delete-line)))
3654 ;; Do the indentation.
3655 (if (null message-yank-prefix
)
3656 (indent-rigidly start
(or end
(mark t
)) message-indentation-spaces
)
3659 (while (< (point) (or end
(mark t
)))
3660 (cond ((looking-at ">")
3661 (insert message-yank-cited-prefix
))
3663 (insert message-yank-empty-prefix
))
3665 (insert message-yank-prefix
)))
3669 (defun message-remove-blank-cited-lines (&optional remove
)
3670 "Remove cited lines containing only blanks.
3671 If REMOVE is non-nil, remove newlines, too.
3673 To use this automatically, you may add this function to
3674 `gnus-message-setup-hook'."
3679 (when (boundp 'message-yank-cited-prefix
)
3680 (concat message-yank-cited-prefix
"\\|"))
3684 (gnus-message 8 "removing `%s'" citexp
)
3687 (while (re-search-forward citexp nil t
)
3688 (replace-match (if remove
"" "\n"))))))
3690 (defvar message-cite-reply-above nil
3691 "If non-nil, start own text above the quote.
3693 Note: Top posting is bad netiquette. Don't use it unless you
3694 really must. You probably want to set variable only for specific
3695 groups, e.g. using `gnus-posting-styles':
3697 (eval (set (make-local-variable 'message-cite-reply-above) t))
3699 This variable has no effect in news postings.")
3701 (defun message-yank-original (&optional arg
)
3702 "Insert the message being replied to, if any.
3703 Puts point before the text and mark after.
3704 Normally indents each nonblank line ARG spaces (default 3). However,
3705 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3707 This function uses `message-cite-function' to do the actual citing.
3709 Just \\[universal-argument] as argument means don't indent, insert no
3710 prefix, and don't delete any headers."
3712 (let ((modified (buffer-modified-p))
3714 (when (and message-reply-buffer
3715 message-cite-function
)
3716 (when message-cite-reply-above
3717 (if (and (not (message-news-p))
3718 (or (eq message-cite-reply-above
'is-evil
)
3720 Top posting is bad netiquette. Please don't top post unless you really must.
3721 Really top post? ")))
3724 (buffer-substring (message-goto-body)
3726 (delete-region (message-goto-body) (point-max)))
3727 (set (make-local-variable 'message-cite-reply-above
) nil
)))
3728 (if (bufferp message-reply-buffer
)
3729 (delete-windows-on message-reply-buffer t
))
3730 (push-mark (save-excursion
3732 ((bufferp message-reply-buffer
)
3733 (insert-buffer-substring message-reply-buffer
))
3734 ((and (consp message-reply-buffer
)
3735 (functionp (car message-reply-buffer
)))
3736 (apply (car message-reply-buffer
)
3737 (cdr message-reply-buffer
))))
3742 (funcall message-cite-function
)
3743 (unless (eq (char-before (mark t
)) ?
\n)
3745 (goto-char (mark t
))
3746 (insert-before-markers ?
\n)
3748 (when message-cite-reply-above
3751 (insert (if (bolp) "\n" "\n\n"))
3752 (message-goto-body))
3753 ;; Add a `message-setup-very-last-hook' here?
3754 ;; Add `gnus-article-highlight-citation' here?
3756 (setq message-checksum
(message-checksum))))))
3758 (defun message-yank-buffer (buffer)
3759 "Insert BUFFER into the current buffer and quote it."
3760 (interactive "bYank buffer: ")
3761 (let ((message-reply-buffer (get-buffer buffer
)))
3762 (save-window-excursion
3763 (message-yank-original))))
3765 (defun message-buffers ()
3766 "Return a list of active message buffers."
3768 (save-current-buffer
3769 (dolist (buffer (buffer-list t
))
3771 (when (and (eq major-mode
'message-mode
)
3772 (null message-sent-message-via
))
3773 (push (buffer-name buffer
) buffers
))))
3774 (nreverse buffers
)))
3776 (defun message-cite-original-1 (strip-signature)
3777 "Cite an original message.
3778 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3781 This function uses `mail-citation-hook' if that is non-nil."
3782 (if (and (boundp 'mail-citation-hook
)
3784 (run-hooks 'mail-citation-hook
)
3785 (let* ((start (point))
3789 (when message-indent-citation-function
3790 (if (listp message-indent-citation-function
)
3791 message-indent-citation-function
3792 (list message-indent-citation-function
))))
3793 ;; This function may be called by `gnus-summary-yank-message' and
3794 ;; may insert a different article from the original. So, we will
3795 ;; modify the value of `message-reply-headers' with that article.
3796 (message-reply-headers
3798 (narrow-to-region start end
)
3799 (message-narrow-to-head-1)
3800 (setq x-no-archive
(message-fetch-field "x-no-archive"))
3802 (or (message-fetch-field "subject") "none")
3803 (or (message-fetch-field "from") "nobody")
3804 (message-fetch-field "date")
3805 (message-fetch-field "message-id" t
)
3806 (message-fetch-field "references")
3808 (mml-quote-region start end
)
3809 (when strip-signature
3813 (when (re-search-backward message-signature-separator start t
)
3814 ;; Also peel off any blank lines before the signature.
3816 (while (looking-at "^[ \t]*$")
3819 (delete-region (point) end
)
3820 (unless (search-backward "\n\n" start t
)
3821 ;; Insert a blank line if it is peeled off.
3824 (mapc 'funcall functions
)
3825 (when message-citation-line-function
3828 (funcall message-citation-line-function
))
3829 (when (and x-no-archive
3830 (not message-cite-articles-with-x-no-archive
)
3831 (string-match "yes" x-no-archive
))
3833 (delete-region (point) (mark t
))
3834 (insert "> [Quoted text removed due to X-No-Archive]\n")
3836 (forward-line -
1)))))
3838 (defun message-cite-original ()
3839 "Cite function in the standard Message manner."
3840 (message-cite-original-1 nil
))
3842 (defvar gnus-extract-address-components
)
3844 (autoload 'format-spec
"format-spec")
3846 (defun message-insert-formatted-citation-line (&optional from date
)
3847 "Function that inserts a formatted citation line.
3849 See `message-citation-line-format'."
3850 ;; The optional args are for testing/debugging. They will disappear later.
3852 ;; (with-temp-buffer
3853 ;; (message-insert-formatted-citation-line
3854 ;; "John Doe <john.doe@example.invalid>"
3857 (when (or message-reply-headers
(and from date
))
3859 (setq from
(mail-header-from message-reply-headers
)))
3860 (let* ((data (condition-case ()
3861 (funcall (if (boundp gnus-extract-address-components
)
3862 gnus-extract-address-components
3863 'mail-extract-address-components
)
3869 (net (car (cdr data
)))
3870 (name-or-net (or (car data
)
3871 (car (cdr data
)) from
))
3875 ;; We need Gnus functionality if the user wants date or time from
3876 ;; the original article:
3877 (when (string-match "%[^fnNFL]" message-citation-line-format
)
3878 (autoload 'gnus-date-get-time
"gnus-util")
3879 (gnus-date-get-time (mail-header-date message-reply-headers
)))))
3882 (when (stringp name
)
3883 ;; Guess first name and last name:
3884 (cond ((string-match
3885 "\\`\\(\\w\\|[-.]\\)+ \\(\\w\\|[-.]\\)+\\'" name
)
3886 (setq fname
(nth 0 (split-string name
"[ \t]+"))
3887 lname
(nth 1 (split-string name
"[ \t]+"))))
3889 "\\`\\(\\w\\|[-.]\\)+, \\(\\w\\|[-.]\\)+\\'" name
)
3890 (setq fname
(nth 1 (split-string name
"[ \t,]+"))
3891 lname
(nth 0 (split-string name
"[ \t,]+"))))
3893 "\\`\\(\\w\\|[-.]\\)+\\'" name
)
3896 ;; The following letters are not used in `format-time-string':
3897 (push ?E lst
) (push "<E>" lst
)
3898 (push ?F lst
) (push fname lst
)
3899 ;; We might want to use "" instead of "<X>" later.
3900 (push ?J lst
) (push "<J>" lst
)
3901 (push ?K lst
) (push "<K>" lst
)
3902 (push ?L lst
) (push lname lst
)
3903 (push ?N lst
) (push name-or-net lst
)
3904 (push ?O lst
) (push "<O>" lst
)
3905 (push ?P lst
) (push "<P>" lst
)
3906 (push ?Q lst
) (push "<Q>" lst
)
3907 (push ?f lst
) (push from lst
)
3908 (push ?i lst
) (push "<i>" lst
)
3909 (push ?n lst
) (push net lst
)
3910 (push ?o lst
) (push "<o>" lst
)
3911 (push ?q lst
) (push "<q>" lst
)
3912 (push ?t lst
) (push "<t>" lst
)
3913 (push ?v lst
) (push "<v>" lst
)
3914 ;; Delegate the rest to `format-time-string':
3916 (when (and (not (memq i lst
))
3921 (push (condition-case nil
3922 (format-time-string (format "%%%c" i
) replydate
)
3923 (error (format ">%c<" i
)))
3927 (spec (apply 'format-spec-make flist
)))
3928 (insert (format-spec message-citation-line-format spec
)))
3931 (defun message-cite-original-without-signature ()
3932 "Cite function in the standard Message manner.
3933 This function strips off the signature from the original message."
3934 (message-cite-original-1 t
))
3936 (defun message-insert-citation-line ()
3937 "Insert a simple citation line."
3938 (when message-reply-headers
3939 (insert (mail-header-from message-reply-headers
) " writes:")
3943 (defun message-position-on-field (header &rest afters
)
3944 (let ((case-fold-search t
))
3947 (goto-char (point-min))
3950 (concat "^" (regexp-quote mail-header-separator
) "$"))
3951 (match-beginning 0)))
3952 (goto-char (point-min))
3953 (if (re-search-forward (concat "^" (regexp-quote header
) ":") nil t
)
3955 (re-search-forward "^[^ \t]" nil
'move
)
3957 (skip-chars-backward "\n")
3960 (not (re-search-forward
3961 (concat "^" (regexp-quote (car afters
)) ":")
3965 (re-search-forward "^[^ \t]" nil
'move
)
3966 (beginning-of-line))
3967 (insert header
": \n")
3971 (defun message-remove-signature ()
3972 "Remove the signature from the text between point and mark.
3973 The text will also be indented the normal way."
3975 (let ((start (point))
3977 (if (not (re-search-forward message-signature-separator
(mark t
) t
))
3978 ;; No signature here, so we just indent the cited text.
3979 (message-indent-citation)
3980 ;; Find the last non-empty line.
3982 (while (looking-at "[ \t]*$")
3985 (setq mark
(set-marker (make-marker) (point)))
3987 (message-indent-citation)
3988 ;; Enable undoing the deletion.
3990 (delete-region mark
(mark t
))
3991 (set-marker mark nil
)))))
3996 ;;; Sending messages
3999 (defun message-send-and-exit (&optional arg
)
4000 "Send message like `message-send', then, if no errors, exit from mail buffer."
4002 (let ((buf (current-buffer))
4003 (actions message-exit-actions
))
4004 (when (and (message-send arg
)
4006 (if message-kill-buffer-on-exit
4009 (when (eq buf
(current-buffer))
4010 (message-bury buf
)))
4011 (message-do-actions actions
)
4014 (defun message-dont-send ()
4015 "Don't send the message you have been editing.
4016 Instead, just auto-save the buffer and then bury it."
4018 (set-buffer-modified-p t
)
4020 (let ((actions message-postpone-actions
))
4021 (message-bury (current-buffer))
4022 (message-do-actions actions
)))
4024 (defun message-kill-buffer ()
4025 "Kill the current buffer."
4027 (when (or (not (buffer-modified-p))
4028 (not message-kill-buffer-query
)
4029 (yes-or-no-p "Message modified; kill anyway? "))
4030 (let ((actions message-kill-actions
)
4031 (draft-article message-draft-article
)
4032 (auto-save-file-name buffer-auto-save-file-name
)
4033 (file-name buffer-file-name
)
4034 (modified (buffer-modified-p)))
4035 (setq buffer-file-name nil
)
4036 (kill-buffer (current-buffer))
4037 (when (and (or (and auto-save-file-name
4038 (file-exists-p auto-save-file-name
))
4040 (file-exists-p file-name
)))
4042 ;; If the message buffer has lived in a dedicated window,
4043 ;; `kill-buffer' has killed the frame. Thus the
4044 ;; `yes-or-no-p' may show up in a lowered frame. Make sure
4045 ;; that the user can see the question by raising the
4048 (yes-or-no-p (format "Remove the backup file%s? "
4049 (if modified
" too" "")))))
4051 (delete-file auto-save-file-name
))
4052 (let ((message-draft-article draft-article
))
4053 (message-disassociate-draft)))
4054 (message-do-actions actions
))))
4056 (defun message-bury (buffer)
4057 "Bury this mail BUFFER."
4058 (let ((newbuf (other-buffer buffer
)))
4059 (bury-buffer buffer
)
4060 (if (and (window-dedicated-p (selected-window))
4061 (not (null (delq (selected-frame) (visible-frame-list)))))
4062 (delete-frame (selected-frame))
4063 (switch-to-buffer newbuf
))))
4065 (defun message-send (&optional arg
)
4066 "Send the message in the current buffer.
4067 If `message-interactive' is non-nil, wait for success indication or
4068 error messages, and inform user.
4069 Otherwise any failure is reported in a message back to the user from
4071 The usage of ARG is defined by the instance that called Message.
4072 It should typically alter the sending method in some way or other."
4074 ;; Make it possible to undo the coming changes.
4076 (let ((inhibit-read-only t
))
4077 (put-text-property (point-min) (point-max) 'read-only nil
))
4078 (message-fix-before-sending)
4079 (run-hooks 'message-send-hook
)
4080 (when message-confirm-send
4081 (or (y-or-n-p "Send message? ")
4083 (message message-sending-message
)
4084 (let ((alist message-send-method-alist
)
4086 elem sent dont-barf-on-no-method
4087 (message-options message-options
))
4088 (message-options-set-recipient)
4090 (setq elem
(pop alist
)))
4091 (when (funcall (cadr elem
))
4092 (when (and (or (not (memq (car elem
)
4093 message-sent-message-via
))
4094 (message-fetch-field "supersedes")
4095 (if (or (message-gnksa-enable-p 'multiple-copies
)
4096 (not (eq (car elem
) 'news
)))
4099 "Already sent message via %s; resend? "
4101 (error "Denied posting -- multiple copies")))
4102 (setq success
(funcall (caddr elem
) arg
)))
4106 (let ((fcc (message-fetch-field "Fcc"))
4107 (gcc (message-fetch-field "Gcc")))
4109 (or (eq message-allow-no-recipients
'always
)
4110 (and (not (eq message-allow-no-recipients
'never
))
4111 (setq dont-barf-on-no-method
4113 (format "No receiver, perform %s anyway? "
4114 (cond ((and fcc gcc
) "Fcc and Gcc")
4117 (error "No methods specified to send by"))
4118 (when (or dont-barf-on-no-method
4122 (run-hooks 'message-sent-hook
))
4123 (message "Sending...done")
4124 ;; Do ecomplete address snarfing.
4125 (when (and (message-mail-alias-type-p 'ecomplete
)
4126 (not message-inhibit-ecomplete
))
4127 (message-put-addresses-in-ecomplete))
4128 ;; Mark the buffer as unmodified and delete auto-save.
4129 (set-buffer-modified-p nil
)
4130 (delete-auto-save-file-if-necessary t
)
4131 (message-disassociate-draft)
4132 ;; Delete other mail buffers and stuff.
4133 (message-do-send-housekeeping)
4134 (message-do-actions message-send-actions
)
4138 (defun message-send-via-mail (arg)
4139 "Send the current message via mail."
4140 (message-send-mail arg
))
4142 (defun message-send-via-news (arg)
4143 "Send the current message via news."
4144 (funcall message-send-news-function arg
))
4146 (defmacro message-check
(type &rest forms
)
4147 "Eval FORMS if TYPE is to be checked."
4148 `(or (message-check-element ,type
)
4152 (put 'message-check
'lisp-indent-function
1)
4153 (put 'message-check
'edebug-form-spec
'(form body
))
4155 (defun message-text-with-property (prop &optional start end reverse
)
4156 "Return a list of start and end positions where the text has PROP.
4157 START and END bound the search, they default to `point-min' and
4158 `point-max' respectively. If REVERSE is non-nil, find text which does
4161 (setq start
(point-min)))
4163 (setq end
(point-max)))
4167 (setq start
(text-property-any start end prop nil
)))
4168 (setq next
(next-single-property-change start prop nil end
))
4169 (push (cons start
(or next end
)) regions
)
4172 (or (get-text-property start prop
)
4173 (and (setq start
(next-single-property-change
4174 start prop nil end
))
4175 (get-text-property start prop
))))
4176 (setq next
(text-property-any start end prop nil
))
4177 (push (cons start
(or next end
)) regions
)
4179 (nreverse regions
)))
4181 (defcustom message-bogus-addresses
4182 ;; '("noreply" "nospam" "invalid")
4183 '("noreply" "nospam" "invalid" "@@" "[^[:ascii:]].*@" "[ \t]")
4184 "List of regexps of potentially bogus mail addresses.
4185 See `message-check-recipients' how to setup checking.
4187 This list should make it possible to catch typos or warn about
4188 spam-trap addresses. It doesn't aim to verify strict RFC
4190 :version
"23.1" ;; No Gnus
4191 :group
'message-headers
4193 (const :tag
"None" nil
)
4199 (const :tag
"duplicate @" "@@")
4200 (const :tag
"non-ascii local part" "[^[:ascii:]].*@")
4201 ;; Already caught by `message-valid-fqdn-regexp'
4202 ;; (const :tag "`_' in domain part" "@.*_")
4203 (const :tag
"whitespace" "[ \t]"))
4208 (defun message-fix-before-sending ()
4209 "Do various things to make the message nice before sending it."
4210 ;; Make sure there's a newline at the end of the message.
4211 (goto-char (point-max))
4214 ;; Make the hidden headers visible.
4216 ;; Sort headers before sending the message.
4217 (message-sort-headers)
4218 ;; Make invisible text visible.
4219 ;; It doesn't seem as if this is useful, since the invisible property
4220 ;; is clobbered by an after-change hook anyhow.
4221 (message-check 'invisible-text
4222 (let ((regions (message-text-with-property 'invisible
))
4226 (setq from
(caar regions
)
4228 regions
(cdr regions
))
4229 (put-text-property from to
'invisible nil
)
4230 (message-overlay-put (message-make-overlay from to
)
4232 (unless (yes-or-no-p
4233 "Invisible text found and made visible; continue sending? ")
4234 (error "Invisible text found and made visible")))))
4235 (message-check 'illegible-text
4236 (let (char found choice
)
4239 (skip-chars-forward mm-7bit-chars
)
4240 (when (get-text-property (point) 'no-illegible-text
)
4241 ;; There is a signed or encrypted raw message part
4242 ;; that is considered to be safe.
4243 (goto-char (or (next-single-property-change
4244 (point) 'no-illegible-text
)
4246 (setq char
(char-after)))
4247 (when (or (< (mm-char-int char
) 128)
4248 (and (mm-multibyte-p)
4249 (memq (char-charset char
)
4250 '(eight-bit-control eight-bit-graphic
4251 ;; Emacs 23, Bug#1770:
4254 (not (get-text-property
4255 (point) 'untranslated-utf-8
))))
4256 (message-overlay-put (message-make-overlay (point) (1+ (point)))
4262 (gnus-multiple-choice
4263 "Non-printable characters found. Continue sending?"
4264 `((?d
"Remove non-printable characters and send")
4266 "Replace non-printable characters with \"%s\" and send"
4267 message-replacement-char
))
4268 (?s
"Send as is without removing anything")
4269 (?e
"Continue editing"))))
4271 (error "Non-printable characters"))
4273 (skip-chars-forward mm-7bit-chars
)
4275 (when (let ((char (char-after)))
4276 (or (< (mm-char-int char
) 128)
4277 (and (mm-multibyte-p)
4278 ;; FIXME: Wrong for Emacs 23 (unicode) and for
4279 ;; things like undecodable utf-8 (in Emacs 21?).
4280 ;; Should at least use find-coding-systems-region.
4282 (memq (char-charset char
)
4283 '(eight-bit-control eight-bit-graphic
4284 ;; Emacs 23, Bug#1770:
4287 (not (get-text-property
4288 (point) 'untranslated-utf-8
)))))
4290 (message-kill-all-overlays)
4292 (when (eq choice ?r
)
4293 (insert message-replacement-char
))))
4295 (skip-chars-forward mm-7bit-chars
)))))
4296 (message-check 'bogus-recipient
4297 ;; Warn before sending a mail to an invalid address.
4298 (message-check-recipients)))
4300 (defun message-bogus-recipient-p (recipients)
4301 "Check if a mail address in RECIPIENTS looks bogus.
4303 RECIPIENTS is a mail header. Return a list of potentially bogus
4304 addresses. If none is found, return nil.
4306 An address might be bogus if the domain part is not fully
4307 qualified, see `message-valid-fqdn-regexp', or if there's a
4308 matching entry in `message-bogus-addresses'."
4309 ;; FIXME: How about "foo@subdomain", when the MTA adds ".domain.tld"?
4311 (mapc (lambda (address)
4312 (setq address
(cadr address
))
4316 (not (string-match "@" address
))
4319 message-valid-fqdn-regexp
"\\)\\'") address
)))
4320 (and message-bogus-addresses
4322 (if (listp message-bogus-addresses
)
4323 (mapconcat 'identity
4324 message-bogus-addresses
4326 message-bogus-addresses
)))
4327 (string-match re address
))))
4328 (push address found
)))
4330 (mail-extract-address-components recipients t
))
4333 (defun message-check-recipients ()
4334 "Warn before composing or sending a mail to an invalid address.
4336 This function could be useful in `message-setup-hook'."
4339 (message-narrow-to-headers)
4340 (dolist (hdr '("To" "Cc" "Bcc"))
4341 (let ((addr (message-fetch-field hdr
)))
4342 (when (stringp addr
)
4343 (dolist (bog (message-bogus-recipient-p addr
))
4347 "Address `%s' might be bogus. Continue? " bog
)))
4348 (error "Bogus address"))))))))
4350 (custom-add-option 'message-setup-hook
'message-check-recipients
)
4352 (defun message-add-action (action &rest types
)
4353 "Add ACTION to be performed when doing an exit of type TYPES."
4355 (add-to-list (intern (format "message-%s-actions" (pop types
)))
4358 (defun message-delete-action (action &rest types
)
4359 "Delete ACTION from lists of actions performed when doing an exit of type TYPES."
4362 (set (setq var
(intern (format "message-%s-actions" (pop types
))))
4363 (delq action
(symbol-value var
))))))
4365 (defun message-do-actions (actions)
4366 "Perform all actions in ACTIONS."
4367 ;; Now perform actions on successful sending.
4368 (dolist (action actions
)
4371 ;; A simple function.
4374 ;; Something to be evaled.
4378 (defun message-send-mail-partially ()
4379 "Send mail as message/partial."
4380 ;; replace the header delimiter with a blank line
4381 (goto-char (point-min))
4383 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4384 (replace-match "\n")
4385 (run-hooks 'message-send-mail-hook
)
4386 (let ((p (goto-char (point-min)))
4387 (tembuf (message-generate-new-buffer-clone-locals " message temp"))
4388 (curbuf (current-buffer))
4389 (id (message-make-message-id)) (n 1)
4390 plist total header required-mail-headers
)
4392 (if (< (point-max) (+ p message-send-mail-partially-limit
))
4393 (goto-char (point-max))
4394 (goto-char (+ p message-send-mail-partially-limit
))
4396 (if (<= (point) p
) (forward-line 1))) ;; In case of bad message.
4399 (setq total
(length plist
))
4400 (push (point-max) plist
)
4401 (setq plist
(nreverse plist
))
4404 (setq p
(pop plist
))
4407 (copy-to-buffer tembuf p
(car plist
))
4409 (goto-char (point-min))
4412 (goto-char (point-min))
4413 (narrow-to-region (point) (point))
4416 (setq header
(buffer-substring (point-min) (point)))
4417 (goto-char (point-min))
4418 (narrow-to-region (point) (point))
4420 (message-remove-header "Mime-Version")
4421 (message-remove-header "Content-Type")
4422 (message-remove-header "Content-Transfer-Encoding")
4423 (message-remove-header "Message-ID")
4424 (message-remove-header "Lines")
4425 (goto-char (point-max))
4426 (insert "Mime-Version: 1.0\n")
4427 (setq header
(buffer-string)))
4428 (goto-char (point-max))
4429 (insert (format "Content-Type: message/partial; id=\"%s\"; number=%d; total=%d\n\n"
4432 (let ((mail-header-separator ""))
4433 (when (memq 'Message-ID message-required-mail-headers
)
4434 (insert "Message-ID: " (message-make-message-id) "\n"))
4435 (when (memq 'Lines message-required-mail-headers
)
4436 (insert "Lines: " (message-make-lines) "\n"))
4437 (message-goto-subject)
4439 (insert (format " (%d/%d)" n total
))
4441 (funcall (or message-send-mail-real-function
4442 message-send-mail-function
)))
4444 (setq p
(pop plist
))
4446 (kill-buffer tembuf
))))
4448 (declare-function hashcash-wait-async
"hashcash" (&optional buffer
))
4450 (defun message-send-mail (&optional arg
)
4451 (require 'mail-utils
)
4452 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
4453 (case-fold-search nil
)
4454 (news (message-news-p))
4455 (mailbuf (current-buffer))
4456 (message-this-is-mail t
)
4457 ;; gnus-setup-posting-charset is autoloaded in mml.el (FIXME
4458 ;; maybe it should not be), which this file requires. Hence
4459 ;; the fboundp test is always true. Loading it from gnus-msg
4460 ;; loads many Gnus files (Bug#5642). If
4461 ;; gnus-group-posting-charset-alist hasn't been customized,
4462 ;; this is just going to return nil anyway. FIXME it would
4463 ;; be good to improve this further, because even if g-g-p-c-a
4464 ;; has been customized, that is likely to just be for news.
4465 ;; Eg either move the definition from gnus-msg, or separate out
4466 ;; the mail and news parts.
4467 (message-posting-charset
4468 (if (and (fboundp 'gnus-setup-posting-charset
)
4469 (boundp 'gnus-group-posting-charset-alist
))
4470 (gnus-setup-posting-charset nil
)
4471 message-posting-charset
))
4472 (headers message-required-mail-headers
))
4473 (when (and message-generate-hashcash
4474 (not (eq message-generate-hashcash
'opportunistic
)))
4475 (message "Generating hashcash...")
4477 ;; Wait for calculations already started to finish...
4478 (hashcash-wait-async)
4479 ;; ...and do calculations not already done. mail-add-payment
4480 ;; will leave existing X-Hashcash headers alone.
4482 (message "Generating hashcash...done"))
4484 (message-narrow-to-headers)
4485 ;; Generate the Mail-Followup-To header if the header is not there...
4486 (if (and (message-subscribed-p)
4487 (not (mail-fetch-field "mail-followup-to")))
4490 (cons "Mail-Followup-To" (message-make-mail-followup-to))
4491 message-required-mail-headers
))
4492 ;; otherwise, delete the MFT header if the field is empty
4493 (when (equal "" (mail-fetch-field "mail-followup-to"))
4494 (message-remove-header "^Mail-Followup-To:")))
4495 ;; Insert some headers.
4496 (let ((message-deletable-headers
4497 (if news nil message-deletable-headers
)))
4498 (message-generate-headers headers
))
4499 ;; Check continuation headers.
4500 (message-check 'continuation-headers
4501 (goto-char (point-min))
4502 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4503 (goto-char (match-beginning 0))
4504 (if (y-or-n-p "Fix continuation lines? ")
4507 (unless (y-or-n-p "Send anyway? ")
4508 (error "Failed to send the message")))))
4509 ;; Let the user do all of the above.
4510 (run-hooks 'message-header-hook
))
4512 (with-current-buffer tembuf
4514 ;; Avoid copying text props (except hard newlines).
4515 (insert (with-current-buffer mailbuf
4516 (mml-buffer-substring-no-properties-except-hard-newlines
4517 (point-min) (point-max))))
4518 ;; Remove some headers.
4519 (message-encode-message-body)
4521 (message-narrow-to-headers)
4522 ;; We (re)generate the Lines header.
4523 (when (memq 'Lines message-required-mail-headers
)
4524 (message-generate-headers '(Lines)))
4525 ;; Remove some headers.
4526 (message-remove-header message-ignored-mail-headers t
)
4527 (let ((mail-parse-charset message-default-charset
))
4528 (mail-encode-encoded-word-buffer)))
4529 (goto-char (point-max))
4530 ;; require one newline at the end.
4531 (or (= (preceding-char) ?
\n)
4533 (message-cleanup-headers)
4534 ;; FIXME: we're inserting the courtesy copy after encoding.
4535 ;; This is wrong if the courtesy copy string contains
4536 ;; non-ASCII characters. -- jh
4539 (message-narrow-to-headers)
4541 (not (message-fetch-field "List-Post"))
4542 (not (message-fetch-field "List-ID"))
4543 (or (message-fetch-field "cc")
4544 (message-fetch-field "bcc")
4545 (message-fetch-field "to"))
4546 (let ((content-type (message-fetch-field
4551 (string= "text/plain"
4553 (mail-header-parse-content-type
4557 (message-fetch-field
4558 "content-transfer-encoding")))))))
4559 (message-insert-courtesy-copy
4560 (with-current-buffer mailbuf
4561 message-courtesy-message
)))
4562 ;; Let's make sure we encoded all the body.
4563 (assert (save-excursion
4564 (goto-char (point-min))
4565 (not (re-search-forward "[^\000-\377]" nil t
))))
4566 (mm-disable-multibyte)
4567 (if (or (not message-send-mail-partially-limit
)
4568 (< (buffer-size) message-send-mail-partially-limit
)
4569 (not (message-y-or-n-p
4570 "The message size is too large, split? "
4574 (/ (buffer-size) 1000) "KB, is too large.
4576 Some mail gateways (MTA's) bounce large messages. To avoid the
4577 problem, answer `y', and the message will be split into several
4578 smaller pieces, the size of each is about "
4579 (/ message-send-mail-partially-limit
1000)
4583 However, some mail readers (MUA's) can't read split messages, i.e.,
4584 mails in message/partially format. Answer `n', and the message will be
4587 The size limit is controlled by `message-send-mail-partially-limit'.
4588 If you always want Gnus to send messages in one piece, set
4589 `message-send-mail-partially-limit' to nil.
4592 (message "Sending via mail...")
4593 (funcall (or message-send-mail-real-function
4594 message-send-mail-function
)))
4595 (message-send-mail-partially)))
4596 (kill-buffer tembuf
))
4597 (set-buffer mailbuf
)
4598 (push 'mail message-sent-message-via
)))
4600 (defun message-send-mail-with-sendmail ()
4601 "Send off the prepared buffer with sendmail."
4603 (let ((errbuf (if message-interactive
4604 (message-generate-new-buffer-clone-locals
4607 resend-to-addresses delimline
)
4610 (let ((case-fold-search t
))
4612 (message-narrow-to-headers)
4613 (setq resend-to-addresses
(message-fetch-field "resent-to")))
4614 ;; Change header-delimiter to be what sendmail expects.
4615 (goto-char (point-min))
4617 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4618 (replace-match "\n")
4620 (setq delimline
(point-marker))
4621 (run-hooks 'message-send-mail-hook
)
4622 ;; Insert an extra newline if we need it to work around
4623 ;; Sun's bug that swallows newlines.
4624 (goto-char (1+ delimline
))
4625 (when (eval message-mailer-swallows-blank-line
)
4627 (when message-interactive
4628 (with-current-buffer errbuf
4630 (let* ((default-directory "/")
4631 (coding-system-for-write message-send-coding-system
)
4633 'call-process-region
4635 (list (point-min) (point-max)
4636 (cond ((boundp 'sendmail-program
)
4638 ((file-exists-p "/usr/sbin/sendmail")
4639 "/usr/sbin/sendmail")
4640 ((file-exists-p "/usr/lib/sendmail")
4641 "/usr/lib/sendmail")
4642 ((file-exists-p "/usr/ucblib/sendmail")
4643 "/usr/ucblib/sendmail")
4645 nil errbuf nil
"-oi")
4646 message-sendmail-extra-arguments
4647 ;; Always specify who from,
4648 ;; since some systems have broken sendmails.
4649 ;; But some systems are more broken with -f, so
4650 ;; we'll let users override this.
4651 (and (null message-sendmail-f-is-evil
)
4652 (list "-f" (message-sendmail-envelope-from)))
4653 ;; These mean "report errors by mail"
4654 ;; and "deliver in background".
4655 (if (null message-interactive
) '("-oem" "-odb"))
4656 ;; Get the addresses from the message
4657 ;; unless this is a resend.
4658 ;; We must not do that for a resend
4659 ;; because we would find the original addresses.
4660 ;; For a resend, include the specific addresses.
4661 (if resend-to-addresses
4662 (list resend-to-addresses
)
4664 (unless (or (null cpr
) (and (numberp cpr
) (zerop cpr
)))
4665 (if errbuf
(pop-to-buffer errbuf
))
4666 (error "Sending...failed with exit value %d" cpr
)))
4667 (when message-interactive
4668 (with-current-buffer errbuf
4669 (goto-char (point-min))
4670 (while (re-search-forward "\n+ *" nil t
)
4671 (replace-match "; "))
4672 (if (not (zerop (buffer-size)))
4673 (error "Sending...failed to %s"
4674 (buffer-string))))))
4675 (when (bufferp errbuf
)
4676 (kill-buffer errbuf
)))))
4678 (defun message-send-mail-with-qmail ()
4679 "Pass the prepared message buffer to qmail-inject.
4680 Refer to the documentation for the variable `message-send-mail-function'
4681 to find out how to use this."
4682 ;; replace the header delimiter with a blank line
4683 (goto-char (point-min))
4685 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4686 (replace-match "\n")
4687 (run-hooks 'message-send-mail-hook
)
4690 (let ((coding-system-for-write message-send-coding-system
))
4692 'call-process-region
(point-min) (point-max)
4693 message-qmail-inject-program nil nil nil
4694 ;; qmail-inject's default behavior is to look for addresses on the
4695 ;; command line; if there're none, it scans the headers.
4696 ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
4698 ;; in general, ALL of qmail-inject's defaults are perfect for simply
4699 ;; reading a formatted (i. e., at least a To: or Resent-To header)
4700 ;; message from stdin.
4702 ;; qmail also has the advantage of not having been raped by
4703 ;; various vendors, so we don't have to allow for that, either --
4704 ;; compare this with message-send-mail-with-sendmail and weep
4705 ;; for sendmail's lost innocence.
4707 ;; all this is way cool coz it lets us keep the arguments entirely
4708 ;; free for -inject-arguments -- a big win for the user and for us
4709 ;; since we don't have to play that double-guessing game and the user
4710 ;; gets full control (no gestapo'ish -f's, for instance). --sj
4711 (if (functionp message-qmail-inject-args
)
4712 (funcall message-qmail-inject-args
)
4713 message-qmail-inject-args
)))
4714 ;; qmail-inject doesn't say anything on it's stdout/stderr,
4715 ;; we have to look at the retval instead
4717 (100 (error "qmail-inject reported permanent failure"))
4718 (111 (error "qmail-inject reported transient failure"))
4719 ;; should never happen
4720 (t (error "qmail-inject reported unknown failure"))))
4722 (defun message-send-mail-with-mh ()
4723 "Send the prepared message buffer with mh."
4724 (let ((mh-previous-window-config nil
)
4725 (name (mh-new-draft-name)))
4726 (setq buffer-file-name name
)
4727 ;; MH wants to generate these headers itself.
4728 (when message-mh-deletable-headers
4729 (let ((headers message-mh-deletable-headers
))
4731 (goto-char (point-min))
4732 (and (re-search-forward
4733 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
4734 (message-delete-line))
4736 (run-hooks 'message-send-mail-hook
)
4737 ;; Pass it on to mh.
4740 (defun message-smtpmail-send-it ()
4741 "Send the prepared message buffer with `smtpmail-send-it'.
4742 The only difference from `smtpmail-send-it' is that this command
4743 evaluates `message-send-mail-hook' just before sending a message.
4744 It is useful if your ISP requires the POP-before-SMTP
4745 authentication. See the Gnus manual for details."
4746 (run-hooks 'message-send-mail-hook
)
4749 (defun message-send-mail-with-mailclient ()
4750 "Send the prepared message buffer with `mailclient-send-it'.
4751 The only difference from `mailclient-send-it' is that this
4752 command evaluates `message-send-mail-hook' just before sending a message."
4753 (run-hooks 'message-send-mail-hook
)
4754 (mailclient-send-it))
4756 (defun message-canlock-generate ()
4757 "Return a string that is non-trivial to guess.
4758 Do not use this for anything important, it is cryptographically weak."
4760 (let (sha1-maximum-internal-length)
4761 (sha1 (concat (message-unique-id)
4762 (format "%x%x%x" (random) (random t
) (random))
4763 (prin1-to-string (recent-keys))
4764 (prin1-to-string (garbage-collect))))))
4766 (defvar canlock-password
)
4767 (defvar canlock-password-for-verify
)
4769 (defun message-canlock-password ()
4770 "The password used by message for cancel locks.
4771 This is the value of `canlock-password', if that option is non-nil.
4772 Otherwise, generate and save a value for `canlock-password' first."
4774 (unless canlock-password
4775 (customize-save-variable 'canlock-password
(message-canlock-generate))
4776 (setq canlock-password-for-verify canlock-password
))
4779 (defun message-insert-canlock ()
4780 (when message-insert-canlock
4781 (message-canlock-password)
4782 (canlock-insert-header)))
4784 (autoload 'nnheader-get-report
"nnheader")
4786 (declare-function gnus-setup-posting-charset
"gnus-msg" (group))
4788 (defun message-send-news (&optional arg
)
4790 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*"))
4791 (case-fold-search nil
)
4792 (method (if (functionp message-post-method
)
4793 (funcall message-post-method arg
)
4794 message-post-method
))
4795 (newsgroups-field (save-restriction
4796 (message-narrow-to-headers-or-head)
4797 (message-fetch-field "Newsgroups")))
4798 (followup-field (save-restriction
4799 (message-narrow-to-headers-or-head)
4800 (message-fetch-field "Followup-To")))
4801 ;; BUG: We really need to get the charset for each name in the
4802 ;; Newsgroups and Followup-To lines to allow crossposting
4803 ;; between group namess with incompatible character sets.
4804 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
4805 (group-field-charset
4806 (gnus-group-name-charset method newsgroups-field
))
4807 (followup-field-charset
4808 (gnus-group-name-charset method
(or followup-field
"")))
4809 (rfc2047-header-encoding-alist
4810 (append (when group-field-charset
4811 (list (cons "Newsgroups" group-field-charset
)))
4812 (when followup-field-charset
4813 (list (cons "Followup-To" followup-field-charset
)))
4814 rfc2047-header-encoding-alist
))
4815 (messbuf (current-buffer))
4816 (message-syntax-checks
4818 (listp message-syntax-checks
))
4819 (cons '(existing-newsgroups . disabled
)
4820 message-syntax-checks
)
4821 message-syntax-checks
))
4822 (message-this-is-news t
)
4823 (message-posting-charset
4824 (gnus-setup-posting-charset newsgroups-field
))
4826 (if (not (message-check-news-body-syntax))
4829 (message-narrow-to-headers)
4830 ;; Insert some headers.
4831 (message-generate-headers message-required-news-headers
)
4832 (message-insert-canlock)
4833 ;; Let the user do all of the above.
4834 (run-hooks 'message-header-hook
))
4835 ;; Note: This check will be disabled by the ".*" default value for
4836 ;; gnus-group-name-charset-group-alist. -- Pa 2001-10-07.
4837 (when (and group-field-charset
4838 (listp message-syntax-checks
))
4839 (setq message-syntax-checks
4840 (cons '(valid-newsgroups . disabled
)
4841 message-syntax-checks
)))
4842 (message-cleanup-headers)
4843 (if (not (let ((message-post-method method
))
4844 (message-check-news-syntax)))
4847 (with-current-buffer tembuf
4848 (buffer-disable-undo)
4850 ;; Avoid copying text props (except hard newlines).
4852 (with-current-buffer messbuf
4853 (mml-buffer-substring-no-properties-except-hard-newlines
4854 (point-min) (point-max))))
4855 (message-encode-message-body)
4856 ;; Remove some headers.
4858 (message-narrow-to-headers)
4859 ;; We (re)generate the Lines header.
4860 (when (memq 'Lines message-required-mail-headers
)
4861 (message-generate-headers '(Lines)))
4862 ;; Remove some headers.
4863 (message-remove-header message-ignored-news-headers t
)
4864 (let ((mail-parse-charset message-default-charset
))
4865 (mail-encode-encoded-word-buffer)))
4866 (goto-char (point-max))
4867 ;; require one newline at the end.
4868 (or (= (preceding-char) ?
\n)
4870 (let ((case-fold-search t
))
4871 ;; Remove the delimiter.
4872 (goto-char (point-min))
4874 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4875 (replace-match "\n")
4877 (run-hooks 'message-send-news-hook
)
4878 (gnus-open-server method
)
4879 (message "Sending news via %s..." (gnus-server-string method
))
4880 (setq result
(let ((mail-header-separator ""))
4881 (gnus-request-post method
))))
4882 (kill-buffer tembuf
))
4883 (set-buffer messbuf
)
4885 (push 'news message-sent-message-via
)
4886 (message "Couldn't send message via news: %s"
4887 (nnheader-get-report (car method
)))
4891 ;;; Header generation & syntax checking.
4894 (defun message-check-element (type)
4895 "Return non-nil if this TYPE is not to be checked."
4896 (if (eq message-syntax-checks
'dont-check-for-anything-just-trust-me
)
4898 (let ((able (assq type message-syntax-checks
)))
4900 (eq (cdr able
) 'disabled
)))))
4902 (defun message-check-news-syntax ()
4903 "Check the syntax of the message."
4907 ;; We narrow to the headers and check them first.
4910 (message-narrow-to-headers)
4911 (message-check-news-header-syntax))))))
4913 (defun message-check-news-header-syntax ()
4915 ;; Check Newsgroups header.
4916 (message-check 'newsgroups
4917 (let ((group (message-fetch-field "newsgroups")))
4920 (not (string-match "\\`[ \t]*\\'" group
)))
4923 "The newsgroups field is empty or missing. Posting is denied.")))))
4924 ;; Check the Subject header.
4925 (message-check 'subject
4926 (let* ((case-fold-search t
)
4927 (subject (message-fetch-field "subject")))
4930 (not (string-match "\\`[ \t]*\\'" subject
)))
4933 "The subject field is empty or missing. Posting is denied.")))))
4934 ;; Check for commands in Subject.
4935 (message-check 'subject-cmsg
4936 (if (string-match "^cmsg " (message-fetch-field "subject"))
4938 "The control code \"cmsg\" is in the subject. Really post? ")
4940 ;; Check long header lines.
4941 (message-check 'long-header-lines
4942 (let ((start (point))
4946 (while (and (not found
)
4947 (re-search-forward "^\\([^ \t:]+\\): " nil t
))
4948 (if (> (- (point) (match-beginning 0)) 998)
4950 length
(- (point) (match-beginning 0)))
4951 (setq header
(match-string-no-properties 1)))
4952 (setq start
(match-beginning 0))
4955 (y-or-n-p (format "Your %s header is too long (%d). Really post? "
4958 ;; Check for multiple identical headers.
4959 (message-check 'multiple-headers
4961 (while (and (not found
)
4962 (re-search-forward "^[^ \t:]+: " nil t
))
4964 (or (re-search-forward
4969 (match-beginning 0) (- (match-end 0) 2))))
4974 (y-or-n-p (format "Multiple %s headers. Really post? " found
))
4976 ;; Check for Version and Sendsys.
4977 (message-check 'sendsys
4978 (if (re-search-forward "^Sendsys:\\|^Version:" nil t
)
4980 (format "The article contains a %s command. Really post? "
4981 (buffer-substring (match-beginning 0)
4982 (1- (match-end 0)))))
4984 ;; See whether we can shorten Followup-To.
4985 (message-check 'shorten-followup-to
4986 (let ((newsgroups (message-fetch-field "newsgroups"))
4987 (followup-to (message-fetch-field "followup-to"))
4989 (when (and newsgroups
4990 (string-match "," newsgroups
)
4995 (setq to
(completing-read
4996 "Followups to (default no Followup-To header): "
4999 (message-tokenize-header
5001 (goto-char (point-min))
5002 (insert "Followup-To: " to
"\n"))
5004 ;; Check "Shoot me".
5005 (message-check 'shoot
5006 (if (re-search-forward
5007 "Message-ID.*.i-did-not-set--mail-host-address--so-tickle-me" nil t
)
5008 (y-or-n-p "You appear to have a misconfigured system. Really post? ")
5010 ;; Check for Approved.
5011 (message-check 'approved
5012 (if (re-search-forward "^Approved:" nil t
)
5013 (y-or-n-p "The article contains an Approved header. Really post? ")
5015 ;; Check the Message-ID header.
5016 (message-check 'message-id
5017 (let* ((case-fold-search t
)
5018 (message-id (message-fetch-field "message-id" t
)))
5019 (or (not message-id
)
5020 ;; Is there an @ in the ID?
5021 (and (string-match "@" message-id
)
5022 ;; Is there a dot in the ID?
5023 (string-match "@[^.]*\\." message-id
)
5024 ;; Does the ID end with a dot?
5025 (not (string-match "\\.>" message-id
)))
5027 (format "The Message-ID looks strange: \"%s\". Really post? "
5029 ;; Check the Newsgroups & Followup-To headers.
5030 (message-check 'existing-newsgroups
5031 (let* ((case-fold-search t
)
5032 (newsgroups (message-fetch-field "newsgroups"))
5033 (followup-to (message-fetch-field "followup-to"))
5034 (groups (message-tokenize-header
5036 (concat newsgroups
"," followup-to
)
5038 (post-method (if (functionp message-post-method
)
5039 (funcall message-post-method
)
5040 message-post-method
))
5041 ;; KLUDGE to handle nnvirtual groups. Doing this right
5042 ;; would probably involve a new nnoo function.
5043 ;; -- Per Abrahamsen <abraham@dina.kvl.dk>, 2001-10-17.
5044 (method (if (and (consp post-method
)
5045 (eq (car post-method
) 'nnvirtual
)
5046 gnus-message-group-art
)
5047 (let ((group (car (nnvirtual-find-group-art
5048 (car gnus-message-group-art
)
5049 (cdr gnus-message-group-art
)))))
5050 (gnus-find-method-for-group group
))
5054 (gnus-group-name-decode
5055 (gnus-group-real-name n
)
5056 (gnus-group-name-charset method n
)))
5057 (gnus-groups-from-server method
)))
5060 (when (and (not (equal (car groups
) "poster"))
5061 (not (member (car groups
) known-groups
))
5062 (not (member (car groups
) errors
)))
5063 (push (car groups
) errors
))
5066 ;; Gnus is not running.
5067 ((or (not (and (boundp 'gnus-active-hashtb
)
5068 gnus-active-hashtb
))
5069 (not (boundp 'gnus-read-active-file
)))
5071 ;; We don't have all the group names.
5072 ((and (or (not gnus-read-active-file
)
5073 (eq gnus-read-active-file
'some
))
5077 "Really use %s possibly unknown group%s: %s? "
5078 (if (= (length errors
) 1) "this" "these")
5079 (if (= (length errors
) 1) "" "s")
5080 (mapconcat 'identity errors
", "))))
5081 ;; There were no errors.
5084 ;; There are unknown groups.
5088 "Really post to %s unknown group%s: %s? "
5089 (if (= (length errors
) 1) "this" "these")
5090 (if (= (length errors
) 1) "" "s")
5091 (mapconcat 'identity errors
", ")))))))
5092 ;; Check continuation headers.
5093 (message-check 'continuation-headers
5094 (goto-char (point-min))
5095 (let ((do-posting t
))
5096 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
5097 (goto-char (match-beginning 0))
5098 (if (y-or-n-p "Fix continuation lines? ")
5101 (unless (y-or-n-p "Send anyway? ")
5102 (setq do-posting nil
))))
5104 ;; Check the Newsgroups & Followup-To headers for syntax errors.
5105 (message-check 'valid-newsgroups
5106 (let ((case-fold-search t
)
5107 (headers '("Newsgroups" "Followup-To"))
5109 (while (and headers
(not error
))
5110 (when (setq header
(mail-fetch-field (car headers
)))
5114 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-+_&.a-zA-Z0-9]+\\)*\\'"
5119 (not (string-match "\\.\\'\\|\\.\\." g
)))
5120 (message-tokenize-header header
","))))
5127 (format "The %s header looks odd: \"%s\". Really post? "
5128 (car headers
) header
)))))
5129 (message-check 'repeated-newsgroups
5130 (let ((case-fold-search t
)
5131 (headers '("Newsgroups" "Followup-To"))
5132 header error groups group
)
5135 (when (setq header
(mail-fetch-field (pop headers
)))
5136 (setq groups
(message-tokenize-header header
","))
5137 (while (setq group
(pop groups
))
5138 (when (member group groups
)
5144 (format "Group %s is repeated in headers. Really post? " error
)))))
5145 ;; Check the From header.
5146 (message-check 'from
5147 (let* ((case-fold-search t
)
5148 (from (message-fetch-field "from"))
5152 (message "There is no From line. Posting is denied.")
5154 ((or (not (string-match
5156 (setq ad
(nth 1 (mail-extract-address-components
5157 from
))))) ;larsi@ifi
5158 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5159 (string-match "@\\." ad
) ;larsi@.ifi.uio
5160 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5161 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5162 (string-match "(.*).*(.*)" from
)) ;(lars) (lars)
5164 "Denied posting -- the From looks strange: \"%s\"." from
)
5166 ((let ((addresses (rfc822-addresses from
)))
5167 ;; `rfc822-addresses' returns a string if parsing fails.
5168 (while (and (consp addresses
)
5169 (not (eq (string-to-char (car addresses
)) ?\
()))
5170 (setq addresses
(cdr addresses
)))
5173 "Denied posting -- bad From address: \"%s\"." from
)
5176 ;; Check the Reply-To header.
5177 (message-check 'reply-to
5178 (let* ((case-fold-search t
)
5179 (reply-to (message-fetch-field "reply-to"))
5184 ((string-match "," reply-to
)
5186 (format "Multiple Reply-To addresses: \"%s\". Really post? "
5188 ((or (not (string-match
5190 (setq ad
(nth 1 (mail-extract-address-components
5191 reply-to
))))) ;larsi@ifi
5192 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5193 (string-match "@\\." ad
) ;larsi@.ifi.uio
5194 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5195 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5196 (string-match "(.*).*(.*)" reply-to
)) ;(lars) (lars)
5199 "The Reply-To looks strange: \"%s\". Really post? "
5203 (defun message-check-news-body-syntax ()
5205 ;; Check for long lines.
5206 (message-check 'long-lines
5207 (goto-char (point-min))
5209 (concat "^" (regexp-quote mail-header-separator
) "$"))
5213 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)")
5216 (< (- (point) p
) 80)))
5217 (zerop (forward-line 1))))
5221 "You have lines longer than 79 characters. Really post? ")))
5222 ;; Check whether the article is empty.
5223 (message-check 'empty
5224 (goto-char (point-min))
5226 (concat "^" (regexp-quote mail-header-separator
) "$"))
5229 (goto-char (point-max))
5230 (re-search-backward message-signature-separator nil t
)
5232 (or (re-search-backward "[^ \n\t]" b t
)
5233 (if (message-gnksa-enable-p 'empty-article
)
5234 (y-or-n-p "Empty article. Really post? ")
5235 (message "Denied posting -- Empty article.")
5237 ;; Check for control characters.
5238 (message-check 'control-chars
5239 (if (re-search-forward
5240 (mm-string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
5243 "The article contains control characters. Really post? ")
5245 ;; Check excessive size.
5246 (message-check 'size
5247 (if (> (buffer-size) 60000)
5249 (format "The article is %d octets long. Really post? "
5252 ;; Check whether any new text has been added.
5253 (message-check 'new-text
5255 (not message-checksum
)
5256 (not (eq (message-checksum) message-checksum
))
5257 (if (message-gnksa-enable-p 'quoted-text-only
)
5259 "It looks like no new text has been added. Really post? ")
5260 (message "Denied posting -- no new text has been added.")
5262 ;; Check the length of the signature.
5263 (message-check 'signature
5264 (let (sig-start sig-end
)
5265 (goto-char (point-max))
5266 (if (not (re-search-backward message-signature-separator nil t
))
5268 (setq sig-start
(1+ (point-at-eol)))
5270 (if (re-search-forward
5271 "<#/?\\(multipart\\|part\\|external\\|mml\\)" nil t
)
5272 (- (point-at-bol) 1)
5274 (if (>= (count-lines sig-start sig-end
) 5)
5275 (if (message-gnksa-enable-p 'signature
)
5277 (format "Signature is excessively long (%d lines). Really post? "
5278 (count-lines sig-start sig-end
)))
5279 (message "Denied posting -- Excessive signature.")
5282 ;; Ensure that text follows last quoted portion.
5283 (message-check 'quoting-style
5284 (goto-char (point-max))
5285 (let ((no-problem t
))
5286 (when (search-backward-regexp "^>[^\n]*\n" nil t
)
5287 (setq no-problem
(search-forward-regexp "^[ \t]*[^>\n]" nil t
)))
5290 (if (message-gnksa-enable-p 'quoted-text-only
)
5291 (y-or-n-p "Your text should follow quoted text. Really post? ")
5293 (goto-char (point-min))
5295 (concat "^" (regexp-quote mail-header-separator
) "$"))
5296 (if (search-forward-regexp "^[ \t]*[^>\n]" nil t
)
5297 (y-or-n-p "Your text should follow quoted text. Really post? ")
5298 (message "Denied posting -- only quoted text.")
5301 (defun message-checksum ()
5302 "Return a \"checksum\" for the current buffer."
5305 (goto-char (point-min))
5307 (concat "^" (regexp-quote mail-header-separator
) "$"))
5309 (when (not (looking-at "[ \t\n]"))
5310 (setq sum
(logxor (ash sum
1) (if (natnump sum
) 0 1)
5315 (defun message-do-fcc ()
5316 "Process Fcc headers in the current buffer."
5317 (let ((case-fold-search t
)
5318 (buf (current-buffer))
5320 (mml-externalize-attachments message-fcc-externalize-attachments
))
5323 (message-narrow-to-headers)
5324 (setq file
(message-fetch-field "fcc" t
)))
5326 (set-buffer (get-buffer-create " *message temp*"))
5328 (insert-buffer-substring buf
)
5329 (message-encode-message-body)
5331 (message-narrow-to-headers)
5332 (while (setq file
(message-fetch-field "fcc" t
))
5334 (message-remove-header "fcc" nil t
))
5335 (let ((mail-parse-charset message-default-charset
)
5336 (rfc2047-header-encoding-alist
5337 (cons '("Newsgroups" . default
)
5338 rfc2047-header-encoding-alist
)))
5339 (mail-encode-encoded-word-buffer)))
5340 (goto-char (point-min))
5341 (when (re-search-forward
5342 (concat "^" (regexp-quote mail-header-separator
) "$")
5344 (replace-match "" t t
))
5345 ;; Process FCC operations.
5347 (setq file
(pop list
))
5348 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file
)
5349 ;; Pipe the article to the program in question.
5350 (call-process-region (point-min) (point-max) shell-file-name
5351 nil nil nil shell-command-switch
5352 (match-string 1 file
))
5353 ;; Save the article.
5354 (setq file
(expand-file-name file
))
5355 (unless (file-exists-p (file-name-directory file
))
5356 (make-directory (file-name-directory file
) t
))
5357 (if (and message-fcc-handler-function
5358 (not (eq message-fcc-handler-function
'rmail-output
)))
5359 (funcall message-fcc-handler-function file
)
5360 ;; FIXME this option, rmail-output (also used if
5361 ;; message-fcc-handler-function is nil) is not
5362 ;; documented anywhere AFAICS. It should work in Emacs
5363 ;; 23; I suspect it does not work in Emacs 22.
5364 ;; FIXME I don't see the need for the two different cases here.
5365 ;; mail-use-rfc822 makes no difference (in Emacs 23),and
5366 ;; the third argument just controls \"Wrote file\" message.
5367 (if (and (file-readable-p file
) (mail-file-babyl-p file
))
5368 (rmail-output file
1 nil t
)
5369 (let ((mail-use-rfc822 t
))
5370 (rmail-output file
1 t t
))))))
5371 (kill-buffer (current-buffer))))))
5373 (defun message-output (filename)
5374 "Append this article to Unix/babyl mail file FILENAME."
5375 (if (or (and (file-readable-p filename
)
5376 (mail-file-babyl-p filename
))
5377 ;; gnus-output-to-mail does the wrong thing with live, mbox
5378 ;; Rmail buffers in Emacs 23.
5379 ;; http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597255
5380 (let ((buff (find-buffer-visiting filename
)))
5381 (and buff
(with-current-buffer buff
5382 (eq major-mode
'rmail-mode
)))))
5383 (gnus-output-to-rmail filename t
)
5384 (gnus-output-to-mail filename t
)))
5386 (defun message-cleanup-headers ()
5387 "Do various automatic cleanups of the headers."
5388 ;; Remove empty lines in the header.
5390 (message-narrow-to-headers)
5391 ;; Remove blank lines.
5392 (while (re-search-forward "^[ \t]*\n" nil t
)
5393 (replace-match "" t t
))
5395 ;; Correct Newsgroups and Followup-To headers: Change sequence of
5396 ;; spaces to comma and eliminate spaces around commas. Eliminate
5397 ;; embedded line breaks.
5398 (goto-char (point-min))
5399 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t
)
5403 (if (re-search-forward "^[^ \t]" nil t
)
5407 (goto-char (point-min))
5408 (while (re-search-forward "\n[ \t]+" nil t
)
5409 (replace-match " " t t
)) ;No line breaks (too confusing)
5410 (goto-char (point-min))
5411 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t
)
5412 (replace-match "," t t
))
5413 (goto-char (point-min))
5414 ;; Remove trailing commas.
5415 (when (re-search-forward ",+$" nil t
)
5416 (replace-match "" t t
))))))
5418 (defun message-make-date (&optional now
)
5419 "Make a valid data header.
5420 If NOW, use that time instead."
5421 (let ((system-time-locale "C"))
5422 (format-time-string "%a, %d %b %Y %T %z" now
)))
5424 (defun message-insert-expires (days)
5425 "Insert the Expires header. Expiry in DAYS days."
5426 (interactive "NExpire article in how many days? ")
5428 (message-position-on-field "Expires" "X-Draft-From")
5429 (insert (message-make-expires-date days
))))
5431 (defun message-make-expires-date (days)
5432 "Make date string for the Expires header. Expiry in DAYS days.
5434 In posting styles use `(\"Expires\" (make-expires-date 30))'."
5435 (let* ((cur (decode-time (current-time)))
5436 (nday (+ days
(nth 3 cur
))))
5437 (setf (nth 3 cur
) nday
)
5438 (message-make-date (apply 'encode-time cur
))))
5440 (defun message-make-message-id ()
5441 "Make a unique Message-ID."
5442 (concat "<" (message-unique-id)
5443 (let ((psubject (save-excursion (message-fetch-field "subject")))
5445 (save-excursion (message-fetch-field "supersedes"))))
5447 (and message-reply-headers
5448 (mail-header-references message-reply-headers
)
5449 (mail-header-subject message-reply-headers
)
5452 (message-strip-subject-re
5453 (mail-header-subject message-reply-headers
))
5454 (message-strip-subject-re psubject
))))
5456 (string-match "_-_@" psupersedes
)))
5458 "@" (message-make-fqdn) ">"))
5460 (defvar message-unique-id-char nil
)
5462 ;; If you ever change this function, make sure the new version
5463 ;; cannot generate IDs that the old version could.
5464 ;; You might for example insert a "." somewhere (not next to another dot
5465 ;; or string boundary), or modify the "fsf" string.
5466 (defun message-unique-id ()
5467 ;; Don't use microseconds from (current-time), they may be unsupported.
5468 ;; Instead we use this randomly inited counter.
5469 (setq message-unique-id-char
5470 (%
(1+ (or message-unique-id-char
(logand (random t
) (1- (lsh 1 20)))))
5471 ;; (current-time) returns 16-bit ints,
5472 ;; and 2^16*25 just fits into 4 digits i base 36.
5474 (let ((tm (current-time)))
5476 (if (or (eq system-type
'ms-dos
)
5477 ;; message-number-base36 doesn't handle bigints.
5478 (floatp (user-uid)))
5479 (let ((user (downcase (user-login-name))))
5480 (while (string-match "[^a-z0-9_]" user
)
5481 (aset user
(match-beginning 0) ?_
))
5483 (message-number-base36 (user-uid) -
1))
5484 (message-number-base36 (+ (car tm
)
5485 (lsh (% message-unique-id-char
25) 16)) 4)
5486 (message-number-base36 (+ (nth 1 tm
)
5487 (lsh (/ message-unique-id-char
25) 16)) 4)
5488 ;; Append a given name, because while the generated ID is unique
5489 ;; to this newsreader, other newsreaders might otherwise generate
5490 ;; the same ID via another algorithm.
5493 (defun message-number-base36 (num len
)
5498 (concat (message-number-base36 (/ num
36) (1- len
))
5499 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
5502 (defun message-make-organization ()
5503 "Make an Organization header."
5504 (let* ((organization
5505 (when message-user-organization
5506 (if (functionp message-user-organization
)
5507 (funcall message-user-organization
)
5508 message-user-organization
))))
5510 (mm-enable-multibyte)
5511 (cond ((stringp organization
)
5512 (insert organization
))
5513 ((and (eq t organization
)
5514 message-user-organization-file
5515 (file-exists-p message-user-organization-file
))
5516 (insert-file-contents message-user-organization-file
)))
5517 (goto-char (point-min))
5518 (while (re-search-forward "[\t\n]+" nil t
)
5519 (replace-match "" t t
))
5520 (unless (zerop (buffer-size))
5523 (defun message-make-lines ()
5524 "Count the number of lines and return numeric string."
5529 (int-to-string (count-lines (point) (point-max))))))
5531 (defun message-make-references ()
5532 "Return the References header for this message."
5533 (when message-reply-headers
5534 (let ((message-id (mail-header-id message-reply-headers
))
5535 (references (mail-header-references message-reply-headers
)))
5536 (if (or references message-id
)
5537 (concat (or references
"") (and references
" ")
5541 (defun message-make-in-reply-to ()
5542 "Return the In-Reply-To header for this message."
5543 (when message-reply-headers
5544 (let ((from (mail-header-from message-reply-headers
))
5545 (date (mail-header-date message-reply-headers
))
5546 (msg-id (mail-header-id message-reply-headers
)))
5548 (let ((name (mail-extract-address-components from
)))
5550 msg-id
(if msg-id
" (")
5552 (if (string-match "[^\000-\177]" (car name
))
5553 ;; Quote a string containing non-ASCII characters.
5554 ;; It will make the RFC2047 encoder cause an error
5555 ;; if there are special characters.
5556 (mm-with-multibyte-buffer
5558 (goto-char (point-min))
5559 (while (search-forward "\"" nil t
)
5562 (zerop (%
(skip-chars-backward "\\\\") 2))
5563 (goto-char (match-beginning 0)))
5566 ;; Those quotes will be removed by the RFC2047 encoder.
5567 (concat "\"" (buffer-string) "\""))
5571 (if (or (not date
) (string= date
""))
5572 "(unknown date)" date
)
5573 "\"" (if msg-id
")")))))))
5575 (defun message-make-distribution ()
5576 "Make a Distribution header."
5577 (let ((orig-distribution (message-fetch-reply-field "distribution")))
5578 (cond ((functionp message-distribution-function
)
5579 (funcall message-distribution-function
))
5580 (t orig-distribution
))))
5582 (defun message-make-expires ()
5583 "Return an Expires header based on `message-expires'."
5584 (let ((current (current-time))
5585 (future (* 1.0 message-expires
60 60 24)))
5586 ;; Add the future to current.
5587 (setcar current
(+ (car current
) (round (/ future
(expt 2 16)))))
5588 (setcar (cdr current
) (+ (nth 1 current
) (%
(round future
) (expt 2 16))))
5589 (message-make-date current
)))
5591 (defun message-make-path ()
5593 (let ((login-name (user-login-name)))
5594 (cond ((null message-user-path
)
5595 (concat (system-name) "!" login-name
))
5596 ((stringp message-user-path
)
5597 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
5598 (concat message-user-path
"!" login-name
))
5601 (defun message-make-from (&optional name address
)
5602 "Make a From header."
5603 (let* ((style message-from-style
)
5604 (login (or address
(message-make-address)))
5606 (and (boundp 'user-full-name
)
5609 (when (string= fullname
"&")
5610 (setq fullname
(user-login-name)))
5612 (mm-enable-multibyte)
5615 (equal fullname
""))
5617 ((or (eq style
'angles
)
5618 (and (not (eq style
'parens
))
5619 ;; Use angles if no quoting is needed, or if parens would
5620 ;; need quoting too.
5621 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname
))
5622 (let ((tmp (concat fullname nil
)))
5623 (while (string-match "([^()]*)" tmp
)
5624 (aset tmp
(match-beginning 0) ?-
)
5625 (aset tmp
(1- (match-end 0)) ?-
))
5626 (string-match "[\\()]" tmp
)))))
5628 (goto-char (point-min))
5629 ;; Look for a character that cannot appear unquoted
5630 ;; according to RFC 822.
5631 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil
1)
5632 ;; Quote fullname, escaping specials.
5633 (goto-char (point-min))
5635 (while (re-search-forward "[\"\\]" nil
1)
5636 (replace-match "\\\\\\&" t
))
5638 (insert " <" login
">"))
5639 (t ; 'parens or default
5641 (let ((fullname-start (point)))
5643 (goto-char fullname-start
)
5644 ;; RFC 822 says \ and nonmatching parentheses
5645 ;; must be escaped in comments.
5646 ;; Escape every instance of ()\ ...
5647 (while (re-search-forward "[()\\]" nil
1)
5648 (replace-match "\\\\\\&" t
))
5649 ;; ... then undo escaping of matching parentheses,
5650 ;; including matching nested parentheses.
5651 (goto-char fullname-start
)
5652 (while (re-search-forward
5653 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
5655 (replace-match "\\1(\\3)" t
)
5656 (goto-char fullname-start
)))
5660 (defun message-make-sender ()
5661 "Return the \"real\" user address.
5662 This function tries to ignore all user modifications, and
5663 give as trustworthy answer as possible."
5664 (concat (user-login-name) "@" (system-name)))
5666 (defun message-make-address ()
5667 "Make the address of the user."
5668 (or (message-user-mail-address)
5669 (concat (user-login-name) "@" (message-make-domain))))
5671 (defun message-user-mail-address ()
5672 "Return the pertinent part of `user-mail-address'."
5673 (when (and user-mail-address
5674 (string-match "@.*\\." user-mail-address
))
5675 (if (string-match " " user-mail-address
)
5676 (nth 1 (mail-extract-address-components user-mail-address
))
5677 user-mail-address
)))
5679 (defun message-sendmail-envelope-from ()
5680 "Return the envelope from."
5681 (cond ((eq message-sendmail-envelope-from
'header
)
5682 (nth 1 (mail-extract-address-components
5683 (message-fetch-field "from"))))
5684 ((stringp message-sendmail-envelope-from
)
5685 message-sendmail-envelope-from
)
5687 (message-make-address))))
5689 (defun message-make-fqdn ()
5690 "Return user's fully qualified domain name."
5691 (let* ((system-name (system-name))
5692 (user-mail (message-user-mail-address))
5695 (string-match "@\\(.*\\)\\'" user-mail
))
5696 (match-string 1 user-mail
)))
5697 (case-fold-search t
))
5699 ((and message-user-fqdn
5700 (stringp message-user-fqdn
)
5701 (string-match message-valid-fqdn-regexp message-user-fqdn
)
5702 (not (string-match message-bogus-system-names message-user-fqdn
)))
5703 ;; `message-user-fqdn' seems to be valid
5705 ((and (string-match message-valid-fqdn-regexp system-name
)
5706 (not (string-match message-bogus-system-names system-name
)))
5707 ;; `system-name' returned the right result.
5709 ;; Try `mail-host-address'.
5710 ((and (boundp 'mail-host-address
)
5711 (stringp mail-host-address
)
5712 (string-match message-valid-fqdn-regexp mail-host-address
)
5713 (not (string-match message-bogus-system-names mail-host-address
)))
5715 ;; We try `user-mail-address' as a backup.
5717 (stringp user-domain
)
5718 (string-match message-valid-fqdn-regexp user-domain
)
5719 (not (string-match message-bogus-system-names user-domain
)))
5721 ;; Default to this bogus thing.
5724 ".i-did-not-set--mail-host-address--so-tickle-me")))))
5726 (defun message-make-host-name ()
5727 "Return the name of the host."
5728 (let ((fqdn (message-make-fqdn)))
5729 (string-match "^[^.]+\\." fqdn
)
5730 (substring fqdn
0 (1- (match-end 0)))))
5732 (defun message-make-domain ()
5733 "Return the domain name."
5734 (or mail-host-address
5735 (message-make-fqdn)))
5737 (defun message-to-list-only ()
5738 "Send a message to the list only.
5739 Remove all addresses but the list address from To and Cc headers."
5741 (let ((listaddr (message-make-mail-followup-to t
)))
5744 (message-remove-header "to")
5745 (message-remove-header "cc")
5746 (message-position-on-field "To" "X-Draft-From")
5747 (insert listaddr
)))))
5749 (defun message-make-mail-followup-to (&optional only-show-subscribed
)
5750 "Return the Mail-Followup-To header.
5751 If passed the optional argument ONLY-SHOW-SUBSCRIBED only return the
5752 subscribed address (and not the additional To and Cc header contents)."
5753 (let* ((case-fold-search t
)
5754 (to (message-fetch-field "To"))
5755 (cc (message-fetch-field "cc"))
5756 (msg-recipients (concat to
(and to cc
", ") cc
))
5758 (mapcar 'mail-strip-quoted-names
5759 (message-tokenize-header msg-recipients
)))
5761 (if message-subscribed-address-file
5762 (let (begin end item re
)
5765 (insert-file-contents message-subscribed-address-file
)
5767 (setq begin
(point))
5770 (if (bolp) (setq end
(1- end
)))
5771 (setq item
(regexp-quote (buffer-substring begin end
)))
5772 (if re
(setq re
(concat re
"\\|" item
))
5773 (setq re
(concat "\\`\\(" item
))))
5774 (and re
(list (concat re
"\\)\\'"))))))))
5775 (mft-regexps (apply 'append message-subscribed-regexps
5776 (mapcar 'regexp-quote
5777 message-subscribed-addresses
)
5780 message-subscribed-address-functions
))))
5783 (loop for recipient in recipients
5784 when
(loop for regexp in mft-regexps
5785 when
(string-match regexp recipient
) return t
)
5788 (if only-show-subscribed
5790 msg-recipients
))))))
5792 (defun message-idna-to-ascii-rhs-1 (header)
5793 "Interactively potentially IDNA encode domain names in HEADER."
5794 (let ((field (message-fetch-field header
))
5798 (mm-delete-duplicates
5799 (mapcar (lambda (rhs) (or (cadr (split-string rhs
"@")) ""))
5805 (mail-extract-address-components field t
))))))
5806 ;; Note that `rhs' will be "" if the address does not have
5807 ;; the domain part, i.e., if it is a local user's address.
5808 (setq ace
(if (string-match "\\`[[:ascii:]]*\\'" rhs
)
5810 (downcase (idna-to-ascii rhs
))))
5811 (when (and (not (equal rhs ace
))
5812 (or (not (eq message-use-idna
'ask
))
5813 (y-or-n-p (format "Replace %s with %s in %s:? "
5815 (goto-char (point-min))
5816 (while (re-search-forward (concat "^" header
":") nil t
)
5817 (message-narrow-to-field)
5818 (while (search-forward (concat "@" rhs
) nil t
)
5819 (replace-match (concat "@" ace
) t t
))
5820 (goto-char (point-max))
5823 (defun message-idna-to-ascii-rhs ()
5824 "Possibly IDNA encode non-ASCII domain names in From:, To: and Cc: headers.
5825 See `message-idna-encode'."
5827 (when message-use-idna
5830 ;; `message-narrow-to-head' that recognizes only the first empty
5831 ;; line as the message header separator used to be used here.
5832 ;; However, since there is the "--text follows this line--" line
5833 ;; normally, it failed in narrowing to the headers and potentially
5834 ;; caused the IDNA encoding on lines that look like headers in
5835 ;; the message body.
5836 (message-narrow-to-headers-or-head)
5837 (message-idna-to-ascii-rhs-1 "From")
5838 (message-idna-to-ascii-rhs-1 "To")
5839 (message-idna-to-ascii-rhs-1 "Reply-To")
5840 (message-idna-to-ascii-rhs-1 "Mail-Reply-To")
5841 (message-idna-to-ascii-rhs-1 "Mail-Followup-To")
5842 (message-idna-to-ascii-rhs-1 "Cc")))))
5844 (defun message-generate-headers (headers)
5845 "Prepare article HEADERS.
5846 Headers already prepared in the buffer are not modified."
5847 (setq headers
(append headers message-required-headers
))
5849 (message-narrow-to-headers)
5850 (let* ((Date (message-make-date))
5851 (Message-ID (message-make-message-id))
5852 (Organization (message-make-organization))
5853 (From (message-make-from))
5854 (Path (message-make-path))
5857 (In-Reply-To (message-make-in-reply-to))
5858 (References (message-make-references))
5860 (Distribution (message-make-distribution))
5861 (Lines (message-make-lines))
5862 (User-Agent message-newsreader
)
5863 (Expires (message-make-expires))
5864 (case-fold-search t
)
5866 header value elem header-string
)
5867 ;; First we remove any old generated headers.
5868 (let ((headers message-deletable-headers
))
5869 (unless (buffer-modified-p)
5870 (setq headers
(delq 'Message-ID
(copy-sequence headers
))))
5872 (goto-char (point-min))
5873 (and (re-search-forward
5874 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
5875 (get-text-property (1+ (match-beginning 0)) 'message-deletable
)
5876 (message-delete-line))
5878 ;; Go through all the required headers and see if they are in the
5879 ;; articles already. If they are not, or are empty, they are
5880 ;; inserted automatically - except for Subject, Newsgroups and
5883 (goto-char (point-min))
5884 (setq elem
(pop headers
))
5886 (if (eq (car elem
) 'optional
)
5887 (setq header
(cdr elem
)
5889 (setq header
(car elem
)))
5891 (setq header-string
(if (stringp header
)
5893 (symbol-name header
)))
5894 (when (or (not (re-search-forward
5896 (regexp-quote (downcase header-string
))
5900 ;; The header was found. We insert a space after the
5901 ;; colon, if there is none.
5902 (if (/= (char-after) ?
) (insert " ") (forward-char 1))
5903 ;; Find out whether the header is empty.
5904 (looking-at "[ \t]*\n[^ \t]")))
5905 ;; So we find out what value we should insert.
5909 (eq (car elem
) 'optional
)
5910 (not (member header-string message-inserted-headers
)))
5911 ;; This is an optional header. If the cdr of this
5912 ;; is something that is nil, then we do not insert
5914 (setq header
(cdr elem
))
5915 (or (and (functionp (cdr elem
))
5916 (funcall (cdr elem
)))
5917 (and (boundp (cdr elem
))
5918 (symbol-value (cdr elem
)))))
5920 ;; The element is a cons. Either the cdr is a
5921 ;; string to be inserted verbatim, or it is a
5922 ;; function, and we insert the value returned from
5924 (or (and (stringp (cdr elem
))
5926 (and (functionp (cdr elem
))
5927 (funcall (cdr elem
)))))
5928 ((and (boundp header
)
5929 (symbol-value header
))
5930 ;; The element is a symbol. We insert the value
5931 ;; of this symbol, if any.
5932 (symbol-value header
))
5933 ((not (message-check-element
5934 (intern (downcase (symbol-name header
)))))
5935 ;; We couldn't generate a value for this header,
5936 ;; so we just ask the user.
5937 (read-from-minibuffer
5938 (format "Empty header for %s; enter value: " header
)))))
5939 ;; Finally insert the header.
5941 (not (equal value
"")))
5945 ;; This header didn't exist, so we insert it.
5946 (goto-char (point-max))
5948 (cdr (assq header message-header-format-alist
))))
5950 (funcall formatter header value
)
5951 (insert header-string
": " value
))
5952 (push header-string message-inserted-headers
)
5953 (goto-char (message-fill-field))
5954 ;; We check whether the value was ended by a
5955 ;; newline. If not, we insert one.
5959 ;; The value of this header was empty, so we clear
5960 ;; totally and insert the new value.
5961 (delete-region (point) (point-at-eol))
5962 ;; If the header is optional, and the header was
5963 ;; empty, we can't insert it anyway.
5965 (push header-string message-inserted-headers
)
5967 (message-fill-field)))
5968 ;; Add the deletable property to the headers that require it.
5969 (and (memq header message-deletable-headers
)
5970 (progn (beginning-of-line) (looking-at "[^:]+: "))
5971 (add-text-properties
5972 (point) (match-end 0)
5973 '(message-deletable t face italic
) (current-buffer)))))))
5974 ;; Insert new Sender if the From is strange.
5975 (let ((from (message-fetch-field "from"))
5976 (sender (message-fetch-field "sender"))
5977 (secure-sender (message-make-sender)))
5979 (not (message-check-element 'sender
))
5982 (cadr (mail-extract-address-components from
)))
5983 (downcase secure-sender
)))
5988 (cadr (mail-extract-address-components sender
)))
5989 (downcase secure-sender
)))))
5990 (goto-char (point-min))
5991 ;; Rename any old Sender headers to Original-Sender.
5992 (when (re-search-forward "^\\(Original-\\)*Sender:" nil t
)
5994 (insert "Original-")
5995 (beginning-of-line))
5996 (when (or (message-news-p)
5997 (string-match "@.+\\.." secure-sender
))
5998 (insert "Sender: " secure-sender
"\n"))))
6000 (message-idna-to-ascii-rhs))))
6002 (defun message-insert-courtesy-copy (message)
6003 "Insert a courtesy message in mail copies of combined messages."
6007 (message-narrow-to-headers)
6008 (when (setq newsgroups
(message-fetch-field "newsgroups"))
6009 (goto-char (point-max))
6010 (insert "Posted-To: " newsgroups
"\n")))
6014 ((string-match "%s" message
)
6015 (insert (format message newsgroups
)))
6017 (insert message
)))))))
6020 ;;; Setting up a message buffer
6023 (defun message-skip-to-next-address ()
6024 (let ((end (save-excursion
6025 (message-next-header)
6028 (when (looking-at ",")
6030 (while (and (not (= (point) end
))
6031 (or (not (eq char ?
,))
6033 (skip-chars-forward "^,\"" (point-max))
6034 (when (eq (setq char
(following-char)) ?
\")
6035 (setq quoted
(not quoted
)))
6036 (unless (= (point) end
)
6038 (skip-chars-forward " \t\n")))
6040 (defun message-fill-address (header value
)
6041 (insert (capitalize (symbol-name header
))
6043 (if (consp value
) (car value
) value
)
6045 (message-fill-field-address))
6047 (defun message-split-line ()
6048 "Split current line, moving portion beyond point vertically down.
6049 If the current line has `message-yank-prefix', insert it on the new line."
6052 (split-line message-yank-prefix
) ;; Emacs 22.1+ supports arg.
6056 (defun message-insert-header (header value
)
6057 (insert (capitalize (symbol-name header
))
6059 (if (consp value
) (car value
) value
)))
6061 (defun message-field-name ()
6063 (goto-char (point-min))
6064 (when (looking-at "\\([^:]+\\):")
6065 (intern (capitalize (match-string 1))))))
6067 (defun message-fill-field ()
6070 (message-narrow-to-field)
6071 (let ((field-name (message-field-name)))
6072 (funcall (or (cadr (assq field-name message-field-fillers
))
6073 'message-fill-field-general
)))
6076 (defun message-fill-field-address ()
6078 (message-skip-to-next-address)
6080 (if (and (> (current-column) 78)
6086 (setq last
(1+ (point))))
6087 (setq last
(1+ (point)))))))
6089 (defun message-fill-field-general ()
6090 (let ((begin (point))
6093 (while (and (search-forward "\n" nil t
)
6095 (replace-match " " t t
))
6096 (fill-region-as-paragraph begin
(point-max))
6097 ;; Tapdance around looong Message-IDs.
6099 (when (looking-at "[ \t]*$")
6100 (message-delete-line))
6102 (search-forward ":" nil t
)
6103 (when (looking-at "\n[ \t]+")
6104 (replace-match " " t t
))
6105 (goto-char (point-max))))
6107 (defun message-shorten-1 (list cut surplus
)
6108 "Cut SURPLUS elements out of LIST, beginning with CUTth one."
6109 (setcdr (nthcdr (- cut
2) list
)
6110 (nthcdr (+ (- cut
2) surplus
1) list
)))
6112 (defun message-shorten-references (header references
)
6113 "Trim REFERENCES to be 21 Message-ID long or less, and fold them.
6114 When sending via news, also check that the REFERENCES are less
6115 than 988 characters long, and if they are not, trim them until
6117 ;; 21 is the number suggested by USEAGE.
6124 (goto-char (point-min))
6125 ;; Cons a list of valid references. GNKSA says we must not include MIDs
6126 ;; with whitespace or missing brackets (7.a "Does not propagate broken
6127 ;; Message-IDs in original References").
6128 (while (re-search-forward "<[^ <]+@[^ <]+>" nil t
)
6129 (push (match-string 0) refs
))
6130 (setq refs
(nreverse refs
)
6131 count
(length refs
)))
6133 ;; If the list has more than MAXCOUNT elements, trim it by
6134 ;; removing the CUTth element and the required number of
6135 ;; elements that follow.
6136 (when (> count maxcount
)
6137 (let ((surplus (- count maxcount
)))
6138 (message-shorten-1 refs cut surplus
)
6139 (decf count surplus
)))
6141 ;; When sending via news, make sure the total folded length will
6142 ;; be less than 998 characters. This is to cater to broken INN
6143 ;; 2.3 which counts the total number of characters in a header
6144 ;; rather than the physical line length of each line, as it should.
6146 ;; This hack should be removed when it's believed than INN 2.3 is
6147 ;; no longer widely used.
6149 ;; At this point the headers have not been generated, thus we use
6150 ;; message-this-is-news directly.
6151 (when message-this-is-news
6154 (message-insert-header
6155 header
(mapconcat #'identity refs
" "))
6157 (message-shorten-1 refs cut
1)))
6158 ;; Finally, collect the references back into a string and insert
6159 ;; it into the buffer.
6160 (message-insert-header header
(mapconcat #'identity refs
" "))))
6162 (defun message-position-point ()
6163 "Move point to where the user probably wants to find it."
6164 (message-narrow-to-headers)
6166 ((re-search-forward "^[^:]+:[ \t]*$" nil t
)
6167 (search-backward ":" )
6170 (if (eq (char-after) ?
)
6174 (goto-char (point-max))
6177 (unless (looking-at "$")
6181 (defcustom message-beginning-of-line t
6182 "Whether \\<message-mode-map>\\[message-beginning-of-line]\
6183 goes to beginning of header values."
6185 :group
'message-buffers
6186 :link
'(custom-manual "(message)Movement")
6189 (defun message-beginning-of-line (&optional n
)
6190 "Move point to beginning of header value or to beginning of line.
6191 The prefix argument N is passed directly to `beginning-of-line'.
6193 This command is identical to `beginning-of-line' if point is
6194 outside the message header or if the option `message-beginning-of-line'
6197 If point is in the message header and on a (non-continued) header
6198 line, move point to the beginning of the header value or the beginning of line,
6199 whichever is closer. If point is already at beginning of line, move point to
6200 beginning of header value. Therefore, repeated calls will toggle point
6201 between beginning of field and beginning of line."
6203 (let ((zrs 'zmacs-region-stays
))
6204 (when (and (featurep 'xemacs
) (interactive-p) (boundp zrs
))
6206 (if (and message-beginning-of-line
6207 (message-point-in-header-p))
6208 (let* ((here (point))
6209 (bol (progn (beginning-of-line n
) (point)))
6210 (eol (point-at-eol))
6211 (eoh (re-search-forward ": *" eol t
)))
6213 (if (and eoh
(or (< eoh here
) (= bol here
)))
6215 (beginning-of-line n
)))
6217 (defun message-buffer-name (type &optional to group
)
6218 "Return a new (unique) buffer name based on TYPE and TO."
6220 ;; Generate a new buffer name The Message Way.
6221 ((memq message-generate-new-buffers
'(unique t
))
6222 (generate-new-buffer-name
6226 (or (car (mail-extract-address-components to
))
6229 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6231 ;; Check whether `message-generate-new-buffers' is a function,
6232 ;; and if so, call it.
6233 ((functionp message-generate-new-buffers
)
6234 (funcall message-generate-new-buffers type to group
))
6235 ((eq message-generate-new-buffers
'unsent
)
6236 (generate-new-buffer-name
6237 (concat "*unsent " type
6240 (or (car (mail-extract-address-components to
))
6243 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6245 ;; Search for the existing message buffer with the specified name.
6247 (let* ((new (if (eq message-generate-new-buffers
'standard
)
6248 (generate-new-buffer-name (concat "*" type
" message*"))
6249 (let ((message-generate-new-buffers 'unique
))
6250 (message-buffer-name type to group
))))
6251 (regexp (concat "\\`"
6253 (if (string-match "<[0-9]+>\\'" new
)
6254 (substring new
0 (match-beginning 0))
6256 "\\(?:<\\([0-9]+\\)>\\)?\\'"))
6257 (case-fold-search nil
))
6264 (when (and (string-match regexp
(setq b
(buffer-name b
)))
6265 (eq (with-current-buffer b major-mode
)
6267 (cons (string-to-number (or (match-string 1 b
) "1"))
6270 'car-less-than-car
)))
6273 (defun message-pop-to-buffer (name &optional switch-function
)
6274 "Pop to buffer NAME, and warn if it already exists and is modified."
6275 (let ((buffer (get-buffer name
)))
6277 (buffer-name buffer
))
6278 (let ((window (get-buffer-window buffer
0)))
6280 ;; Raise the frame already displaying the message buffer.
6282 (gnus-select-frame-set-input-focus (window-frame window
))
6283 (select-window window
))
6284 (funcall (or switch-function
'pop-to-buffer
) buffer
)
6285 (set-buffer buffer
))
6286 (when (and (buffer-modified-p)
6289 "Message already being composed; erase? ")
6291 (error "Message being composed")))
6292 (funcall (or switch-function
'pop-to-buffer
) name
)
6297 (defun message-do-send-housekeeping ()
6298 "Kill old message buffers."
6299 ;; We might have sent this buffer already. Delete it from the
6301 (setq message-buffer-list
(delq (current-buffer) message-buffer-list
))
6302 (while (and message-max-buffers
6304 (>= (length message-buffer-list
) message-max-buffers
))
6305 ;; Kill the oldest buffer -- unless it has been changed.
6306 (let ((buffer (pop message-buffer-list
)))
6307 (when (and (buffer-name buffer
)
6308 (not (buffer-modified-p buffer
)))
6309 (kill-buffer buffer
))))
6310 ;; Rename the buffer.
6311 (if message-send-rename-function
6312 (funcall message-send-rename-function
)
6313 ;; Note: mail-abbrevs of XEmacs renames buffer name behind Gnus.
6315 "\\`\\*\\(sent \\|unsent \\)?\\(.+\\)\\*[^\\*]*\\|\\`mail to "
6317 (let ((name (match-string 2 (buffer-name)))
6319 (if (not (or (null name
)
6320 (string-equal name
"mail")
6321 (string-equal name
"posting")))
6322 (setq name
(concat "*sent " name
"*"))
6323 (message-narrow-to-headers)
6324 (setq to
(message-fetch-field "to"))
6325 (setq group
(message-fetch-field "newsgroups"))
6329 (to (concat "*sent mail to "
6330 (or (car (mail-extract-address-components to
))
6332 ((and group
(not (string= group
"")))
6333 (concat "*sent posting on " group
"*"))
6334 (t "*sent mail*"))))
6335 (unless (string-equal name
(buffer-name))
6336 (rename-buffer name t
)))))
6337 ;; Push the current buffer onto the list.
6338 (when message-max-buffers
6339 (setq message-buffer-list
6340 (nconc message-buffer-list
(list (current-buffer))))))
6342 (defun message-mail-user-agent ()
6344 ((not message-mail-user-agent
) nil
)
6345 ((eq message-mail-user-agent t
) mail-user-agent
)
6346 (t message-mail-user-agent
))))
6347 (if (memq mua
'(message-user-agent gnus-user-agent
))
6351 ;; YANK-ACTION, if non-nil, can be a buffer or a yank action of the
6352 ;; form (FUNCTION . ARGS).
6353 (defun message-setup (headers &optional yank-action actions
6354 continue switch-function
)
6355 (let ((mua (message-mail-user-agent))
6357 (if (not (and message-this-is-mail mua
))
6358 (message-setup-1 headers yank-action actions
)
6359 (setq headers
(copy-sequence headers
))
6360 (setq field
(assq 'Subject headers
))
6362 (setq subject
(cdr field
))
6363 (setq headers
(delq field headers
)))
6364 (setq field
(assq 'To headers
))
6366 (setq to
(cdr field
))
6367 (setq headers
(delq field headers
)))
6368 (let ((mail-user-agent mua
))
6369 (compose-mail to subject
6370 (mapcar (lambda (item)
6372 (format "%s" (car item
))
6375 continue switch-function
6376 (if (bufferp yank-action
)
6377 (list 'insert-buffer yank-action
)
6381 (defun message-headers-to-generate (headers included-headers excluded-headers
)
6382 "Return a list that includes all headers from HEADERS.
6383 If INCLUDED-HEADERS is a list, just include those headers. If it is
6384 t, include all headers. In any case, headers from EXCLUDED-HEADERS
6388 (dolist (header headers
)
6389 (setq header-name
(cond
6390 ((and (consp header
)
6391 (eq (car header
) 'optional
))
6392 ;; On the form (optional . Header)
6395 ;; On the form (Header . function)
6400 (when (and (not (memq header-name excluded-headers
))
6401 (or (eq included-headers t
)
6402 (memq header-name included-headers
)))
6403 (push header result
)))
6406 (defun message-setup-1 (headers &optional yank-action actions
)
6407 (dolist (action actions
)
6409 (add-to-list 'message-send-actions
6410 `(apply ',(car action
) ',(cdr action
)))))
6411 (setq message-reply-buffer
6412 (if (and (consp yank-action
)
6413 (eq (car yank-action
) 'insert-buffer
))
6416 (goto-char (point-min))
6417 ;; Insert all the headers.
6420 (alist message-header-format-alist
))
6422 (unless (assq (caar h
) message-header-format-alist
)
6423 (push (list (caar h
)) alist
))
6427 (delete-region (point) (progn (forward-line -
1) (point)))
6428 (when message-default-headers
6430 (if (functionp message-default-headers
)
6431 (funcall message-default-headers
)
6432 message-default-headers
))
6433 (or (bolp) (insert ?
\n)))
6434 (insert mail-header-separator
"\n")
6436 (when (message-news-p)
6437 (when message-default-news-headers
6438 (insert message-default-news-headers
)
6439 (or (bolp) (insert ?
\n)))
6440 (when message-generate-headers-first
6441 (message-generate-headers
6442 (message-headers-to-generate
6443 (append message-required-news-headers
6444 message-required-headers
)
6445 message-generate-headers-first
6446 '(Lines Subject
)))))
6447 (when (message-mail-p)
6448 (when message-default-mail-headers
6449 (insert message-default-mail-headers
)
6450 (or (bolp) (insert ?
\n)))
6451 (when message-generate-headers-first
6452 (message-generate-headers
6453 (message-headers-to-generate
6454 (append message-required-mail-headers
6455 message-required-headers
)
6456 message-generate-headers-first
6457 '(Lines Subject
)))))
6458 (run-hooks 'message-signature-setup-hook
)
6459 (message-insert-signature)
6461 (message-narrow-to-headers)
6462 (run-hooks 'message-header-setup-hook
))
6463 (setq buffer-undo-list nil
)
6464 (when message-generate-hashcash
6465 ;; Generate hashcash headers for recipients already known
6466 (mail-add-payment-async))
6467 ;; Gnus posting styles are applied via buffer-local `message-setup-hook'
6469 (run-hooks 'message-setup-hook
)
6470 ;; Do this last to give it precedence over posting styles, etc.
6471 (when (message-mail-p)
6473 (message-narrow-to-headers)
6474 (if message-alternative-emails
6475 (message-use-alternative-email-as-from))))
6476 (message-position-point)
6477 ;; Allow correct handling of `message-checksum' in `message-yank-original':
6478 (set-buffer-modified-p nil
)
6481 (defun message-set-auto-save-file-name ()
6482 "Associate the message buffer with a file in the drafts directory."
6483 (when message-auto-save-directory
6484 (unless (file-directory-p
6485 (directory-file-name message-auto-save-directory
))
6486 (make-directory message-auto-save-directory t
))
6488 (setq message-draft-article
6489 (nndraft-request-associate-buffer "drafts"))
6491 ;; If Gnus were alive, draft messages would be saved in the drafts folder.
6492 ;; But Gnus is not alive, so arrange to save the draft message in a
6493 ;; regular file in message-auto-save-directory. Append a unique
6494 ;; time-based suffix to the filename to allow multiple drafts to be saved
6495 ;; simultaneously without overwriting each other (which mimics the
6496 ;; functionality of the Gnus drafts folder).
6497 (setq buffer-file-name
(expand-file-name
6499 (if (memq system-type
6500 '(ms-dos windows-nt cygwin
))
6503 (format-time-string "-%Y%m%d-%H%M%S"))
6504 message-auto-save-directory
))
6505 (setq buffer-auto-save-file-name
(make-auto-save-file-name)))
6506 (clear-visited-file-modtime)
6507 (setq buffer-file-coding-system message-draft-coding-system
)))
6509 (defun message-disassociate-draft ()
6510 "Disassociate the message buffer from the drafts directory."
6511 (when message-draft-article
6512 (nndraft-request-expire-articles
6513 (list message-draft-article
) "drafts" nil t
)))
6515 (defun message-insert-headers ()
6516 "Generate the headers for the article."
6520 (message-narrow-to-headers)
6521 (when (message-news-p)
6522 (message-generate-headers
6525 (copy-sequence message-required-news-headers
)))))
6526 (when (message-mail-p)
6527 (message-generate-headers
6530 (copy-sequence message-required-mail-headers
))))))))
6535 ;;; Commands for interfacing with message
6539 (defun message-mail (&optional to subject
6540 other-headers continue switch-function
6541 yank-action send-actions
)
6542 "Start editing a mail message to be sent.
6543 OTHER-HEADERS is an alist of header/value pairs. CONTINUE says whether
6544 to continue editing a message already being composed. SWITCH-FUNCTION
6545 is a function used to switch to and display the mail buffer."
6547 (let ((message-this-is-mail t
))
6548 (unless (message-mail-user-agent)
6549 (message-pop-to-buffer
6550 ;; Search for the existing message buffer if `continue' is non-nil.
6551 (let ((message-generate-new-buffers
6552 (when (or (not continue
)
6553 (eq message-generate-new-buffers
'standard
)
6554 (functionp message-generate-new-buffers
))
6555 message-generate-new-buffers
)))
6556 (message-buffer-name "mail" to
))
6560 `((To .
,(or to
"")) (Subject .
,(or subject
"")))
6561 (when other-headers other-headers
))
6562 yank-action send-actions continue switch-function
)
6563 ;; FIXME: Should return nil if failure.
6567 (defun message-news (&optional newsgroups subject
)
6568 "Start editing a news article to be sent."
6570 (let ((message-this-is-news t
))
6571 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
))
6572 (message-setup `((Newsgroups .
,(or newsgroups
""))
6573 (Subject .
,(or subject
""))))))
6575 (defun message-alter-recipients-discard-bogus-full-name (addrcell)
6576 "Discard mail address in full names.
6577 When the full name in reply headers contains the mail
6578 address (e.g. \"foo@bar <foo@bar>\"), discard full name.
6579 ADDRCELL is a cons cell where the car is the mail address and the
6580 cdr is the complete address (full name and mail address)."
6581 (if (string-match (concat (regexp-quote (car addrcell
)) ".*"
6582 (regexp-quote (car addrcell
)))
6584 (cons (car addrcell
) (car addrcell
))
6587 (defcustom message-alter-recipients-function nil
6588 "Function called to allow alteration of reply header structures.
6589 It is called in `message-get-reply-headers' for each recipient.
6590 The function is called with one parameter, a cons cell ..."
6591 :type
'(choice (const :tag
"None" nil
)
6592 (const :tag
"Discard bogus full name"
6593 message-alter-recipients-discard-bogus-full-name
)
6595 :version
"23.1" ;; No Gnus
6596 :group
'message-headers
)
6598 (defun message-get-reply-headers (wide &optional to-address address-headers
)
6599 (let (follow-to mct never-mct to cc author mft recipients extra
)
6600 ;; Find all relevant headers we need.
6602 (message-narrow-to-headers-or-head)
6603 ;; Gmane renames "To". Look at "Original-To", too, if it is present in
6604 ;; message-header-synonyms.
6605 (setq to
(or (message-fetch-field "to")
6606 (and (loop for synonym in message-header-synonyms
6607 when
(memq 'Original-To synonym
)
6609 (message-fetch-field "original-to")))
6610 cc
(message-fetch-field "cc")
6611 extra
(when message-extra-wide-headers
6612 (mapconcat 'identity
6613 (mapcar 'message-fetch-field
6614 message-extra-wide-headers
)
6616 mct
(message-fetch-field "mail-copies-to")
6617 author
(or (message-fetch-field "mail-reply-to")
6618 (message-fetch-field "reply-to")
6619 (message-fetch-field "from")
6621 mft
(and message-use-mail-followup-to
6622 (message-fetch-field "mail-followup-to"))))
6624 ;; Handle special values of Mail-Copies-To.
6626 (cond ((or (equal (downcase mct
) "never")
6627 (equal (downcase mct
) "nobody"))
6630 ((or (equal (downcase mct
) "always")
6631 (equal (downcase mct
) "poster"))
6632 (setq mct author
))))
6635 ;; Build (textual) list of new recipient addresses.
6638 (setq recipients
(concat ", " to-address
))
6639 ;; If the author explicitly asked for a copy, we don't deny it to them.
6640 (if mct
(setq recipients
(concat recipients
", " mct
))))
6642 (setq recipients
(concat ", " author
)))
6644 (dolist (header address-headers
)
6645 (let ((value (message-fetch-field header
)))
6647 (setq recipients
(concat recipients
", " value
))))))
6649 (string-match "[^ \t,]" mft
)
6650 (or (not (eq message-use-mail-followup-to
'ask
))
6651 (message-y-or-n-p "Obey Mail-Followup-To? " t
"\
6652 You should normally obey the Mail-Followup-To: header. In this
6653 article, it has the value of
6657 which directs your response to " (if (string-match "," mft
)
6658 "the specified addresses"
6659 "that address only") ".
6661 Most commonly, Mail-Followup-To is used by a mailing list poster to
6662 express that responses should be sent to just the list, and not the
6665 If a message is posted to several mailing lists, Mail-Followup-To may
6666 also be used to direct the following discussion to one list only,
6667 because discussions that are spread over several lists tend to be
6668 fragmented and very difficult to follow.
6670 Also, some source/announcement lists are not intended for discussion;
6671 responses here are directed to other addresses.
6673 You may customize the variable `message-use-mail-followup-to', if you
6674 want to get rid of this query permanently.")))
6675 (setq recipients
(concat ", " mft
)))
6677 (setq recipients
(if never-mct
"" (concat ", " author
)))
6678 (if to
(setq recipients
(concat recipients
", " to
)))
6679 (if cc
(setq recipients
(concat recipients
", " cc
)))
6680 (if extra
(setq recipients
(concat recipients
", " extra
)))
6681 (if mct
(setq recipients
(concat recipients
", " mct
)))))
6682 (if (>= (length recipients
) 2)
6683 ;; Strip the leading ", ".
6684 (setq recipients
(substring recipients
2)))
6685 ;; Squeeze whitespace.
6686 (while (string-match "[ \t][ \t]+" recipients
)
6687 (setq recipients
(replace-match " " t t recipients
)))
6688 ;; Remove addresses that match `rmail-dont-reply-to-names'.
6689 (let ((rmail-dont-reply-to-names (message-dont-reply-to-names)))
6690 (setq recipients
(rmail-dont-reply-to recipients
)))
6691 ;; Perhaps "Mail-Copies-To: never" removed the only address?
6692 (if (string-equal recipients
"")
6693 (setq recipients author
))
6694 ;; Convert string to a list of (("foo@bar" . "Name <Foo@BAR>") ...).
6698 (if message-alter-recipients-function
6699 (funcall message-alter-recipients-function
6700 (cons (downcase (mail-strip-quoted-names addr
))
6702 (cons (downcase (mail-strip-quoted-names addr
)) addr
)))
6703 (message-tokenize-header recipients
)))
6704 ;; Remove first duplicates. (Why not all duplicates? Is this a bug?)
6705 (let ((s recipients
))
6707 (setq recipients
(delq (assoc (car (pop s
)) s
) recipients
))))
6709 ;; Remove hierarchical lists that are contained within each other,
6710 ;; if message-hierarchical-addresses is defined.
6711 (when message-hierarchical-addresses
6712 (let ((plain-addrs (mapcar 'car recipients
))
6715 (setq subaddrs
(assoc (car plain-addrs
)
6716 message-hierarchical-addresses
)
6717 plain-addrs
(cdr plain-addrs
))
6719 (setq subaddrs
(cdr subaddrs
))
6721 (setq recip
(assoc (car subaddrs
) recipients
)
6722 subaddrs
(cdr subaddrs
))
6724 (setq recipients
(delq recip recipients
))))))))
6726 (setq recipients
(message-prune-recipients recipients
))
6728 ;; Build the header alist. Allow the user to be asked whether
6729 ;; or not to reply to all recipients in a wide reply.
6730 (setq follow-to
(list (cons 'To
(cdr (pop recipients
)))))
6731 (when (and recipients
6732 (or (not message-wide-reply-confirm-recipients
)
6733 (y-or-n-p "Reply to all recipients? ")))
6734 (setq recipients
(mapconcat
6735 (lambda (addr) (cdr addr
)) recipients
", "))
6736 (if (string-match "^ +" recipients
)
6737 (setq recipients
(substring recipients
(match-end 0))))
6738 (push (cons 'Cc recipients
) follow-to
)))
6741 (defun message-prune-recipients (recipients)
6742 (dolist (rule message-prune-recipient-rules
)
6743 (let ((match (car rule
))
6746 (dolist (recipient recipients
)
6747 (setq address
(car recipient
))
6748 (when (string-match match address
)
6749 (setq dup-match
(replace-match (cadr rule
) nil nil address
))
6750 (dolist (recipient recipients
)
6751 ;; Don't delete the address that triggered this.
6752 (when (and (not (eq address
(car recipient
)))
6753 (string-match dup-match
(car recipient
)))
6754 (setq recipients
(delq recipient recipients
))))))))
6757 (defcustom message-simplify-subject-functions
6758 '(message-strip-list-identifiers
6759 message-strip-subject-re
6760 message-strip-subject-trailing-was
6761 message-strip-subject-encoded-words
)
6762 "List of functions taking a string argument that simplify subjects.
6763 The functions are applied when replying to a message.
6765 Useful functions to put in this list include:
6766 `message-strip-list-identifiers', `message-strip-subject-re',
6767 `message-strip-subject-trailing-was', and
6768 `message-strip-subject-encoded-words'."
6769 :version
"22.1" ;; Gnus 5.10.9
6770 :group
'message-various
6771 :type
'(repeat function
))
6773 (defun message-simplify-subject (subject &optional functions
)
6774 "Return simplified SUBJECT."
6777 (setq functions message-simplify-subject-functions
))
6778 (when (and (memq 'message-strip-list-identifiers functions
)
6779 gnus-list-identifiers
)
6780 (setq subject
(message-strip-list-identifiers subject
)))
6781 (when (memq 'message-strip-subject-re functions
)
6782 (setq subject
(concat "Re: " (message-strip-subject-re subject
))))
6783 (when (and (memq 'message-strip-subject-trailing-was functions
)
6784 message-subject-trailing-was-query
)
6785 (setq subject
(message-strip-subject-trailing-was subject
)))
6786 (when (memq 'message-strip-subject-encoded-words functions
)
6787 (setq subject
(message-strip-subject-encoded-words subject
)))
6791 (defun message-reply (&optional to-address wide
)
6792 "Start editing a reply to the article in the current buffer."
6794 (require 'gnus-sum
) ; for gnus-list-identifiers
6795 (let ((cur (current-buffer))
6796 from subject date reply-to to cc
6797 references message-id follow-to
6798 (inhibit-point-motion-hooks t
)
6799 (message-this-is-mail t
)
6802 (message-narrow-to-head-1)
6803 ;; Allow customizations to have their say.
6805 ;; This is a regular reply.
6806 (when (functionp message-reply-to-function
)
6808 (setq follow-to
(funcall message-reply-to-function
))))
6809 ;; This is a followup.
6810 (when (functionp message-wide-reply-to-function
)
6813 (funcall message-wide-reply-to-function
)))))
6814 (setq message-id
(message-fetch-field "message-id" t
)
6815 references
(message-fetch-field "references")
6816 date
(message-fetch-field "date")
6817 from
(or (message-fetch-field "from") "nobody")
6818 subject
(or (message-fetch-field "subject") "none"))
6820 ;; Strip list identifiers, "Re: ", and "was:"
6821 (setq subject
(message-simplify-subject subject
))
6823 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6824 (string-match "<[^>]+>" gnus-warning
))
6825 (setq message-id
(match-string 0 gnus-warning
)))
6828 (setq follow-to
(message-get-reply-headers wide to-address
))))
6830 (unless (message-mail-user-agent)
6831 (message-pop-to-buffer
6832 (message-buffer-name
6833 (if wide
"wide reply" "reply") from
6834 (if wide to-address nil
))))
6836 (setq message-reply-headers
6837 (vector 0 subject from date message-id references
0 0 ""))
6840 `((Subject .
,subject
)
6845 (defun message-wide-reply (&optional to-address
)
6846 "Make a \"wide\" reply to the message in the current buffer."
6848 (message-reply to-address t
))
6851 (defun message-followup (&optional to-newsgroups
)
6852 "Follow up to the message in the current buffer.
6853 If TO-NEWSGROUPS, use that as the new Newsgroups line."
6855 (require 'gnus-sum
) ; for gnus-list-identifiers
6856 (let ((cur (current-buffer))
6857 from subject date reply-to mrt mct
6858 references message-id follow-to
6859 (inhibit-point-motion-hooks t
)
6860 (message-this-is-news t
)
6861 followup-to distribution newsgroups gnus-warning posted-to
)
6864 (goto-char (point-min))
6865 (if (search-forward "\n\n" nil t
)
6868 (when (functionp message-followup-to-function
)
6870 (funcall message-followup-to-function
)))
6871 (setq from
(message-fetch-field "from")
6872 date
(message-fetch-field "date")
6873 subject
(or (message-fetch-field "subject") "none")
6874 references
(message-fetch-field "references")
6875 message-id
(message-fetch-field "message-id" t
)
6876 followup-to
(message-fetch-field "followup-to")
6877 newsgroups
(message-fetch-field "newsgroups")
6878 posted-to
(message-fetch-field "posted-to")
6879 reply-to
(message-fetch-field "reply-to")
6880 mrt
(message-fetch-field "mail-reply-to")
6881 distribution
(message-fetch-field "distribution")
6882 mct
(message-fetch-field "mail-copies-to"))
6883 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6884 (string-match "<[^>]+>" gnus-warning
))
6885 (setq message-id
(match-string 0 gnus-warning
)))
6886 ;; Remove bogus distribution.
6887 (when (and (stringp distribution
)
6888 (let ((case-fold-search t
))
6889 (string-match "world" distribution
)))
6890 (setq distribution nil
))
6891 ;; Strip list identifiers, "Re: ", and "was:"
6892 (setq subject
(message-simplify-subject subject
))
6895 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups
))
6897 (setq message-reply-headers
6898 (vector 0 subject from date message-id references
0 0 ""))
6901 `((Subject .
,subject
)
6904 (list (cons 'Newsgroups to-newsgroups
)))
6905 (follow-to follow-to
)
6906 ((and followup-to message-use-followup-to
)
6909 ((equal (downcase followup-to
) "poster")
6910 (if (or (eq message-use-followup-to
'use
)
6911 (message-y-or-n-p "Obey Followup-To: poster? " t
"\
6912 You should normally obey the Followup-To: header.
6914 `Followup-To: poster' sends your response via e-mail instead of news.
6916 A typical situation where `Followup-To: poster' is used is when the poster
6917 does not read the newsgroup, so he wouldn't see any replies sent to it.
6919 You may customize the variable `message-use-followup-to', if you
6920 want to get rid of this query permanently."))
6922 (setq message-this-is-news nil
)
6923 (cons 'To
(or mrt reply-to from
"")))
6924 (cons 'Newsgroups newsgroups
)))
6926 (if (or (equal followup-to newsgroups
)
6927 (not (eq message-use-followup-to
'ask
))
6929 (concat "Obey Followup-To: " followup-to
"? ") t
"\
6930 You should normally obey the Followup-To: header.
6932 `Followup-To: " followup-to
"'
6933 directs your response to " (if (string-match "," followup-to
)
6934 "the specified newsgroups"
6935 "that newsgroup only") ".
6937 If a message is posted to several newsgroups, Followup-To is often
6938 used to direct the following discussion to one newsgroup only,
6939 because discussions that are spread over several newsgroup tend to
6940 be fragmented and very difficult to follow.
6942 Also, some source/announcement newsgroups are not intended for discussion;
6943 responses here are directed to other newsgroups.
6945 You may customize the variable `message-use-followup-to', if you
6946 want to get rid of this query permanently."))
6947 (cons 'Newsgroups followup-to
)
6948 (cons 'Newsgroups newsgroups
))))))
6950 `((Newsgroups .
,posted-to
)))
6952 `((Newsgroups .
,newsgroups
))))
6953 ,@(and distribution
(list (cons 'Distribution distribution
)))
6955 (not (or (equal (downcase mct
) "never")
6956 (equal (downcase mct
) "nobody"))))
6957 (list (cons 'Cc
(if (or (equal (downcase mct
) "always")
6958 (equal (downcase mct
) "poster"))
6959 (or mrt reply-to from
"")
6964 (defun message-is-yours-p ()
6965 "Non-nil means current article is yours.
6966 If you have added 'cancel-messages to `message-shoot-gnksa-feet', all articles
6967 are yours except those that have Cancel-Lock header not belonging to you.
6968 Instead of shooting GNKSA feet, you should modify `message-alternative-emails'
6969 regexp to match all of yours addresses."
6970 ;; Canlock-logic as suggested by Per Abrahamsen
6971 ;; <abraham@dina.kvl.dk>
6973 ;; IF article has cancel-lock THEN
6974 ;; IF we can verify it THEN
6977 ;; error: cancellock: article is not yours
6979 ;; Use old rules, comparing sender...
6982 (message-narrow-to-head-1)
6983 (if (message-fetch-field "Cancel-Lock")
6984 (if (null (canlock-verify))
6986 (error "Failed to verify Cancel-lock: This article is not yours"))
6989 (message-gnksa-enable-p 'cancel-messages
)
6990 (and (setq sender
(message-fetch-field "sender"))
6991 (string-equal (downcase sender
)
6992 (downcase (message-make-sender))))
6993 ;; Email address in From field equals to our address
6994 (and (setq from
(message-fetch-field "from"))
6996 (downcase (car (mail-header-parse-address from
)))
6997 (downcase (car (mail-header-parse-address
6998 (message-make-from))))))
6999 ;; Email address in From field matches
7000 ;; 'message-alternative-emails' regexp
7002 message-alternative-emails
7004 message-alternative-emails
7005 (car (mail-header-parse-address from
))))))))))
7008 (defun message-cancel-news (&optional arg
)
7009 "Cancel an article you posted.
7010 If ARG, allow editing of the cancellation message."
7012 (unless (message-news-p)
7013 (error "This is not a news article; canceling is impossible"))
7014 (let (from newsgroups message-id distribution buf
)
7016 ;; Get header info from original article.
7018 (message-narrow-to-head-1)
7019 (setq from
(message-fetch-field "from")
7020 newsgroups
(message-fetch-field "newsgroups")
7021 message-id
(message-fetch-field "message-id" t
)
7022 distribution
(message-fetch-field "distribution")))
7023 ;; Make sure that this article was written by the user.
7024 (unless (message-is-yours-p)
7025 (error "This article is not yours"))
7026 (when (yes-or-no-p "Do you really want to cancel this article? ")
7027 ;; Make control message.
7030 (setq buf
(set-buffer (get-buffer-create " *message cancel*"))))
7032 (insert "Newsgroups: " newsgroups
"\n"
7034 "Subject: cmsg cancel " message-id
"\n"
7035 "Control: cancel " message-id
"\n"
7037 (concat "Distribution: " distribution
"\n")
7039 mail-header-separator
"\n"
7040 message-cancel-message
)
7041 (run-hooks 'message-cancel-hook
)
7043 (message "Canceling your article...")
7044 (if (let ((message-syntax-checks
7045 'dont-check-for-anything-just-trust-me
))
7046 (funcall message-send-news-function
))
7047 (message "Canceling your article...done"))
7048 (kill-buffer buf
))))))
7051 (defun message-supersede ()
7052 "Start composing a message to supersede the current message.
7053 This is done simply by taking the old article and adding a Supersedes
7054 header line with the old Message-ID."
7056 (let ((cur (current-buffer)))
7057 ;; Check whether the user owns the article that is to be superseded.
7058 (unless (message-is-yours-p)
7059 (error "This article is not yours"))
7060 ;; Get a normal message buffer.
7061 (message-pop-to-buffer (message-buffer-name "supersede"))
7062 (insert-buffer-substring cur
)
7064 (message-narrow-to-head-1)
7065 ;; Remove unwanted headers.
7066 (when message-ignored-supersedes-headers
7067 (message-remove-header message-ignored-supersedes-headers t
))
7068 (goto-char (point-min))
7069 (if (not (re-search-forward "^Message-ID: " nil t
))
7070 (error "No Message-ID in this article")
7071 (replace-match "Supersedes: " t t
))
7072 (goto-char (point-max))
7073 (insert mail-header-separator
)
7078 (defun message-recover ()
7079 "Reread contents of current buffer from its last auto-save file."
7081 (let ((file-name (make-auto-save-file-name)))
7082 (cond ((save-window-excursion
7083 (with-output-to-temp-buffer "*Directory*"
7084 (with-current-buffer standard-output
7085 (fundamental-mode)) ; for Emacs 20.4+
7086 (buffer-disable-undo standard-output
)
7087 (let ((default-directory "/"))
7089 "ls" nil standard-output nil
"-l" file-name
)))
7090 (yes-or-no-p (format "Recover auto save file %s? " file-name
)))
7091 (let ((buffer-read-only nil
))
7093 (insert-file-contents file-name nil
)))
7094 (t (error "message-recover cancelled")))))
7096 ;;; Washing Subject:
7098 (defun message-wash-subject (subject)
7099 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT.
7100 Previous forwarders, replyers, etc. may add it."
7103 (goto-char (point-min))
7104 ;; strip Re/Fwd stuff off the beginning
7105 (while (re-search-forward
7106 "\\([Rr][Ee]:\\|[Ff][Ww][Dd]\\(\\[[0-9]*\\]\\)?:\\|[Ff][Ww]:\\)" nil t
)
7109 ;; and gnus-style forwards [foo@bar.com] subject
7110 (goto-char (point-min))
7111 (while (re-search-forward "\\[[^ \t]*\\(@\\|\\.\\)[^ \t]*\\]" nil t
)
7115 (goto-char (point-max))
7116 (while (re-search-backward "([Ff][Ww][Dd])" nil t
)
7119 ;; and finally, any whitespace that was left-over
7120 (goto-char (point-min))
7121 (while (re-search-forward "^[ \t]+" nil t
)
7123 (goto-char (point-max))
7124 (while (re-search-backward "[ \t]+$" nil t
)
7129 ;;; Forwarding messages.
7131 (defvar message-forward-decoded-p nil
7132 "Non-nil means the original message is decoded.")
7134 (defun message-forward-subject-name-subject (subject)
7135 "Generate a SUBJECT for a forwarded message.
7136 The form is: [Source] Subject, where if the original message was mail,
7137 Source is the name of the sender, and if the original message was
7138 news, Source is the list of newsgroups is was posted to."
7139 (let* ((group (message-fetch-field "newsgroups"))
7140 (from (message-fetch-field "from"))
7143 (gnus-group-decoded-name group
)
7145 (car (gnus-extract-address-components from
))
7146 (cadr (gnus-extract-address-components from
))))
7149 (if message-forward-decoded-p
7151 (mail-decode-encoded-word-string prefix
))
7154 (defun message-forward-subject-author-subject (subject)
7155 "Generate a SUBJECT for a forwarded message.
7156 The form is: [Source] Subject, where if the original message was mail,
7157 Source is the sender, and if the original message was news, Source is
7158 the list of newsgroups is was posted to."
7159 (let* ((group (message-fetch-field "newsgroups"))
7162 (gnus-group-decoded-name group
)
7163 (or (message-fetch-field "from")
7166 (if message-forward-decoded-p
7168 (mail-decode-encoded-word-string prefix
))
7171 (defun message-forward-subject-fwd (subject)
7172 "Generate a SUBJECT for a forwarded message.
7173 The form is: Fwd: Subject, where Subject is the original subject of
7175 (if (string-match "^Fwd: " subject
)
7177 (concat "Fwd: " subject
)))
7179 (defun message-make-forward-subject ()
7180 "Return a Subject header suitable for the message in the current buffer."
7183 (message-narrow-to-head-1)
7184 (let ((funcs message-make-forward-subject-function
)
7185 (subject (message-fetch-field "Subject")))
7188 (if message-forward-decoded-p
7190 (mail-decode-encoded-word-string subject
))
7192 (when message-wash-forwarded-subjects
7193 (setq subject
(message-wash-subject subject
)))
7194 ;; Make sure funcs is a list.
7197 (setq funcs
(list funcs
)))
7198 ;; Apply funcs in order, passing subject generated by previous
7199 ;; func to the next one.
7200 (dolist (func funcs
)
7201 (when (functionp func
)
7202 (setq subject
(funcall func subject
))))
7205 (defvar gnus-article-decoded-p
)
7209 (defun message-forward (&optional news digest
)
7210 "Forward the current message via mail.
7211 Optional NEWS will use news to forward instead of mail.
7212 Optional DIGEST will use digest to forward."
7214 (let* ((cur (current-buffer))
7215 (message-forward-decoded-p
7216 (if (local-variable-p 'gnus-article-decoded-p
(current-buffer))
7217 gnus-article-decoded-p
;; In an article buffer.
7218 message-forward-decoded-p
))
7219 (subject (message-make-forward-subject)))
7221 (message-news nil subject
)
7222 (message-mail nil subject
))
7223 (message-forward-make-body cur digest
)))
7225 (defun message-forward-make-body-plain (forward-buffer)
7227 "\n-------------------- Start of forwarded message --------------------\n")
7229 (contents (with-current-buffer forward-buffer
(buffer-string)))
7231 (unless (featurep 'xemacs
)
7232 (unless (mm-multibyte-string-p contents
)
7233 (error "Attempt to insert unibyte string from the buffer \"%s\"\
7234 to the multibyte buffer \"%s\""
7235 (if (bufferp forward-buffer
)
7236 (buffer-name forward-buffer
)
7239 (insert (mm-with-multibyte-buffer
7242 (goto-char (point-min))
7243 (when (looking-at "From ")
7244 (replace-match "X-From-Line: "))
7246 (unless (bolp) (insert "\n"))
7249 "-------------------- End of forwarded message --------------------\n")
7250 (message-remove-ignored-headers b e
)))
7252 (defun message-remove-ignored-headers (b e
)
7253 (when message-forward-ignored-headers
7255 (narrow-to-region b e
)
7257 (narrow-to-region (point)
7258 (or (search-forward "\n\n" nil t
) (point)))
7259 (let ((ignored (if (stringp message-forward-ignored-headers
)
7260 (list message-forward-ignored-headers
)
7261 message-forward-ignored-headers
)))
7262 (dolist (elem ignored
)
7263 (message-remove-header elem t
))))))
7265 (defun message-forward-make-body-mime (forward-buffer)
7267 (insert "\n\n<#part type=message/rfc822 disposition=inline raw=t>\n")
7269 (narrow-to-region (point) (point))
7270 (mml-insert-buffer forward-buffer
)
7271 (goto-char (point-min))
7272 (when (looking-at "From ")
7273 (replace-match "X-From-Line: "))
7274 (goto-char (point-max)))
7275 (insert "<#/part>\n")
7276 ;; Consider there is no illegible text.
7277 (add-text-properties
7279 `(no-illegible-text t rear-nonsticky t start-open t
))))
7281 (defun message-forward-make-body-mml (forward-buffer)
7282 (insert "\n\n<#mml type=message/rfc822 disposition=inline>\n")
7283 (let ((b (point)) e
)
7284 (if (not message-forward-decoded-p
)
7285 (let ((contents (with-current-buffer forward-buffer
(buffer-string))))
7286 (unless (featurep 'xemacs
)
7287 (unless (mm-multibyte-string-p contents
)
7288 (error "Attempt to insert unibyte string from the buffer \"%s\"\
7289 to the multibyte buffer \"%s\""
7290 (if (bufferp forward-buffer
)
7291 (buffer-name forward-buffer
)
7294 (insert (mm-with-multibyte-buffer
7297 (goto-char (point-min))
7298 (when (looking-at "From ")
7299 (replace-match "X-From-Line: "))
7302 (narrow-to-region (point) (point))
7303 (mml-insert-buffer forward-buffer
)
7304 (goto-char (point-min))
7305 (when (looking-at "From ")
7306 (replace-match "X-From-Line: "))
7307 (goto-char (point-max))))
7309 (insert "<#/mml>\n")
7310 (when (and (not message-forward-decoded-p
)
7311 message-forward-ignored-headers
)
7312 (message-remove-ignored-headers b e
))))
7314 (defun message-forward-make-body-digest-plain (forward-buffer)
7316 "\n-------------------- Start of forwarded message --------------------\n")
7317 (let ((b (point)) e
)
7318 (mml-insert-buffer forward-buffer
)
7321 "\n-------------------- End of forwarded message --------------------\n")))
7323 (defun message-forward-make-body-digest-mime (forward-buffer)
7324 (insert "\n<#multipart type=digest>\n")
7325 (let ((b (point)) e
)
7326 (insert-buffer-substring forward-buffer
)
7328 (insert "<#/multipart>\n")
7330 (narrow-to-region b e
)
7332 (narrow-to-region (point)
7333 (or (search-forward "\n\n" nil t
) (point)))
7334 (delete-region (point-min) (point-max)))))
7336 (defun message-forward-make-body-digest (forward-buffer)
7337 (if message-forward-as-mime
7338 (message-forward-make-body-digest-mime forward-buffer
)
7339 (message-forward-make-body-digest-plain forward-buffer
)))
7341 (autoload 'mm-uu-dissect-text-parts
"mm-uu")
7342 (autoload 'mm-uu-dissect
"mm-uu")
7344 (defun message-signed-or-encrypted-p (&optional dont-emulate-mime handles
)
7345 "Say whether the current buffer contains signed or encrypted message.
7346 If DONT-EMULATE-MIME is nil, this function does the MIME emulation on
7347 messages that don't conform to PGP/MIME described in RFC2015. HANDLES
7348 is for the internal use."
7350 (let ((mm-decrypt-option 'never
)
7351 (mm-verify-option 'never
))
7352 (if (setq handles
(mm-dissect-buffer nil t
))
7353 (unless dont-emulate-mime
7354 (mm-uu-dissect-text-parts handles
))
7355 (unless dont-emulate-mime
7356 (setq handles
(mm-uu-dissect))))))
7357 ;; Check text/plain message in which there is a signed or encrypted
7358 ;; body that has been encoded by B or Q.
7359 (unless (or handles dont-emulate-mime
)
7360 (let ((cur (current-buffer))
7361 (mm-decrypt-option 'never
)
7362 (mm-verify-option 'never
))
7364 (insert-buffer-substring cur
)
7365 (when (setq handles
(mm-dissect-buffer t t
))
7367 (bufferp (car handles
))
7368 (mm-destroy-parts handles
))
7369 (equal (mm-handle-media-type handles
) "text/plain"))
7371 (mm-decode-content-transfer-encoding
7372 (mm-handle-encoding handles
))
7373 (setq handles
(mm-uu-dissect)))
7374 (setq handles nil
))))))
7378 (dolist (handle (if (stringp (car handles
))
7379 (if (member (car handles
)
7380 '("multipart/signed"
7381 "multipart/encrypted"))
7385 (if (stringp (car handle
))
7386 (when (message-signed-or-encrypted-p dont-emulate-mime handle
)
7388 (when (and (bufferp (car handle
))
7389 (equal (mm-handle-media-type handle
)
7391 (with-current-buffer (mm-handle-buffer handle
)
7392 (when (message-signed-or-encrypted-p dont-emulate-mime
)
7393 (throw 'found t
)))))))
7394 (mm-destroy-parts handles
))))
7397 (defun message-forward-make-body (forward-buffer &optional digest
)
7398 ;; Put point where we want it before inserting the forwarded
7400 (if message-forward-before-signature
7402 (goto-char (point-max)))
7404 (message-forward-make-body-digest forward-buffer
)
7405 (if message-forward-as-mime
7406 (if (and message-forward-show-mml
7407 (not (and (eq message-forward-show-mml
'best
)
7408 ;; Use the raw form in the body if it contains
7409 ;; signed or encrypted message so as not to be
7410 ;; destroyed by re-encoding.
7411 (with-current-buffer forward-buffer
7413 (message-signed-or-encrypted-p)
7415 (message-forward-make-body-mml forward-buffer
)
7416 (message-forward-make-body-mime forward-buffer
))
7417 (message-forward-make-body-plain forward-buffer
)))
7418 (message-position-point))
7420 (declare-function rmail-toggle-header
"rmail" (&optional arg
))
7423 (defun message-forward-rmail-make-body (forward-buffer)
7424 (save-window-excursion
7425 (set-buffer forward-buffer
)
7426 (if (rmail-msg-is-pruned)
7427 (if (fboundp 'rmail-msg-restore-non-pruned-header
)
7428 (rmail-msg-restore-non-pruned-header) ; Emacs 22
7429 (rmail-toggle-header 0)))) ; Emacs 23
7430 (message-forward-make-body forward-buffer
))
7432 ;; Fixme: Should have defcustom.
7434 (defun message-insinuate-rmail ()
7435 "Let RMAIL use message to forward."
7437 (setq rmail-enable-mime-composing t
)
7438 (setq rmail-insert-mime-forwarded-message-function
7439 'message-forward-rmail-make-body
))
7442 (defun message-resend (address)
7443 "Resend the current article to ADDRESS."
7445 (list (message-read-from-minibuffer "Resend message to: ")))
7446 (message "Resending message to %s..." address
)
7448 (let ((cur (current-buffer))
7450 ;; We first set up a normal mail buffer.
7451 (unless (message-mail-user-agent)
7452 (set-buffer (get-buffer-create " *message resend*"))
7454 (let ((message-this-is-mail t
)
7455 message-generate-hashcash
7457 (message-setup `((To .
,address
))))
7458 ;; Insert our usual headers.
7459 (message-generate-headers '(From Date To Message-ID
))
7460 (message-narrow-to-headers)
7461 ;; Remove X-Draft-From header etc.
7462 (message-remove-header message-ignored-mail-headers t
)
7463 ;; Rename them all to "Resent-*".
7464 (goto-char (point-min))
7465 (while (re-search-forward "^[A-Za-z]" nil t
)
7470 (delete-region (point) (point-max))
7472 ;; Insert the message to be resent.
7473 (insert-buffer-substring cur
)
7474 (goto-char (point-min))
7475 (search-forward "\n\n")
7478 (narrow-to-region beg
(point))
7479 (message-remove-header message-ignored-resent-headers t
)
7480 (goto-char (point-max)))
7481 (insert mail-header-separator
)
7482 ;; Rename all old ("Also-")Resent headers.
7483 (while (re-search-backward "^\\(Also-\\)*Resent-" beg t
)
7486 ;; Quote any "From " lines at the beginning.
7488 (when (looking-at "From ")
7489 (replace-match "X-From-Line: "))
7491 (let ((message-inhibit-body-encoding
7492 ;; Don't do any further encoding if it looks like the
7493 ;; message has already been encoded.
7494 (let ((case-fold-search t
))
7495 (re-search-forward "^mime-version:" nil t
)))
7496 (message-inhibit-ecomplete t
)
7497 message-required-mail-headers
7498 message-generate-hashcash
7499 rfc2047-encode-encoded-words
)
7500 (message-send-mail))
7501 (kill-buffer (current-buffer)))
7502 (message "Resending message to %s...done" address
)))
7505 (defun message-bounce ()
7506 "Re-mail the current message.
7507 This only makes sense if the current message is a bounce message that
7508 contains some mail you have written which has been bounced back to
7511 (let ((handles (mm-dissect-buffer t
))
7513 (message-pop-to-buffer (message-buffer-name "bounce"))
7514 (if (stringp (car handles
))
7515 ;; This is a MIME bounce.
7516 (mm-insert-part (car (last handles
)))
7517 ;; This is a non-MIME bounce, so we try to remove things
7519 (mm-insert-part handles
)
7521 (goto-char (point-min))
7522 (re-search-forward "\n\n+" nil t
)
7523 (setq boundary
(point))
7524 ;; We remove everything before the bounced mail.
7525 (if (or (re-search-forward message-unsent-separator nil t
)
7527 (search-forward "\n\n" nil
'move
)
7528 (re-search-backward "^Return-Path:.*\n" boundary t
)))
7531 (delete-region (point-min)
7532 (if (re-search-forward "^[^ \n\t]+:" nil t
)
7535 (goto-char boundary
)
7536 (when (re-search-backward "^.?From .*\n" nil t
)
7537 (delete-region (match-beginning 0) (match-end 0)))))
7540 (message-narrow-to-head-1)
7541 (message-remove-header message-ignored-bounced-headers t
)
7542 (goto-char (point-max))
7543 (insert mail-header-separator
))
7544 (message-position-point)))
7547 ;;; Interactive entry points for new message buffers.
7551 (defun message-mail-other-window (&optional to subject
)
7552 "Like `message-mail' command, but display mail buffer in another window."
7554 (unless (message-mail-user-agent)
7555 (let ((pop-up-windows t
)
7556 (special-display-buffer-names nil
)
7557 (special-display-regexps nil
)
7558 (same-window-buffer-names nil
)
7559 (same-window-regexps nil
))
7560 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7561 (let ((message-this-is-mail t
))
7562 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7563 nil nil nil
'switch-to-buffer-other-window
)))
7566 (defun message-mail-other-frame (&optional to subject
)
7567 "Like `message-mail' command, but display mail buffer in another frame."
7569 (unless (message-mail-user-agent)
7570 (let ((pop-up-frames t
)
7571 (special-display-buffer-names nil
)
7572 (special-display-regexps nil
)
7573 (same-window-buffer-names nil
)
7574 (same-window-regexps nil
))
7575 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7576 (let ((message-this-is-mail t
))
7577 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7578 nil nil nil
'switch-to-buffer-other-frame
)))
7581 (defun message-news-other-window (&optional newsgroups subject
)
7582 "Start editing a news article to be sent."
7584 (let ((pop-up-windows t
)
7585 (special-display-buffer-names nil
)
7586 (special-display-regexps nil
)
7587 (same-window-buffer-names nil
)
7588 (same-window-regexps nil
))
7589 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7590 (let ((message-this-is-news t
))
7591 (message-setup `((Newsgroups .
,(or newsgroups
""))
7592 (Subject .
,(or subject
""))))))
7595 (defun message-news-other-frame (&optional newsgroups subject
)
7596 "Start editing a news article to be sent."
7598 (let ((pop-up-frames t
)
7599 (special-display-buffer-names nil
)
7600 (special-display-regexps nil
)
7601 (same-window-buffer-names nil
)
7602 (same-window-regexps nil
))
7603 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7604 (let ((message-this-is-news t
))
7605 (message-setup `((Newsgroups .
,(or newsgroups
""))
7606 (Subject .
,(or subject
""))))))
7610 ;; This code should be moved to underline.el (from which it is stolen).
7613 (defun message-bold-region (start end
)
7614 "Bold all nonblank characters in the region.
7615 Works by overstriking characters.
7616 Called from program, takes two arguments START and END
7617 which specify the range to operate on."
7620 (let ((end1 (make-marker)))
7621 (move-marker end1
(max start end
))
7622 (goto-char (min start end
))
7623 (while (< (point) end1
)
7624 (or (looking-at "[_\^@- ]")
7625 (insert (char-after) "\b"))
7626 (forward-char 1)))))
7629 (defun message-unbold-region (start end
)
7630 "Remove all boldness (overstruck characters) in the region.
7631 Called from program, takes two arguments START and END
7632 which specify the range to operate on."
7635 (let ((end1 (make-marker)))
7636 (move-marker end1
(max start end
))
7637 (goto-char (min start end
))
7638 (while (search-forward "\b" end1 t
)
7639 (if (eq (char-after) (char-after (- (point) 2)))
7640 (delete-char -
2))))))
7642 (defun message-exchange-point-and-mark ()
7643 "Exchange point and mark, but don't activate region if it was inactive."
7644 (goto-char (prog1 (mark t
)
7645 (set-marker (mark-marker) (point)))))
7647 (defalias 'message-make-overlay
'make-overlay
)
7648 (defalias 'message-delete-overlay
'delete-overlay
)
7649 (defalias 'message-overlay-put
'overlay-put
)
7650 (defun message-kill-all-overlays ()
7651 (if (featurep 'xemacs
)
7652 (map-extents (lambda (extent ignore
) (delete-extent extent
)))
7653 (mapcar #'delete-overlay
(overlays-in (point-min) (point-max)))))
7655 ;; Support for toolbar
7656 (defvar tool-bar-mode
)
7658 ;; Note: The :set function in the `message-tool-bar*' variables will only
7659 ;; affect _new_ message buffers. We might add a function that walks thru all
7660 ;; message-mode buffers and force the update.
7661 (defun message-tool-bar-update (&optional symbol value
)
7662 "Update message mode toolbar.
7663 Setter function for custom variables."
7664 (setq-default message-tool-bar-map nil
)
7666 ;; When used as ":set" function:
7667 (set-default symbol value
)))
7669 (defcustom message-tool-bar
(if (eq gmm-tool-bar-style
'gnome
)
7670 'message-tool-bar-gnome
7671 'message-tool-bar-retro
)
7672 "Specifies the message mode tool bar.
7674 It can be either a list or a symbol refering to a list. See
7675 `gmm-tool-bar-from-list' for the format of the list. The
7676 default key map is `message-mode-map'.
7678 Pre-defined symbols include `message-tool-bar-gnome' and
7679 `message-tool-bar-retro'."
7680 :type
'(repeat gmm-tool-bar-list-item
)
7681 :type
'(choice (const :tag
"GNOME style" message-tool-bar-gnome
)
7682 (const :tag
"Retro look" message-tool-bar-retro
)
7683 (repeat :tag
"User defined list" gmm-tool-bar-item
)
7685 :version
"23.1" ;; No Gnus
7686 :initialize
'custom-initialize-default
7687 :set
'message-tool-bar-update
7690 (defcustom message-tool-bar-gnome
7691 '((ispell-message "spell" nil
7692 :visible
(or (not (boundp 'flyspell-mode
))
7693 (not flyspell-mode
)))
7694 (flyspell-buffer "spell" t
7695 :visible
(and (boundp 'flyspell-mode
)
7697 :help
"Flyspell whole buffer")
7698 (gmm-ignore "separator")
7699 (message-send-and-exit "mail/send")
7700 (message-dont-send "mail/save-draft")
7701 (message-kill-buffer "close") ;; stock_cancel
7702 (mml-attach-file "attach" mml-mode-map
)
7703 (mml-preview "mail/preview" mml-mode-map
)
7704 (mml-secure-message-sign-encrypt "lock" mml-mode-map
:visible nil
)
7705 (message-insert-importance-high "important" nil
:visible nil
)
7706 (message-insert-importance-low "unimportant" nil
:visible nil
)
7707 (message-insert-disposition-notification-to "receipt" nil
:visible nil
)
7708 (gmm-customize-mode "preferences" t
:help
"Edit mode preferences")
7709 (message-info "help" t
:help
"Message manual"))
7710 "List of items for the message tool bar (GNOME style).
7712 See `gmm-tool-bar-from-list' for details on the format of the list."
7713 :type
'(repeat gmm-tool-bar-item
)
7714 :version
"23.1" ;; No Gnus
7715 :initialize
'custom-initialize-default
7716 :set
'message-tool-bar-update
7719 (defcustom message-tool-bar-retro
7720 '(;; Old Emacs 21 icon for consistency.
7721 (message-send-and-exit "gnus/mail-send")
7722 (message-kill-buffer "close")
7723 (message-dont-send "cancel")
7724 (mml-attach-file "attach" mml-mode-map
)
7725 (ispell-message "spell")
7726 (mml-preview "preview" mml-mode-map
)
7727 (message-insert-importance-high "gnus/important")
7728 (message-insert-importance-low "gnus/unimportant")
7729 (message-insert-disposition-notification-to "gnus/receipt"))
7730 "List of items for the message tool bar (retro style).
7732 See `gmm-tool-bar-from-list' for details on the format of the list."
7733 :type
'(repeat gmm-tool-bar-item
)
7734 :version
"23.1" ;; No Gnus
7735 :initialize
'custom-initialize-default
7736 :set
'message-tool-bar-update
7739 (defcustom message-tool-bar-zap-list
7740 '(new-file open-file dired kill-buffer write-file
7741 print-buffer customize help
)
7742 "List of icon items from the global tool bar.
7743 These items are not displayed on the message mode tool bar.
7745 See `gmm-tool-bar-from-list' for the format of the list."
7746 :type
'gmm-tool-bar-zap-list
7747 :version
"23.1" ;; No Gnus
7748 :initialize
'custom-initialize-default
7749 :set
'message-tool-bar-update
7752 (defvar image-load-path
)
7754 (defun message-make-tool-bar (&optional force
)
7755 "Make a message mode tool bar from `message-tool-bar-list'.
7756 When FORCE, rebuild the tool bar."
7757 (when (and (not (featurep 'xemacs
))
7758 (boundp 'tool-bar-mode
)
7760 (or (not message-tool-bar-map
) force
))
7761 (setq message-tool-bar-map
7763 (gmm-image-load-path-for-library "message"
7764 "mail/save-draft.xpm"
7766 (image-load-path (cons (car load-path
)
7767 (when (boundp 'image-load-path
)
7769 (gmm-tool-bar-from-list message-tool-bar
7770 message-tool-bar-zap-list
7771 'message-mode-map
))))
7772 message-tool-bar-map
)
7774 ;;; Group name completion.
7776 (defcustom message-newgroups-header-regexp
7777 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
7778 "Regexp that match headers that lists groups."
7782 (defcustom message-completion-alist
7783 (list (cons message-newgroups-header-regexp
'message-expand-group
)
7784 '("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . message-expand-name
)
7785 '("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
7786 . message-expand-name
)
7787 '("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):"
7788 . message-expand-name
))
7789 "Alist of (RE . FUN). Use FUN for completion on header lines matching RE."
7792 :type
'(alist :key-type regexp
:value-type function
))
7794 (defcustom message-expand-name-databases
7796 "List of databases to try for name completion (`message-expand-name').
7797 Each element is a symbol and can be `bbdb' or `eudc'."
7799 :type
'(set (const bbdb
) (const eudc
)))
7801 (defcustom message-tab-body-function nil
7802 "*Function to execute when `message-tab' (TAB) is executed in the body.
7803 If nil, the function bound in `text-mode-map' or `global-map' is executed."
7806 :link
'(custom-manual "(message)Various Commands")
7807 :type
'(choice (const nil
)
7810 (declare-function mail-abbrev-in-expansion-header-p
"mailabbrev" ())
7812 (defun message-tab ()
7813 "Complete names according to `message-completion-alist'.
7814 Execute function specified by `message-tab-body-function' when not in
7817 (let ((alist message-completion-alist
))
7819 (let ((mail-abbrev-mode-regexp (caar alist
)))
7820 (not (mail-abbrev-in-expansion-header-p))))
7821 (setq alist
(cdr alist
)))
7822 (funcall (or (cdar alist
) message-tab-body-function
7823 (lookup-key text-mode-map
"\t")
7824 (lookup-key global-map
"\t")
7825 'indent-relative
))))
7830 (let ((standard-output (current-buffer)))
7831 (eval '(display-completion-list nil
"")))
7832 (defalias 'message-display-completion-list
'display-completion-list
))
7833 (error ;; Don't use `wrong-number-of-arguments' here because of XEmacs.
7834 (defun message-display-completion-list (completions &optional ignore
)
7835 "Display the list of completions, COMPLETIONS, using `standard-output'."
7836 (display-completion-list completions
)))))
7838 (defun message-expand-group ()
7839 "Expand the group name under point."
7840 (let* ((b (save-excursion
7845 (skip-chars-forward "^:")
7848 (skip-chars-backward "^, \t\n") (point))))
7849 (completion-ignore-case t
)
7850 (e (progn (skip-chars-forward "^,\t\n ") (point)))
7851 (hashtb (and (boundp 'gnus-active-hashtb
) gnus-active-hashtb
)))
7852 (message-completion-in-region e b hashtb
)))
7854 (defalias 'message-completion-in-region
7855 (if (fboundp 'completion-in-region
)
7856 'completion-in-region
7857 (lambda (e b hashtb
)
7858 (let* ((string (buffer-substring b e
))
7859 (completions (all-completions string hashtb
))
7861 (delete-region b
(point))
7863 ((= (length completions
) 1)
7864 (if (string= (car completions
) string
)
7867 (message "Only matching group"))
7868 (insert (car completions
))))
7869 ((and (setq comp
(try-completion string hashtb
))
7870 (not (string= comp string
)))
7875 (message "No matching groups")
7876 (save-selected-window
7877 (pop-to-buffer "*Completions*")
7878 (buffer-disable-undo)
7879 (let ((buffer-read-only nil
))
7881 (let ((standard-output (current-buffer)))
7882 (message-display-completion-list (sort completions
'string
<)
7884 (setq buffer-read-only nil
)
7885 (goto-char (point-min))
7886 (delete-region (point)
7887 (progn (forward-line 3) (point))))))))))))
7889 (defun message-expand-name ()
7890 (cond ((and (memq 'eudc message-expand-name-databases
)
7891 (boundp 'eudc-protocol
)
7893 (eudc-expand-inline))
7894 ((and (memq 'bbdb message-expand-name-databases
)
7895 (fboundp 'bbdb-complete-name
))
7896 (bbdb-complete-name))
7902 (defun message-talkative-question (ask question show
&rest text
)
7903 "Call FUNCTION with argument QUESTION; optionally display TEXT... args.
7904 If SHOW is non-nil, the arguments TEXT... are displayed in a temp buffer.
7905 The following arguments may contain lists of values."
7907 (setq text
(message-flatten-list text
)))
7908 (save-window-excursion
7909 (with-output-to-temp-buffer " *MESSAGE information message*"
7910 (with-current-buffer " *MESSAGE information message*"
7911 (fundamental-mode) ; for Emacs 20.4+
7913 (goto-char (point-min))))
7914 (funcall ask question
))
7915 (funcall ask question
)))
7917 (defun message-flatten-list (list)
7918 "Return a new, flat list that contains all elements of LIST.
7920 \(message-flatten-list '(1 (2 3 (4 5 (6))) 7))
7923 (apply 'append
(mapcar 'message-flatten-list list
)))
7927 (defun message-generate-new-buffer-clone-locals (name &optional varstr
)
7928 "Create and return a buffer with name based on NAME using `generate-new-buffer'.
7929 Then clone the local variables and values from the old buffer to the
7930 new one, cloning only the locals having a substring matching the
7932 (let ((oldbuf (current-buffer)))
7933 (with-current-buffer (generate-new-buffer name
)
7934 (message-clone-locals oldbuf varstr
)
7937 (defun message-clone-locals (buffer &optional varstr
)
7938 "Clone the local variables from BUFFER to the current buffer."
7939 (let ((locals (with-current-buffer buffer
(buffer-local-variables)))
7940 (regexp "^gnus\\|^nn\\|^message\\|^sendmail\\|^smtp\\|^user-mail-address"))
7943 (when (and (consp local
)
7945 (string-match regexp
(symbol-name (car local
)))
7947 (string-match varstr
(symbol-name (car local
)))))
7949 (set (make-local-variable (car local
))
7957 (defvar message-inhibit-body-encoding nil
)
7959 (defun message-encode-message-body ()
7960 (unless message-inhibit-body-encoding
7961 (let ((mail-parse-charset (or mail-parse-charset
7962 message-default-charset
))
7963 (case-fold-search t
)
7964 lines content-type-p
)
7967 (narrow-to-region (point) (point-max))
7968 (let ((new (mml-generate-mime)))
7970 (delete-region (point-min) (point-max))
7972 (goto-char (point-min))
7973 (if (eq (aref new
0) ?
\n)
7975 (search-forward "\n\n")
7976 (setq lines
(buffer-substring (point-min) (1- (point))))
7977 (delete-region (point-min) (point))))))
7979 (message-narrow-to-headers-or-head)
7980 (message-remove-header "Mime-Version")
7981 (goto-char (point-max))
7982 (insert "MIME-Version: 1.0\n")
7985 (setq content-type-p
7987 (re-search-backward "^Content-Type:" nil t
))))
7989 (message-narrow-to-headers-or-head)
7990 (message-remove-first-header "Content-Type")
7991 (message-remove-first-header "Content-Transfer-Encoding"))
7992 ;; We always make sure that the message has a Content-Type
7993 ;; header. This is because some broken MTAs and MUAs get
7994 ;; awfully confused when confronted with a message with a
7995 ;; MIME-Version header and without a Content-Type header. For
7996 ;; instance, Solaris' /usr/bin/mail.
7997 (unless content-type-p
7998 (goto-char (point-min))
7999 ;; For unknown reason, MIME-Version doesn't exist.
8000 (when (re-search-forward "^MIME-Version:" nil t
)
8002 (insert "Content-Type: text/plain; charset=us-ascii\n"))))))
8004 (defun message-read-from-minibuffer (prompt &optional initial-contents
)
8005 "Read from the minibuffer while providing abbrev expansion."
8006 (if (fboundp 'mail-abbrevs-setup
)
8007 (let ((mail-abbrev-mode-regexp "")
8008 (minibuffer-setup-hook 'mail-abbrevs-setup
)
8009 (minibuffer-local-map message-minibuffer-local-map
))
8010 (read-from-minibuffer prompt initial-contents
))
8011 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook
)
8012 (minibuffer-local-map message-minibuffer-local-map
))
8013 (read-string prompt initial-contents
))))
8015 (defun message-use-alternative-email-as-from ()
8016 "Set From field of the outgoing message to the first matching
8017 address in `message-alternative-emails', looking at To, Cc and
8018 From headers in the original article."
8019 (require 'mail-utils
)
8020 (let* ((fields '("To" "Cc" "From"))
8023 (mail-strip-quoted-names
8024 (mapconcat 'message-fetch-reply-field fields
","))
8028 (if (string-match message-alternative-emails
(car emails
))
8029 (setq email
(car emails
)
8032 (unless (or (not email
) (equal email user-mail-address
))
8033 (message-remove-header "From")
8034 (goto-char (point-max))
8035 (insert "From: " (let ((user-mail-address email
)) (message-make-from))
8038 (defun message-options-get (symbol)
8039 (cdr (assq symbol message-options
)))
8041 (defun message-options-set (symbol value
)
8042 (let ((the-cons (assq symbol message-options
)))
8045 (setcdr the-cons value
)
8046 (setq message-options
(delq the-cons message-options
)))
8048 (push (cons symbol value
) message-options
))))
8051 (defun message-options-set-recipient ()
8053 (message-narrow-to-headers-or-head)
8054 (message-options-set 'message-sender
8055 (mail-strip-quoted-names
8056 (message-fetch-field "from")))
8057 (message-options-set 'message-recipients
8058 (mail-strip-quoted-names
8059 (let ((to (message-fetch-field "to"))
8060 (cc (message-fetch-field "cc"))
8061 (bcc (message-fetch-field "bcc")))
8064 (if (and to cc
) ", ")
8066 (if (and (or to cc
) bcc
) ", ")
8069 (defun message-hide-headers ()
8070 "Hide headers based on the `message-hidden-headers' variable."
8071 (let ((regexps (if (stringp message-hidden-headers
)
8072 (list message-hidden-headers
)
8073 message-hidden-headers
))
8074 (inhibit-point-motion-hooks t
)
8075 (after-change-functions nil
)
8076 (end-of-headers (point-min)))
8080 (message-narrow-to-headers)
8081 (goto-char (point-min))
8083 (if (not (message-hide-header-p regexps
))
8084 (message-next-header)
8085 (let ((begin (point))
8087 (message-next-header)
8088 (setq header
(buffer-substring begin
(point))
8089 header-len
(- (point) begin
))
8090 (delete-region begin
(point))
8091 (goto-char end-of-headers
)
8093 (setq end-of-headers
8094 (+ end-of-headers header-len
))))))))
8095 (narrow-to-region end-of-headers
(point-max))))
8097 (defun message-hide-header-p (regexps)
8100 (when (eq (car regexps
) 'not
)
8103 (dolist (regexp regexps
)
8104 (setq result
(or result
(looking-at regexp
))))
8109 (declare-function ecomplete-add-item
"ecomplete" (type key text
))
8110 (declare-function ecomplete-save
"ecomplete" ())
8112 (defun message-put-addresses-in-ecomplete ()
8113 (require 'ecomplete
)
8114 (dolist (header '("to" "cc" "from" "reply-to"))
8115 (let ((value (message-field-value header
)))
8116 (dolist (string (mail-header-parse-addresses value
'raw
))
8118 (gnus-replace-in-string
8119 (gnus-replace-in-string string
"^ +\\| +$" "") "\n" ""))
8120 (ecomplete-add-item 'mail
(car (mail-header-parse-address string
))
8124 (autoload 'ecomplete-display-matches
"ecomplete")
8126 (defun message-display-abbrev (&optional choose
)
8127 "Display the next possible abbrev for the text before point."
8128 (interactive (list t
))
8129 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?
\t ?
))
8130 (message-point-in-header-p)
8133 (while (and (memq (char-after) '(?
\t ?
))
8134 (zerop (forward-line -
1))))
8135 (looking-at "To:\\|Cc:")))
8136 (let* ((end (point))
8137 (start (save-excursion
8138 (and (re-search-backward "[\n\t ]" nil t
)
8140 (word (when start
(buffer-substring start end
)))
8141 (match (when (and word
8142 (not (zerop (length word
))))
8143 (ecomplete-display-matches 'mail word choose
))))
8144 (when (and choose match
)
8145 (delete-region start end
)
8148 ;; To send pre-formatted letters like the example below, you can use
8149 ;; `message-send-form-letter':
8150 ;; --8<---------------cut here---------------start------------->8---
8151 ;; To: alice@invalid.invalid
8152 ;; Subject: Verification of your contact information
8153 ;; From: Contact verification <admin@foo.invalid>
8154 ;; --text follows this line--
8156 ;; please verify that your contact information is still valid:
8157 ;; Alice A, A avenue 11, 1111 A town, Austria
8158 ;; ----------next form letter message follows this line----------
8159 ;; To: bob@invalid.invalid
8160 ;; Subject: Verification of your contact information
8161 ;; From: Contact verification <admin@foo.invalid>
8162 ;; --text follows this line--
8164 ;; please verify that your contact information is still valid:
8165 ;; Bob, B street 22, 22222 Be town, Belgium
8166 ;; ----------next form letter message follows this line----------
8167 ;; To: charlie@invalid.invalid
8168 ;; Subject: Verification of your contact information
8169 ;; From: Contact verification <admin@foo.invalid>
8170 ;; --text follows this line--
8172 ;; please verify that your contact information is still valid:
8173 ;; Charlie Chaplin, C plaza 33, 33333 C town, Chile
8174 ;; --8<---------------cut here---------------end--------------->8---
8176 ;; FIXME: What is the most common term (circular letter, form letter, serial
8177 ;; letter, standard letter) for such kind of letter? See also
8178 ;; <http://en.wikipedia.org/wiki/Form_letter>
8180 ;; FIXME: Maybe extent message-mode's font-lock support to recognize
8181 ;; `message-form-letter-separator', i.e. highlight each message like a single
8184 (defcustom message-form-letter-separator
8185 "\n----------next form letter message follows this line----------\n"
8186 "Separator for `message-send-form-letter'."
8187 ;; :group 'message-form-letter
8188 :group
'message-various
8189 :version
"23.1" ;; No Gnus
8192 (defcustom message-send-form-letter-delay
1
8193 "Delay in seconds when sending a message with `message-send-form-letter'.
8194 Only used when `message-send-form-letter' is called with non-nil
8196 ;; :group 'message-form-letter
8197 :group
'message-various
8198 :version
"23.1" ;; No Gnus
8201 (defun message-send-form-letter (&optional force
)
8202 "Sent all form letter messages from current buffer.
8203 Unless FORCE, prompt before sending.
8205 The messages are separated by `message-form-letter-separator'.
8206 Header and body are separated by `mail-header-separator'."
8208 (let ((sent 0) (skipped 0)
8212 (goto-char (point-min))
8215 end
(if (search-forward message-form-letter-separator nil t
)
8216 (- (point) (length message-form-letter-separator
) -
1)
8220 (buffer-substring-no-properties start end
))
8221 (setq buff
(generate-new-buffer "*mail - form letter*"))
8222 (with-current-buffer buff
8225 (setq to
(message-fetch-field "To"))
8226 (switch-to-buffer buff
)
8228 (sit-for message-send-form-letter-delay
))
8230 (y-or-n-p (format "Send message to `%s'? " to
)))
8232 (setq sent
(1+ sent
))
8233 (message-send-and-exit))
8234 (message (format "Message to `%s' skipped." to
))
8235 (setq skipped
(1+ skipped
)))
8236 (when (buffer-live-p buff
)
8237 (kill-buffer buff
))))
8238 (message "%s message(s) sent, %s skipped." sent skipped
)))
8240 (defun message-replace-header (header new-value
&optional after force
)
8241 "Remove HEADER and insert the NEW-VALUE.
8242 If AFTER, insert after this header. If FORCE, insert new field
8243 even if NEW-VALUE is empty."
8244 ;; Similar to `nnheader-replace-header' but for message buffers.
8247 (message-narrow-to-headers)
8248 (message-remove-header header
))
8249 (when (or force
(> (length new-value
) 0))
8251 (message-position-on-field header after
)
8252 (message-position-on-field header
))
8253 (insert new-value
))))
8255 (defcustom message-recipients-without-full-name
8256 (list "ding@gnus.org"
8258 "emacs-devel@gnu.org"
8259 "emacs-pretest-bug@gnu.org"
8260 "bug-gnu-emacs@gnu.org")
8261 "Mail addresses that have no full name.
8262 Used in `message-simplify-recipients'."
8263 ;; Maybe the addresses could be extracted from
8264 ;; `gnus-parameter-to-list-alist'?
8265 :type
'(choice (const :tag
"None" nil
)
8267 :version
"23.1" ;; No Gnus
8268 :group
'message-headers
)
8270 (defun message-simplify-recipients ()
8272 (dolist (hdr '("Cc" "To"))
8273 (message-replace-header
8277 (if (and message-recipients-without-full-name
8279 (regexp-opt message-recipients-without-full-name
)
8283 (message-make-from (car addrcomp
) (cadr addrcomp
))
8285 (when (message-fetch-field hdr
)
8286 (mail-extract-address-components
8287 (message-fetch-field hdr
) t
))
8290 (when (featurep 'xemacs
)
8291 (require 'messagexmas
)
8292 (message-xmas-redefine))
8296 (run-hooks 'message-load-hook
)
8299 ;; coding: iso-8859-1
8302 ;;; message.el ends here