1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996-2016 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: mail, news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; This mode provides mail-sending facilities from within Emacs. It
26 ;; consists mainly of large chunks of code from the sendmail.el,
27 ;; gnus-msg.el and rnewspost.el files.
37 ;; Only for the trivial macros mail-header-from, mail-header-date
38 ;; mail-header-references, mail-header-subject, mail-header-id
39 (eval-when-compile (require 'nnheader
))
40 ;; This is apparently necessary even though things are autoloaded.
41 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
42 ;; require mailabbrev here.
43 (if (featurep 'xemacs
)
44 (require 'mail-abbrevs
)
45 (require 'mailabbrev
))
49 (require 'format-spec
)
52 (autoload 'mailclient-send-it
"mailclient") ;; Emacs 22 or contrib/
54 (defvar gnus-message-group-art
)
55 (defvar gnus-list-identifiers
) ; gnus-sum is required where necessary
56 (defvar rmail-enable-mime-composing
)
58 (defgroup message
'((user-mail-address custom-variable
)
59 (user-full-name custom-variable
))
60 "Mail and news message composing."
61 :link
'(custom-manual "(message)Top")
65 (put 'user-mail-address
'custom-type
'string
)
66 (put 'user-full-name
'custom-type
'string
)
68 (defgroup message-various nil
69 "Various Message Variables."
70 :link
'(custom-manual "(message)Various Message Variables")
73 (defgroup message-buffers nil
75 :link
'(custom-manual "(message)Message Buffers")
78 (defgroup message-sending nil
80 :link
'(custom-manual "(message)Sending Variables")
83 (defgroup message-interface nil
85 :link
'(custom-manual "(message)Interface")
88 (defgroup message-forwarding nil
90 :link
'(custom-manual "(message)Forwarding")
91 :group
'message-interface
)
93 (defgroup message-insertion nil
95 :link
'(custom-manual "(message)Insertion")
98 (defgroup message-headers nil
100 :link
'(custom-manual "(message)Message Headers")
103 (defgroup message-news nil
104 "Composing News Messages."
107 (defgroup message-mail nil
108 "Composing Mail Messages."
111 (defgroup message-faces nil
112 "Faces used for message composing."
116 (defcustom message-directory
"~/Mail/"
117 "*Directory from which all other mail file variables are derived."
118 :group
'message-various
121 (defcustom message-max-buffers
10
122 "*How many buffers to keep before starting to kill them off."
123 :group
'message-buffers
126 (defcustom message-send-rename-function nil
127 "Function called to rename the buffer after sending it."
128 :group
'message-buffers
129 :type
'(choice function
(const nil
)))
131 (defcustom message-fcc-handler-function
'message-output
132 "*A function called to save outgoing articles.
133 This function will be called with the name of the file to store the
134 article in. The default function is `message-output' which saves in Unix
136 :type
'(radio (function-item message-output
)
137 (function :tag
"Other"))
138 :group
'message-sending
)
140 (defcustom message-fcc-externalize-attachments nil
141 "If non-nil, attachments are included as external parts in Fcc copies."
144 :group
'message-sending
)
146 (defcustom message-courtesy-message
147 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
148 "*This is inserted at the start of a mailed copy of a posted message.
149 If the string contains the format spec \"%s\", the Newsgroups
150 the article has been posted to will be inserted there.
151 If this variable is nil, no such courtesy message will be added."
152 :group
'message-sending
153 :type
'(radio string
(const nil
)))
155 (defcustom message-ignored-bounced-headers
156 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
157 "*Regexp that matches headers to be removed in resent bounced mail."
158 :group
'message-interface
161 (defcustom message-from-style mail-from-style
162 "Specifies how \"From\" headers look.
164 If nil, they contain just the return address like:
166 If `parens', they look like:
167 king@grassland.com (Elvis Parsley)
168 If `angles', they look like:
169 Elvis Parsley <king@grassland.com>
171 Otherwise, most addresses look like `angles', but they look like
172 `parens' if `angles' would need quoting and `parens' would not."
174 :type
'(choice (const :tag
"simple" nil
)
178 :group
'message-headers
)
180 (defcustom message-insert-canlock t
181 "Whether to insert a Cancel-Lock header in news postings."
183 :group
'message-headers
186 (defcustom message-syntax-checks
187 (if message-insert-canlock
'((sender . disabled
)) nil
)
188 ;; Guess this one shouldn't be easy to customize...
189 "*Controls what syntax checks should not be performed on outgoing posts.
190 To disable checking of long signatures, for instance, add
191 `(signature . disabled)' to this list.
193 Don't touch this variable unless you really know what you're doing.
195 Checks include `approved', `bogus-recipient', `continuation-headers',
196 `control-chars', `empty', `existing-newsgroups', `from', `illegible-text',
197 `invisible-text', `long-header-lines', `long-lines', `message-id',
198 `multiple-headers', `new-text', `newsgroups', `quoting-style',
199 `repeated-newsgroups', `reply-to', `sender', `sendsys', `shoot',
200 `shorten-followup-to', `signature', `size', `subject', `subject-cmsg'
201 and `valid-newsgroups'."
203 :type
'(repeat sexp
)) ; Fixme: improve this
205 (defcustom message-required-headers
'((optional . References
)
207 "*Headers to be generated or prompted for when sending a message.
208 Also see `message-required-news-headers' and
209 `message-required-mail-headers'."
212 :group
'message-headers
213 :link
'(custom-manual "(message)Message Headers")
214 :type
'(repeat sexp
))
216 (defcustom message-draft-headers
'(References From Date
)
217 "*Headers to be generated when saving a draft message."
220 :group
'message-headers
221 :link
'(custom-manual "(message)Message Headers")
222 :type
'(repeat sexp
))
224 (defcustom message-required-news-headers
225 '(From Newsgroups Subject Date Message-ID
226 (optional . Organization
)
227 (optional . User-Agent
))
228 "*Headers to be generated or prompted for when posting an article.
229 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
230 Message-ID. Organization, Lines, In-Reply-To, Expires, and
231 User-Agent are optional. If you don't want message to insert some
232 header, remove it from this list."
234 :group
'message-headers
235 :link
'(custom-manual "(message)Message Headers")
236 :type
'(repeat sexp
))
238 (defcustom message-required-mail-headers
239 '(From Subject Date
(optional . In-Reply-To
) Message-ID
240 (optional . User-Agent
))
241 "*Headers to be generated or prompted for when mailing a message.
242 It is recommended that From, Date, To, Subject and Message-ID be
243 included. Organization and User-Agent are optional."
245 :group
'message-headers
246 :link
'(custom-manual "(message)Message Headers")
247 :type
'(repeat sexp
))
249 (defcustom message-prune-recipient-rules nil
250 "Rules for how to prune the list of recipients when doing wide replies.
251 This is a list of regexps and regexp matches."
254 :group
'message-headers
255 :link
'(custom-manual "(message)Wide Reply")
256 :type
'(repeat regexp
))
258 (defcustom message-deletable-headers
'(Message-ID Date Lines
)
259 "Headers to be deleted if they already exist and were generated by message previously."
260 :group
'message-headers
261 :link
'(custom-manual "(message)Message Headers")
264 (defcustom message-ignored-news-headers
265 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:\\|^X-Message-SMTP-Method:\\|^X-Gnus-Delayed:"
266 "*Regexp of headers to be removed unconditionally before posting."
268 :group
'message-headers
269 :link
'(custom-manual "(message)Message Headers")
270 :type
'(repeat :value-to-internal
(lambda (widget value
)
271 (custom-split-regexp-maybe value
))
272 :match
(lambda (widget value
)
274 (widget-editable-list-match widget value
)))
277 (defcustom message-ignored-mail-headers
278 "^\\([GF]cc\\|Resent-Fcc\\|Xref\\|X-Draft-From\\|X-Gnus-Agent-Meta-Information\\):"
279 "*Regexp of headers to be removed unconditionally before mailing."
281 :group
'message-headers
282 :link
'(custom-manual "(message)Mail Headers")
285 (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:"
286 "*Header lines matching this regexp will be deleted before posting.
287 It's best to delete old Path and Date headers before posting to avoid
289 :group
'message-interface
290 :link
'(custom-manual "(message)Superseding")
291 :type
'(repeat :value-to-internal
(lambda (widget value
)
292 (custom-split-regexp-maybe value
))
293 :match
(lambda (widget value
)
295 (widget-editable-list-match widget value
)))
298 (defcustom message-subject-re-regexp
299 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
300 "*Regexp matching \"Re: \" in the subject line."
301 :group
'message-various
302 :link
'(custom-manual "(message)Message Headers")
305 ;;; Start of variables adopted from `message-utils.el'.
307 (defcustom message-subject-trailing-was-query t
308 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
309 If nil, leave the subject unchanged. If it is the symbol `ask', query
310 the user what do do. In this case, the subject is matched against
311 `message-subject-trailing-was-ask-regexp'. If
312 `message-subject-trailing-was-query' is t, always strip the trailing
313 old subject. In this case, `message-subject-trailing-was-regexp' is
316 :type
'(choice (const :tag
"never" nil
)
317 (const :tag
"always strip" t
)
319 :link
'(custom-manual "(message)Message Headers")
320 :group
'message-various
)
322 (defcustom message-subject-trailing-was-ask-regexp
323 "[ \t]*\\([[(]+[Ww][Aa][Ss]:?[ \t]*.*[])]+\\)"
324 "*Regexp matching \"(was: <old subject>)\" in the subject line.
326 The function `message-strip-subject-trailing-was' uses this regexp if
327 `message-subject-trailing-was-query' is set to the symbol `ask'. If
328 the variable is t instead of `ask', use
329 `message-subject-trailing-was-regexp' instead.
331 It is okay to create some false positives here, as the user is asked."
333 :group
'message-various
334 :link
'(custom-manual "(message)Message Headers")
337 (defcustom message-subject-trailing-was-regexp
338 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
339 "*Regexp matching \"(was: <old subject>)\" in the subject line.
341 If `message-subject-trailing-was-query' is set to t, the subject is
342 matched against `message-subject-trailing-was-regexp' in
343 `message-strip-subject-trailing-was'. You should use a regexp creating very
344 few false positives here."
346 :group
'message-various
347 :link
'(custom-manual "(message)Message Headers")
350 ;;; marking inserted text
352 (defcustom message-mark-insert-begin
353 "--8<---------------cut here---------------start------------->8---\n"
354 "How to mark the beginning of some inserted text."
357 :link
'(custom-manual "(message)Insertion Variables")
358 :group
'message-various
)
360 (defcustom message-mark-insert-end
361 "--8<---------------cut here---------------end--------------->8---\n"
362 "How to mark the end of some inserted text."
365 :link
'(custom-manual "(message)Insertion Variables")
366 :group
'message-various
)
368 (defcustom message-archive-header
"X-No-Archive: Yes\n"
369 "Header to insert when you don't want your article to be archived.
370 Archives \(such as groups.google.com) respect this header."
373 :link
'(custom-manual "(message)Header Commands")
374 :group
'message-various
)
376 (defcustom message-archive-note
377 "X-No-Archive: Yes - save http://groups.google.com/"
378 "Note to insert why you wouldn't want this posting archived.
379 If nil, don't insert any text in the body."
381 :type
'(radio string
(const nil
))
382 :link
'(custom-manual "(message)Header Commands")
383 :group
'message-various
)
385 ;;; Crossposts and Followups
386 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
387 ;; new suggestions by R. Weikusat <rw at another.de>
389 (defvar message-cross-post-old-target nil
390 "Old target for cross-posts or follow-ups.")
391 (make-variable-buffer-local 'message-cross-post-old-target
)
393 (defcustom message-cross-post-default t
394 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
395 If nil, `message-cross-post-followup-to' will only do a followup. Note that
396 you can explicitly override this setting by calling
397 `message-cross-post-followup-to' with a prefix."
400 :group
'message-various
)
402 (defcustom message-cross-post-note
"Crosspost & Followup-To: "
403 "Note to insert before signature to notify of cross-post and follow-up."
406 :group
'message-various
)
408 (defcustom message-followup-to-note
"Followup-To: "
409 "Note to insert before signature to notify of follow-up only."
412 :group
'message-various
)
414 (defcustom message-cross-post-note-function
'message-cross-post-insert-note
415 "Function to use to insert note about Crosspost or Followup-To.
416 The function will be called with four arguments. The function should not only
417 insert a note, but also ensure old notes are deleted. See the documentation
418 for `message-cross-post-insert-note'."
421 :group
'message-various
)
423 ;;; End of variables adopted from `message-utils.el'.
425 (defcustom message-signature-separator
"^-- $"
426 "Regexp matching the signature separator.
427 This variable is used to strip off the signature from quoted text
428 when `message-cite-function' is
429 `message-cite-original-without-signature'. Most useful values
430 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
432 :type
'(choice (const :tag
"strict" "^-- $")
433 (const :tag
"loose" "^-- *$")
435 :version
"22.3" ;; Gnus 5.10.12 (changed default)
436 :link
'(custom-manual "(message)Various Message Variables")
437 :group
'message-various
)
439 (defcustom message-elide-ellipsis
"\n[...]\n\n"
440 "*The string which is inserted for elided text.
441 This is a format-spec string, and you can use %l to say how many
442 lines were removed, and %c to say how many characters were
445 :link
'(custom-manual "(message)Various Commands")
446 :group
'message-various
)
448 (defcustom message-interactive mail-interactive
449 "Non-nil means when sending a message wait for and display errors.
450 A value of nil means let mailer mail back a message to report errors."
452 :group
'message-sending
454 :link
'(custom-manual "(message)Sending Variables")
457 (defcustom message-confirm-send nil
458 "When non-nil, ask for confirmation when sending a message."
459 :group
'message-sending
461 :version
"23.1" ;; No Gnus
462 :link
'(custom-manual "(message)Sending Variables")
465 (defcustom message-generate-new-buffers
'unsent
466 "*Say whether to create a new message buffer to compose a message.
467 Valid values include:
470 Generate the buffer name in the Message way (e.g., *mail*, *news*,
471 *mail to whom*, *news on group*, etc.) and continue editing in the
472 existing buffer of that name. If there is no such buffer, it will
476 Create the new buffer with the name generated in the Message way.
479 Similar to `unique' but the buffer name begins with \"*unsent \".
482 Similar to nil but the buffer name is simpler like *mail message*.
485 If this is a function, call that function with three parameters:
486 The type, the To address and the group name (any of these may be nil).
487 The function should return the new buffer name."
489 :group
'message-buffers
490 :link
'(custom-manual "(message)Message Buffers")
491 :type
'(choice (const nil
)
492 (sexp :tag
"unique" :format
"unique\n" :value unique
493 :match
(lambda (widget value
) (memq value
'(unique t
))))
496 (function :format
"\n %{%t%}: %v")))
498 (defcustom message-kill-buffer-on-exit nil
499 "*Non-nil means that the message buffer will be killed after sending a message."
500 :group
'message-buffers
501 :link
'(custom-manual "(message)Message Buffers")
504 (defcustom message-kill-buffer-query t
505 "*Non-nil means that killing a modified message buffer has to be confirmed.
506 This is used by `message-kill-buffer'."
507 :version
"23.1" ;; No Gnus
508 :group
'message-buffers
511 (defcustom message-user-organization
512 (or (getenv "ORGANIZATION") t
)
513 "String to be used as an Organization header.
514 If t, use `message-user-organization-file'."
515 :group
'message-headers
516 :type
'(choice string
517 (const :tag
"consult file" t
)))
519 (defcustom message-user-organization-file
521 (dolist (f (list "/etc/organization"
522 "/etc/news/organization"
523 "/usr/lib/news/organization"))
524 (when (file-readable-p f
)
527 "*Local news organization file."
528 :type
'(choice (const nil
) file
)
529 :link
'(custom-manual "(message)News Headers")
530 :group
'message-headers
)
532 (defcustom message-make-forward-subject-function
533 #'message-forward-subject-name-subject
534 "*List of functions called to generate subject headers for forwarded messages.
535 The subject generated by the previous function is passed into each
538 The provided functions are:
540 * `message-forward-subject-author-subject' Source of article (author or
541 newsgroup), in brackets followed by the subject
542 * `message-forward-subject-name-subject' Source of article (name of author
543 or newsgroup), in brackets followed by the subject
544 * `message-forward-subject-fwd' Subject of article with `Fwd:' prepended
546 :group
'message-forwarding
547 :link
'(custom-manual "(message)Forwarding")
548 :type
'(radio (function-item message-forward-subject-author-subject
)
549 (function-item message-forward-subject-fwd
)
550 (function-item message-forward-subject-name-subject
)
551 (repeat :tag
"List of functions" function
)))
553 (defcustom message-forward-as-mime t
554 "*Non-nil means forward messages as an inline/rfc822 MIME section.
555 Otherwise, directly inline the old message in the forwarded message."
557 :group
'message-forwarding
558 :link
'(custom-manual "(message)Forwarding")
561 (defcustom message-forward-show-mml
'best
562 "*Non-nil means show forwarded messages as MML (decoded from MIME).
563 Otherwise, forwarded messages are unchanged.
564 Can also be the symbol `best' to indicate that MML should be
565 used, except when it is a bad idea to use MML. One example where
566 it is a bad idea is when forwarding a signed or encrypted
567 message, because converting MIME to MML would invalidate the
570 :group
'message-forwarding
571 :type
'(choice (const :tag
"use MML" t
)
572 (const :tag
"don't use MML " nil
)
573 (const :tag
"use MML when appropriate" best
)))
575 (defcustom message-forward-before-signature t
576 "*Non-nil means put forwarded message before signature, else after."
577 :group
'message-forwarding
580 (defcustom message-wash-forwarded-subjects nil
581 "*Non-nil means try to remove as much cruft as possible from the subject.
582 Done before generating the new subject of a forward."
583 :group
'message-forwarding
584 :link
'(custom-manual "(message)Forwarding")
587 (defcustom message-ignored-resent-headers
588 ;; `Delivered-To' needs to be removed because some mailers use it to
589 ;; detect loops, so if you resend a message to an address that ultimately
590 ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
591 ;; case you may be removed from the list on the grounds that mail to you
592 ;; bounced with a "mailing loop" error).
593 "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:\
594 \\|^X-Content-Length:\\|^X-UIDL:"
595 "*All headers that match this regexp will be deleted when resending a message."
597 :group
'message-interface
598 :link
'(custom-manual "(message)Resending")
599 :type
'(repeat :value-to-internal
(lambda (widget value
)
600 (custom-split-regexp-maybe value
))
601 :match
(lambda (widget value
)
603 (widget-editable-list-match widget value
)))
606 (defcustom message-forward-ignored-headers
"^Content-Transfer-Encoding:\\|^X-Gnus"
607 "*All headers that match this regexp will be deleted when forwarding a message.
608 This may also be a list of regexps."
610 :group
'message-forwarding
611 :type
'(repeat :value-to-internal
(lambda (widget value
)
612 (custom-split-regexp-maybe value
))
613 :match
(lambda (widget value
)
615 (widget-editable-list-match widget value
)))
618 (defcustom message-forward-included-headers nil
619 "If non-nil, delete non-matching headers when forwarding a message.
620 Only headers that match this regexp will be included. This
621 variable should be a regexp or a list of regexps."
623 :group
'message-forwarding
624 :type
'(repeat :value-to-internal
(lambda (widget value
)
625 (custom-split-regexp-maybe value
))
626 :match
(lambda (widget value
)
628 (widget-editable-list-match widget value
)))
631 (defcustom message-ignored-cited-headers
"."
632 "*Delete these headers from the messages you yank."
633 :group
'message-insertion
634 :link
'(custom-manual "(message)Insertion Variables")
637 (defcustom message-cite-prefix-regexp mail-citation-prefix-regexp
638 "*Regexp matching the longest possible citation prefix on a line."
640 :group
'message-insertion
641 :link
'(custom-manual "(message)Insertion Variables")
643 :set
(lambda (symbol value
)
645 (custom-set-default symbol value
)
646 (if (boundp 'gnus-message-cite-prefix-regexp
)
647 (setq gnus-message-cite-prefix-regexp
648 (concat "^\\(?:" value
"\\)"))))))
650 (defcustom message-cancel-message
"I am canceling my own article.\n"
651 "Message to be inserted in the cancel message."
652 :group
'message-interface
653 :link
'(custom-manual "(message)Canceling News")
656 (defun message-send-mail-function ()
657 "Return suitable value for the variable `message-send-mail-function'."
658 (cond ((and (require 'sendmail
)
659 (boundp 'sendmail-program
)
661 (executable-find sendmail-program
))
662 'message-send-mail-with-sendmail
)
663 ((and (locate-library "smtpmail")
664 (boundp 'smtpmail-default-smtp-server
)
665 smtpmail-default-smtp-server
)
666 'message-smtpmail-send-it
)
667 ((locate-library "mailclient")
668 'message-send-mail-with-mailclient
)
670 (error "Don't know how to send mail. Please customize `message-send-mail-function'"))))
672 (defun message-default-send-mail-function ()
673 (cond ((eq send-mail-function
'smtpmail-send-it
) 'message-smtpmail-send-it
)
674 ((eq send-mail-function
'feedmail-send-it
) 'feedmail-send-it
)
675 ((eq send-mail-function
'sendmail-query-once
) 'sendmail-query-once
)
676 ((eq send-mail-function
'mailclient-send-it
)
677 'message-send-mail-with-mailclient
)
678 (t (message-send-mail-function))))
680 ;; Useful to set in site-init.el
681 (defcustom message-send-mail-function
(message-default-send-mail-function)
682 "Function to call to send the current buffer as mail.
683 The headers should be delimited by a line whose contents match the
684 variable `mail-header-separator'.
686 Valid values include `message-send-mail-with-sendmail'
687 `message-send-mail-with-mh', `message-send-mail-with-qmail',
688 `message-smtpmail-send-it', `smtpmail-send-it',
689 `feedmail-send-it' and `message-send-mail-with-mailclient'. The
690 default is system dependent and determined by the function
691 `message-send-mail-function'.
693 See also `send-mail-function'."
694 :type
'(radio (function-item message-send-mail-with-sendmail
)
695 (function-item message-send-mail-with-mh
)
696 (function-item message-send-mail-with-qmail
)
697 (function-item message-smtpmail-send-it
)
698 (function-item smtpmail-send-it
)
699 (function-item feedmail-send-it
)
700 (function-item message-send-mail-with-mailclient
701 :tag
"Use Mailclient package")
702 (function :tag
"Other"))
703 :group
'message-sending
705 :initialize
'custom-initialize-default
706 :link
'(custom-manual "(message)Mail Variables")
707 :group
'message-mail
)
709 (defcustom message-send-news-function
'message-send-news
710 "Function to call to send the current buffer as news.
711 The headers should be delimited by a line whose contents match the
712 variable `mail-header-separator'."
713 :group
'message-sending
715 :link
'(custom-manual "(message)News Variables")
718 (defcustom message-reply-to-function nil
719 "If non-nil, function that should return a list of headers.
720 This function should pick out addresses from the To, Cc, and From headers
721 and respond with new To and Cc headers."
722 :group
'message-interface
723 :link
'(custom-manual "(message)Reply")
724 :type
'(choice function
(const nil
)))
726 (defcustom message-wide-reply-to-function nil
727 "If non-nil, function that should return a list of headers.
728 This function should pick out addresses from the To, Cc, and From headers
729 and respond with new To and Cc headers."
730 :group
'message-interface
731 :link
'(custom-manual "(message)Wide Reply")
732 :type
'(choice function
(const nil
)))
734 (defcustom message-followup-to-function nil
735 "If non-nil, function that should return a list of headers.
736 This function should pick out addresses from the To, Cc, and From headers
737 and respond with new To and Cc headers."
738 :group
'message-interface
739 :link
'(custom-manual "(message)Followup")
740 :type
'(choice function
(const nil
)))
742 (defcustom message-extra-wide-headers nil
743 "If non-nil, a list of additional address headers.
744 These are used when composing a wide reply."
745 :group
'message-sending
746 :type
'(repeat string
))
748 (defcustom message-use-followup-to
'ask
749 "*Specifies what to do with Followup-To header.
750 If nil, always ignore the header. If it is t, use its value, but
751 query before using the \"poster\" value. If it is the symbol `ask',
752 always query the user whether to use the value. If it is the symbol
753 `use', always use the value."
754 :group
'message-interface
755 :link
'(custom-manual "(message)Followup")
756 :type
'(choice (const :tag
"ignore" nil
)
757 (const :tag
"use & query" t
)
761 (defcustom message-use-mail-followup-to
'use
762 "*Specifies what to do with Mail-Followup-To header.
763 If nil, always ignore the header. If it is the symbol `ask', always
764 query the user whether to use the value. If it is the symbol `use',
765 always use the value."
767 :group
'message-interface
768 :link
'(custom-manual "(message)Mailing Lists")
769 :type
'(choice (const :tag
"ignore" nil
)
773 (defcustom message-subscribed-address-functions nil
774 "*Specifies functions for determining list subscription.
775 If nil, do not attempt to determine list subscription with functions.
776 If non-nil, this variable contains a list of functions which return
777 regular expressions to match lists. These functions can be used in
778 conjunction with `message-subscribed-regexps' and
779 `message-subscribed-addresses'."
781 :group
'message-interface
782 :link
'(custom-manual "(message)Mailing Lists")
783 :type
'(repeat sexp
))
785 (defcustom message-subscribed-address-file nil
786 "*A file containing addresses the user is subscribed to.
787 If nil, do not look at any files to determine list subscriptions. If
788 non-nil, each line of this file should be a mailing list address."
790 :group
'message-interface
791 :link
'(custom-manual "(message)Mailing Lists")
792 :type
'(radio file
(const nil
)))
794 (defcustom message-subscribed-addresses nil
795 "*Specifies a list of addresses the user is subscribed to.
796 If nil, do not use any predefined list subscriptions. This list of
797 addresses can be used in conjunction with
798 `message-subscribed-address-functions' and `message-subscribed-regexps'."
800 :group
'message-interface
801 :link
'(custom-manual "(message)Mailing Lists")
802 :type
'(repeat string
))
804 (defcustom message-subscribed-regexps nil
805 "*Specifies a list of addresses the user is subscribed to.
806 If nil, do not use any predefined list subscriptions. This list of
807 regular expressions can be used in conjunction with
808 `message-subscribed-address-functions' and `message-subscribed-addresses'."
810 :group
'message-interface
811 :link
'(custom-manual "(message)Mailing Lists")
812 :type
'(repeat regexp
))
814 (defcustom message-allow-no-recipients
'ask
815 "Specifies what to do when there are no recipients other than Gcc/Fcc.
816 If it is the symbol `always', the posting is allowed. If it is the
817 symbol `never', the posting is not allowed. If it is the symbol
818 `ask', you are prompted."
820 :group
'message-interface
821 :link
'(custom-manual "(message)Message Headers")
822 :type
'(choice (const always
)
826 (defcustom message-sendmail-f-is-evil nil
827 "*Non-nil means don't add \"-f username\" to the sendmail command line.
828 Doing so would be even more evil than leaving it out."
829 :group
'message-sending
830 :link
'(custom-manual "(message)Mail Variables")
833 (defcustom message-sendmail-envelope-from
834 ;; `mail-envelope-from' is unavailable unless sendmail.el is loaded.
835 (if (boundp 'mail-envelope-from
) mail-envelope-from
)
836 "*Envelope-from when sending mail with sendmail.
837 If this is nil, use `user-mail-address'. If it is the symbol
838 `header', use the From: header of the message."
840 :type
'(choice (string :tag
"From name")
841 (const :tag
"Use From: header from message" header
)
842 (const :tag
"Use `user-mail-address'" nil
))
843 :link
'(custom-manual "(message)Mail Variables")
844 :group
'message-sending
)
846 (defcustom message-sendmail-extra-arguments nil
847 "Additional arguments to `sendmail-program'."
848 ;; E.g. '("-a" "account") for msmtp
849 :version
"23.1" ;; No Gnus
850 :type
'(repeat string
)
851 ;; :link '(custom-manual "(message)Mail Variables")
852 :group
'message-sending
)
854 ;; qmail-related stuff
855 (defcustom message-qmail-inject-program
"/var/qmail/bin/qmail-inject"
856 "Location of the qmail-inject program."
857 :group
'message-sending
858 :link
'(custom-manual "(message)Mail Variables")
861 (defcustom message-qmail-inject-args nil
862 "Arguments passed to qmail-inject programs.
863 This should be a list of strings, one string for each argument.
864 It may also be a function.
866 For e.g., if you wish to set the envelope sender address so that bounces
867 go to the right place or to deal with listserv's usage of that address, you
868 might set this variable to (\"-f\" \"you@some.where\")."
869 :group
'message-sending
870 :link
'(custom-manual "(message)Mail Variables")
871 :type
'(choice (function)
874 (defvar gnus-post-method
)
875 (defvar gnus-select-method
)
876 (defcustom message-post-method
877 (cond ((and (boundp 'gnus-post-method
)
878 (listp gnus-post-method
)
881 ((boundp 'gnus-select-method
)
884 "*Method used to post news.
885 Note that when posting from inside Gnus, for instance, this
886 variable isn't used."
888 :group
'message-sending
889 ;; This should be the `gnus-select-method' widget, but that might
890 ;; create a dependence to `gnus.el'.
893 (defcustom message-generate-headers-first nil
894 "Which headers should be generated before starting to compose a message.
895 If t, generate all required headers. This can also be a list of headers to
896 generate. The variables `message-required-news-headers' and
897 `message-required-mail-headers' specify which headers to generate.
899 Note that the variable `message-deletable-headers' specifies headers which
900 are to be deleted and then re-generated before sending, so this variable
901 will not have a visible effect for those headers."
902 :group
'message-headers
903 :link
'(custom-manual "(message)Message Headers")
904 :type
'(choice (const :tag
"None" nil
)
906 (repeat (sexp :tag
"Header"))))
908 (defcustom message-fill-column
72
909 "Column beyond which automatic line-wrapping should happen.
910 Local value for message buffers. If non-nil, also turn on
911 auto-fill in message buffers."
912 :group
'message-various
913 ;; :link '(custom-manual "(message)Message Headers")
914 :type
'(choice (const :tag
"Don't turn on auto fill" nil
)
917 (defcustom message-setup-hook nil
918 "Normal hook, run each time a new outgoing message is initialized.
919 The function `message-setup' runs this hook."
920 :group
'message-various
921 :link
'(custom-manual "(message)Various Message Variables")
924 (defcustom message-cancel-hook nil
925 "Hook run when canceling articles."
926 :group
'message-various
927 :link
'(custom-manual "(message)Various Message Variables")
930 (defcustom message-signature-setup-hook nil
931 "Normal hook, run each time a new outgoing message is initialized.
932 It is run after the headers have been inserted and before
933 the signature is inserted."
934 :group
'message-various
935 :link
'(custom-manual "(message)Various Message Variables")
938 (defcustom message-mode-hook nil
939 "Hook run in message mode buffers."
940 :group
'message-various
943 (defcustom message-header-hook nil
944 "Hook run in a message mode buffer narrowed to the headers."
945 :group
'message-various
948 (defcustom message-header-setup-hook nil
949 "Hook called narrowed to the headers when setting up a message buffer."
950 :group
'message-various
951 :link
'(custom-manual "(message)Various Message Variables")
954 (defcustom message-minibuffer-local-map
955 (let ((map (make-sparse-keymap 'message-minibuffer-local-map
)))
956 (set-keymap-parent map minibuffer-local-map
)
958 "Keymap for `message-read-from-minibuffer'."
959 ;; FIXME improve type.
960 :type
'(restricted-sexp :match-alternatives
(symbolp keymapp
))
962 :group
'message-various
)
964 (defcustom message-citation-line-function
'message-insert-citation-line
965 "*Function called to insert the \"Whomever writes:\" line.
967 Predefined functions include `message-insert-citation-line' and
968 `message-insert-formatted-citation-line' (see the variable
969 `message-citation-line-format').
971 Note that Gnus provides a feature where the reader can click on
972 `writes:' to hide the cited text. If you change this line too much,
973 people who read your message will have to change their Gnus
974 configuration. See the variable `gnus-cite-attribution-suffix'."
976 (function-item :tag
"plain" message-insert-citation-line
)
977 (function-item :tag
"formatted" message-insert-formatted-citation-line
)
978 (function :tag
"Other"))
979 :link
'(custom-manual "(message)Insertion Variables")
980 :group
'message-insertion
)
982 (defcustom message-citation-line-format
"On %a, %b %d %Y, %N wrote:\n"
983 "Format of the \"Whomever writes:\" line.
985 The string is formatted using `format-spec'. The following constructs
988 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
989 %n The mail address, e.g. \"john.doe@example.invalid\".
990 %N The real name if present, e.g.: \"John Doe\", else fall
991 back to the mail address.
992 %F The first name if present, e.g.: \"John\", else fall
993 back to the mail address.
994 %L The last name if present, e.g.: \"Doe\".
995 %Z, %z The time zone in the numeric form, e.g.:\"+0000\".
997 All other format specifiers are passed to `format-time-string'
998 which is called using the date from the article your replying to, but
999 the date in the formatted string will be expressed in the author's
1000 time zone as much as possible.
1001 Extracting the first (%F) and last name (%L) is done heuristically,
1002 so you should always check it yourself.
1004 Please also read the note in the documentation of
1005 `message-citation-line-function'."
1006 :type
'(choice (const :tag
"Plain" "%f writes:")
1007 (const :tag
"Include date" "On %a, %b %d %Y, %n wrote:")
1009 :link
'(custom-manual "(message)Insertion Variables")
1010 :version
"23.1" ;; No Gnus
1011 :group
'message-insertion
)
1013 (defcustom message-yank-prefix mail-yank-prefix
1014 "*Prefix inserted on the lines of yanked messages.
1015 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1016 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
1019 :link
'(custom-manual "(message)Insertion Variables")
1020 :group
'message-insertion
)
1022 (defcustom message-yank-cited-prefix
">"
1023 "*Prefix inserted on cited lines of yanked messages.
1024 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1025 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1028 :link
'(custom-manual "(message)Insertion Variables")
1029 :group
'message-insertion
)
1031 (defcustom message-yank-empty-prefix
">"
1032 "*Prefix inserted on empty lines of yanked messages.
1033 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1036 :link
'(custom-manual "(message)Insertion Variables")
1037 :group
'message-insertion
)
1039 (defcustom message-indentation-spaces mail-indentation-spaces
1040 "*Number of spaces to insert at the beginning of each cited line.
1041 Used by `message-yank-original' via `message-yank-cite'."
1043 :group
'message-insertion
1044 :link
'(custom-manual "(message)Insertion Variables")
1047 (defcustom message-cite-function
'message-cite-original-without-signature
1048 "*Function for citing an original message.
1049 Predefined functions include `message-cite-original' and
1050 `message-cite-original-without-signature'.
1051 Note that these functions use `mail-citation-hook' if that is non-nil."
1052 :type
'(radio (function-item message-cite-original
)
1053 (function-item message-cite-original-without-signature
)
1054 (function-item sc-cite-original
)
1055 (function :tag
"Other"))
1056 :link
'(custom-manual "(message)Insertion Variables")
1057 :version
"22.3" ;; Gnus 5.10.12 (changed default)
1058 :group
'message-insertion
)
1060 (defcustom message-indent-citation-function
'message-indent-citation
1061 "*Function for modifying a citation just inserted in the mail buffer.
1062 This can also be a list of functions. Each function can find the
1063 citation between (point) and (mark t). And each function should leave
1064 point and mark around the citation text as modified."
1066 :link
'(custom-manual "(message)Insertion Variables")
1067 :group
'message-insertion
)
1069 (defcustom message-signature mail-signature
1070 "*String to be inserted at the end of the message buffer.
1071 If t, the `message-signature-file' file will be inserted instead.
1072 If a function, the result from the function will be used instead.
1073 If a form, the result from the form will be used instead."
1077 :link
'(custom-manual "(message)Insertion Variables")
1078 :group
'message-insertion
)
1080 (defcustom message-signature-file mail-signature-file
1081 "*Name of file containing the text inserted at end of message buffer.
1082 Ignored if the named file doesn't exist.
1083 If nil, don't insert a signature.
1084 If a path is specified, the value of `message-signature-directory' is ignored,
1087 :type
'(choice file
(const :tags
"None" nil
))
1088 :link
'(custom-manual "(message)Insertion Variables")
1089 :group
'message-insertion
)
1091 (defcustom message-signature-directory nil
1092 "*Name of directory containing signature files.
1093 Comes in handy if you have many such files, handled via posting styles for
1095 If nil, `message-signature-file' is expected to specify the directory if
1097 :type
'(choice string
(const :tags
"None" nil
))
1098 :link
'(custom-manual "(message)Insertion Variables")
1099 :group
'message-insertion
)
1101 (defcustom message-signature-insert-empty-line t
1102 "*If non-nil, insert an empty line before the signature separator."
1105 :link
'(custom-manual "(message)Insertion Variables")
1106 :group
'message-insertion
)
1108 (defcustom message-cite-reply-position
'traditional
1109 "*Where the reply should be positioned.
1110 If `traditional', reply inline.
1111 If `above', reply above quoted text.
1112 If `below', reply below quoted text.
1114 Note: Many newsgroups frown upon nontraditional reply styles. You
1115 probably want to set this variable only for specific groups,
1116 e.g. using `gnus-posting-styles':
1118 (eval (set (make-local-variable \\='message-cite-reply-position) \\='above))"
1120 :type
'(choice (const :tag
"Reply inline" traditional
)
1121 (const :tag
"Reply above" above
)
1122 (const :tag
"Reply below" below
))
1123 :group
'message-insertion
)
1125 (defcustom message-cite-style nil
1126 "*The overall style to be used when yanking cited text.
1127 Value is either nil (no variable overrides) or a let-style list
1128 of pairs (VARIABLE VALUE) that will be bound in
1129 `message-yank-original' to do the quoting.
1131 Presets to impersonate popular mail agents are found in the
1132 message-cite-style-* variables. This variable is intended for
1133 use in `gnus-posting-styles', such as:
1135 ((posting-from-work-p) (eval (set (make-local-variable \\='message-cite-style) message-cite-style-outlook)))"
1137 :group
'message-insertion
1138 :type
'(choice (const :tag
"Do not override variables" :value nil
)
1139 (const :tag
"MS Outlook" :value message-cite-style-outlook
)
1140 (const :tag
"Mozilla Thunderbird" :value message-cite-style-thunderbird
)
1141 (const :tag
"Gmail" :value message-cite-style-gmail
)
1142 (variable :tag
"User-specified")))
1144 (defconst message-cite-style-outlook
1145 '((message-cite-function 'message-cite-original
)
1146 (message-citation-line-function 'message-insert-formatted-citation-line
)
1147 (message-cite-reply-position 'above
)
1148 (message-yank-prefix "")
1149 (message-yank-cited-prefix "")
1150 (message-yank-empty-prefix "")
1151 (message-citation-line-format "\n\n-----------------------\nOn %a, %b %d %Y, %N wrote:\n"))
1152 "Message citation style used by MS Outlook. Use with message-cite-style.")
1154 (defconst message-cite-style-thunderbird
1155 '((message-cite-function 'message-cite-original
)
1156 (message-citation-line-function 'message-insert-formatted-citation-line
)
1157 (message-cite-reply-position 'above
)
1158 (message-yank-prefix "> ")
1159 (message-yank-cited-prefix ">")
1160 (message-yank-empty-prefix ">")
1161 (message-citation-line-format "On %D %R %p, %N wrote:"))
1162 "Message citation style used by Mozilla Thunderbird. Use with message-cite-style.")
1164 (defconst message-cite-style-gmail
1165 '((message-cite-function 'message-cite-original
)
1166 (message-citation-line-function 'message-insert-formatted-citation-line
)
1167 (message-cite-reply-position 'above
)
1168 (message-yank-prefix " ")
1169 (message-yank-cited-prefix " ")
1170 (message-yank-empty-prefix " ")
1171 (message-citation-line-format "On %e %B %Y %R, %f wrote:\n"))
1172 "Message citation style used by Gmail. Use with message-cite-style.")
1174 (defcustom message-distribution-function nil
1175 "*Function called to return a Distribution header."
1176 :group
'message-news
1177 :group
'message-headers
1178 :link
'(custom-manual "(message)News Headers")
1179 :type
'(choice function
(const nil
)))
1181 (defcustom message-expires
14
1182 "Number of days before your article expires."
1183 :group
'message-news
1184 :group
'message-headers
1185 :link
'(custom-manual "(message)News Headers")
1188 (defcustom message-user-path nil
1189 "If nil, use the NNTP server name in the Path header.
1190 If stringp, use this; if non-nil, use no host name (user name only)."
1191 :group
'message-news
1192 :group
'message-headers
1193 :link
'(custom-manual "(message)News Headers")
1194 :type
'(choice (const :tag
"nntp" nil
)
1195 (string :tag
"name")
1196 (sexp :tag
"none" :format
"%t" t
)))
1198 ;; This can be the name of a buffer, or a cons cell (FUNCTION . ARGS)
1199 ;; for yanking the original buffer.
1200 (defvar message-reply-buffer nil
)
1201 (defvar message-reply-headers nil
1202 "The headers of the current replied article.
1203 It is a vector of the following headers:
1204 [number subject from date id references chars lines xref extra].")
1205 (defvar message-newsreader nil
)
1206 (defvar message-mailer nil
)
1207 (defvar message-sent-message-via nil
)
1208 (defvar message-checksum nil
)
1209 (defvar message-send-actions nil
1210 "A list of actions to be performed upon successful sending of a message.")
1211 (defvar message-return-action nil
1212 "Action to return to the caller after sending or postponing a message.")
1213 (defvar message-exit-actions nil
1214 "A list of actions to be performed upon exiting after sending a message.")
1215 (defvar message-kill-actions nil
1216 "A list of actions to be performed before killing a message buffer.")
1217 (defvar message-postpone-actions nil
1218 "A list of actions to be performed after postponing a message.")
1220 (define-widget 'message-header-lines
'text
1221 "All header lines must be LFD terminated."
1222 :format
"%{%t%}:%n%v"
1223 :valid-regexp
"^\\'"
1224 :error
"All header lines must be newline terminated")
1226 (defcustom message-default-headers
""
1227 "Header lines to be inserted in outgoing messages.
1228 This can be set to a string containing or a function returning
1229 header lines to be inserted before you edit the message, so you
1230 can edit or delete these lines. If set to a function, it is
1231 called and its result is inserted."
1233 :group
'message-headers
1234 :link
'(custom-manual "(message)Message Headers")
1236 (message-header-lines :tag
"String")
1237 (function :tag
"Function")))
1239 (defcustom message-default-mail-headers
1240 ;; Ease the transition from mail-mode to message-mode. See bugs#4431, 5555.
1241 (concat (if (and (boundp 'mail-default-reply-to
)
1242 (stringp mail-default-reply-to
))
1243 (format "Reply-to: %s\n" mail-default-reply-to
))
1244 (if (and (boundp 'mail-self-blind
)
1246 (format "BCC: %s\n" user-mail-address
))
1247 (if (and (boundp 'mail-archive-file-name
)
1248 (stringp mail-archive-file-name
))
1249 (format "FCC: %s\n" mail-archive-file-name
))
1250 ;; Use the value of `mail-default-headers' if available.
1251 ;; Note: as for XEmacs 21.4 and 21.5, it is unavailable
1252 ;; unless sendmail.el is loaded.
1253 (if (boundp 'mail-default-headers
)
1254 mail-default-headers
))
1255 "*A string of header lines to be inserted in outgoing mails."
1257 :group
'message-headers
1258 :group
'message-mail
1259 :link
'(custom-manual "(message)Mail Headers")
1260 :type
'message-header-lines
)
1262 (defcustom message-default-news-headers
""
1263 "*A string of header lines to be inserted in outgoing news articles."
1264 :group
'message-headers
1265 :group
'message-news
1266 :link
'(custom-manual "(message)News Headers")
1267 :type
'message-header-lines
)
1269 ;; Note: could use /usr/ucb/mail instead of sendmail;
1270 ;; options -t, and -v if not interactive.
1271 (defcustom message-mailer-swallows-blank-line
1272 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1273 system-configuration
)
1274 (file-readable-p "/etc/sendmail.cf")
1276 (insert-file-contents "/etc/sendmail.cf")
1277 (goto-char (point-min))
1278 (let ((case-fold-search nil
))
1279 (re-search-forward "^OR\\>" nil t
))))
1280 ;; According to RFC822, "The field-name must be composed of printable
1281 ;; ASCII characters (i. e., characters that have decimal values between
1282 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1284 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1285 "*Set this non-nil if the system's mailer runs the header and body together.
1286 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1287 The value should be an expression to test whether the problem will
1289 :group
'message-sending
1290 :link
'(custom-manual "(message)Mail Variables")
1295 (define-mail-user-agent 'message-user-agent
1296 'message-mail
'message-send-and-exit
1297 'message-kill-buffer
'message-send-hook
)
1299 (defvar message-mh-deletable-headers
'(Message-ID Date Lines Sender
)
1300 "If non-nil, delete the deletable headers before feeding to mh.")
1302 (defvar message-send-method-alist
1303 '((news message-news-p message-send-via-news
)
1304 (mail message-mail-p message-send-via-mail
))
1305 "Alist of ways to send outgoing messages.
1306 Each element has the form
1308 (TYPE PREDICATE FUNCTION)
1310 where TYPE is a symbol that names the method; PREDICATE is a function
1311 called without any parameters to determine whether the message is
1312 a message of type TYPE; and FUNCTION is a function to be called if
1313 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1316 (defcustom message-mail-alias-type
'abbrev
1317 "*What alias expansion type to use in Message buffers.
1318 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1319 an electric completion mode. nil switches mail aliases off.
1320 This can also be a list of values."
1322 :link
'(custom-manual "(message)Mail Aliases")
1323 :type
'(choice (const :tag
"Use Mailabbrev" abbrev
)
1324 (const :tag
"Use ecomplete" ecomplete
)
1325 (const :tag
"No expansion" nil
)))
1327 (defcustom message-self-insert-commands
'(self-insert-command)
1328 "List of `self-insert-command's used to trigger ecomplete.
1329 When one of those commands is invoked to enter a character in To or Cc
1330 header, ecomplete will suggest the candidates of recipients (see also
1331 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1332 text and it replaces `self-insert-command' with the other command, e.g.
1333 `egg-self-insert-command', you may want to add it to this list."
1334 :group
'message-various
1335 :type
'(repeat function
))
1337 (defcustom message-auto-save-directory
1338 (if (file-writable-p message-directory
)
1339 (file-name-as-directory (expand-file-name "drafts" message-directory
))
1341 "*Directory where Message auto-saves buffers if Gnus isn't running.
1342 If nil, Message won't auto-save."
1343 :group
'message-buffers
1344 :link
'(custom-manual "(message)Various Message Variables")
1345 :type
'(choice directory
(const :tag
"Don't auto-save" nil
)))
1347 (defcustom message-default-charset
1348 (and (not (mm-multibyte-p)) 'iso-8859-1
)
1349 "Default charset used in non-MULE Emacsen.
1350 If nil, you might be asked to input the charset."
1353 :link
'(custom-manual "(message)Various Message Variables")
1356 (defcustom message-dont-reply-to-names
1357 (and (boundp 'mail-dont-reply-to-names
) mail-dont-reply-to-names
)
1358 "*Addresses to prune when doing wide replies.
1359 This can be a regexp or a list of regexps. Also, a value of nil means
1360 exclude your own user name only."
1363 :link
'(custom-manual "(message)Wide Reply")
1364 :type
'(choice (const :tag
"Yourself" nil
)
1366 (repeat :tag
"Regexp List" regexp
)))
1368 (defsubst message-dont-reply-to-names
()
1369 (gmm-regexp-concat message-dont-reply-to-names
))
1371 (defvar message-shoot-gnksa-feet nil
1372 "*A list of GNKSA feet you are allowed to shoot.
1373 Gnus gives you all the opportunity you could possibly want for
1374 shooting yourself in the foot. Also, Gnus allows you to shoot the
1375 feet of Good Net-Keeping Seal of Approval. The following are foot
1377 `empty-article' Allow you to post an empty article;
1378 `quoted-text-only' Allow you to post quoted text only;
1379 `multiple-copies' Allow you to post multiple copies;
1380 `cancel-messages' Allow you to cancel or supersede messages from
1381 your other email addresses;
1382 `canlock-verify' Allow you to cancel messages without verifying canlock.")
1384 (defsubst message-gnksa-enable-p
(feature)
1385 (or (not (listp message-shoot-gnksa-feet
))
1386 (memq feature message-shoot-gnksa-feet
)))
1388 (defcustom message-hidden-headers
'("^References:" "^Face:" "^X-Face:"
1390 "Regexp of headers to be hidden when composing new messages.
1391 This can also be a list of regexps to match headers. Or a list
1392 starting with `not' and followed by regexps."
1395 :link
'(custom-manual "(message)Message Headers")
1397 :format
"%{%t%}: %[Value Type%] %v"
1398 (regexp :menu-tag
"regexp" :format
"regexp\n%t: %v")
1399 (repeat :menu-tag
"(regexp ...)" :format
"(regexp ...)\n%v%i"
1400 (regexp :format
"%t: %v"))
1401 (cons :menu-tag
"(not regexp ...)" :format
"(not regexp ...)\n%v"
1403 (repeat :format
"%v%i"
1404 (regexp :format
"%t: %v")))))
1406 (defcustom message-cite-articles-with-x-no-archive t
1407 "If non-nil, cite text from articles that has X-No-Archive set."
1411 ;;; Internal variables.
1412 ;;; Well, not really internal.
1414 (defvar message-mode-syntax-table
1415 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1416 (modify-syntax-entry ?%
". " table
)
1417 (modify-syntax-entry ?
> ". " table
)
1418 (modify-syntax-entry ?
< ". " table
)
1420 "Syntax table used while in Message mode.")
1422 (defface message-header-to
1425 (:foreground
"DarkOliveGreen1" :bold t
))
1428 (:foreground
"MidnightBlue" :bold t
))
1430 (:bold t
:italic t
)))
1431 "Face used for displaying From headers."
1432 :group
'message-faces
)
1433 ;; backward-compatibility alias
1434 (put 'message-header-to-face
'face-alias
'message-header-to
)
1435 (put 'message-header-to-face
'obsolete-face
"22.1")
1437 (defface message-header-cc
1440 (:foreground
"chartreuse1" :bold t
))
1443 (:foreground
"MidnightBlue"))
1446 "Face used for displaying Cc headers."
1447 :group
'message-faces
)
1448 ;; backward-compatibility alias
1449 (put 'message-header-cc-face
'face-alias
'message-header-cc
)
1450 (put 'message-header-cc-face
'obsolete-face
"22.1")
1452 (defface message-header-subject
1455 (:foreground
"OliveDrab1"))
1458 (:foreground
"navy blue" :bold t
))
1461 "Face used for displaying subject headers."
1462 :group
'message-faces
)
1463 ;; backward-compatibility alias
1464 (put 'message-header-subject-face
'face-alias
'message-header-subject
)
1465 (put 'message-header-subject-face
'obsolete-face
"22.1")
1467 (defface message-header-newsgroups
1470 (:foreground
"yellow" :bold t
:italic t
))
1473 (:foreground
"blue4" :bold t
:italic t
))
1475 (:bold t
:italic t
)))
1476 "Face used for displaying newsgroups headers."
1477 :group
'message-faces
)
1478 ;; backward-compatibility alias
1479 (put 'message-header-newsgroups-face
'face-alias
'message-header-newsgroups
)
1480 (put 'message-header-newsgroups-face
'obsolete-face
"22.1")
1482 (defface message-header-other
1485 (:foreground
"VioletRed1"))
1488 (:foreground
"steel blue"))
1490 (:bold t
:italic t
)))
1491 "Face used for displaying newsgroups headers."
1492 :group
'message-faces
)
1493 ;; backward-compatibility alias
1494 (put 'message-header-other-face
'face-alias
'message-header-other
)
1495 (put 'message-header-other-face
'obsolete-face
"22.1")
1497 (defface message-header-name
1500 (:foreground
"green"))
1503 (:foreground
"cornflower blue"))
1506 "Face used for displaying header names."
1507 :group
'message-faces
)
1508 ;; backward-compatibility alias
1509 (put 'message-header-name-face
'face-alias
'message-header-name
)
1510 (put 'message-header-name-face
'obsolete-face
"22.1")
1512 (defface message-header-xheader
1515 (:foreground
"DeepSkyBlue1"))
1518 (:foreground
"blue"))
1521 "Face used for displaying X-Header headers."
1522 :group
'message-faces
)
1523 ;; backward-compatibility alias
1524 (put 'message-header-xheader-face
'face-alias
'message-header-xheader
)
1525 (put 'message-header-xheader-face
'obsolete-face
"22.1")
1527 (defface message-separator
1530 (:foreground
"LightSkyBlue1"))
1533 (:foreground
"brown"))
1536 "Face used for displaying the separator."
1537 :group
'message-faces
)
1538 ;; backward-compatibility alias
1539 (put 'message-separator-face
'face-alias
'message-separator
)
1540 (put 'message-separator-face
'obsolete-face
"22.1")
1542 (defface message-cited-text
1545 (:foreground
"LightPink1"))
1548 (:foreground
"red"))
1551 "Face used for displaying cited text names."
1552 :group
'message-faces
)
1553 ;; backward-compatibility alias
1554 (put 'message-cited-text-face
'face-alias
'message-cited-text
)
1555 (put 'message-cited-text-face
'obsolete-face
"22.1")
1557 (defface message-mml
1560 (:foreground
"MediumSpringGreen"))
1563 (:foreground
"ForestGreen"))
1566 "Face used for displaying MML."
1567 :group
'message-faces
)
1568 ;; backward-compatibility alias
1569 (put 'message-mml-face
'face-alias
'message-mml
)
1570 (put 'message-mml-face
'obsolete-face
"22.1")
1572 (defun message-font-lock-make-header-matcher (regexp)
1575 (let ((start (point)))
1578 (goto-char (point-min))
1579 (if (re-search-forward
1580 (concat "^" (regexp-quote mail-header-separator
) "$")
1582 (setq limit
(min limit
(match-beginning 0))))
1584 (and (< start limit
)
1585 (re-search-forward ,regexp limit t
))))))
1586 (if (featurep 'bytecomp
)
1590 (defvar message-font-lock-keywords
1591 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1592 `((,(message-font-lock-make-header-matcher
1593 (concat "^\\([Tt]o:\\)" content
))
1594 (1 'message-header-name
)
1595 (2 'message-header-to nil t
))
1596 (,(message-font-lock-make-header-matcher
1597 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content
))
1598 (1 'message-header-name
)
1599 (2 'message-header-cc nil t
))
1600 (,(message-font-lock-make-header-matcher
1601 (concat "^\\([Ss]ubject:\\)" content
))
1602 (1 'message-header-name
)
1603 (2 'message-header-subject nil t
))
1604 (,(message-font-lock-make-header-matcher
1605 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content
))
1606 (1 'message-header-name
)
1607 (2 'message-header-newsgroups nil t
))
1608 (,(message-font-lock-make-header-matcher
1609 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content
))
1610 (1 'message-header-name
)
1611 (2 'message-header-xheader
))
1612 (,(message-font-lock-make-header-matcher
1613 (concat "^\\([A-Z][^: \n\t]+:\\)" content
))
1614 (1 'message-header-name
)
1615 (2 'message-header-other nil t
))
1616 ,@(if (and mail-header-separator
1617 (not (equal mail-header-separator
"")))
1618 `((,(concat "^\\(" (regexp-quote mail-header-separator
) "\\)$")
1619 1 'message-separator
))
1622 (re-search-forward (concat "^\\("
1623 message-cite-prefix-regexp
1626 (0 'message-cited-text
))
1627 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1629 "Additional expressions to highlight in Message mode.")
1632 ;; XEmacs does it like this. For Emacs, we have to set the
1633 ;; `font-lock-defaults' buffer-local variable.
1634 (put 'message-mode
'font-lock-defaults
'(message-font-lock-keywords t
))
1636 (defvar message-face-alist
1637 '((bold . message-bold-region
)
1638 (underline . underline-region
)
1639 (default .
(lambda (b e
)
1640 (message-unbold-region b e
)
1641 (ununderline-region b e
))))
1642 "Alist of mail and news faces for facemenu.
1643 The cdr of each entry is a function for applying the face to a region.")
1645 (defcustom message-send-hook nil
1646 "Hook run before sending messages.
1647 This hook is run quite early when sending."
1648 :group
'message-various
1649 :options
'(ispell-message)
1650 :link
'(custom-manual "(message)Various Message Variables")
1653 (defcustom message-send-mail-hook nil
1654 "Hook run before sending mail messages.
1655 This hook is run very late -- just before the message is sent as
1657 :group
'message-various
1658 :link
'(custom-manual "(message)Various Message Variables")
1661 (defcustom message-send-news-hook nil
1662 "Hook run before sending news messages.
1663 This hook is run very late -- just before the message is sent as
1665 :group
'message-various
1666 :link
'(custom-manual "(message)Various Message Variables")
1669 (defcustom message-sent-hook nil
1670 "Hook run after sending messages."
1671 :group
'message-various
1674 (defvar message-send-coding-system
'binary
1675 "Coding system to encode outgoing mail.")
1677 (defvar message-draft-coding-system
1678 mm-auto-save-coding-system
1679 "*Coding system to compose mail.
1680 If you'd like to make it possible to share draft files between XEmacs
1681 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1682 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1684 (defcustom message-send-mail-partially-limit nil
1685 "The limitation of messages sent as message/partial.
1686 The lower bound of message size in characters, beyond which the message
1687 should be sent in several parts. If it is nil, the size is unlimited."
1689 :group
'message-buffers
1690 :link
'(custom-manual "(message)Mail Variables")
1691 :type
'(choice (const :tag
"unlimited" nil
)
1694 (defcustom message-alternative-emails nil
1695 "*Regexp matching alternative email addresses.
1696 The first address in the To, Cc or From headers of the original
1697 article matching this variable is used as the From field of
1700 This variable has precedence over posting styles and anything that runs
1701 off `message-setup-hook'."
1702 :group
'message-headers
1703 :link
'(custom-manual "(message)Message Headers")
1704 :type
'(choice (const :tag
"Always use primary" nil
)
1707 (defcustom message-hierarchical-addresses nil
1708 "A list of hierarchical mail address definitions.
1710 Inside each entry, the first address is the \"top\" address, and
1711 subsequent addresses are subaddresses; this is used to indicate that
1712 mail sent to the first address will automatically be delivered to the
1713 subaddresses. So if the first address appears in the recipient list
1714 for a message, the subaddresses will be removed (if present) before
1715 the mail is sent. All addresses in this structure should be
1718 :group
'message-headers
1719 :type
'(repeat (repeat string
)))
1721 (defcustom message-mail-user-agent nil
1722 "Like `mail-user-agent'.
1723 Except if it is nil, use Gnus native MUA; if it is t, use
1726 :type
'(radio (const :tag
"Gnus native"
1729 (const :tag
"`mail-user-agent'"
1732 (function-item :tag
"Default Emacs mail"
1734 sendmail-user-agent
)
1735 (function-item :tag
"Emacs interface to MH"
1738 (function :tag
"Other"))
1742 (defcustom message-wide-reply-confirm-recipients nil
1743 "Whether to confirm a wide reply to multiple email recipients.
1744 If this variable is nil, don't ask whether to reply to all recipients.
1745 If this variable is non-nil, pose the question \"Reply to all
1746 recipients?\" before a wide reply to multiple recipients. If the user
1747 answers yes, reply to all recipients as usual. If the user answers
1748 no, only reply back to the author."
1750 :group
'message-headers
1751 :link
'(custom-manual "(message)Wide Reply")
1754 (defcustom message-user-fqdn nil
1755 "*Domain part of Message-Ids."
1757 :group
'message-headers
1758 :link
'(custom-manual "(message)News Headers")
1759 :type
'(radio (const :format
"%v " nil
)
1760 (string :format
"FQDN: %v")))
1762 (defcustom message-use-idna
1763 (and (or (mm-coding-system-p 'utf-8
)
1765 (let (mucs-ignore-version-incompatibilities)
1766 (require 'un-define
))
1771 (invalid-operation))
1773 (executable-find idna-program
)
1774 (string= (idna-to-ascii "räksmörgås") "xn--rksmrgs-5wao1o")
1776 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1777 GNU Libidn, and in particular the elisp package \"idna.el\" and
1778 the external program \"idn\", must be installed for this
1779 functionality to work."
1781 :group
'message-headers
1782 :link
'(custom-manual "(message)IDNA")
1783 :type
'(choice (const :tag
"Ask" ask
)
1784 (const :tag
"Never" nil
)
1785 (const :tag
"Always" t
)))
1787 (defcustom message-generate-hashcash
(if (executable-find "hashcash") 'opportunistic
)
1788 "*Whether to generate X-Hashcash: headers.
1789 If t, always generate hashcash headers. If `opportunistic',
1790 only generate hashcash headers if it can be done without the user
1791 waiting (i.e., only asynchronously).
1793 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1795 :group
'message-headers
1796 :link
'(custom-manual "(message)Mail Headers")
1797 :type
'(choice (const :tag
"Always" t
)
1798 (const :tag
"Never" nil
)
1799 (const :tag
"Opportunistic" opportunistic
)))
1801 ;;; Internal variables.
1803 (defvar message-sending-message
"Sending...")
1804 (defvar message-buffer-list nil
)
1805 (defvar message-this-is-news nil
)
1806 (defvar message-this-is-mail nil
)
1807 (defvar message-draft-article nil
)
1808 (defvar message-mime-part nil
)
1809 (defvar message-posting-charset nil
)
1810 (defvar message-inserted-headers nil
)
1811 (defvar message-inhibit-ecomplete nil
)
1813 ;; Byte-compiler warning
1814 (defvar gnus-active-hashtb
)
1815 (defvar gnus-read-active-file
)
1817 ;;; Regexp matching the delimiter of messages in UNIX mail format
1818 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1819 ;;; of rmail.el's rmail-unix-mail-delimiter.
1820 (defvar message-unix-mail-delimiter
1821 (let ((time-zone-regexp
1822 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1823 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1829 ;; Many things can happen to an RFC 822 mailbox before it is put into
1830 ;; a `From' line. The leading phrase can be stripped, e.g.
1831 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1832 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1833 ;; can be removed, e.g.
1834 ;; From: joe@y.z (Joe K
1836 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1839 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1840 ;; The mailbox can be removed or be replaced by white space, e.g.
1841 ;; From: "Joe User"{space}{tab}
1843 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1844 ;; where {space} and {tab} represent the Ascii space and tab characters.
1845 ;; We want to match the results of any of these manglings.
1846 ;; The following regexp rejects names whose first characters are
1847 ;; obviously bogus, but after that anything goes.
1848 "\\([^\0-\b\n-\r\^?].*\\)?"
1850 ;; The time the message was sent.
1851 "\\([^\0-\r \^?]+\\) +" ; day of the week
1852 "\\([^\0-\r \^?]+\\) +" ; month
1853 "\\([0-3]?[0-9]\\) +" ; day of month
1854 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1856 ;; Perhaps a time zone, specified by an abbreviation, or by a
1861 " \\([0-9][0-9]+\\) *"
1863 ;; On some systems the time zone can appear after the year, too.
1867 "\\(remote from .*\\)?"
1870 "Regexp matching the delimiter of messages in UNIX mail format.")
1872 (defvar message-unsent-separator
1873 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1874 "^ *---+ +Returned message +---+ *$\\|"
1875 "^Start of returned message$\\|"
1876 "^ *---+ +Original message +---+ *$\\|"
1877 "^ *--+ +begin message +--+ *$\\|"
1878 "^ *---+ +Original message follows +---+ *$\\|"
1879 "^ *---+ +Undelivered message follows +---+ *$\\|"
1880 "^------ This is a copy of the message, including all the headers. ------ *$\\|"
1881 "^|? *---+ +Message text follows: +---+ *|?$")
1882 "A regexp that matches the separator before the text of a failed message.")
1884 (defvar message-field-fillers
1885 '((To message-fill-field-address
)
1886 (Cc message-fill-field-address
)
1887 (From message-fill-field-address
))
1888 "Alist of header names/filler functions.")
1890 (defvar message-header-format-alist
1905 (References . message-shorten-references
)
1907 "Alist used for formatting headers.")
1909 (defvar message-options nil
1910 "Some saved answers when sending message.")
1911 ;; FIXME: On XEmacs this causes problems since let-binding like:
1912 ;; (let ((message-options message-options)) ...)
1913 ;; as in `message-send' and `mml-preview' loses to buffer-local
1914 ;; variable initialization.
1915 (unless (featurep 'xemacs
)
1916 (make-variable-buffer-local 'message-options
))
1918 (defvar message-send-mail-real-function nil
1919 "Internal send mail function.")
1921 (defvar message-bogus-system-names
"\\`localhost\\.\\|\\.local\\'"
1922 "The regexp of bogus system names.")
1924 (defcustom message-valid-fqdn-regexp
1925 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1927 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1928 "aero\\|arpa\\|asia\\|bitnet\\|biz\\|bofh\\|"
1929 "cat\\|com\\|coop\\|edu\\|gov\\|"
1930 "info\\|int\\|jobs\\|"
1931 "mil\\|mobi\\|museum\\|name\\|net\\|"
1932 "org\\|pro\\|tel\\|travel\\|uucp\\|"
1933 ;; ICANN-era generic top-level domains
1934 "academy\\|actor\\|agency\\|airforce\\|archi\\|associates\\|axa\\|"
1935 "bar\\|bargains\\|bayern\\|beer\\|berlin\\|best\\|bid\\|bike\\|"
1936 "biz\\|black\\|blackfriday\\|blue\\|boutique\\|build\\|builders\\|"
1937 "buzz\\|cab\\|camera\\|camp\\|capital\\|cards\\|care\\|career\\|"
1938 "careers\\|cash\\|catering\\|center\\|ceo\\|cheap\\|christmas\\|"
1939 "church\\|citic\\|cleaning\\|clinic\\|clothing\\|club\\|codes\\|"
1940 "coffee\\|college\\|cologne\\|com\\|community\\|company\\|computer\\|"
1941 "construction\\|contractors\\|cooking\\|cool\\|country\\|creditcard\\|"
1942 "cruises\\|dance\\|dating\\|democrat\\|dental\\|desi\\|design\\|"
1943 "diamonds\\|directory\\|discount\\|domains\\|education\\|email\\|"
1944 "engineering\\|enterprises\\|equipment\\|estate\\|eus\\|events\\|"
1945 "exchange\\|expert\\|exposed\\|fail\\|farm\\|feedback\\|finance\\|"
1946 "financial\\|fish\\|fishing\\|fitness\\|flights\\|florist\\|foo\\|"
1947 "foundation\\|frogans\\|fund\\|furniture\\|futbol\\|gal\\|"
1948 "gallery\\|gift\\|glass\\|globo\\|gmo\\|gop\\|graphics\\|gratis\\|"
1949 "gripe\\|guide\\|guitars\\|guru\\|hamburg\\|haus\\|hiphop\\|"
1950 "holdings\\|holiday\\|homes\\|horse\\|house\\|immobilien\\|"
1951 "industries\\|info\\|ink\\|institute\\|insure\\|international\\|"
1952 "investments\\|jetzt\\|juegos\\|kaufen\\|kim\\|kitchen\\|kiwi\\|"
1953 "koeln\\|kred\\|land\\|lat\\|latino\\|lease\\|life\\|lighting\\|"
1954 "limited\\|limo\\|link\\|loans\\|london\\|luxe\\|luxury\\|"
1955 "management\\|mango\\|marketing\\|media\\|meet\\|menu\\|miami\\|"
1956 "moda\\|moe\\|monash\\|moscow\\|motorcycles\\|nagoya\\|name\\|"
1957 "net\\|neustar\\|ninja\\|nyc\\|okinawa\\|onl\\|org\\|paris\\|"
1958 "partners\\|parts\\|photo\\|photography\\|photos\\|pics\\|"
1959 "pictures\\|pink\\|plumbing\\|pro\\|productions\\|properties\\|"
1960 "pub\\|qpon\\|quebec\\|recipes\\|red\\|reisen\\|ren\\|rentals\\|"
1961 "repair\\|report\\|rest\\|reviews\\|rich\\|rocks\\|rodeo\\|"
1962 "ruhr\\|ryukyu\\|saarland\\|schule\\|scot\\|services\\|sexy\\|"
1963 "shiksha\\|shoes\\|singles\\|social\\|sohu\\|solar\\|solutions\\|"
1964 "soy\\|supplies\\|supply\\|support\\|surgery\\|systems\\|tattoo\\|"
1965 "tax\\|technology\\|tienda\\|tips\\|today\\|tokyo\\|tools\\|"
1966 "town\\|toys\\|trade\\|training\\|university\\|uno\\|vacations\\|"
1967 "vegas\\|ventures\\|viajes\\|villas\\|vision\\|vodka\\|vote\\|"
1968 "voting\\|voto\\|voyage\\|wang\\|watch\\|webcam\\|wed\\|wien\\|"
1969 "wiki\\|works\\|wtc\\|wtf\\|xyz\\|yachts\\|yokohama\\|you\\|"
1971 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1972 ;; http://en.wikipedia.org/wiki/GTLD
1973 ;; `approved, but not yet in operation': .xxx
1974 ;; "dead" nato bitnet uucp
1975 "Regular expression that matches a valid FQDN."
1976 ;; see also: gnus-button-valid-fqdn-regexp
1978 :group
'message-headers
1981 (autoload 'gnus-alive-p
"gnus-util")
1982 (autoload 'gnus-delay-article
"gnus-delay")
1983 (autoload 'gnus-extract-address-components
"gnus-util")
1984 (autoload 'gnus-find-method-for-group
"gnus")
1985 (autoload 'gnus-group-decoded-name
"gnus-group")
1986 (autoload 'gnus-group-name-charset
"gnus-group")
1987 (autoload 'gnus-group-name-decode
"gnus-group")
1988 (autoload 'gnus-groups-from-server
"gnus")
1989 (autoload 'gnus-make-local-hook
"gnus-util")
1990 (autoload 'gnus-open-server
"gnus-int")
1991 (autoload 'gnus-output-to-mail
"gnus-util")
1992 (autoload 'gnus-output-to-rmail
"gnus-util")
1993 (autoload 'gnus-request-post
"gnus-int")
1994 (autoload 'gnus-select-frame-set-input-focus
"gnus-util")
1995 (autoload 'gnus-server-string
"gnus")
1996 (autoload 'idna-to-ascii
"idna")
1997 (autoload 'message-setup-toolbar
"messagexmas")
1998 (autoload 'mh-new-draft-name
"mh-comp")
1999 (autoload 'mh-send-letter
"mh-comp")
2000 (autoload 'nndraft-request-associate-buffer
"nndraft")
2001 (autoload 'nndraft-request-expire-articles
"nndraft")
2002 (autoload 'nnvirtual-find-group-art
"nnvirtual")
2003 (autoload 'rmail-msg-is-pruned
"rmail")
2004 (autoload 'rmail-output
"rmailout")
2006 ;; Emacs < 24.1 do not have mail-dont-reply-to
2007 (unless (fboundp 'mail-dont-reply-to
)
2008 (defalias 'mail-dont-reply-to
'rmail-dont-reply-to
))
2011 (if (featurep 'emacs
)
2013 (defun message-kill-all-overlays ()
2014 (mapcar #'delete-overlay
(overlays-in (point-min) (point-max))))
2015 (defalias 'message-window-inside-pixel-edges
2016 'window-inside-pixel-edges
))
2017 (defun message-kill-all-overlays ()
2018 (map-extents (lambda (extent ignore
) (delete-extent extent
))))
2019 (defalias 'message-window-inside-pixel-edges
'ignore
)))
2024 ;;; Utility functions.
2027 (defmacro message-y-or-n-p
(question show
&rest text
)
2028 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
2029 `(message-talkative-question 'y-or-n-p
,question
,show
,@text
))
2031 (defmacro message-delete-line
(&optional n
)
2032 "Delete the current line (and the next N lines)."
2033 `(delete-region (progn (beginning-of-line) (point))
2034 (progn (forward-line ,(or n
1)) (point))))
2036 (defun message-mark-active-p ()
2037 "Non-nil means the mark and region are currently active in this buffer."
2040 (defun message-unquote-tokens (elems)
2041 "Remove double quotes (\") from strings in list ELEMS."
2042 (mapcar (lambda (item)
2043 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item
)
2044 (setq item
(concat (match-string 1 item
)
2045 (match-string 2 item
))))
2049 (defun message-tokenize-header (header &optional separator
)
2050 "Split HEADER into a list of header elements.
2051 SEPARATOR is a string of characters to be used as separators. \",\"
2052 is used by default."
2055 (let ((regexp (format "[%s]+" (or separator
",")))
2057 beg quoted elems paren
)
2059 (mm-enable-multibyte)
2060 (setq beg
(point-min))
2062 (goto-char (point-min))
2067 (cond ((and (> (point) beg
)
2069 (and (looking-at regexp
)
2072 (push (buffer-substring beg
(point)) elems
)
2073 (setq beg
(match-end 0)))
2074 ((eq (char-after) ?
\")
2075 (setq quoted
(not quoted
)))
2076 ((and (eq (char-after) ?\
()
2079 ((and (eq (char-after) ?\
))
2082 (nreverse elems
)))))
2084 (autoload 'nnheader-insert-file-contents
"nnheader")
2086 (defun message-mail-file-mbox-p (file)
2087 "Say whether FILE looks like a Unix mbox file."
2088 (when (and (file-exists-p file
)
2089 (file-readable-p file
)
2090 (file-regular-p file
))
2092 (nnheader-insert-file-contents file
)
2093 (goto-char (point-min))
2094 (looking-at message-unix-mail-delimiter
))))
2096 (defun message-fetch-field (header &optional not-all
)
2097 "The same as `mail-fetch-field', only remove all newlines.
2098 The buffer is expected to be narrowed to just the header of the message;
2099 see `message-narrow-to-headers-or-head'."
2100 (let* ((inhibit-point-motion-hooks t
)
2101 (value (mail-fetch-field header nil
(not not-all
))))
2103 (while (string-match "\n[\t ]+" value
)
2104 (setq value
(replace-match " " t t value
)))
2107 (defun message-field-value (header &optional not-all
)
2108 "The same as `message-fetch-field', only narrow to the headers first."
2111 (message-narrow-to-headers-or-head)
2112 (message-fetch-field header not-all
))))
2114 (defun message-narrow-to-field ()
2115 "Narrow the buffer to the header on the current line."
2117 (while (looking-at "[ \t]")
2123 (if (re-search-forward "^[^ \n\t]" nil t
)
2126 (goto-char (point-min)))
2128 (defun message-add-header (&rest headers
)
2129 "Add the HEADERS to the message header, skipping those already present."
2132 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers
))
2133 (error "Invalid header `%s'" (car headers
)))
2134 (setq hclean
(match-string 1 (car headers
)))
2136 (message-narrow-to-headers)
2137 (unless (re-search-forward (concat "^" (regexp-quote hclean
) ":") nil t
)
2138 (goto-char (point-max))
2139 (if (string-match "\n$" (car headers
))
2140 (insert (car headers
))
2141 (insert (car headers
) ?
\n)))))
2142 (setq headers
(cdr headers
))))
2144 (defmacro message-with-reply-buffer
(&rest forms
)
2145 "Evaluate FORMS in the reply buffer, if it exists."
2146 `(when (and (bufferp message-reply-buffer
)
2147 (buffer-name message-reply-buffer
))
2148 (with-current-buffer message-reply-buffer
2151 (put 'message-with-reply-buffer
'lisp-indent-function
0)
2152 (put 'message-with-reply-buffer
'edebug-form-spec
'(body))
2154 (defun message-fetch-reply-field (header)
2155 "Fetch field HEADER from the message we're replying to."
2156 (message-with-reply-buffer
2158 (mail-narrow-to-head)
2159 (message-fetch-field header
))))
2161 (defun message-strip-list-identifiers (subject)
2162 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
2163 (require 'gnus-sum
) ; for gnus-list-identifiers
2164 (let ((regexp (if (stringp gnus-list-identifiers
)
2165 gnus-list-identifiers
2166 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
2167 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
2168 " *\\)\\)+\\(Re: +\\)?\\)") subject
)
2169 (concat (substring subject
0 (match-beginning 1))
2170 (or (match-string 3 subject
)
2171 (match-string 5 subject
))
2176 (defun message-strip-subject-re (subject)
2177 "Remove \"Re:\" from subject lines in string SUBJECT."
2178 (if (string-match message-subject-re-regexp subject
)
2179 (substring subject
(match-end 0))
2182 (defcustom message-replacement-char
"."
2183 "Replacement character used instead of unprintable or not decodable chars."
2184 :group
'message-various
2185 :version
"22.1" ;; Gnus 5.10.9
2186 :type
'(choice string
2190 ;; FIXME: We also should call `message-strip-subject-encoded-words'
2191 ;; when forwarding. Probably in `message-make-forward-subject' and
2192 ;; `message-forward-make-body'.
2194 (defun message-strip-subject-encoded-words (subject)
2195 "Fix non-decodable words in SUBJECT."
2196 ;; Cf. `gnus-simplify-subject-fully'.
2197 (let* ((case-fold-search t
)
2198 (replacement-chars (format "[%s%s%s]"
2199 message-replacement-char
2200 message-replacement-char
2201 message-replacement-char
))
2202 (enc-word-re "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?\\([^?]+\\)\\(\\?=\\)")
2207 (goto-char (point-min))
2208 (when (re-search-forward enc-word-re nil t
)
2209 (setq cs-string
(match-string 1)))))
2210 cs-coding q-or-b word-beg word-end
)
2211 (if (or (not have-marker
) ;; No encoded word found...
2212 ;; ... or double encoding was correct:
2213 (and (stringp cs-string
)
2214 (setq cs-string
(downcase cs-string
))
2215 (mm-coding-system-p (intern cs-string
))
2219 Decoded Subject \"%s\"
2220 contains a valid encoded word. Decode again? "
2222 (setq cs-coding
(intern cs-string
))))))
2226 (goto-char (point-min))
2227 (while (re-search-forward enc-word-re nil t
)
2228 (setq cs-string
(downcase (match-string 1))
2229 q-or-b
(match-string 2)
2230 word-beg
(match-beginning 0)
2231 word-end
(match-end 0))
2233 (if (mm-coding-system-p (intern cs-string
))
2234 (setq cs-coding
(intern cs-string
))
2236 ;; No double encoded subject? => bogus charset.
2239 (mm-read-coding-system
2240 (gnus-format-message "\
2241 Decoded Subject \"%s\"
2242 contains an encoded word. The charset `%s' is unknown or invalid.
2243 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
2245 subject cs-string message-replacement-char
)))
2247 (replace-match (concat "=?" (symbol-name cs-coding
)
2250 (goto-char word-beg
)
2251 (re-search-forward "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?" word-end t
)
2254 (if (string-match "\\`Q\\'" q-or-b
)
2257 (message "Replacing non-decodable characters with \"%s\"."
2258 message-replacement-char
)
2259 (while (re-search-forward "\\(=[A-F0-9][A-F0-9]\\)+"
2261 (replace-match message-replacement-char
)))
2263 (message "Replacing non-decodable characters with \"%s\"."
2265 (re-search-forward "[^?]+" word-end t
)
2266 (replace-match replacement-chars
))
2267 (re-search-forward "\\?=")
2268 (replace-match "")))))
2269 (rfc2047-decode-region (point-min) (point-max))
2272 ;;; Start of functions adopted from `message-utils.el'.
2274 (defun message-strip-subject-trailing-was (subject)
2275 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
2276 Leading \"Re: \" is not stripped by this function. Use the function
2277 `message-strip-subject-re' for this."
2278 (let* ((query message-subject-trailing-was-query
)
2283 message-subject-trailing-was-ask-regexp
2284 message-subject-trailing-was-regexp
)
2287 (setq new
(substring subject
0 (match-beginning 0))))
2288 (if (or (not found
) (eq query nil
))
2291 (if (message-y-or-n-p
2292 "Strip `(was: <old subject>)' in subject? " t
2294 "Strip `(was: <old subject>)' in subject "
2295 "and use the new one instead?\n\n"
2296 "Current subject is: \""
2298 "New subject would be: \""
2300 "See the variable `message-subject-trailing-was-query' "
2301 "to get rid of this query."
2306 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
2308 (defun message-change-subject (new-subject)
2309 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
2312 (read-from-minibuffer "New subject: ")))
2313 (cond ((and (not (or (null new-subject
) ; new subject not empty
2314 (zerop (string-width new-subject
))
2315 (string-match "^[ \t]*$" new-subject
))))
2319 (message-narrow-to-headers)
2320 (message-fetch-field "Subject"))))
2321 (cond ((not old-subject
)
2322 (error "No current subject"))
2325 (regexp-quote new-subject
)
2327 old-subject
)) ; yes, it really is a new subject
2328 ;; delete eventual Re: prefix
2330 (message-strip-subject-re old-subject
))
2331 (message-goto-subject)
2332 (message-delete-line)
2333 (insert (concat "Subject: "
2336 old-subject
")\n")))))))))
2338 (defun message-mark-inserted-region (beg end
&optional verbatim
)
2339 "Mark some region in the current article with enclosing tags.
2340 See `message-mark-insert-begin' and `message-mark-insert-end'.
2341 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2342 (interactive "r\nP")
2344 ;; add to the end of the region first, otherwise end would be invalid
2346 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2348 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2350 (defun message-mark-insert-file (file &optional verbatim
)
2351 "Insert FILE at point, marking it with enclosing tags.
2352 See `message-mark-insert-begin' and `message-mark-insert-end'.
2353 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2354 (interactive "fFile to insert: \nP")
2355 ;; reverse insertion to get correct result.
2357 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2359 (insert-file-contents file
)
2361 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2363 (defun message-add-archive-header ()
2364 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
2365 The note can be customized using `message-archive-note'. When called with a
2366 prefix argument, ask for a text to insert. If you don't want the note in the
2367 body, set `message-archive-note' to nil."
2369 (if current-prefix-arg
2370 (setq message-archive-note
2371 (read-from-minibuffer "Reason for No-Archive: "
2372 (cons message-archive-note
0))))
2374 (if (message-goto-signature)
2375 (re-search-backward message-signature-separator
))
2376 (when message-archive-note
2377 (insert message-archive-note
)
2379 (message-add-header message-archive-header
)
2380 (message-sort-headers)))
2382 (defun message-cross-post-followup-to-header (target-group)
2383 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2384 With prefix-argument just set Follow-Up, don't cross-post."
2386 (list ; Completion based on Gnus
2387 (completing-read "Followup To: "
2388 (if (boundp 'gnus-newsrc-alist
)
2390 nil nil
'("poster" .
0)
2391 (if (boundp 'gnus-group-history
)
2392 'gnus-group-history
))))
2393 (message-remove-header "Follow[Uu]p-[Tt]o" t
)
2394 (message-goto-newsgroups)
2396 ;; if we already did a crosspost before, kill old target
2397 (if (and message-cross-post-old-target
2399 (regexp-quote (concat "," message-cross-post-old-target
))
2402 ;; unless (followup is to poster or user explicitly asked not
2403 ;; to cross-post, or target-group is already in Newsgroups)
2404 ;; add target-group to Newsgroups line.
2406 ;; def: cross-post, req:no
2407 (and message-cross-post-default
(not current-prefix-arg
))
2408 ;; def: no-cross-post, req:yes
2409 (and (not message-cross-post-default
) current-prefix-arg
))
2410 (not (string-match "poster" target-group
))
2411 (not (string-match (regexp-quote target-group
)
2412 (message-fetch-field "Newsgroups"))))
2414 (insert (concat "," target-group
))))
2415 (end-of-line) ; ensure Followup: comes after Newsgroups:
2416 ;; unless new followup would be identical to Newsgroups line
2417 ;; make a new Followup-To line
2418 (if (not (string-match (concat "^[ \t]*"
2421 (message-fetch-field "Newsgroups")))
2422 (insert (concat "\nFollowup-To: " target-group
)))
2423 (setq message-cross-post-old-target target-group
))
2425 (defun message-cross-post-insert-note (target-group cross-post in-old
2427 "Insert a in message body note about a set Followup or Crosspost.
2428 If there have been previous notes, delete them. TARGET-GROUP specifies the
2429 group to Followup-To. When CROSS-POST is t, insert note about
2430 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2431 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2432 been made to before the user asked for a Crosspost."
2433 ;; start scanning body for previous uses
2434 (message-goto-signature)
2435 (let ((head (re-search-backward
2436 (concat "^" mail-header-separator
)
2437 nil t
))) ; just search in body
2438 (message-goto-signature)
2439 (while (re-search-backward
2440 (concat "^" (regexp-quote message-cross-post-note
) ".*")
2442 (message-delete-line))
2443 (message-goto-signature)
2444 (while (re-search-backward
2445 (concat "^" (regexp-quote message-followup-to-note
) ".*")
2447 (message-delete-line))
2449 (if (message-goto-signature)
2450 (re-search-backward message-signature-separator
))
2453 (string-match "^[ \t]*poster[ \t]*$" target-group
))
2454 (insert (concat message-followup-to-note target-group
"\n"))
2455 (insert (concat message-cross-post-note target-group
"\n")))))
2457 (defun message-cross-post-followup-to (target-group)
2458 "Crossposts message and set Followup-To to TARGET-GROUP.
2459 With prefix-argument just set Follow-Up, don't cross-post."
2461 (list ; Completion based on Gnus
2462 (completing-read "Followup To: "
2463 (if (boundp 'gnus-newsrc-alist
)
2465 nil nil
'("poster" .
0)
2466 (if (boundp 'gnus-group-history
)
2467 'gnus-group-history
))))
2468 (cond ((not (or (null target-group
) ; new subject not empty
2469 (zerop (string-width target-group
))
2470 (string-match "^[ \t]*$" target-group
)))
2472 (let* ((old-groups (message-fetch-field "Newsgroups"))
2473 (in-old (string-match
2474 (regexp-quote target-group
)
2475 (or old-groups
""))))
2476 ;; check whether target exactly matches old Newsgroups
2477 (cond ((not old-groups
)
2478 (error "No current newsgroup"))
2482 (regexp-quote target-group
)
2485 ;; yes, Newsgroups line must change
2486 (message-cross-post-followup-to-header target-group
)
2487 ;; insert note whether we do cross-post or followup-to
2488 (funcall message-cross-post-note-function
2490 (if (or (and message-cross-post-default
2491 (not current-prefix-arg
))
2492 (and (not message-cross-post-default
)
2493 current-prefix-arg
)) t
)
2494 in-old old-groups
))))))))
2496 ;;; Reduce To: to Cc: or Bcc: header
2498 (defun message-reduce-to-to-cc ()
2499 "Replace contents of To: header with contents of Cc: or Bcc: header."
2502 (save-restriction (message-narrow-to-headers)
2503 (message-fetch-field "cc")))
2505 (if (and (not cc-content
)
2508 (message-narrow-to-headers)
2509 (message-fetch-field "bcc"))))
2514 (message-delete-line)
2515 (insert (concat "To: " cc-content
"\n"))
2517 (message-narrow-to-headers)
2518 (message-remove-header (if bcc
2522 ;;; End of functions adopted from `message-utils.el'.
2524 (defun message-remove-header (header &optional is-regexp first reverse
)
2525 "Remove HEADER in the narrowed buffer.
2526 If IS-REGEXP, HEADER is a regular expression.
2527 If FIRST, only remove the first instance of the header.
2528 If REVERSE, remove headers that doesn't match HEADER.
2529 Return the number of headers removed."
2530 (goto-char (point-min))
2531 (let ((regexp (if is-regexp header
(concat "^" (regexp-quote header
) ":")))
2533 (case-fold-search t
)
2535 (while (and (not (eobp))
2538 (not (looking-at regexp
))
2539 (looking-at regexp
))
2546 ;; There might be a continuation header, so we have to search
2547 ;; until we find a new non-continuation line.
2550 (if (re-search-forward "^[^ \t]" nil t
)
2551 (goto-char (match-beginning 0))
2554 (if (re-search-forward "^[^ \t]" nil t
)
2555 (goto-char (match-beginning 0))
2556 (goto-char (point-max)))))
2559 (defun message-remove-first-header (header)
2560 "Remove the first instance of HEADER if there is more than one."
2562 (regexp (concat "^" (regexp-quote header
) ":")))
2564 (goto-char (point-min))
2565 (while (re-search-forward regexp nil t
)
2568 (message-remove-header header nil t
)
2571 (defun message-narrow-to-headers ()
2572 "Narrow the buffer to the head of the message."
2575 (goto-char (point-min))
2576 (if (re-search-forward
2577 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
)
2580 (goto-char (point-min)))
2582 (defun message-narrow-to-head-1 ()
2583 "Like `message-narrow-to-head'. Don't widen."
2585 (goto-char (point-min))
2586 (if (search-forward "\n\n" nil
1)
2589 (goto-char (point-min)))
2591 ;; FIXME: clarify difference: message-narrow-to-head,
2592 ;; message-narrow-to-headers-or-head, message-narrow-to-headers
2593 (defun message-narrow-to-head ()
2594 "Narrow the buffer to the head of the message.
2595 Point is left at the beginning of the narrowed-to region."
2597 (message-narrow-to-head-1))
2599 (defun message-narrow-to-headers-or-head ()
2600 "Narrow the buffer to the head of the message."
2603 (goto-char (point-min))
2604 (if (re-search-forward (concat "\\(\n\\)\n\\|^\\("
2605 (regexp-quote mail-header-separator
)
2608 (or (match-end 1) (match-beginning 2))
2610 (goto-char (point-min)))
2612 (defun message-news-p ()
2613 "Say whether the current buffer contains a news message."
2614 (and (not message-this-is-mail
)
2615 (or message-this-is-news
2618 (message-narrow-to-headers)
2619 (and (message-fetch-field "newsgroups")
2620 (not (message-fetch-field "posted-to"))))))))
2622 (defun message-mail-p ()
2623 "Say whether the current buffer contains a mail message."
2624 (and (not message-this-is-news
)
2625 (or message-this-is-mail
2628 (message-narrow-to-headers)
2629 (or (message-fetch-field "to")
2630 (message-fetch-field "cc")
2631 (message-fetch-field "bcc")))))))
2633 (defun message-subscribed-p ()
2634 "Say whether we need to insert a MFT header."
2635 (or message-subscribed-regexps
2636 message-subscribed-addresses
2637 message-subscribed-address-file
2638 message-subscribed-address-functions
))
2640 (defun message-next-header ()
2641 "Go to the beginning of the next header."
2643 (or (eobp) (forward-char 1))
2644 (not (if (re-search-forward "^[^ \t]" nil t
)
2646 (goto-char (point-max)))))
2648 (defun message-sort-headers-1 ()
2649 "Sort the buffer as headers using `message-rank' text props."
2650 (goto-char (point-min))
2653 nil
'message-next-header
2655 (message-next-header)
2659 (or (get-text-property (point) 'message-rank
)
2662 (defun message-sort-headers ()
2663 "Sort the headers of the current message according to `message-header-format-alist'."
2667 (let ((max (1+ (length message-header-format-alist
)))
2669 (message-narrow-to-headers)
2670 (while (re-search-forward "^[^ \n]+:" nil t
)
2672 (match-beginning 0) (1+ (match-beginning 0))
2674 (if (setq rank
(length (memq (assq (intern (buffer-substring
2676 (1- (match-end 0))))
2677 message-header-format-alist
)
2678 message-header-format-alist
)))
2681 (message-sort-headers-1))))
2683 (defun message-kill-address ()
2684 "Kill the address under point."
2686 (let ((start (point)))
2687 (message-skip-to-next-address)
2688 (kill-region start
(if (bolp) (1- (point)) (point)))))
2691 (autoload 'Info-goto-node
"info")
2692 (defvar mml2015-use
)
2694 (defun message-info (&optional arg
)
2695 "Display the Message manual.
2697 Prefixed with one \\[universal-argument], display the Emacs MIME
2698 manual. With two \\[universal-argument]'s, display the EasyPG or
2699 PGG manual, depending on the value of `mml2015-use'."
2701 ;; Don't use `info' because support for `(filename)nodename' is not
2702 ;; available in XEmacs < 21.5.12.
2703 (Info-goto-node (format "(%s)Top"
2707 ((eq arg
4) 'emacs-mime
)
2708 ;; `booleanp' only available in Emacs 22+
2709 ((and (not (memq arg
'(nil t
)))
2723 (defvar message-mode-map nil
)
2725 (unless message-mode-map
2726 (setq message-mode-map
(make-keymap))
2727 (set-keymap-parent message-mode-map text-mode-map
)
2728 (define-key message-mode-map
"\C-c?" 'describe-mode
)
2730 (define-key message-mode-map
"\C-c\C-f\C-t" 'message-goto-to
)
2731 (define-key message-mode-map
"\C-c\C-f\C-o" 'message-goto-from
)
2732 (define-key message-mode-map
"\C-c\C-f\C-b" 'message-goto-bcc
)
2733 (define-key message-mode-map
"\C-c\C-f\C-w" 'message-goto-fcc
)
2734 (define-key message-mode-map
"\C-c\C-f\C-c" 'message-goto-cc
)
2735 (define-key message-mode-map
"\C-c\C-f\C-s" 'message-goto-subject
)
2736 (define-key message-mode-map
"\C-c\C-f\C-r" 'message-goto-reply-to
)
2737 (define-key message-mode-map
"\C-c\C-f\C-n" 'message-goto-newsgroups
)
2738 (define-key message-mode-map
"\C-c\C-f\C-d" 'message-goto-distribution
)
2739 (define-key message-mode-map
"\C-c\C-f\C-f" 'message-goto-followup-to
)
2740 (define-key message-mode-map
"\C-c\C-f\C-m" 'message-goto-mail-followup-to
)
2741 (define-key message-mode-map
"\C-c\C-f\C-k" 'message-goto-keywords
)
2742 (define-key message-mode-map
"\C-c\C-f\C-u" 'message-goto-summary
)
2743 (define-key message-mode-map
"\C-c\C-f\C-i"
2744 'message-insert-or-toggle-importance
)
2745 (define-key message-mode-map
"\C-c\C-f\C-a"
2746 'message-generate-unsubscribed-mail-followup-to
)
2748 ;; modify headers (and insert notes in body)
2749 (define-key message-mode-map
"\C-c\C-fs" 'message-change-subject
)
2751 (define-key message-mode-map
"\C-c\C-fx" 'message-cross-post-followup-to
)
2752 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2753 (define-key message-mode-map
"\C-c\C-ft" 'message-reduce-to-to-cc
)
2754 (define-key message-mode-map
"\C-c\C-fa" 'message-add-archive-header
)
2755 ;; mark inserted text
2756 (define-key message-mode-map
"\C-c\M-m" 'message-mark-inserted-region
)
2757 (define-key message-mode-map
"\C-c\M-f" 'message-mark-insert-file
)
2759 (define-key message-mode-map
"\C-c\C-b" 'message-goto-body
)
2760 (define-key message-mode-map
"\C-c\C-i" 'message-goto-signature
)
2762 (define-key message-mode-map
"\C-c\C-t" 'message-insert-to
)
2763 (define-key message-mode-map
"\C-c\C-fw" 'message-insert-wide-reply
)
2764 (define-key message-mode-map
"\C-c\C-n" 'message-insert-newsgroups
)
2765 (define-key message-mode-map
"\C-c\C-l" 'message-to-list-only
)
2766 (define-key message-mode-map
"\C-c\C-f\C-e" 'message-insert-expires
)
2768 (define-key message-mode-map
"\C-c\C-u" 'message-insert-or-toggle-importance
)
2769 (define-key message-mode-map
"\C-c\M-n"
2770 'message-insert-disposition-notification-to
)
2772 (define-key message-mode-map
"\C-c\C-y" 'message-yank-original
)
2773 (define-key message-mode-map
"\C-c\M-\C-y" 'message-yank-buffer
)
2774 (define-key message-mode-map
"\C-c\C-q" 'message-fill-yanked-message
)
2775 (define-key message-mode-map
"\C-c\C-w" 'message-insert-signature
)
2776 (define-key message-mode-map
"\C-c\M-h" 'message-insert-headers
)
2777 (define-key message-mode-map
"\C-c\C-r" 'message-caesar-buffer-body
)
2778 (define-key message-mode-map
"\C-c\C-o" 'message-sort-headers
)
2779 (define-key message-mode-map
"\C-c\M-r" 'message-rename-buffer
)
2781 (define-key message-mode-map
"\C-c\C-c" 'message-send-and-exit
)
2782 (define-key message-mode-map
"\C-c\C-s" 'message-send
)
2783 (define-key message-mode-map
"\C-c\C-k" 'message-kill-buffer
)
2784 (define-key message-mode-map
"\C-c\C-d" 'message-dont-send
)
2785 (define-key message-mode-map
"\C-c\n" 'gnus-delay-article
)
2787 (define-key message-mode-map
"\C-c\M-k" 'message-kill-address
)
2788 (define-key message-mode-map
"\C-c\C-e" 'message-elide-region
)
2789 (define-key message-mode-map
"\C-c\C-v" 'message-delete-not-region
)
2790 (define-key message-mode-map
"\C-c\C-z" 'message-kill-to-signature
)
2791 (define-key message-mode-map
"\M-\r" 'message-newline-and-reformat
)
2792 (define-key message-mode-map
[remap split-line
] 'message-split-line
)
2794 (define-key message-mode-map
"\C-c\C-a" 'mml-attach-file
)
2796 (define-key message-mode-map
"\C-a" 'message-beginning-of-line
)
2797 (define-key message-mode-map
"\t" 'message-tab
)
2799 (define-key message-mode-map
"\M-n" 'message-display-abbrev
))
2802 message-mode-menu message-mode-map
"Message Menu."
2804 ["Yank Original" message-yank-original message-reply-buffer
]
2805 ["Fill Yanked Message" message-fill-yanked-message t
]
2806 ["Insert Signature" message-insert-signature t
]
2807 ["Caesar (rot13) Message" message-caesar-buffer-body t
]
2808 ["Caesar (rot13) Region" message-caesar-region
(message-mark-active-p)]
2809 ["Elide Region" message-elide-region
2810 :active
(message-mark-active-p)
2811 ,@(if (featurep 'xemacs
) nil
2812 '(:help
"Replace text in region with an ellipsis"))]
2813 ["Delete Outside Region" message-delete-not-region
2814 :active
(message-mark-active-p)
2815 ,@(if (featurep 'xemacs
) nil
2816 '(:help
"Delete all quoted text outside region"))]
2817 ["Kill To Signature" message-kill-to-signature t
]
2818 ["Newline and Reformat" message-newline-and-reformat t
]
2819 ["Rename buffer" message-rename-buffer t
]
2820 ["Spellcheck" ispell-message
2821 ,@(if (featurep 'xemacs
) '(t)
2822 '(:help
"Spellcheck this message"))]
2824 ["Insert Region Marked" message-mark-inserted-region
2825 :active
(message-mark-active-p)
2826 ,@(if (featurep 'xemacs
) nil
2827 '(:help
"Mark region with enclosing tags"))]
2828 ["Insert File Marked..." message-mark-insert-file
2829 ,@(if (featurep 'xemacs
) '(t)
2830 '(:help
"Insert file at point marked with enclosing tags"))]
2832 ["Send Message" message-send-and-exit
2833 ,@(if (featurep 'xemacs
) '(t)
2834 '(:help
"Send this message"))]
2835 ["Postpone Message" message-dont-send
2836 ,@(if (featurep 'xemacs
) '(t)
2837 '(:help
"File this draft message and exit"))]
2838 ["Send at Specific Time..." gnus-delay-article
2839 ,@(if (featurep 'xemacs
) '(t)
2840 '(:help
"Ask, then arrange to send message at that time"))]
2841 ["Kill Message" message-kill-buffer
2842 ,@(if (featurep 'xemacs
) '(t)
2843 '(:help
"Delete this message without sending"))]
2845 ["Message manual" message-info
2846 ,@(if (featurep 'xemacs
) '(t)
2847 '(:help
"Display the Message manual"))]))
2850 message-mode-field-menu message-mode-map
""
2852 ["To" message-goto-to t
]
2853 ["From" message-goto-from t
]
2854 ["Subject" message-goto-subject t
]
2855 ["Change subject..." message-change-subject t
]
2856 ["Cc" message-goto-cc t
]
2857 ["Bcc" message-goto-bcc t
]
2858 ["Fcc" message-goto-fcc t
]
2859 ["Reply-To" message-goto-reply-to t
]
2860 ["Flag As Important" message-insert-importance-high
2861 ,@(if (featurep 'xemacs
) '(t)
2862 '(:help
"Mark this message as important"))]
2863 ["Flag As Unimportant" message-insert-importance-low
2864 ,@(if (featurep 'xemacs
) '(t)
2865 '(:help
"Mark this message as unimportant"))]
2867 message-insert-disposition-notification-to
2868 ,@(if (featurep 'xemacs
) '(t)
2869 '(:help
"Request a receipt notification"))]
2871 ;; (typical) news stuff
2872 ["Summary" message-goto-summary t
]
2873 ["Keywords" message-goto-keywords t
]
2874 ["Newsgroups" message-goto-newsgroups t
]
2875 ["Fetch Newsgroups" message-insert-newsgroups t
]
2876 ["Followup-To" message-goto-followup-to t
]
2877 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2878 ["Crosspost / Followup-To..." message-cross-post-followup-to t
]
2879 ["Distribution" message-goto-distribution t
]
2880 ["Expires" message-insert-expires t
]
2881 ["X-No-Archive" message-add-archive-header t
]
2883 ;; (typical) mailing-lists stuff
2884 ["Fetch To" message-insert-to
2885 ,@(if (featurep 'xemacs
) '(t)
2886 '(:help
"Insert a To header that points to the author."))]
2887 ["Fetch To and Cc" message-insert-wide-reply
2888 ,@(if (featurep 'xemacs
) '(t)
2890 "Insert To and Cc headers as if you were doing a wide reply."))]
2892 ["Send to list only" message-to-list-only t
]
2893 ["Mail-Followup-To" message-goto-mail-followup-to t
]
2894 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2895 ,@(if (featurep 'xemacs
) '(t)
2896 '(:help
"Insert a reasonable `Mail-Followup-To:' header."))]
2897 ["Reduce To: to Cc:" message-reduce-to-to-cc t
]
2899 ["Sort Headers" message-sort-headers t
]
2900 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t
]
2901 ;; We hide `message-hidden-headers' by narrowing the buffer.
2902 ["Show Hidden Headers" widen t
]
2903 ["Goto Body" message-goto-body t
]
2904 ["Goto Signature" message-goto-signature t
]))
2906 (defvar message-tool-bar-map nil
)
2908 (defvar facemenu-add-face-function
)
2909 (defvar facemenu-remove-face-function
)
2911 ;;; Forbidden properties
2913 ;; We use `after-change-functions' to keep special text properties
2914 ;; that interfere with the normal function of message mode out of the
2917 (defcustom message-strip-special-text-properties t
2918 "Strip special properties from the message buffer.
2920 Emacs has a number of special text properties which can break message
2921 composing in various ways. If this option is set, message will strip
2922 these properties from the message composition buffer. However, some
2923 packages requires these properties to be present in order to work.
2924 If you use one of these packages, turn this option off, and hope the
2925 message composition doesn't break too bad."
2927 :group
'message-various
2928 :link
'(custom-manual "(message)Various Message Variables")
2931 (defvar message-forbidden-properties
2932 ;; No reason this should be clutter up customize. We make it a
2933 ;; property list (rather than a list of property symbols), to be
2934 ;; directly useful for `remove-text-properties'.
2935 '(field nil read-only nil invisible nil intangible nil
2936 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2937 insert-behind-hooks nil point-entered nil point-left nil
)
2938 ;; Other special properties:
2939 ;; category, face, display: probably doesn't do any harm.
2940 ;; fontified: is used by font-lock.
2941 ;; syntax-table, local-map: I dunno.
2942 ;; We need to add XEmacs names to the list.
2943 "Property list of with properties forbidden in message buffers.
2944 The values of the properties are ignored, only the property names are used.")
2946 (defun message-tamago-not-in-use-p (pos)
2947 "Return t when tamago version 4 is not in use at the cursor position.
2948 Tamago version 4 is a popular input method for writing Japanese text.
2949 It uses the properties `intangible', `invisible', `modification-hooks'
2950 and `read-only' when translating ascii or kana text to kanji text.
2951 These properties are essential to work, so we should never strip them."
2952 (not (and (boundp 'egg-modefull-mode
)
2953 (symbol-value 'egg-modefull-mode
)
2954 (or (memq (get-text-property pos
'intangible
)
2955 '(its-part-1 its-part-2
))
2956 (get-text-property pos
'egg-end
)
2957 (get-text-property pos
'egg-lang
)
2958 (get-text-property pos
'egg-start
)))))
2960 (defsubst message-mail-alias-type-p
(type)
2961 (if (atom message-mail-alias-type
)
2962 (eq message-mail-alias-type type
)
2963 (memq type message-mail-alias-type
)))
2965 (defun message-strip-forbidden-properties (begin end
&optional old-length
)
2966 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2967 This function is intended to be called from `after-change-functions'.
2968 See also `message-forbidden-properties'."
2969 (when (and (message-mail-alias-type-p 'ecomplete
)
2970 (memq this-command message-self-insert-commands
))
2971 (message-display-abbrev))
2972 (when (and message-strip-special-text-properties
2973 (message-tamago-not-in-use-p begin
))
2974 (let ((buffer-read-only nil
)
2975 (inhibit-read-only t
))
2976 (remove-text-properties begin end message-forbidden-properties
))))
2978 (autoload 'ecomplete-setup
"ecomplete") ;; for Emacs <23.
2980 (defvar message-smileys
'(":-)" ":)"
2983 "A list of recognized smiley faces in `message-mode'.")
2985 (defun message--syntax-propertize (beg end
)
2986 "Syntax-propertize certain message text specially."
2987 (let ((citation-regexp (concat "^" message-cite-prefix-regexp
".*$"))
2988 (smiley-regexp (regexp-opt message-smileys
)))
2990 (while (search-forward-regexp citation-regexp
2992 (let ((start (match-beginning 0))
2993 (end (match-end 0)))
2994 (add-text-properties start
(1+ start
)
2995 `(syntax-table ,(string-to-syntax "<")))
2996 (add-text-properties end
(min (1+ end
) (point-max))
2997 `(syntax-table ,(string-to-syntax ">")))))
2999 (while (search-forward-regexp smiley-regexp
3001 (add-text-properties (match-beginning 0) (match-end 0)
3002 `(syntax-table ,(string-to-syntax "."))))))
3005 (define-derived-mode message-mode text-mode
"Message"
3006 "Major mode for editing mail and news to be sent.
3007 Like Text Mode but with these additional commands:\\<message-mode-map>
3008 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
3009 C-c C-d Postpone sending the message C-c C-k Kill the message
3010 C-c C-f move to a header field (and create it if there isn't):
3011 C-c C-f C-t move to To C-c C-f C-s move to Subject
3012 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
3013 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
3014 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
3015 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
3016 C-c C-f C-o move to From (\"Originator\")
3017 C-c C-f C-f move to Followup-To
3018 C-c C-f C-m move to Mail-Followup-To
3019 C-c C-f C-e move to Expires
3020 C-c C-f C-i cycle through Importance values
3021 C-c C-f s change subject and append \"(was: <Old Subject>)\"
3022 C-c C-f x crossposting with FollowUp-To header and note in body
3023 C-c C-f t replace To: header with contents of Cc: or Bcc:
3024 C-c C-f a Insert X-No-Archive: header and a note in the body
3025 C-c C-t `message-insert-to' (add a To header to a news followup)
3026 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
3027 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
3028 C-c C-b `message-goto-body' (move to beginning of message text).
3029 C-c C-i `message-goto-signature' (move to the beginning of the signature).
3030 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
3031 C-c C-y `message-yank-original' (insert current message, if any).
3032 C-c C-q `message-fill-yanked-message' (fill what was yanked).
3033 C-c C-e `message-elide-region' (elide the text between point and mark).
3034 C-c C-v `message-delete-not-region' (remove the text outside the region).
3035 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
3036 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
3037 C-c C-a `mml-attach-file' (attach a file as MIME).
3038 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
3039 C-c M-n `message-insert-disposition-notification-to' (request receipt).
3040 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
3041 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
3042 M-RET `message-newline-and-reformat' (break the line and reformat)."
3043 (set (make-local-variable 'message-reply-buffer
) nil
)
3044 (set (make-local-variable 'message-inserted-headers
) nil
)
3045 (set (make-local-variable 'message-send-actions
) nil
)
3046 (set (make-local-variable 'message-return-action
) nil
)
3047 (set (make-local-variable 'message-exit-actions
) nil
)
3048 (set (make-local-variable 'message-kill-actions
) nil
)
3049 (set (make-local-variable 'message-postpone-actions
) nil
)
3050 (set (make-local-variable 'message-draft-article
) nil
)
3051 (setq buffer-offer-save t
)
3052 (set (make-local-variable 'facemenu-add-face-function
)
3054 (let ((face-fun (cdr (assq face message-face-alist
))))
3056 (funcall face-fun
(point) end
)
3057 (error "Face %s not configured for %s mode" face mode-name
)))
3059 (set (make-local-variable 'facemenu-remove-face-function
) t
)
3060 (set (make-local-variable 'message-reply-headers
) nil
)
3061 (make-local-variable 'message-newsreader
)
3062 (make-local-variable 'message-mailer
)
3063 (make-local-variable 'message-post-method
)
3064 (set (make-local-variable 'message-sent-message-via
) nil
)
3065 (set (make-local-variable 'message-checksum
) nil
)
3066 (set (make-local-variable 'message-mime-part
) 0)
3067 (message-setup-fill-variables)
3068 (when message-fill-column
3069 (setq fill-column message-fill-column
)
3070 (turn-on-auto-fill))
3071 ;; Allow using comment commands to add/remove quoting.
3072 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
3073 (when message-yank-prefix
3074 (set (make-local-variable 'comment-start
) message-yank-prefix
)
3075 (set (make-local-variable 'comment-start-skip
)
3076 (concat "^" (regexp-quote message-yank-prefix
) "[ \t]*")))
3077 (if (featurep 'xemacs
)
3078 (message-setup-toolbar)
3079 (set (make-local-variable 'font-lock-defaults
)
3080 '(message-font-lock-keywords t
))
3081 (if (boundp 'tool-bar-map
)
3082 (set (make-local-variable 'tool-bar-map
) (message-make-tool-bar))))
3083 (easy-menu-add message-mode-menu message-mode-map
)
3084 (easy-menu-add message-mode-field-menu message-mode-map
)
3085 (gnus-make-local-hook 'after-change-functions
)
3086 ;; Mmmm... Forbidden properties...
3087 (add-hook 'after-change-functions
'message-strip-forbidden-properties
3089 ;; Allow mail alias things.
3091 ((message-mail-alias-type-p 'abbrev
)
3092 (if (fboundp 'mail-abbrevs-setup
)
3093 (mail-abbrevs-setup)
3094 (if (fboundp 'mail-aliases-setup
) ; warning avoidance
3095 (mail-aliases-setup))))
3096 ((message-mail-alias-type-p 'ecomplete
)
3098 (add-hook 'completion-at-point-functions
'message-completion-function nil t
)
3099 (unless buffer-file-name
3100 (message-set-auto-save-file-name))
3101 (unless (buffer-base-buffer)
3102 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
3103 ;; multibyte is not necessary at all. -- zsh
3104 (mm-enable-multibyte))
3105 (set (make-local-variable 'indent-tabs-mode
) nil
) ;No tabs for indentation.
3107 ;; Syntactic fontification. Helps `show-paren-mode',
3108 ;; `electric-pair-mode', and C-M-* navigation by syntactically
3109 ;; excluding citations and other artifacts.
3111 (set (make-local-variable 'syntax-propertize-function
) 'message--syntax-propertize
)
3112 (set (make-local-variable 'parse-sexp-ignore-comments
) t
))
3114 (defun message-setup-fill-variables ()
3115 "Setup message fill variables."
3116 (set (make-local-variable 'fill-paragraph-function
)
3117 'message-fill-paragraph
)
3118 (make-local-variable 'paragraph-separate
)
3119 (make-local-variable 'paragraph-start
)
3120 (make-local-variable 'adaptive-fill-regexp
)
3121 (unless (boundp 'adaptive-fill-first-line-regexp
)
3122 (setq adaptive-fill-first-line-regexp nil
))
3123 (make-local-variable 'adaptive-fill-first-line-regexp
)
3124 (let ((quote-prefix-regexp
3125 ;; User should change message-cite-prefix-regexp if
3126 ;; message-yank-prefix is set to an abnormal value.
3127 (concat "\\(" message-cite-prefix-regexp
"\\)[ \t]*")))
3128 (setq paragraph-start
3130 (regexp-quote mail-header-separator
) "$\\|"
3131 "[ \t]*$\\|" ; blank lines
3132 "-- $\\|" ; signature delimiter
3133 "---+$\\|" ; delimiters for forwarded messages
3134 page-delimiter
"$\\|" ; spoiler warnings
3135 ".*wrote:$\\|" ; attribution lines
3136 quote-prefix-regexp
"$\\|" ; empty lines in quoted text
3138 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
3139 (setq paragraph-separate paragraph-start
)
3140 (setq adaptive-fill-regexp
3141 (concat quote-prefix-regexp
"\\|" adaptive-fill-regexp
))
3142 (setq adaptive-fill-first-line-regexp
3143 (concat quote-prefix-regexp
"\\|"
3144 adaptive-fill-first-line-regexp
)))
3145 (make-local-variable 'auto-fill-inhibit-regexp
)
3146 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
3147 (setq auto-fill-inhibit-regexp nil
)
3148 (make-local-variable 'normal-auto-fill-function
)
3149 (setq normal-auto-fill-function
'message-do-auto-fill
)
3150 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
3151 ;; In that case, ensure that it uses the right function. The real
3152 ;; solution would be not to use `define-derived-mode', and run
3153 ;; `text-mode-hook' ourself at the end of the mode.
3154 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
3155 ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
3156 ;; now careful to run parent hooks after the body. --Stef
3157 (when auto-fill-function
3158 (setq auto-fill-function normal-auto-fill-function
)))
3163 ;;; Message mode commands
3166 ;;; Movement commands
3168 (defun message-goto-to ()
3169 "Move point to the To header."
3172 (message-position-on-field "To"))
3174 (defun message-goto-from ()
3175 "Move point to the From header."
3178 (message-position-on-field "From"))
3180 (defun message-goto-subject ()
3181 "Move point to the Subject header."
3184 (message-position-on-field "Subject"))
3186 (defun message-goto-cc ()
3187 "Move point to the Cc header."
3190 (message-position-on-field "Cc" "To"))
3192 (defun message-goto-bcc ()
3193 "Move point to the Bcc header."
3196 (message-position-on-field "Bcc" "Cc" "To"))
3198 (defun message-goto-fcc ()
3199 "Move point to the Fcc header."
3202 (message-position-on-field "Fcc" "To" "Newsgroups"))
3204 (defun message-goto-reply-to ()
3205 "Move point to the Reply-To header."
3208 (message-position-on-field "Reply-To" "Subject"))
3210 (defun message-goto-newsgroups ()
3211 "Move point to the Newsgroups header."
3214 (message-position-on-field "Newsgroups"))
3216 (defun message-goto-distribution ()
3217 "Move point to the Distribution header."
3220 (message-position-on-field "Distribution"))
3222 (defun message-goto-followup-to ()
3223 "Move point to the Followup-To header."
3226 (message-position-on-field "Followup-To" "Newsgroups"))
3228 (defun message-goto-mail-followup-to ()
3229 "Move point to the Mail-Followup-To header."
3232 (message-position-on-field "Mail-Followup-To" "To"))
3234 (defun message-goto-keywords ()
3235 "Move point to the Keywords header."
3238 (message-position-on-field "Keywords" "Subject"))
3240 (defun message-goto-summary ()
3241 "Move point to the Summary header."
3244 (message-position-on-field "Summary" "Subject"))
3246 (defun message-goto-body ()
3247 "Move point to the beginning of the message body."
3249 (when (and (gmm-called-interactively-p 'any
)
3250 (looking-at "[ \t]*\n"))
3253 (goto-char (point-min))
3254 (or (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3255 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t
)))
3257 (defun message-in-body-p ()
3258 "Return t if point is in the message body."
3261 (goto-char (point-min))
3262 (or (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3263 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t
))
3266 (defun message-goto-eoh ()
3267 "Move point to the end of the headers."
3272 (defun message-goto-signature ()
3273 "Move point to the beginning of the message signature.
3274 If there is no signature in the article, go to the end and
3278 (goto-char (point-min))
3279 (if (re-search-forward message-signature-separator nil t
)
3281 (goto-char (point-max))
3284 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc
)
3285 "Insert a reasonable MFT header in a post to an unsubscribed list.
3286 When making original posts to a mailing list you are not subscribed to,
3287 you have to type in a MFT header by hand. The contents, usually, are
3288 the addresses of the list and your own address. This function inserts
3289 such a header automatically. It fetches the contents of the To: header
3290 in the current mail buffer, and appends the current `user-mail-address'.
3292 If the optional argument INCLUDE-CC is non-nil, the addresses in the
3293 Cc: header are also put into the MFT."
3298 (message-narrow-to-headers)
3299 (message-remove-header "Mail-Followup-To")
3300 (setq cc
(and include-cc
(message-fetch-field "Cc")))
3302 (concat (message-fetch-field "To") "," cc
)
3303 (message-fetch-field "To"))))
3304 (message-goto-mail-followup-to)
3305 (insert (concat tos
", " user-mail-address
))))
3309 (defun message-insert-to (&optional force
)
3310 "Insert a To header that points to the author of the article being replied to.
3311 If the original author requested not to be sent mail, don't insert unless the
3312 prefix FORCE is given."
3314 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
3315 (dont (and mct
(or (equal (downcase mct
) "never")
3316 (equal (downcase mct
) "nobody"))))
3317 (to (or (message-fetch-reply-field "mail-reply-to")
3318 (message-fetch-reply-field "reply-to")
3319 (message-fetch-reply-field "from"))))
3323 "Ignoring the user request not to have copies sent via mail"
3324 "Complying with the user request not to have copies sent via mail")))
3325 (when (and force
(not to
))
3326 (error "No mail address in the article"))
3327 (when (and to
(or force
(not dont
)))
3328 (message-carefully-insert-headers (list (cons 'To to
))))))
3330 (defun message-insert-wide-reply ()
3331 "Insert To and Cc headers as if you were doing a wide reply."
3333 (let ((headers (message-with-reply-buffer
3334 (message-get-reply-headers t
))))
3335 (message-carefully-insert-headers headers
)))
3337 (defcustom message-header-synonyms
3340 "List of lists of header synonyms.
3341 E.g., if this list contains a member list with elements `Cc' and `To',
3342 then `message-carefully-insert-headers' will not insert a `To' header
3343 when the message is already `Cc'ed to the recipient."
3345 :group
'message-headers
3346 :link
'(custom-manual "(message)Message Headers")
3347 :type
'(repeat sexp
))
3349 (defun message-carefully-insert-headers (headers)
3350 "Insert the HEADERS, an alist, into the message buffer.
3351 Does not insert the headers when they are already present there
3352 or in the synonym headers, defined by `message-header-synonyms'."
3353 ;; FIXME: Should compare only the address and not the full name. Comparison
3354 ;; should be done case-folded (and with `string=' rather than
3356 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
3357 (dolist (header headers
)
3358 (let* ((header-name (symbol-name (car header
)))
3359 (new-header (cdr header
))
3360 (synonyms (loop for synonym in message-header-synonyms
3361 when
(memq (car header
) synonym
) return synonym
))
3363 (loop for synonym in synonyms
3364 for old-header
= (mail-fetch-field (symbol-name synonym
))
3365 when
(and old-header
(string-match new-header old-header
))
3368 (message "already have `%s' in `%s'" new-header old-header
)
3369 (when (and (message-position-on-field header-name
)
3370 (setq old-header
(mail-fetch-field header-name
))
3371 (not (string-match "\\` *\\'" old-header
)))
3373 (insert new-header
)))))
3375 (defun message-widen-reply ()
3376 "Widen the reply to include maximum recipients."
3379 (and (bufferp message-reply-buffer
)
3380 (buffer-name message-reply-buffer
)
3381 (with-current-buffer message-reply-buffer
3382 (message-get-reply-headers t
)))))
3385 (message-narrow-to-headers)
3386 (dolist (elem follow-to
)
3387 (message-remove-header (symbol-name (car elem
)))
3388 (goto-char (point-min))
3389 (insert (symbol-name (car elem
)) ": "
3390 (cdr elem
) "\n"))))))
3392 (defun message-insert-newsgroups ()
3393 "Insert the Newsgroups header from the article being replied to."
3395 (let ((old-newsgroups (mail-fetch-field "newsgroups"))
3396 (new-newsgroups (message-fetch-reply-field "newsgroups"))
3399 (message-position-on-field "Newsgroups")
3401 ((not new-newsgroups
)
3402 (error "No Newsgroups to insert"))
3403 ((not old-newsgroups
)
3404 (insert new-newsgroups
))
3406 (setq new-newsgroups
(split-string new-newsgroups
"[, ]+")
3407 old-newsgroups
(split-string old-newsgroups
"[, ]+"))
3408 (dolist (group new-newsgroups
)
3409 (unless (member group old-newsgroups
)
3410 (push group insert-newsgroups
)))
3411 (if (null insert-newsgroups
)
3412 (error "Newgroup%s already in the header"
3413 (if (> (length new-newsgroups
) 1)
3415 (when old-newsgroups
3417 (dolist (group insert-newsgroups
)
3421 (insert group
)))))))
3425 ;;; Various commands
3427 (defun message-delete-not-region (beg end
)
3428 "Delete everything in the body of the current message outside of the region."
3433 ;; snarf citation prefix, if appropriate
3434 (unless (eq (point) (progn (beginning-of-line) (point)))
3435 (when (looking-at message-cite-prefix-regexp
)
3436 (setq citeprefix
(match-string 0))))
3438 (delete-region (point) (if (not (message-goto-signature))
3444 (delete-region beg
(progn (message-goto-body)
3448 (insert citeprefix
))))
3449 (when (message-goto-signature)
3452 (defun message-kill-to-signature (&optional arg
)
3453 "Kill all text up to the signature.
3454 If a numeric argument or prefix arg is given, leave that number
3455 of lines before the signature intact."
3459 (let ((point (point)))
3460 (narrow-to-region point
(point-max))
3461 (message-goto-signature)
3463 (if (and arg
(numberp arg
))
3464 (forward-line (- -
1 arg
))
3466 (unless (= point
(point))
3467 (kill-region point
(point))
3471 (defun message-newline-and-reformat (&optional arg not-break
)
3472 "Insert four newlines, and then reformat if inside quoted text.
3473 Prefix arg means justify as well."
3474 (interactive (list (if current-prefix-arg
'full
)))
3475 (let (quoted point beg end leading-space bolp fill-paragraph-function
)
3476 (setq point
(point))
3479 (setq bolp
(= beg point
))
3480 ;; Find first line of the paragraph.
3482 (while (and (not (eobp))
3483 (not (looking-at message-cite-prefix-regexp
))
3484 (looking-at paragraph-start
))
3487 (when (looking-at message-cite-prefix-regexp
)
3488 (setq quoted
(match-string 0))
3489 (goto-char (match-end 0))
3490 (looking-at "[ \t]*")
3491 (setq leading-space
(match-string 0)))
3495 (< (- point beg
) (length quoted
)))
3496 ;; break inside the cite prefix.
3502 (while (and (not (eobp))
3503 (not (looking-at paragraph-separate
))
3504 (looking-at message-cite-prefix-regexp
)
3505 (equal quoted
(match-string 0)))
3506 (goto-char (match-end 0))
3507 (looking-at "[ \t]*")
3508 (if (> (length leading-space
) (length (match-string 0)))
3509 (setq leading-space
(match-string 0)))
3513 (while (and (if (bobp) nil
(forward-line -
1) t
)
3514 (not (looking-at paragraph-start
))
3515 (looking-at message-cite-prefix-regexp
)
3516 (equal quoted
(match-string 0)))
3518 (goto-char (match-end 0))
3519 (looking-at "[ \t]*")
3520 (if (> (length leading-space
) (length (match-string 0)))
3521 (setq leading-space
(match-string 0)))))
3522 (while (and (not (eobp))
3523 (not (looking-at paragraph-separate
))
3524 (not (looking-at message-cite-prefix-regexp
)))
3528 (while (and (if (bobp) nil
(forward-line -
1) t
)
3529 (not (looking-at paragraph-start
))
3530 (not (looking-at message-cite-prefix-regexp
)))
3531 (setq beg
(point))))
3534 (narrow-to-region beg end
)
3541 (setq point
(point))
3542 ;; (newline 2) doesn't mark both newline's as hard, so call
3543 ;; newline twice. -jas
3546 (delete-region (point) (re-search-forward "[ \t]*"))
3547 (when (and quoted
(not bolp
))
3548 (insert quoted leading-space
)))
3551 (let* ((adaptive-fill-regexp
3552 (regexp-quote (concat quoted leading-space
)))
3553 (adaptive-fill-first-line-regexp
3554 adaptive-fill-regexp
))
3555 (fill-paragraph arg
))
3556 (fill-paragraph arg
))
3557 (if point
(goto-char point
)))))
3559 (defun message-fill-paragraph (&optional arg
)
3560 "Message specific function to fill a paragraph.
3561 This function is used as the value of `fill-paragraph-function' in
3562 Message buffers and is not meant to be called directly."
3563 (interactive (list (if current-prefix-arg
'full
)))
3564 (if (if (boundp 'filladapt-mode
) filladapt-mode
)
3566 (if (message-point-in-header-p)
3567 (message-fill-field)
3568 (message-newline-and-reformat arg t
))
3571 (defun message-point-in-header-p ()
3572 "Return t if point is in the header."
3577 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
))
3579 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
))))
3581 (defun message-do-auto-fill ()
3582 "Like `do-auto-fill', but don't fill in message header."
3583 (unless (message-point-in-header-p)
3586 (defun message-insert-signature (&optional force
)
3587 "Insert a signature. See documentation for variable `message-signature'."
3588 (interactive (list 0))
3591 ((and (null message-signature
)
3594 (goto-char (point-max))
3595 (not (re-search-backward message-signature-separator nil t
))))
3596 ((and (null message-signature
)
3599 ((functionp message-signature
)
3600 (funcall message-signature
))
3601 ((listp message-signature
)
3602 (eval message-signature
))
3603 (t message-signature
)))
3606 (cond ((stringp signature
)
3608 ((and (eq t signature
) message-signature-file
)
3609 (setq signature-file
3610 (if (and message-signature-directory
3611 ;; don't actually use the signature directory
3612 ;; if message-signature-file contains a path.
3613 (not (file-name-directory
3614 message-signature-file
)))
3615 (expand-file-name message-signature-file
3616 message-signature-directory
)
3617 message-signature-file
))
3618 (file-exists-p signature-file
))))
3620 (goto-char (point-max))
3621 ;; Insert the signature.
3624 (when message-signature-insert-empty-line
3628 (if (eq signature t
)
3629 (insert-file-contents signature-file
)
3631 (goto-char (point-max))
3632 (or (bolp) (newline)))))
3634 (defun message-insert-importance-high ()
3635 "Insert header to mark message as important."
3639 (message-narrow-to-headers)
3640 (message-remove-header "Importance"))
3642 (insert "Importance: high\n")))
3644 (defun message-insert-importance-low ()
3645 "Insert header to mark message as unimportant."
3649 (message-narrow-to-headers)
3650 (message-remove-header "Importance"))
3652 (insert "Importance: low\n")))
3654 (defun message-insert-or-toggle-importance ()
3655 "Insert a \"Importance: high\" header, or cycle through the header values.
3656 The three allowed values according to RFC 1327 are `high', `normal'
3663 (message-narrow-to-headers)
3664 (when (setq cur
(message-fetch-field "Importance"))
3665 (message-remove-header "Importance")
3666 (setq new
(cond ((string= cur
"high")
3668 ((string= cur
"low")
3673 (insert (format "Importance: %s\n" new
)))))
3675 (defun message-insert-disposition-notification-to ()
3676 "Request a disposition notification (return receipt) to this message.
3677 Note that this should not be used in newsgroups."
3681 (message-narrow-to-headers)
3682 (message-remove-header "Disposition-Notification-To"))
3684 (insert (format "Disposition-Notification-To: %s\n"
3685 (or (message-field-value "Reply-to")
3686 (message-field-value "From")
3687 (message-make-from))))))
3689 (defun message-elide-region (b e
)
3690 "Elide the text in the region.
3691 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3694 (let ((lines (count-lines b e
))
3697 (insert (format-spec message-elide-ellipsis
3701 (defvar message-caesar-translation-table nil
)
3703 (defun message-caesar-region (b e
&optional n
)
3704 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3707 (min (point) (or (mark t
) (point)))
3708 (max (point) (or (mark t
) (point)))
3709 (when current-prefix-arg
3710 (prefix-numeric-value current-prefix-arg
))))
3712 (setq n
(if (numberp n
) (mod n
26) 13)) ;canonize N
3713 (unless (or (zerop n
) ; no action needed for a rot of 0
3714 (= b e
)) ; no region to rotate
3715 ;; We build the table, if necessary.
3716 (when (or (not message-caesar-translation-table
)
3717 (/= (aref message-caesar-translation-table ?a
) (+ ?a n
)))
3718 (setq message-caesar-translation-table
3719 (message-make-caesar-translation-table n
)))
3720 (translate-region b e message-caesar-translation-table
)))
3722 (defun message-make-caesar-translation-table (n)
3723 "Create a rot table with offset N."
3725 (table (make-string 256 0)))
3726 (while (< (incf i
) 256)
3729 (substring table
0 ?A
)
3730 (substring table
(+ ?A n
) (+ ?A n
(- 26 n
)))
3731 (substring table ?A
(+ ?A n
))
3732 (substring table
(+ ?A
26) ?a
)
3733 (substring table
(+ ?a n
) (+ ?a n
(- 26 n
)))
3734 (substring table ?a
(+ ?a n
))
3735 (substring table
(+ ?a
26) 255))))
3737 (defun message-caesar-buffer-body (&optional rotnum wide
)
3738 "Caesar rotate all letters in the current buffer by 13 places.
3739 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3740 With prefix arg, specifies the number of places to rotate each letter forward.
3741 Mail and USENET news headers are not rotated unless WIDE is non-nil."
3742 (interactive (if current-prefix-arg
3743 (list (prefix-numeric-value current-prefix-arg
))
3747 (when (and (not wide
) (message-goto-body))
3748 (narrow-to-region (point) (point-max)))
3749 (message-caesar-region (point-min) (point-max) rotnum
))))
3751 (defun message-pipe-buffer-body (program)
3752 "Pipe the message body in the current buffer through PROGRAM."
3755 (when (message-goto-body)
3756 (narrow-to-region (point) (point-max)))
3757 (shell-command-on-region
3758 (point-min) (point-max) program nil t
))))
3760 (defun message-rename-buffer (&optional enter-string
)
3761 "Rename the *message* buffer to \"*message* RECIPIENT\".
3762 If the function is run with a prefix, it will ask for a new buffer
3763 name, rather than giving an automatic name."
3764 (interactive "Pbuffer name: ")
3767 (goto-char (point-min))
3768 (narrow-to-region (point)
3769 (search-forward mail-header-separator nil
'end
))
3771 (if (message-news-p) (message-fetch-field "Newsgroups")
3772 (message-fetch-field "To"))
3775 (if (string-match "," mail-to
)
3776 (concat (substring mail-to
0 (match-beginning 0)) ", ...")
3778 (name-default (concat "*message* " mail-trimmed-to
))
3779 (name (if enter-string
3780 (read-string "New buffer name: " name-default
)
3782 (rename-buffer name t
)))))
3784 (defun message-fill-yanked-message (&optional justifyp
)
3785 "Fill the paragraphs of a message yanked into this one.
3786 Numeric argument means justify as well."
3789 (goto-char (point-min))
3790 (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3791 (let ((fill-prefix message-yank-prefix
))
3792 (fill-individual-paragraphs (point) (point-max) justifyp
))))
3794 (defun message-indent-citation (&optional start end yank-only
)
3795 "Modify text just inserted from a message to be cited.
3796 The inserted text should be the region.
3797 When this function returns, the region is again around the modified text.
3799 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3800 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3801 (unless start
(setq start
(point)))
3803 ;; Remove unwanted headers.
3804 (when message-ignored-cited-headers
3809 (if (search-forward "\n\n" nil t
)
3812 (message-remove-header message-ignored-cited-headers t
)
3813 (when (= (point-min) (point-max))
3814 (setq all-removed t
))
3815 (goto-char (point-max)))
3819 ;; Delete blank lines at the start of the buffer.
3820 (while (and (point-min)
3823 (message-delete-line))
3824 ;; Delete blank lines at the end of the buffer.
3825 (goto-char (point-max))
3826 (unless (eq (preceding-char) ?
\n)
3828 (while (and (zerop (forward-line -
1))
3830 (message-delete-line)))
3831 ;; Do the indentation.
3832 (if (null message-yank-prefix
)
3833 (indent-rigidly start
(or end
(mark t
)) message-indentation-spaces
)
3836 (while (< (point) (or end
(mark t
)))
3837 (cond ((looking-at ">")
3838 (insert message-yank-cited-prefix
))
3840 (insert message-yank-empty-prefix
))
3842 (insert message-yank-prefix
)))
3846 (defun message-remove-blank-cited-lines (&optional remove
)
3847 "Remove cited lines containing only blanks.
3848 If REMOVE is non-nil, remove newlines, too.
3850 To use this automatically, you may add this function to
3851 `gnus-message-setup-hook'."
3856 (when (boundp 'message-yank-cited-prefix
)
3857 (concat message-yank-cited-prefix
"\\|"))
3861 (gnus-message 8 "removing `%s'" citexp
)
3864 (while (re-search-forward citexp nil t
)
3865 (replace-match (if remove
"" "\n"))))))
3867 (defun message--yank-original-internal (arg)
3868 (let ((modified (buffer-modified-p))
3870 (when (and message-reply-buffer
3871 message-cite-function
)
3872 (when (equal message-cite-reply-position
'above
)
3875 (buffer-substring (message-goto-body)
3877 (delete-region (message-goto-body) (point-max))))
3878 (if (bufferp message-reply-buffer
)
3879 (delete-windows-on message-reply-buffer t
))
3880 (push-mark (save-excursion
3882 ((bufferp message-reply-buffer
)
3883 (insert-buffer-substring message-reply-buffer
))
3884 ((and (consp message-reply-buffer
)
3885 (functionp (car message-reply-buffer
)))
3886 (apply (car message-reply-buffer
)
3887 (cdr message-reply-buffer
))))
3892 (funcall message-cite-function
)
3893 (unless (eq (char-before (mark t
)) ?
\n)
3895 (goto-char (mark t
))
3896 (insert-before-markers ?
\n)
3898 (case message-cite-reply-position
3902 (insert (if (bolp) "\n" "\n\n"))
3903 (message-goto-body))
3905 (message-goto-signature)))
3906 ;; Add a `message-setup-very-last-hook' here?
3907 ;; Add `gnus-article-highlight-citation' here?
3909 (setq message-checksum
(message-checksum))))))
3911 (defun message-yank-original (&optional arg
)
3912 "Insert the message being replied to, if any.
3913 Puts point before the text and mark after.
3914 Normally indents each nonblank line ARG spaces (default 3). However,
3915 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3917 This function uses `message-cite-function' to do the actual citing.
3919 Just \\[universal-argument] as argument means don't indent, insert no
3920 prefix, and don't delete any headers."
3922 ;; eval the let forms contained in message-cite-style
3924 `(let ,(if (symbolp message-cite-style
)
3925 (symbol-value message-cite-style
)
3927 (message--yank-original-internal ',arg
))))
3929 (defun message-yank-buffer (buffer)
3930 "Insert BUFFER into the current buffer and quote it."
3931 (interactive "bYank buffer: ")
3932 (let ((message-reply-buffer (get-buffer buffer
)))
3933 (save-window-excursion
3934 (message-yank-original))))
3936 (defun message-buffers ()
3937 "Return a list of active message buffers."
3939 (save-current-buffer
3940 (dolist (buffer (buffer-list t
))
3942 (when (and (derived-mode-p 'message-mode
)
3943 (null message-sent-message-via
))
3944 (push (buffer-name buffer
) buffers
))))
3945 (nreverse buffers
)))
3947 (defun message-cite-original-1 (strip-signature)
3948 "Cite an original message.
3949 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3952 This function uses `mail-citation-hook' if that is non-nil."
3953 (if (and (boundp 'mail-citation-hook
)
3955 (run-hooks 'mail-citation-hook
)
3956 (let* ((start (point))
3960 (when message-indent-citation-function
3961 (if (listp message-indent-citation-function
)
3962 message-indent-citation-function
3963 (list message-indent-citation-function
))))
3964 ;; This function may be called by `gnus-summary-yank-message' and
3965 ;; may insert a different article from the original. So, we will
3966 ;; modify the value of `message-reply-headers' with that article.
3967 (message-reply-headers
3969 (narrow-to-region start end
)
3970 (message-narrow-to-head-1)
3971 (setq x-no-archive
(message-fetch-field "x-no-archive"))
3973 (or (message-fetch-field "subject") "none")
3974 (or (message-fetch-field "from") "nobody")
3975 (message-fetch-field "date")
3976 (message-fetch-field "message-id" t
)
3977 (message-fetch-field "references")
3979 (mml-quote-region start end
)
3980 (when strip-signature
3984 (when (re-search-backward message-signature-separator start t
)
3985 ;; Also peel off any blank lines before the signature.
3987 (while (looking-at "^[ \t]*$")
3990 (delete-region (point) end
)
3991 (unless (search-backward "\n\n" start t
)
3992 ;; Insert a blank line if it is peeled off.
3995 (mapc 'funcall functions
)
3996 (when message-citation-line-function
3999 (funcall message-citation-line-function
))
4000 (when (and x-no-archive
4001 (not message-cite-articles-with-x-no-archive
)
4002 (string-match "yes" x-no-archive
))
4004 (delete-region (point) (mark t
))
4005 (insert "> [Quoted text removed due to X-No-Archive]\n")
4007 (forward-line -
1)))))
4009 (defun message-cite-original ()
4010 "Cite function in the standard Message manner."
4011 (message-cite-original-1 nil
))
4013 (autoload 'format-spec
"format-spec")
4014 (autoload 'gnus-date-get-time
"gnus-util")
4016 (defun message-insert-formatted-citation-line (&optional from date tz
)
4017 "Function that inserts a formatted citation line.
4018 The optional FROM, and DATE are strings containing the contents of
4019 the From header and the Date header respectively. The optional TZ
4020 is a number of seconds, overrides the time zone of DATE.
4022 See `message-citation-line-format'."
4023 ;; The optional args are for testing/debugging. They will disappear later.
4025 ;; (with-temp-buffer
4026 ;; (message-insert-formatted-citation-line
4027 ;; "John Doe <john.doe@example.invalid>"
4028 ;; (message-make-date))
4030 (when (or message-reply-headers
(and from date
))
4032 (setq from
(mail-header-from message-reply-headers
)))
4033 (let* ((data (condition-case ()
4034 (funcall (if (boundp 'gnus-extract-address-components
)
4035 gnus-extract-address-components
4036 'mail-extract-address-components
)
4042 (net (car (cdr data
)))
4043 (name-or-net (or (car data
)
4044 (car (cdr data
)) from
))
4046 (when (string-match "%[^fnNFL]" message-citation-line-format
)
4047 (cond ((numberp (car-safe date
)) date
) ;; backward compatibility
4048 (date (gnus-date-get-time date
))
4051 (setq date
(mail-header-date message-reply-headers
)))))))
4053 (when (stringp date
)
4054 (nth 8 (parse-time-string date
)))))
4057 (when (stringp name
)
4058 ;; Guess first name and last name:
4063 (if (string-match "\\`\\(\\w\\|[-.]\\)+\\'"
4067 (split-string name
"[ \t]+"))))
4068 (count (length names
)))
4070 (setq fname
(car names
)
4072 ((or (= count
2) (= count
3))
4073 (setq fname
(car names
)
4074 lname
(mapconcat 'identity
(cdr names
) " ")))
4076 (setq fname
(mapconcat 'identity
4077 (butlast names
(- count
2))
4079 lname
(mapconcat 'identity
4082 (when (string-match "\\(.*\\),\\'" fname
)
4083 (let ((newlname (match-string 1 fname
)))
4084 (setq fname lname lname newlname
)))))
4085 ;; The following letters are not used in `format-time-string':
4086 (push ?E lst
) (push "<E>" lst
)
4087 (push ?F lst
) (push (or fname name-or-net
) lst
)
4088 ;; We might want to use "" instead of "<X>" later.
4089 (push ?J lst
) (push "<J>" lst
)
4090 (push ?K lst
) (push "<K>" lst
)
4091 (push ?L lst
) (push lname lst
)
4092 (push ?N lst
) (push name-or-net lst
)
4093 (push ?O lst
) (push "<O>" lst
)
4094 (push ?P lst
) (push "<P>" lst
)
4095 (push ?Q lst
) (push "<Q>" lst
)
4096 (push ?f lst
) (push from lst
)
4097 (push ?i lst
) (push "<i>" lst
)
4098 (push ?n lst
) (push net lst
)
4099 (push ?o lst
) (push "<o>" lst
)
4100 (push ?q lst
) (push "<q>" lst
)
4101 (push ?t lst
) (push "<t>" lst
)
4102 (push ?v lst
) (push "<v>" lst
)
4103 ;; Delegate the rest to `format-time-string':
4105 (when (and (not (memq i lst
))
4110 (push (condition-case nil
4111 (gmm-format-time-string (format "%%%c" i
) time tz
)
4112 (error (format ">%c<" i
)))
4116 (spec (apply 'format-spec-make flist
)))
4117 (insert (format-spec message-citation-line-format spec
)))
4120 (defun message-cite-original-without-signature ()
4121 "Cite function in the standard Message manner.
4122 This function strips off the signature from the original message."
4123 (message-cite-original-1 t
))
4125 (defun message-insert-citation-line ()
4126 "Insert a simple citation line."
4127 (when message-reply-headers
4128 (insert (mail-header-from message-reply-headers
) " writes:")
4132 (defun message-position-on-field (header &rest afters
)
4133 (let ((case-fold-search t
))
4136 (goto-char (point-min))
4139 (concat "^" (regexp-quote mail-header-separator
) "$"))
4140 (match-beginning 0)))
4141 (goto-char (point-min))
4142 (if (re-search-forward (concat "^" (regexp-quote header
) ":") nil t
)
4144 (re-search-forward "^[^ \t]" nil
'move
)
4146 (skip-chars-backward "\n")
4149 (not (re-search-forward
4150 (concat "^" (regexp-quote (car afters
)) ":")
4154 (re-search-forward "^[^ \t]" nil
'move
)
4155 (beginning-of-line))
4156 (insert header
": \n")
4163 ;;; Sending messages
4166 (defun message-send-and-exit (&optional arg
)
4167 "Send message like `message-send', then, if no errors, exit from mail buffer.
4168 The usage of ARG is defined by the instance that called Message.
4169 It should typically alter the sending method in some way or other."
4171 (let ((buf (current-buffer))
4172 (actions message-exit-actions
))
4173 (when (and (message-send arg
)
4176 (if message-kill-buffer-on-exit
4178 (message-do-actions actions
)
4181 (defun message-dont-send ()
4182 "Don't send the message you have been editing.
4183 Instead, just auto-save the buffer and then bury it."
4185 (set-buffer-modified-p t
)
4187 (let ((actions message-postpone-actions
))
4188 (message-bury (current-buffer))
4189 (message-do-actions actions
)))
4191 (defun message-kill-buffer ()
4192 "Kill the current buffer."
4194 (when (or (not (buffer-modified-p))
4195 (not message-kill-buffer-query
)
4196 (yes-or-no-p "Message modified; kill anyway? "))
4197 (let ((actions message-kill-actions
)
4198 (draft-article message-draft-article
)
4199 (auto-save-file-name buffer-auto-save-file-name
)
4200 (file-name buffer-file-name
)
4201 (modified (buffer-modified-p)))
4202 (setq buffer-file-name nil
)
4203 (kill-buffer (current-buffer))
4204 (when (and (or (and auto-save-file-name
4205 (file-exists-p auto-save-file-name
))
4207 (file-exists-p file-name
)))
4209 ;; If the message buffer has lived in a dedicated window,
4210 ;; `kill-buffer' has killed the frame. Thus the
4211 ;; `yes-or-no-p' may show up in a lowered frame. Make sure
4212 ;; that the user can see the question by raising the
4215 (yes-or-no-p (format "Remove the backup file%s? "
4216 (if modified
" too" "")))))
4218 (delete-file auto-save-file-name
))
4219 (let ((message-draft-article draft-article
))
4220 (message-disassociate-draft)))
4221 (message-do-actions actions
))))
4223 (defun message-bury (buffer)
4224 "Bury this mail BUFFER."
4225 ;; Note that this is not quite the same as (bury-buffer buffer),
4226 ;; since bury-buffer does extra stuff with a nil argument.
4227 ;; Eg http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg00539.html
4228 (with-current-buffer buffer
(bury-buffer))
4229 (if message-return-action
4230 (apply (car message-return-action
) (cdr message-return-action
))))
4232 (autoload 'mml-secure-bcc-is-safe
"mml-sec")
4234 (defun message-send (&optional arg
)
4235 "Send the message in the current buffer.
4236 If `message-interactive' is non-nil, wait for success indication or
4237 error messages, and inform user.
4238 Otherwise any failure is reported in a message back to the user from
4240 The usage of ARG is defined by the instance that called Message.
4241 It should typically alter the sending method in some way or other."
4243 ;; Make it possible to undo the coming changes.
4245 (let ((inhibit-read-only t
))
4246 (put-text-property (point-min) (point-max) 'read-only nil
))
4247 (message-fix-before-sending)
4248 (mml-secure-bcc-is-safe)
4249 (run-hooks 'message-send-hook
)
4250 (when message-confirm-send
4251 (or (y-or-n-p "Send message? ")
4253 (message message-sending-message
)
4254 (let ((alist message-send-method-alist
)
4256 elem sent dont-barf-on-no-method
4257 (message-options message-options
))
4258 (message-options-set-recipient)
4260 (setq elem
(pop alist
)))
4261 (when (funcall (cadr elem
))
4262 (when (and (or (not (memq (car elem
)
4263 message-sent-message-via
))
4264 (message-fetch-field "supersedes")
4265 (if (or (message-gnksa-enable-p 'multiple-copies
)
4266 (not (eq (car elem
) 'news
)))
4269 "Already sent message via %s; resend? "
4271 (error "Denied posting -- multiple copies")))
4272 (setq success
(funcall (caddr elem
) arg
)))
4276 (let ((fcc (message-fetch-field "Fcc"))
4277 (gcc (message-fetch-field "Gcc")))
4279 (or (eq message-allow-no-recipients
'always
)
4280 (and (not (eq message-allow-no-recipients
'never
))
4281 (setq dont-barf-on-no-method
4283 (format "No receiver, perform %s anyway? "
4284 (cond ((and fcc gcc
) "Fcc and Gcc")
4287 (error "No methods specified to send by"))
4288 (when (or dont-barf-on-no-method
4292 (run-hooks 'message-sent-hook
))
4293 (message "Sending...done")
4294 ;; Do ecomplete address snarfing.
4295 (when (and (message-mail-alias-type-p 'ecomplete
)
4296 (not message-inhibit-ecomplete
))
4297 (message-put-addresses-in-ecomplete))
4298 ;; Mark the buffer as unmodified and delete auto-save.
4299 (set-buffer-modified-p nil
)
4300 (delete-auto-save-file-if-necessary t
)
4301 (message-disassociate-draft)
4302 ;; Delete other mail buffers and stuff.
4303 (message-do-send-housekeeping)
4304 (message-do-actions message-send-actions
)
4308 (defun message-send-via-mail (arg)
4309 "Send the current message via mail."
4310 (message-send-mail arg
))
4312 (defun message-send-via-news (arg)
4313 "Send the current message via news."
4314 (funcall message-send-news-function arg
))
4316 (defmacro message-check
(type &rest forms
)
4317 "Eval FORMS if TYPE is to be checked."
4318 `(or (message-check-element ,type
)
4322 (put 'message-check
'lisp-indent-function
1)
4323 (put 'message-check
'edebug-form-spec
'(form body
))
4325 (defun message-text-with-property (prop &optional start end reverse
)
4326 "Return a list of start and end positions where the text has PROP.
4327 START and END bound the search, they default to `point-min' and
4328 `point-max' respectively. If REVERSE is non-nil, find text which does
4331 (setq start
(point-min)))
4333 (setq end
(point-max)))
4337 (setq start
(text-property-any start end prop nil
)))
4338 (setq next
(next-single-property-change start prop nil end
))
4339 (push (cons start
(or next end
)) regions
)
4342 (or (get-text-property start prop
)
4343 (and (setq start
(next-single-property-change
4344 start prop nil end
))
4345 (get-text-property start prop
))))
4346 (setq next
(text-property-any start end prop nil
))
4347 (push (cons start
(or next end
)) regions
)
4349 (nreverse regions
)))
4351 (defcustom message-bogus-addresses
4352 '("noreply" "nospam" "invalid" "@@" "[^[:ascii:]].*@" "[ \t]")
4353 "List of regexps of potentially bogus mail addresses.
4354 See `message-check-recipients' how to setup checking.
4356 This list should make it possible to catch typos or warn about
4357 spam-trap addresses. It doesn't aim to verify strict RFC
4359 :version
"23.1" ;; No Gnus
4360 :group
'message-headers
4362 (const :tag
"None" nil
)
4368 (const :tag
"duplicate @" "@@")
4369 (const :tag
"non-ascii local part" "[^[:ascii:]].*@")
4370 ;; Already caught by `message-valid-fqdn-regexp'
4371 ;; (const :tag "`_' in domain part" "@.*_")
4372 (const :tag
"whitespace" "[ \t]"))
4377 (defun message-fix-before-sending ()
4378 "Do various things to make the message nice before sending it."
4379 ;; Make sure there's a newline at the end of the message.
4380 (goto-char (point-max))
4383 ;; Make the hidden headers visible.
4385 ;; Sort headers before sending the message.
4386 (message-sort-headers)
4387 ;; Make invisible text visible.
4388 ;; It doesn't seem as if this is useful, since the invisible property
4389 ;; is clobbered by an after-change hook anyhow.
4390 (message-check 'invisible-text
4391 (let ((regions (message-text-with-property 'invisible
))
4395 (setq from
(caar regions
)
4397 regions
(cdr regions
))
4398 (put-text-property from to
'invisible nil
)
4399 (overlay-put (make-overlay from to
) 'face
'highlight
))
4400 (unless (yes-or-no-p
4401 "Invisible text found and made visible; continue sending? ")
4402 (error "Invisible text found and made visible")))))
4403 (message-check 'illegible-text
4404 (let (char found choice nul-chars
)
4406 (setq nul-chars
(save-excursion
4407 (search-forward "\000" nil t
)))
4409 (skip-chars-forward mm-7bit-chars
)
4410 (when (get-text-property (point) 'no-illegible-text
)
4411 ;; There is a signed or encrypted raw message part
4412 ;; that is considered to be safe.
4413 (goto-char (or (next-single-property-change
4414 (point) 'no-illegible-text
)
4416 (setq char
(char-after)))
4417 (when (or (< (mm-char-int char
) 128)
4418 (and (mm-multibyte-p)
4419 (memq (char-charset char
)
4420 '(eight-bit-control eight-bit-graphic
4421 ;; Emacs 23, Bug#1770:
4424 (not (get-text-property
4425 (point) 'untranslated-utf-8
))))
4426 (overlay-put (make-overlay (point) (1+ (point))) 'face
'highlight
)
4431 (gnus-multiple-choice
4433 "NUL characters found, which may cause problems. Continue sending?"
4434 "Non-printable characters found. Continue sending?")
4435 `((?d
"Remove non-printable characters and send")
4437 "Replace non-printable characters with \"%s\" and send"
4438 message-replacement-char
))
4439 (?s
"Send as is without removing anything")
4440 (?e
"Continue editing"))))
4442 (error "Non-printable characters"))
4444 (skip-chars-forward mm-7bit-chars
)
4446 (when (let ((char (char-after)))
4447 (or (< (mm-char-int char
) 128)
4448 (and (mm-multibyte-p)
4449 ;; FIXME: Wrong for Emacs 23 (unicode) and for
4450 ;; things like undecodable utf-8 (in Emacs 21?).
4451 ;; Should at least use find-coding-systems-region.
4453 (memq (char-charset char
)
4454 '(eight-bit-control eight-bit-graphic
4455 ;; Emacs 23, Bug#1770:
4458 (not (get-text-property
4459 (point) 'untranslated-utf-8
)))))
4461 (message-kill-all-overlays)
4463 (when (eq choice ?r
)
4464 (insert message-replacement-char
))))
4466 (skip-chars-forward mm-7bit-chars
)))))
4467 (message-check 'bogus-recipient
4468 ;; Warn before sending a mail to an invalid address.
4469 (message-check-recipients)))
4471 (defun message-bogus-recipient-p (recipients)
4472 "Check if a mail address in RECIPIENTS looks bogus.
4474 RECIPIENTS is a mail header. Return a list of potentially bogus
4475 addresses. If none is found, return nil.
4477 An address might be bogus if the domain part is not fully
4478 qualified, see `message-valid-fqdn-regexp', or if there's a
4479 matching entry in `message-bogus-addresses'."
4480 ;; FIXME: How about "foo@subdomain", when the MTA adds ".domain.tld"?
4482 (mapc (lambda (address)
4483 (setq address
(or (cadr address
) ""))
4485 (or (string= "" address
)
4488 (not (string-match "@" address
))
4491 message-valid-fqdn-regexp
"\\)\\'") address
)))
4492 (and message-bogus-addresses
4494 (if (listp message-bogus-addresses
)
4495 (mapconcat 'identity
4496 message-bogus-addresses
4498 message-bogus-addresses
)))
4499 (string-match re address
))))
4500 (push address found
)))
4502 (mail-extract-address-components recipients t
))
4505 (defun message-check-recipients ()
4506 "Warn before composing or sending a mail to an invalid address.
4508 This function could be useful in `message-setup-hook'."
4511 (message-narrow-to-headers)
4512 (dolist (hdr '("To" "Cc" "Bcc"))
4513 (let ((addr (message-fetch-field hdr
)))
4514 (when (stringp addr
)
4515 (dolist (bog (message-bogus-recipient-p addr
))
4518 (gnus-format-message
4519 "Address `%s'%s might be bogus. Continue? "
4521 ;; If the encoded version of the email address
4522 ;; is different from the unencoded version,
4523 ;; then we likely have invisible characters or
4524 ;; the like. Display the encoded version,
4526 (let ((encoded (rfc2047-encode-string bog
)))
4527 (if (string= encoded bog
)
4529 (format " (%s)" encoded
))))))
4530 (error "Bogus address"))))))))
4532 (custom-add-option 'message-setup-hook
'message-check-recipients
)
4534 (defun message-add-action (action &rest types
)
4535 "Add ACTION to be performed when doing an exit of type TYPES."
4537 (add-to-list (intern (format "message-%s-actions" (pop types
)))
4540 (defun message-delete-action (action &rest types
)
4541 "Delete ACTION from lists of actions performed when doing an exit of type TYPES."
4544 (set (setq var
(intern (format "message-%s-actions" (pop types
))))
4545 (delq action
(symbol-value var
))))))
4547 (defun message-do-actions (actions)
4548 "Perform all actions in ACTIONS."
4549 ;; Now perform actions on successful sending.
4550 (dolist (action actions
)
4553 ;; A simple function.
4556 ;; Something to be evalled.
4560 (defun message-send-mail-partially ()
4561 "Send mail as message/partial."
4562 ;; replace the header delimiter with a blank line
4563 (goto-char (point-min))
4565 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4566 (replace-match "\n")
4567 (run-hooks 'message-send-mail-hook
)
4568 (let ((p (goto-char (point-min)))
4569 (tembuf (message-generate-new-buffer-clone-locals " message temp"))
4570 (curbuf (current-buffer))
4571 (id (message-make-message-id)) (n 1)
4574 (if (< (point-max) (+ p message-send-mail-partially-limit
))
4575 (goto-char (point-max))
4576 (goto-char (+ p message-send-mail-partially-limit
))
4578 (if (<= (point) p
) (forward-line 1))) ;; In case of bad message.
4581 (setq total
(length plist
))
4582 (push (point-max) plist
)
4583 (setq plist
(nreverse plist
))
4586 (setq p
(pop plist
))
4589 (copy-to-buffer tembuf p
(car plist
))
4591 (goto-char (point-min))
4594 (goto-char (point-min))
4595 (narrow-to-region (point) (point))
4598 (setq header
(buffer-substring (point-min) (point)))
4599 (goto-char (point-min))
4600 (narrow-to-region (point) (point))
4602 (message-remove-header "Mime-Version")
4603 (message-remove-header "Content-Type")
4604 (message-remove-header "Content-Transfer-Encoding")
4605 (message-remove-header "Message-ID")
4606 (message-remove-header "Lines")
4607 (goto-char (point-max))
4608 (insert "Mime-Version: 1.0\n")
4609 (setq header
(buffer-string)))
4610 (goto-char (point-max))
4611 (insert (format "Content-Type: message/partial; id=\"%s\"; number=%d; total=%d\n\n"
4614 (let ((mail-header-separator ""))
4615 (when (memq 'Message-ID message-required-mail-headers
)
4616 (insert "Message-ID: " (message-make-message-id) "\n"))
4617 (when (memq 'Lines message-required-mail-headers
)
4618 (insert "Lines: " (message-make-lines) "\n"))
4619 (message-goto-subject)
4621 (insert (format " (%d/%d)" n total
))
4623 (if message-send-mail-real-function
4624 (funcall message-send-mail-real-function
)
4625 (message-multi-smtp-send-mail)))
4627 (setq p
(pop plist
))
4629 (kill-buffer tembuf
))))
4631 (declare-function hashcash-wait-async
"hashcash" (&optional buffer
))
4633 (defun message-send-mail (&optional arg
)
4634 (require 'mail-utils
)
4635 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
4636 (case-fold-search nil
)
4637 (news (message-news-p))
4638 (mailbuf (current-buffer))
4639 (message-this-is-mail t
)
4640 ;; gnus-setup-posting-charset is autoloaded in mml.el (FIXME
4641 ;; maybe it should not be), which this file requires. Hence
4642 ;; the fboundp test is always true. Loading it from gnus-msg
4643 ;; loads many Gnus files (Bug#5642). If
4644 ;; gnus-group-posting-charset-alist hasn't been customized,
4645 ;; this is just going to return nil anyway. FIXME it would
4646 ;; be good to improve this further, because even if g-g-p-c-a
4647 ;; has been customized, that is likely to just be for news.
4648 ;; Eg either move the definition from gnus-msg, or separate out
4649 ;; the mail and news parts.
4650 (message-posting-charset
4651 (if (and (fboundp 'gnus-setup-posting-charset
)
4652 (boundp 'gnus-group-posting-charset-alist
))
4653 (gnus-setup-posting-charset nil
)
4654 message-posting-charset
))
4655 (headers message-required-mail-headers
)
4657 (when (and message-generate-hashcash
4658 (not (eq message-generate-hashcash
'opportunistic
)))
4659 (message "Generating hashcash...")
4661 ;; Wait for calculations already started to finish...
4662 (hashcash-wait-async)
4663 ;; ...and do calculations not already done. mail-add-payment
4664 ;; will leave existing X-Hashcash headers alone.
4666 (message "Generating hashcash...done"))
4668 (message-narrow-to-headers)
4669 ;; Generate the Mail-Followup-To header if the header is not there...
4670 (if (and (message-subscribed-p)
4671 (not (mail-fetch-field "mail-followup-to")))
4674 (cons "Mail-Followup-To" (message-make-mail-followup-to))
4675 message-required-mail-headers
))
4676 ;; otherwise, delete the MFT header if the field is empty
4677 (when (equal "" (mail-fetch-field "mail-followup-to"))
4678 (message-remove-header "^Mail-Followup-To:")))
4679 ;; Insert some headers.
4680 (let ((message-deletable-headers
4681 (if news nil message-deletable-headers
)))
4682 (message-generate-headers headers
))
4683 ;; Check continuation headers.
4684 (message-check 'continuation-headers
4685 (goto-char (point-min))
4686 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4687 (goto-char (match-beginning 0))
4688 (if (y-or-n-p "Fix continuation lines? ")
4691 (unless (y-or-n-p "Send anyway? ")
4692 (error "Failed to send the message")))))
4693 ;; Let the user do all of the above.
4694 (run-hooks 'message-header-hook
))
4695 (setq options message-options
)
4697 (with-current-buffer tembuf
4699 (setq message-options options
)
4700 ;; Avoid copying text props (except hard newlines).
4701 (insert (with-current-buffer mailbuf
4702 (mml-buffer-substring-no-properties-except-hard-newlines
4703 (point-min) (point-max))))
4704 ;; Remove some headers.
4705 (message-encode-message-body)
4707 (message-narrow-to-headers)
4708 ;; We (re)generate the Lines header.
4709 (when (memq 'Lines message-required-mail-headers
)
4710 (message-generate-headers '(Lines)))
4711 ;; Remove some headers.
4712 (message-remove-header message-ignored-mail-headers t
)
4713 (let ((mail-parse-charset message-default-charset
))
4714 (mail-encode-encoded-word-buffer)))
4715 (goto-char (point-max))
4716 ;; require one newline at the end.
4717 (or (= (preceding-char) ?
\n)
4719 (message-cleanup-headers)
4720 ;; FIXME: we're inserting the courtesy copy after encoding.
4721 ;; This is wrong if the courtesy copy string contains
4722 ;; non-ASCII characters. -- jh
4725 (message-narrow-to-headers)
4727 (not (message-fetch-field "List-Post"))
4728 (not (message-fetch-field "List-ID"))
4729 (or (message-fetch-field "cc")
4730 (message-fetch-field "bcc")
4731 (message-fetch-field "to"))
4732 (let ((content-type (message-fetch-field
4737 (string= "text/plain"
4739 (mail-header-parse-content-type
4743 (message-fetch-field
4744 "content-transfer-encoding")))))))
4745 (message-insert-courtesy-copy
4746 (with-current-buffer mailbuf
4747 message-courtesy-message
)))
4748 ;; Let's make sure we encoded all the body.
4749 (assert (save-excursion
4750 (goto-char (point-min))
4751 (not (re-search-forward "[^\000-\377]" nil t
))))
4752 (mm-disable-multibyte)
4753 (if (or (not message-send-mail-partially-limit
)
4754 (< (buffer-size) message-send-mail-partially-limit
)
4755 (not (message-y-or-n-p
4756 "The message size is too large, split? "
4760 (/ (buffer-size) 1000) "KB, is too large.
4762 Some mail gateways (MTA's) bounce large messages. To avoid the
4763 problem, answer `y', and the message will be split into several
4764 smaller pieces, the size of each is about "
4765 (/ message-send-mail-partially-limit
1000)
4769 However, some mail readers (MUA's) can't read split messages, i.e.,
4770 mails in message/partially format. Answer `n', and the message will be
4773 The size limit is controlled by `message-send-mail-partially-limit'.
4774 If you always want Gnus to send messages in one piece, set
4775 `message-send-mail-partially-limit' to nil.
4778 (message "Sending via mail...")
4779 (if message-send-mail-real-function
4780 (funcall message-send-mail-real-function
)
4781 (message-multi-smtp-send-mail)))
4782 (message-send-mail-partially))
4783 (setq options message-options
))
4784 (kill-buffer tembuf
))
4785 (set-buffer mailbuf
)
4786 (setq message-options options
)
4787 (push 'mail message-sent-message-via
)))
4789 (defvar sendmail-program
)
4790 (defvar smtpmail-smtp-user
)
4792 (defun message-multi-smtp-send-mail ()
4793 "Send the current buffer to `message-send-mail-function'.
4794 Or, if there's a header that specifies a different method, use
4796 (let ((method (message-field-value "X-Message-SMTP-Method")))
4798 (funcall message-send-mail-function
)
4799 (message-remove-header "X-Message-SMTP-Method")
4800 (setq method
(split-string method
))
4802 ((equal (car method
) "sendmail")
4803 (message-send-mail-with-sendmail))
4804 ((equal (car method
) "smtp")
4806 (let ((smtpmail-smtp-server (nth 1 method
))
4807 (smtpmail-smtp-service (nth 2 method
))
4808 (smtpmail-smtp-user (or (nth 3 method
) smtpmail-smtp-user
)))
4809 (message-smtpmail-send-it)))
4811 (error "Unknown method %s" method
))))))
4813 (defun message-send-mail-with-sendmail ()
4814 "Send off the prepared buffer with sendmail."
4816 (let ((errbuf (if message-interactive
4817 (message-generate-new-buffer-clone-locals
4820 resend-to-addresses delimline
)
4823 (let ((case-fold-search t
))
4825 (message-narrow-to-headers)
4826 (setq resend-to-addresses
(message-fetch-field "resent-to")))
4827 ;; Change header-delimiter to be what sendmail expects.
4828 (goto-char (point-min))
4830 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4831 (replace-match "\n")
4833 (setq delimline
(point-marker))
4834 (run-hooks 'message-send-mail-hook
)
4835 ;; Insert an extra newline if we need it to work around
4836 ;; Sun's bug that swallows newlines.
4837 (goto-char (1+ delimline
))
4838 (when (eval message-mailer-swallows-blank-line
)
4840 (when message-interactive
4841 (with-current-buffer errbuf
4843 (let* ((default-directory "/")
4844 (coding-system-for-write message-send-coding-system
)
4846 'call-process-region
4848 (list (point-min) (point-max) sendmail-program
4849 nil errbuf nil
"-oi")
4850 message-sendmail-extra-arguments
4851 ;; Always specify who from,
4852 ;; since some systems have broken sendmails.
4853 ;; But some systems are more broken with -f, so
4854 ;; we'll let users override this.
4855 (and (null message-sendmail-f-is-evil
)
4856 (list "-f" (message-sendmail-envelope-from)))
4857 ;; These mean "report errors by mail"
4858 ;; and "deliver in background".
4859 (if (null message-interactive
) '("-oem" "-odb"))
4860 ;; Get the addresses from the message
4861 ;; unless this is a resend.
4862 ;; We must not do that for a resend
4863 ;; because we would find the original addresses.
4864 ;; For a resend, include the specific addresses.
4865 (if resend-to-addresses
4866 (list resend-to-addresses
)
4868 (unless (or (null cpr
) (and (numberp cpr
) (zerop cpr
)))
4870 (pop-to-buffer errbuf
)
4872 (error "Sending...failed with exit value %d" cpr
)))
4873 (when message-interactive
4874 (with-current-buffer errbuf
4875 (goto-char (point-min))
4876 (while (re-search-forward "\n+ *" nil t
)
4877 (replace-match "; "))
4878 (if (not (zerop (buffer-size)))
4879 (error "Sending...failed to %s"
4880 (buffer-string))))))
4881 (when (bufferp errbuf
)
4882 (kill-buffer errbuf
)))))
4884 (defun message-send-mail-with-qmail ()
4885 "Pass the prepared message buffer to qmail-inject.
4886 Refer to the documentation for the variable `message-send-mail-function'
4887 to find out how to use this."
4888 ;; replace the header delimiter with a blank line
4889 (goto-char (point-min))
4891 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4892 (replace-match "\n")
4893 (run-hooks 'message-send-mail-hook
)
4896 (let ((coding-system-for-write message-send-coding-system
))
4898 'call-process-region
(point-min) (point-max)
4899 message-qmail-inject-program nil nil nil
4900 ;; qmail-inject's default behavior is to look for addresses on the
4901 ;; command line; if there're none, it scans the headers.
4902 ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
4904 ;; in general, ALL of qmail-inject's defaults are perfect for simply
4905 ;; reading a formatted (i. e., at least a To: or Resent-To header)
4906 ;; message from stdin.
4908 ;; qmail also has the advantage of not having been raped by
4909 ;; various vendors, so we don't have to allow for that, either --
4910 ;; compare this with message-send-mail-with-sendmail and weep
4911 ;; for sendmail's lost innocence.
4913 ;; all this is way cool coz it lets us keep the arguments entirely
4914 ;; free for -inject-arguments -- a big win for the user and for us
4915 ;; since we don't have to play that double-guessing game and the user
4916 ;; gets full control (no gestapo'ish -f's, for instance). --sj
4917 (if (functionp message-qmail-inject-args
)
4918 (funcall message-qmail-inject-args
)
4919 message-qmail-inject-args
)))
4920 ;; qmail-inject doesn't say anything on it's stdout/stderr,
4921 ;; we have to look at the retval instead
4923 (100 (error "qmail-inject reported permanent failure"))
4924 (111 (error "qmail-inject reported transient failure"))
4925 ;; should never happen
4926 (t (error "qmail-inject reported unknown failure"))))
4928 (defvar mh-previous-window-config
)
4930 (defun message-send-mail-with-mh ()
4931 "Send the prepared message buffer with mh."
4932 (let ((mh-previous-window-config nil
)
4933 (name (mh-new-draft-name)))
4934 (setq buffer-file-name name
)
4935 ;; MH wants to generate these headers itself.
4936 (when message-mh-deletable-headers
4937 (let ((headers message-mh-deletable-headers
))
4939 (goto-char (point-min))
4940 (and (re-search-forward
4941 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
4942 (message-delete-line))
4944 (run-hooks 'message-send-mail-hook
)
4945 ;; Pass it on to mh.
4948 (defun message-smtpmail-send-it ()
4949 "Send the prepared message buffer with `smtpmail-send-it'.
4950 The only difference from `smtpmail-send-it' is that this command
4951 evaluates `message-send-mail-hook' just before sending a message.
4952 It is useful if your ISP requires the POP-before-SMTP
4953 authentication. See the Gnus manual for details."
4954 (run-hooks 'message-send-mail-hook
)
4955 ;; Change header-delimiter to be what smtpmail expects.
4956 (goto-char (point-min))
4957 (when (re-search-forward
4958 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4959 (replace-match "\n"))
4962 (defun message-send-mail-with-mailclient ()
4963 "Send the prepared message buffer with `mailclient-send-it'.
4964 The only difference from `mailclient-send-it' is that this
4965 command evaluates `message-send-mail-hook' just before sending a message."
4966 (run-hooks 'message-send-mail-hook
)
4967 (mailclient-send-it))
4969 (defun message-canlock-generate ()
4970 "Return a string that is non-trivial to guess.
4971 Do not use this for anything important, it is cryptographically weak."
4973 (let (sha1-maximum-internal-length)
4974 (sha1 (concat (message-unique-id)
4975 (format "%x%x%x" (random) (random) (random))
4976 (prin1-to-string (recent-keys))
4977 (prin1-to-string (garbage-collect))))))
4979 (defvar canlock-password
)
4980 (defvar canlock-password-for-verify
)
4982 (defun message-canlock-password ()
4983 "The password used by message for cancel locks.
4984 This is the value of `canlock-password', if that option is non-nil.
4985 Otherwise, generate and save a value for `canlock-password' first."
4987 (unless canlock-password
4988 (customize-save-variable 'canlock-password
(message-canlock-generate))
4989 (setq canlock-password-for-verify canlock-password
))
4992 (defun message-insert-canlock ()
4993 (when message-insert-canlock
4994 (message-canlock-password)
4995 (canlock-insert-header)))
4997 (autoload 'nnheader-get-report
"nnheader")
4999 (declare-function gnus-setup-posting-charset
"gnus-msg" (group))
5001 (defun message-send-news (&optional arg
)
5003 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*"))
5004 (case-fold-search nil
)
5005 (method (if (functionp message-post-method
)
5006 (funcall message-post-method arg
)
5007 message-post-method
))
5008 (newsgroups-field (save-restriction
5009 (message-narrow-to-headers-or-head)
5010 (message-fetch-field "Newsgroups")))
5011 (followup-field (save-restriction
5012 (message-narrow-to-headers-or-head)
5013 (message-fetch-field "Followup-To")))
5014 ;; BUG: We really need to get the charset for each name in the
5015 ;; Newsgroups and Followup-To lines to allow crossposting
5016 ;; between group names with incompatible character sets.
5017 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
5018 (group-field-charset
5019 (gnus-group-name-charset method newsgroups-field
))
5020 (followup-field-charset
5021 (gnus-group-name-charset method
(or followup-field
"")))
5022 (rfc2047-header-encoding-alist
5023 (append (when group-field-charset
5024 (list (cons "Newsgroups" group-field-charset
)))
5025 (when followup-field-charset
5026 (list (cons "Followup-To" followup-field-charset
)))
5027 rfc2047-header-encoding-alist
))
5028 (messbuf (current-buffer))
5029 (message-syntax-checks
5031 (listp message-syntax-checks
))
5032 (cons '(existing-newsgroups . disabled
)
5033 message-syntax-checks
)
5034 message-syntax-checks
))
5035 (message-this-is-news t
)
5036 (message-posting-charset
5037 (gnus-setup-posting-charset newsgroups-field
))
5039 (if (not (message-check-news-body-syntax))
5042 (message-narrow-to-headers)
5043 ;; Insert some headers.
5044 (message-generate-headers message-required-news-headers
)
5045 (message-insert-canlock)
5046 ;; Let the user do all of the above.
5047 (run-hooks 'message-header-hook
))
5048 ;; Note: This check will be disabled by the ".*" default value for
5049 ;; gnus-group-name-charset-group-alist. -- Pa 2001-10-07.
5050 (when (and group-field-charset
5051 (listp message-syntax-checks
))
5052 (setq message-syntax-checks
5053 (cons '(valid-newsgroups . disabled
)
5054 message-syntax-checks
)))
5055 (message-cleanup-headers)
5056 (if (not (let ((message-post-method method
))
5057 (message-check-news-syntax)))
5060 (with-current-buffer tembuf
5061 (buffer-disable-undo)
5063 ;; Avoid copying text props (except hard newlines).
5065 (with-current-buffer messbuf
5066 (mml-buffer-substring-no-properties-except-hard-newlines
5067 (point-min) (point-max))))
5068 (message-encode-message-body)
5069 ;; Remove some headers.
5071 (message-narrow-to-headers)
5072 ;; We (re)generate the Lines header.
5073 (when (memq 'Lines message-required-mail-headers
)
5074 (message-generate-headers '(Lines)))
5075 ;; Remove some headers.
5076 (message-remove-header message-ignored-news-headers t
)
5077 (let ((mail-parse-charset message-default-charset
))
5078 (mail-encode-encoded-word-buffer)))
5079 (goto-char (point-max))
5080 ;; require one newline at the end.
5081 (or (= (preceding-char) ?
\n)
5083 (let ((case-fold-search t
))
5084 ;; Remove the delimiter.
5085 (goto-char (point-min))
5087 (concat "^" (regexp-quote mail-header-separator
) "\n"))
5088 (replace-match "\n")
5090 (run-hooks 'message-send-news-hook
)
5091 (gnus-open-server method
)
5092 (message "Sending news via %s..." (gnus-server-string method
))
5093 (setq result
(let ((mail-header-separator ""))
5094 (gnus-request-post method
))))
5095 (kill-buffer tembuf
))
5096 (set-buffer messbuf
)
5098 (push 'news message-sent-message-via
)
5099 (message "Couldn't send message via news: %s"
5100 (nnheader-get-report (car method
)))
5104 ;;; Header generation & syntax checking.
5107 (defun message-check-element (type)
5108 "Return non-nil if this TYPE is not to be checked."
5109 (if (eq message-syntax-checks
'dont-check-for-anything-just-trust-me
)
5111 (let ((able (assq type message-syntax-checks
)))
5113 (eq (cdr able
) 'disabled
)))))
5115 (defun message-check-news-syntax ()
5116 "Check the syntax of the message."
5120 ;; We narrow to the headers and check them first.
5123 (message-narrow-to-headers)
5124 (message-check-news-header-syntax))))))
5126 (defun message-check-news-header-syntax ()
5128 ;; Check Newsgroups header.
5129 (message-check 'newsgroups
5130 (let ((group (message-fetch-field "newsgroups")))
5133 (not (string-match "\\`[ \t]*\\'" group
)))
5136 "The newsgroups field is empty or missing. Posting is denied.")))))
5137 ;; Check the Subject header.
5138 (message-check 'subject
5139 (let* ((case-fold-search t
)
5140 (subject (message-fetch-field "subject")))
5143 (not (string-match "\\`[ \t]*\\'" subject
)))
5146 "The subject field is empty or missing. Posting is denied.")))))
5147 ;; Check for commands in Subject.
5148 (message-check 'subject-cmsg
5149 (if (string-match "^cmsg " (message-fetch-field "subject"))
5151 "The control code \"cmsg\" is in the subject. Really post? ")
5153 ;; Check long header lines.
5154 (message-check 'long-header-lines
5158 (while (and (not found
)
5159 (re-search-forward "^\\([^ \t:]+\\): " nil t
))
5160 (if (> (- (point) (match-beginning 0)) 998)
5162 length
(- (point) (match-beginning 0)))
5163 (setq header
(match-string-no-properties 1)))
5166 (y-or-n-p (format "Your %s header is too long (%d). Really post? "
5169 ;; Check for multiple identical headers.
5170 (message-check 'multiple-headers
5172 (while (and (not found
)
5173 (re-search-forward "^[^ \t:]+: " nil t
))
5175 (or (re-search-forward
5180 (match-beginning 0) (- (match-end 0) 2))))
5185 (y-or-n-p (format "Multiple %s headers. Really post? " found
))
5187 ;; Check for Version and Sendsys.
5188 (message-check 'sendsys
5189 (if (re-search-forward "^Sendsys:\\|^Version:" nil t
)
5191 (format "The article contains a %s command. Really post? "
5192 (buffer-substring (match-beginning 0)
5193 (1- (match-end 0)))))
5195 ;; See whether we can shorten Followup-To.
5196 (message-check 'shorten-followup-to
5197 (let ((newsgroups (message-fetch-field "newsgroups"))
5198 (followup-to (message-fetch-field "followup-to"))
5200 (when (and newsgroups
5201 (string-match "," newsgroups
)
5206 (setq to
(completing-read
5207 "Followups to (default no Followup-To header): "
5210 (message-tokenize-header
5212 (goto-char (point-min))
5213 (insert "Followup-To: " to
"\n"))
5215 ;; Check "Shoot me".
5216 (message-check 'shoot
5217 (if (re-search-forward
5218 "Message-ID.*.i-did-not-set--mail-host-address--so-tickle-me" nil t
)
5219 (y-or-n-p "You appear to have a misconfigured system. Really post? ")
5221 ;; Check for Approved.
5222 (message-check 'approved
5223 (if (re-search-forward "^Approved:" nil t
)
5224 (y-or-n-p "The article contains an Approved header. Really post? ")
5226 ;; Check the Message-ID header.
5227 (message-check 'message-id
5228 (let* ((case-fold-search t
)
5229 (message-id (message-fetch-field "message-id" t
)))
5230 (or (not message-id
)
5231 ;; Is there an @ in the ID?
5232 (and (string-match "@" message-id
)
5233 ;; Is there a dot in the ID?
5234 (string-match "@[^.]*\\." message-id
)
5235 ;; Does the ID end with a dot?
5236 (not (string-match "\\.>" message-id
)))
5238 (format "The Message-ID looks strange: \"%s\". Really post? "
5240 ;; Check the Newsgroups & Followup-To headers.
5241 (message-check 'existing-newsgroups
5242 (let* ((case-fold-search t
)
5243 (newsgroups (message-fetch-field "newsgroups"))
5244 (followup-to (message-fetch-field "followup-to"))
5245 (groups (message-tokenize-header
5247 (concat newsgroups
"," followup-to
)
5249 (post-method (if (functionp message-post-method
)
5250 (funcall message-post-method
)
5251 message-post-method
))
5252 ;; KLUDGE to handle nnvirtual groups. Doing this right
5253 ;; would probably involve a new nnoo function.
5254 ;; -- Per Abrahamsen <abraham@dina.kvl.dk>, 2001-10-17.
5255 (method (if (and (consp post-method
)
5256 (eq (car post-method
) 'nnvirtual
)
5257 gnus-message-group-art
)
5258 (let ((group (car (nnvirtual-find-group-art
5259 (car gnus-message-group-art
)
5260 (cdr gnus-message-group-art
)))))
5261 (gnus-find-method-for-group group
))
5265 (gnus-group-name-decode
5266 (gnus-group-real-name n
)
5267 (gnus-group-name-charset method n
)))
5268 (gnus-groups-from-server method
)))
5271 (when (and (not (equal (car groups
) "poster"))
5272 (not (member (car groups
) known-groups
))
5273 (not (member (car groups
) errors
)))
5274 (push (car groups
) errors
))
5277 ;; Gnus is not running.
5278 ((or (not (and (boundp 'gnus-active-hashtb
)
5279 gnus-active-hashtb
))
5280 (not (boundp 'gnus-read-active-file
)))
5282 ;; We don't have all the group names.
5283 ((and (or (not gnus-read-active-file
)
5284 (eq gnus-read-active-file
'some
))
5288 "Really use %s possibly unknown group%s: %s? "
5289 (if (= (length errors
) 1) "this" "these")
5290 (if (= (length errors
) 1) "" "s")
5291 (mapconcat 'identity errors
", "))))
5292 ;; There were no errors.
5295 ;; There are unknown groups.
5299 "Really post to %s unknown group%s: %s? "
5300 (if (= (length errors
) 1) "this" "these")
5301 (if (= (length errors
) 1) "" "s")
5302 (mapconcat 'identity errors
", ")))))))
5303 ;; Check continuation headers.
5304 (message-check 'continuation-headers
5305 (goto-char (point-min))
5306 (let ((do-posting t
))
5307 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
5308 (goto-char (match-beginning 0))
5309 (if (y-or-n-p "Fix continuation lines? ")
5312 (unless (y-or-n-p "Send anyway? ")
5313 (setq do-posting nil
))))
5315 ;; Check the Newsgroups & Followup-To headers for syntax errors.
5316 (message-check 'valid-newsgroups
5317 (let ((case-fold-search t
)
5318 (headers '("Newsgroups" "Followup-To"))
5320 (while (and headers
(not error
))
5321 (when (setq header
(mail-fetch-field (car headers
)))
5325 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-+_&.a-zA-Z0-9]+\\)*\\'"
5330 (not (string-match "\\.\\'\\|\\.\\." g
)))
5331 (message-tokenize-header header
","))))
5338 (format "The %s header looks odd: \"%s\". Really post? "
5339 (car headers
) header
)))))
5340 (message-check 'repeated-newsgroups
5341 (let ((case-fold-search t
)
5342 (headers '("Newsgroups" "Followup-To"))
5343 header error groups group
)
5346 (when (setq header
(mail-fetch-field (pop headers
)))
5347 (setq groups
(message-tokenize-header header
","))
5348 (while (setq group
(pop groups
))
5349 (when (member group groups
)
5355 (format "Group %s is repeated in headers. Really post? " error
)))))
5356 ;; Check the From header.
5357 (message-check 'from
5358 (let* ((case-fold-search t
)
5359 (from (message-fetch-field "from"))
5363 (message "There is no From line. Posting is denied.")
5365 ((or (not (string-match
5367 (setq ad
(nth 1 (mail-extract-address-components
5368 from
))))) ;larsi@ifi
5369 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5370 (string-match "@\\." ad
) ;larsi@.ifi.uio
5371 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5372 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5373 (string-match "(.*).*(.*)" from
)) ;(lars) (lars)
5375 "Denied posting -- the From looks strange: \"%s\"." from
)
5377 ((let ((addresses (rfc822-addresses from
)))
5378 ;; `rfc822-addresses' returns a string if parsing fails.
5379 (while (and (consp addresses
)
5380 (not (eq (string-to-char (car addresses
)) ?\
()))
5381 (setq addresses
(cdr addresses
)))
5384 "Denied posting -- bad From address: \"%s\"." from
)
5387 ;; Check the Reply-To header.
5388 (message-check 'reply-to
5389 (let* ((case-fold-search t
)
5390 (reply-to (message-fetch-field "reply-to"))
5395 ((string-match "," reply-to
)
5397 (format "Multiple Reply-To addresses: \"%s\". Really post? "
5399 ((or (not (string-match
5401 (setq ad
(nth 1 (mail-extract-address-components
5402 reply-to
))))) ;larsi@ifi
5403 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5404 (string-match "@\\." ad
) ;larsi@.ifi.uio
5405 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5406 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5407 (string-match "(.*).*(.*)" reply-to
)) ;(lars) (lars)
5410 "The Reply-To looks strange: \"%s\". Really post? "
5414 (defun message-check-news-body-syntax ()
5416 ;; Check for long lines.
5417 (message-check 'long-lines
5418 (goto-char (point-min))
5420 (concat "^" (regexp-quote mail-header-separator
) "$"))
5424 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)")
5427 (< (- (point) p
) 80)))
5428 (zerop (forward-line 1))))
5432 "You have lines longer than 79 characters. Really post? ")))
5433 ;; Check whether the article is empty.
5434 (message-check 'empty
5435 (goto-char (point-min))
5437 (concat "^" (regexp-quote mail-header-separator
) "$"))
5440 (goto-char (point-max))
5441 (re-search-backward message-signature-separator nil t
)
5443 (or (re-search-backward "[^ \n\t]" b t
)
5444 (if (message-gnksa-enable-p 'empty-article
)
5445 (y-or-n-p "Empty article. Really post? ")
5446 (message "Denied posting -- Empty article.")
5448 ;; Check for control characters.
5449 (message-check 'control-chars
5450 (if (re-search-forward
5451 (mm-string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
5454 "The article contains control characters. Really post? ")
5456 ;; Check excessive size.
5457 (message-check 'size
5458 (if (> (buffer-size) 60000)
5460 (format "The article is %d octets long. Really post? "
5463 ;; Check whether any new text has been added.
5464 (message-check 'new-text
5466 (not message-checksum
)
5467 (not (eq (message-checksum) message-checksum
))
5468 (if (message-gnksa-enable-p 'quoted-text-only
)
5470 "It looks like no new text has been added. Really post? ")
5471 (message "Denied posting -- no new text has been added.")
5473 ;; Check the length of the signature.
5474 (message-check 'signature
5475 (let (sig-start sig-end
)
5476 (goto-char (point-max))
5477 (if (not (re-search-backward message-signature-separator nil t
))
5479 (setq sig-start
(1+ (point-at-eol)))
5481 (if (re-search-forward
5482 "<#/?\\(multipart\\|part\\|external\\|mml\\)" nil t
)
5483 (- (point-at-bol) 1)
5485 (if (>= (count-lines sig-start sig-end
) 5)
5486 (if (message-gnksa-enable-p 'signature
)
5488 (format "Signature is excessively long (%d lines). Really post? "
5489 (count-lines sig-start sig-end
)))
5490 (message "Denied posting -- Excessive signature.")
5493 ;; Ensure that text follows last quoted portion.
5494 (message-check 'quoting-style
5495 (goto-char (point-max))
5496 (let ((no-problem t
))
5497 (when (search-backward-regexp "^>[^\n]*\n" nil t
)
5498 (setq no-problem
(search-forward-regexp "^[ \t]*[^>\n]" nil t
)))
5501 (if (message-gnksa-enable-p 'quoted-text-only
)
5502 (y-or-n-p "Your text should follow quoted text. Really post? ")
5504 (goto-char (point-min))
5506 (concat "^" (regexp-quote mail-header-separator
) "$"))
5507 (if (search-forward-regexp "^[ \t]*[^>\n]" nil t
)
5508 (y-or-n-p "Your text should follow quoted text. Really post? ")
5509 (message "Denied posting -- only quoted text.")
5512 (defun message-checksum ()
5513 "Return a \"checksum\" for the current buffer."
5516 (goto-char (point-min))
5518 (concat "^" (regexp-quote mail-header-separator
) "$"))
5520 (when (not (looking-at "[ \t\n]"))
5521 (setq sum
(logxor (ash sum
1) (if (natnump sum
) 0 1)
5526 (defun message-do-fcc ()
5527 "Process Fcc headers in the current buffer."
5528 (let ((case-fold-search t
)
5529 (buf (current-buffer))
5531 (mml-externalize-attachments message-fcc-externalize-attachments
))
5534 (message-narrow-to-headers)
5535 (setq file
(message-fetch-field "fcc" t
)))
5537 (set-buffer (get-buffer-create " *message temp*"))
5539 (insert-buffer-substring buf
)
5540 (message-encode-message-body)
5542 (message-narrow-to-headers)
5543 (while (setq file
(message-fetch-field "fcc" t
))
5545 (message-remove-header "fcc" nil t
))
5546 (let ((mail-parse-charset message-default-charset
)
5547 (rfc2047-header-encoding-alist
5548 (cons '("Newsgroups" . default
)
5549 rfc2047-header-encoding-alist
)))
5550 (mail-encode-encoded-word-buffer)))
5551 (goto-char (point-min))
5552 (when (re-search-forward
5553 (concat "^" (regexp-quote mail-header-separator
) "$")
5555 (replace-match "" t t
))
5556 ;; Process FCC operations.
5558 (setq file
(pop list
))
5559 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file
)
5560 ;; Pipe the article to the program in question.
5561 (call-process-region (point-min) (point-max) shell-file-name
5562 nil nil nil shell-command-switch
5563 (match-string 1 file
))
5564 ;; Save the article.
5565 (setq file
(expand-file-name file
))
5566 (unless (file-exists-p (file-name-directory file
))
5567 (make-directory (file-name-directory file
) t
))
5568 (if (and message-fcc-handler-function
5569 (not (eq message-fcc-handler-function
'rmail-output
)))
5570 (funcall message-fcc-handler-function file
)
5571 ;; FIXME this option, rmail-output (also used if
5572 ;; message-fcc-handler-function is nil) is not
5573 ;; documented anywhere AFAICS. It should work in Emacs
5574 ;; 23; I suspect it does not work in Emacs 22.
5575 ;; FIXME I don't see the need for the two different cases here.
5576 ;; mail-use-rfc822 makes no difference (in Emacs 23),and
5577 ;; the third argument just controls \"Wrote file\" message.
5578 (if (and (file-readable-p file
) (mail-file-babyl-p file
))
5579 (rmail-output file
1 nil t
)
5580 (let ((mail-use-rfc822 t
))
5581 (rmail-output file
1 t t
))))))
5582 (kill-buffer (current-buffer))))))
5584 (defun message-output (filename)
5585 "Append this article to Unix/babyl mail file FILENAME."
5586 (if (or (and (file-readable-p filename
)
5587 (mail-file-babyl-p filename
))
5588 ;; gnus-output-to-mail does the wrong thing with live, mbox
5589 ;; Rmail buffers in Emacs 23.
5590 ;; http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597255
5591 (let ((buff (find-buffer-visiting filename
)))
5592 (and buff
(with-current-buffer buff
5593 (eq major-mode
'rmail-mode
)))))
5594 (gnus-output-to-rmail filename t
)
5595 (gnus-output-to-mail filename t
)))
5597 (defun message-cleanup-headers ()
5598 "Do various automatic cleanups of the headers."
5599 ;; Remove empty lines in the header.
5601 (message-narrow-to-headers)
5602 ;; Remove blank lines.
5603 (while (re-search-forward "^[ \t]*\n" nil t
)
5604 (replace-match "" t t
))
5606 ;; Correct Newsgroups and Followup-To headers: Change sequence of
5607 ;; spaces to comma and eliminate spaces around commas. Eliminate
5608 ;; embedded line breaks.
5609 (goto-char (point-min))
5610 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t
)
5614 (if (re-search-forward "^[^ \t]" nil t
)
5618 (goto-char (point-min))
5619 (while (re-search-forward "\n[ \t]+" nil t
)
5620 (replace-match " " t t
)) ;No line breaks (too confusing)
5621 (goto-char (point-min))
5622 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t
)
5623 (replace-match "," t t
))
5624 (goto-char (point-min))
5625 ;; Remove trailing commas.
5626 (when (re-search-forward ",+$" nil t
)
5627 (replace-match "" t t
))))))
5629 (defun message-make-date (&optional now
)
5630 "Make a valid data header.
5631 If NOW, use that time instead."
5632 (let ((system-time-locale "C"))
5633 (format-time-string "%a, %d %b %Y %T %z" now
)))
5635 (defun message-insert-expires (days)
5636 "Insert the Expires header. Expiry in DAYS days."
5637 (interactive "NExpire article in how many days? ")
5639 (message-position-on-field "Expires" "X-Draft-From")
5640 (insert (message-make-expires-date days
))))
5642 (defun message-make-expires-date (days)
5643 "Make date string for the Expires header. Expiry in DAYS days.
5645 In posting styles use `(\"Expires\" (make-expires-date 30))'."
5646 (let* ((cur (decode-time))
5647 (nday (+ days
(nth 3 cur
))))
5648 (setf (nth 3 cur
) nday
)
5649 (message-make-date (apply 'encode-time cur
))))
5651 (defun message-make-message-id ()
5652 "Make a unique Message-ID."
5653 (concat "<" (message-unique-id)
5654 (let ((psubject (save-excursion (message-fetch-field "subject")))
5656 (save-excursion (message-fetch-field "supersedes"))))
5658 (and message-reply-headers
5659 (mail-header-references message-reply-headers
)
5660 (mail-header-subject message-reply-headers
)
5663 (message-strip-subject-re
5664 (mail-header-subject message-reply-headers
))
5665 (message-strip-subject-re psubject
))))
5667 (string-match "_-_@" psupersedes
)))
5669 "@" (message-make-fqdn) ">"))
5671 (defvar message-unique-id-char nil
)
5673 ;; If you ever change this function, make sure the new version
5674 ;; cannot generate IDs that the old version could.
5675 ;; You might for example insert a "." somewhere (not next to another dot
5676 ;; or string boundary), or modify the "fsf" string.
5677 (defun message-unique-id ()
5678 ;; Don't use microseconds from (current-time), they may be unsupported.
5679 ;; Instead we use this randomly inited counter.
5680 (setq message-unique-id-char
5681 (%
(1+ (or message-unique-id-char
5682 (logand (random most-positive-fixnum
) (1- (lsh 1 20)))))
5683 ;; (current-time) returns 16-bit ints,
5684 ;; and 2^16*25 just fits into 4 digits i base 36.
5686 (let ((tm (current-time)))
5688 (if (or (eq system-type
'ms-dos
)
5689 ;; message-number-base36 doesn't handle bigints.
5690 (floatp (user-uid)))
5691 (let ((user (downcase (user-login-name))))
5692 (while (string-match "[^a-z0-9_]" user
)
5693 (aset user
(match-beginning 0) ?_
))
5695 (message-number-base36 (user-uid) -
1))
5696 (message-number-base36 (+ (car tm
)
5697 (lsh (% message-unique-id-char
25) 16)) 4)
5698 (message-number-base36 (+ (nth 1 tm
)
5699 (lsh (/ message-unique-id-char
25) 16)) 4)
5700 ;; Append a given name, because while the generated ID is unique
5701 ;; to this newsreader, other newsreaders might otherwise generate
5702 ;; the same ID via another algorithm.
5705 (defun message-number-base36 (num len
)
5710 (concat (message-number-base36 (/ num
36) (1- len
))
5711 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
5714 (defun message-make-organization ()
5715 "Make an Organization header."
5716 (let* ((organization
5717 (when message-user-organization
5718 (if (functionp message-user-organization
)
5719 (funcall message-user-organization
)
5720 message-user-organization
))))
5722 (mm-enable-multibyte)
5723 (cond ((stringp organization
)
5724 (insert organization
))
5725 ((and (eq t organization
)
5726 message-user-organization-file
5727 (file-exists-p message-user-organization-file
))
5728 (insert-file-contents message-user-organization-file
)))
5729 (goto-char (point-min))
5730 (while (re-search-forward "[\t\n]+" nil t
)
5731 (replace-match "" t t
))
5732 (unless (zerop (buffer-size))
5735 (defun message-make-lines ()
5736 "Count the number of lines and return numeric string."
5741 (int-to-string (count-lines (point) (point-max))))))
5743 (defun message-make-references ()
5744 "Return the References header for this message."
5745 (when message-reply-headers
5746 (let ((message-id (mail-header-id message-reply-headers
))
5747 (references (mail-header-references message-reply-headers
)))
5748 (if (or references message-id
)
5749 (concat (or references
"") (and references
" ")
5753 (defun message-make-in-reply-to ()
5754 "Return the In-Reply-To header for this message."
5755 (when message-reply-headers
5756 (let ((from (mail-header-from message-reply-headers
))
5757 (date (mail-header-date message-reply-headers
))
5758 (msg-id (mail-header-id message-reply-headers
)))
5760 (let ((name (mail-extract-address-components from
)))
5762 msg-id
(if msg-id
" (")
5764 (if (string-match "[^\000-\177]" (car name
))
5765 ;; Quote a string containing non-ASCII characters.
5766 ;; It will make the RFC2047 encoder cause an error
5767 ;; if there are special characters.
5768 (mm-with-multibyte-buffer
5770 (goto-char (point-min))
5771 (while (search-forward "\"" nil t
)
5774 (zerop (%
(skip-chars-backward "\\\\") 2))
5775 (goto-char (match-beginning 0)))
5778 ;; Those quotes will be removed by the RFC2047 encoder.
5779 (concat "\"" (buffer-string) "\""))
5783 (if (or (not date
) (string= date
""))
5784 "(unknown date)" date
)
5785 "\"" (if msg-id
")")))))))
5787 (defun message-make-distribution ()
5788 "Make a Distribution header."
5789 (let ((orig-distribution (message-fetch-reply-field "distribution")))
5790 (cond ((functionp message-distribution-function
)
5791 (funcall message-distribution-function
))
5792 (t orig-distribution
))))
5794 (defun message-make-expires ()
5795 "Return an Expires header based on `message-expires'."
5796 (let ((current (current-time))
5797 (future (* 1.0 message-expires
60 60 24)))
5798 ;; Add the future to current.
5799 (setcar current
(+ (car current
) (round (/ future
(expt 2 16)))))
5800 (setcar (cdr current
) (+ (nth 1 current
) (%
(round future
) (expt 2 16))))
5801 (message-make-date current
)))
5803 (defun message-make-path ()
5805 (let ((login-name (user-login-name)))
5806 (cond ((null message-user-path
)
5807 (concat (system-name) "!" login-name
))
5808 ((stringp message-user-path
)
5809 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
5810 (concat message-user-path
"!" login-name
))
5813 (defun message-make-from (&optional name address
)
5814 "Make a From header."
5815 (let* ((style message-from-style
)
5816 (login (or address
(message-make-address)))
5818 (and (boundp 'user-full-name
)
5821 (when (string= fullname
"&")
5822 (setq fullname
(user-login-name)))
5824 (mm-enable-multibyte)
5827 (equal fullname
""))
5829 ((or (eq style
'angles
)
5830 (and (not (eq style
'parens
))
5831 ;; Use angles if no quoting is needed, or if parens would
5832 ;; need quoting too.
5833 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname
))
5834 (let ((tmp (concat fullname nil
)))
5835 (while (string-match "([^()]*)" tmp
)
5836 (aset tmp
(match-beginning 0) ?-
)
5837 (aset tmp
(1- (match-end 0)) ?-
))
5838 (string-match "[\\()]" tmp
)))))
5840 (goto-char (point-min))
5841 ;; Look for a character that cannot appear unquoted
5842 ;; according to RFC 822.
5843 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil
1)
5844 ;; Quote fullname, escaping specials.
5845 (goto-char (point-min))
5847 (while (re-search-forward "[\"\\]" nil
1)
5848 (replace-match "\\\\\\&" t
))
5850 (insert " <" login
">"))
5851 (t ; 'parens or default
5853 (let ((fullname-start (point)))
5855 (goto-char fullname-start
)
5856 ;; RFC 822 says \ and nonmatching parentheses
5857 ;; must be escaped in comments.
5858 ;; Escape every instance of ()\ ...
5859 (while (re-search-forward "[()\\]" nil
1)
5860 (replace-match "\\\\\\&" t
))
5861 ;; ... then undo escaping of matching parentheses,
5862 ;; including matching nested parentheses.
5863 (goto-char fullname-start
)
5864 (while (re-search-forward
5865 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
5867 (replace-match "\\1(\\3)" t
)
5868 (goto-char fullname-start
)))
5872 (defun message-make-sender ()
5873 "Return the \"real\" user address.
5874 This function tries to ignore all user modifications, and
5875 give as trustworthy answer as possible."
5876 (concat (user-login-name) "@" (system-name)))
5878 (defun message-make-address ()
5879 "Make the address of the user."
5880 (or (message-user-mail-address)
5881 (concat (user-login-name) "@" (message-make-domain))))
5883 (defun message-user-mail-address ()
5884 "Return the pertinent part of `user-mail-address'."
5885 (when (and user-mail-address
5886 (string-match "@.*\\." user-mail-address
))
5887 (if (string-match " " user-mail-address
)
5888 (nth 1 (mail-extract-address-components user-mail-address
))
5889 user-mail-address
)))
5891 (defun message-sendmail-envelope-from ()
5892 "Return the envelope from."
5893 (cond ((eq message-sendmail-envelope-from
'header
)
5894 (nth 1 (mail-extract-address-components
5895 (message-fetch-field "from"))))
5896 ((stringp message-sendmail-envelope-from
)
5897 message-sendmail-envelope-from
)
5899 (message-make-address))))
5901 (defun message-make-fqdn ()
5902 "Return user's fully qualified domain name."
5903 (let* ((sysname (system-name))
5904 (user-mail (message-user-mail-address))
5907 (string-match "@\\(.*\\)\\'" user-mail
))
5908 (match-string 1 user-mail
)))
5909 (case-fold-search t
))
5911 ((and message-user-fqdn
5912 (stringp message-user-fqdn
)
5913 (string-match message-valid-fqdn-regexp message-user-fqdn
)
5914 (not (string-match message-bogus-system-names message-user-fqdn
)))
5915 ;; `message-user-fqdn' seems to be valid
5917 ((and (string-match message-valid-fqdn-regexp sysname
)
5918 (not (string-match message-bogus-system-names sysname
)))
5919 ;; `system-name' returned the right result.
5921 ;; Try `mail-host-address'.
5922 ((and (boundp 'mail-host-address
)
5923 (stringp mail-host-address
)
5924 (string-match message-valid-fqdn-regexp mail-host-address
)
5925 (not (string-match message-bogus-system-names mail-host-address
)))
5927 ;; We try `user-mail-address' as a backup.
5929 (stringp user-domain
)
5930 (string-match message-valid-fqdn-regexp user-domain
)
5931 (not (string-match message-bogus-system-names user-domain
)))
5933 ;; Default to this bogus thing.
5936 ".i-did-not-set--mail-host-address--so-tickle-me")))))
5938 (defun message-make-domain ()
5939 "Return the domain name."
5940 (or mail-host-address
5941 (message-make-fqdn)))
5943 (defun message-to-list-only ()
5944 "Send a message to the list only.
5945 Remove all addresses but the list address from To and Cc headers."
5947 (let ((listaddr (message-make-mail-followup-to t
)))
5950 (message-remove-header "to")
5951 (message-remove-header "cc")
5952 (message-position-on-field "To" "X-Draft-From")
5953 (insert listaddr
)))))
5955 (defun message-make-mail-followup-to (&optional only-show-subscribed
)
5956 "Return the Mail-Followup-To header.
5957 If passed the optional argument ONLY-SHOW-SUBSCRIBED only return the
5958 subscribed address (and not the additional To and Cc header contents)."
5959 (let* ((case-fold-search t
)
5960 (to (message-fetch-field "To"))
5961 (cc (message-fetch-field "cc"))
5962 (msg-recipients (concat to
(and to cc
", ") cc
))
5964 (mapcar 'mail-strip-quoted-names
5965 (message-tokenize-header msg-recipients
)))
5967 (if message-subscribed-address-file
5968 (let (begin end item re
)
5971 (insert-file-contents message-subscribed-address-file
)
5973 (setq begin
(point))
5976 (if (bolp) (setq end
(1- end
)))
5977 (setq item
(regexp-quote (buffer-substring begin end
)))
5978 (if re
(setq re
(concat re
"\\|" item
))
5979 (setq re
(concat "\\`\\(" item
))))
5980 (and re
(list (concat re
"\\)\\'"))))))))
5981 (mft-regexps (apply 'append message-subscribed-regexps
5982 (mapcar 'regexp-quote
5983 message-subscribed-addresses
)
5986 message-subscribed-address-functions
))))
5989 (loop for recipient in recipients
5990 when
(loop for regexp in mft-regexps
5991 when
(string-match regexp recipient
) return t
)
5994 (if only-show-subscribed
5996 msg-recipients
))))))
5998 (defun message-idna-to-ascii-rhs-1 (header)
5999 "Interactively potentially IDNA encode domain names in HEADER."
6000 (let ((field (message-fetch-field header
))
6004 (mm-delete-duplicates
6005 (mapcar (lambda (rhs) (or (cadr (split-string rhs
"@")) ""))
6011 (mail-extract-address-components field t
))))))
6012 ;; Note that `rhs' will be "" if the address does not have
6013 ;; the domain part, i.e., if it is a local user's address.
6014 (setq ace
(if (string-match "\\`[[:ascii:]]*\\'" rhs
)
6016 (downcase (idna-to-ascii rhs
))))
6017 (when (and (not (equal rhs ace
))
6018 (or (not (eq message-use-idna
'ask
))
6019 (y-or-n-p (format "Replace %s with %s in %s:? "
6021 (goto-char (point-min))
6022 (while (re-search-forward (concat "^" header
":") nil t
)
6023 (message-narrow-to-field)
6024 (while (search-forward (concat "@" rhs
) nil t
)
6025 (replace-match (concat "@" ace
) t t
))
6026 (goto-char (point-max))
6029 (defun message-idna-to-ascii-rhs ()
6030 "Possibly IDNA encode non-ASCII domain names in From:, To: and Cc: headers.
6031 See `message-idna-encode'."
6033 (when message-use-idna
6036 ;; `message-narrow-to-head' that recognizes only the first empty
6037 ;; line as the message header separator used to be used here.
6038 ;; However, since there is the "--text follows this line--" line
6039 ;; normally, it failed in narrowing to the headers and potentially
6040 ;; caused the IDNA encoding on lines that look like headers in
6041 ;; the message body.
6042 (message-narrow-to-headers-or-head)
6043 (message-idna-to-ascii-rhs-1 "From")
6044 (message-idna-to-ascii-rhs-1 "To")
6045 (message-idna-to-ascii-rhs-1 "Reply-To")
6046 (message-idna-to-ascii-rhs-1 "Mail-Reply-To")
6047 (message-idna-to-ascii-rhs-1 "Mail-Followup-To")
6048 (message-idna-to-ascii-rhs-1 "Cc")))))
6052 (defvar Organization
)
6057 (defvar In-Reply-To
)
6060 (defvar Distribution
)
6065 (defun message-generate-headers (headers)
6066 "Prepare article HEADERS.
6067 Headers already prepared in the buffer are not modified."
6068 (setq headers
(append headers message-required-headers
))
6070 (message-narrow-to-headers)
6071 (let* ((Date (message-make-date))
6072 (Message-ID (message-make-message-id))
6073 (Organization (message-make-organization))
6074 (From (message-make-from))
6075 (Path (message-make-path))
6078 (In-Reply-To (message-make-in-reply-to))
6079 (References (message-make-references))
6081 (Distribution (message-make-distribution))
6082 (Lines (message-make-lines))
6083 (User-Agent message-newsreader
)
6084 (Expires (message-make-expires))
6085 (case-fold-search t
)
6087 header value elem header-string
)
6088 ;; First we remove any old generated headers.
6089 (let ((headers message-deletable-headers
))
6090 (unless (buffer-modified-p)
6091 (setq headers
(delq 'Message-ID
(copy-sequence headers
))))
6093 (goto-char (point-min))
6094 (and (re-search-forward
6095 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
6096 (get-text-property (1+ (match-beginning 0)) 'message-deletable
)
6097 (message-delete-line))
6099 ;; Go through all the required headers and see if they are in the
6100 ;; articles already. If they are not, or are empty, they are
6101 ;; inserted automatically - except for Subject, Newsgroups and
6104 (goto-char (point-min))
6105 (setq elem
(pop headers
))
6107 (if (eq (car elem
) 'optional
)
6108 (setq header
(cdr elem
)
6110 (setq header
(car elem
)))
6112 (setq header-string
(if (stringp header
)
6114 (symbol-name header
)))
6115 (when (or (not (re-search-forward
6117 (regexp-quote (downcase header-string
))
6121 ;; The header was found. We insert a space after the
6122 ;; colon, if there is none.
6123 (if (/= (char-after) ?
) (insert " ") (forward-char 1))
6124 ;; Find out whether the header is empty.
6125 (looking-at "[ \t]*\n[^ \t]")))
6126 ;; So we find out what value we should insert.
6130 (eq (car elem
) 'optional
)
6131 (not (member header-string message-inserted-headers
)))
6132 ;; This is an optional header. If the cdr of this
6133 ;; is something that is nil, then we do not insert
6135 (setq header
(cdr elem
))
6136 (or (and (functionp (cdr elem
))
6137 (funcall (cdr elem
)))
6138 (and (boundp (cdr elem
))
6139 (symbol-value (cdr elem
)))))
6141 ;; The element is a cons. Either the cdr is a
6142 ;; string to be inserted verbatim, or it is a
6143 ;; function, and we insert the value returned from
6145 (or (and (stringp (cdr elem
))
6147 (and (functionp (cdr elem
))
6148 (funcall (cdr elem
)))))
6149 ((and (boundp header
)
6150 (symbol-value header
))
6151 ;; The element is a symbol. We insert the value
6152 ;; of this symbol, if any.
6153 (symbol-value header
))
6154 ((not (message-check-element
6155 (intern (downcase (symbol-name header
)))))
6156 ;; We couldn't generate a value for this header,
6157 ;; so we just ask the user.
6158 (read-from-minibuffer
6159 (format "Empty header for %s; enter value: " header
)))))
6160 ;; Finally insert the header.
6162 (not (equal value
"")))
6166 ;; This header didn't exist, so we insert it.
6167 (goto-char (point-max))
6169 (cdr (assq header message-header-format-alist
))))
6171 (funcall formatter header value
)
6172 (insert header-string
": " value
))
6173 (push header-string message-inserted-headers
)
6174 (goto-char (message-fill-field))
6175 ;; We check whether the value was ended by a
6176 ;; newline. If not, we insert one.
6180 ;; The value of this header was empty, so we clear
6181 ;; totally and insert the new value.
6182 (delete-region (point) (point-at-eol))
6183 ;; If the header is optional, and the header was
6184 ;; empty, we can't insert it anyway.
6186 (push header-string message-inserted-headers
)
6188 (message-fill-field)))
6189 ;; Add the deletable property to the headers that require it.
6190 (and (memq header message-deletable-headers
)
6191 (progn (beginning-of-line) (looking-at "[^:]+: "))
6192 (add-text-properties
6193 (point) (match-end 0)
6194 '(message-deletable t face italic
) (current-buffer)))))))
6195 ;; Insert new Sender if the From is strange.
6196 (let ((from (message-fetch-field "from"))
6197 (sender (message-fetch-field "sender"))
6198 (secure-sender (message-make-sender)))
6200 (not (message-check-element 'sender
))
6203 (cadr (mail-extract-address-components from
)))
6204 (downcase secure-sender
)))
6209 (cadr (mail-extract-address-components sender
)))
6210 (downcase secure-sender
)))))
6211 (goto-char (point-min))
6212 ;; Rename any old Sender headers to Original-Sender.
6213 (when (re-search-forward "^\\(Original-\\)*Sender:" nil t
)
6215 (insert "Original-")
6216 (beginning-of-line))
6217 (when (or (message-news-p)
6218 (string-match "@.+\\.." secure-sender
))
6219 (insert "Sender: " secure-sender
"\n"))))
6221 (message-idna-to-ascii-rhs))))
6223 (defun message-insert-courtesy-copy (message)
6224 "Insert a courtesy message in mail copies of combined messages."
6228 (message-narrow-to-headers)
6229 (when (setq newsgroups
(message-fetch-field "newsgroups"))
6230 (goto-char (point-max))
6231 (insert "Posted-To: " newsgroups
"\n")))
6235 ((string-match "%s" message
)
6236 (insert (format message newsgroups
)))
6238 (insert message
)))))))
6241 ;;; Setting up a message buffer
6244 (defun message-skip-to-next-address ()
6245 (let ((end (save-excursion
6246 (message-next-header)
6249 (when (looking-at ",")
6251 (while (and (not (= (point) end
))
6252 (or (not (eq char ?
,))
6254 (skip-chars-forward "^,\"" end
)
6255 (when (eq (setq char
(following-char)) ?
\")
6256 (setq quoted
(not quoted
)))
6257 (unless (= (point) end
)
6259 (skip-chars-forward " \t\n")))
6261 (defun message-split-line ()
6262 "Split current line, moving portion beyond point vertically down.
6263 If the current line has `message-yank-prefix', insert it on the new line."
6266 (split-line message-yank-prefix
) ;; Emacs 22.1+ supports arg.
6270 (defun message-insert-header (header value
)
6271 (insert (capitalize (symbol-name header
))
6273 (if (consp value
) (car value
) value
)))
6275 (defun message-field-name ()
6277 (goto-char (point-min))
6278 (when (looking-at "\\([^:]+\\):")
6279 (intern (capitalize (match-string 1))))))
6281 (defun message-fill-field ()
6284 (message-narrow-to-field)
6285 (let ((field-name (message-field-name)))
6286 (funcall (or (cadr (assq field-name message-field-fillers
))
6287 'message-fill-field-general
)))
6290 (defun message-fill-field-address ()
6293 (message-skip-to-next-address)
6299 (when (and (> (current-column) 78)
6303 (delete-char (- (skip-chars-backward " \t")))
6305 (setq last
(point)))
6306 (forward-line end
)))
6308 (defun message-fill-field-general ()
6309 (let ((begin (point))
6312 (while (and (search-forward "\n" nil t
)
6314 (replace-match " " t t
))
6315 (fill-region-as-paragraph begin
(point-max))
6316 ;; Tapdance around looong Message-IDs.
6318 (when (looking-at "[ \t]*$")
6319 (message-delete-line))
6321 (search-forward ":" nil t
)
6322 (when (looking-at "\n[ \t]+")
6323 (replace-match " " t t
))
6324 (goto-char (point-max))))
6326 (defun message-shorten-1 (list cut surplus
)
6327 "Cut SURPLUS elements out of LIST, beginning with CUTth one."
6328 (setcdr (nthcdr (- cut
2) list
)
6329 (nthcdr (+ (- cut
2) surplus
1) list
)))
6331 (defun message-shorten-references (header references
)
6332 "Trim REFERENCES to be 21 Message-ID long or less, and fold them.
6333 When sending via news, also check that the REFERENCES are less
6334 than 988 characters long, and if they are not, trim them until
6336 ;; 21 is the number suggested by USAGE.
6343 (goto-char (point-min))
6344 ;; Cons a list of valid references. GNKSA says we must not include MIDs
6345 ;; with whitespace or missing brackets (7.a "Does not propagate broken
6346 ;; Message-IDs in original References").
6347 (while (re-search-forward "<[^ <]+@[^ <]+>" nil t
)
6348 (push (match-string 0) refs
))
6349 (setq refs
(nreverse refs
)
6350 count
(length refs
)))
6352 ;; If the list has more than MAXCOUNT elements, trim it by
6353 ;; removing the CUTth element and the required number of
6354 ;; elements that follow.
6355 (when (> count maxcount
)
6356 (let ((surplus (- count maxcount
)))
6357 (message-shorten-1 refs cut surplus
)
6358 (decf count surplus
)))
6360 ;; When sending via news, make sure the total folded length will
6361 ;; be less than 998 characters. This is to cater to broken INN
6362 ;; 2.3 which counts the total number of characters in a header
6363 ;; rather than the physical line length of each line, as it should.
6365 ;; This hack should be removed when it's believed than INN 2.3 is
6366 ;; no longer widely used.
6368 ;; At this point the headers have not been generated, thus we use
6369 ;; message-this-is-news directly.
6370 (when message-this-is-news
6373 (message-insert-header
6374 header
(mapconcat #'identity refs
" "))
6376 (message-shorten-1 refs cut
1)))
6377 ;; Finally, collect the references back into a string and insert
6378 ;; it into the buffer.
6379 (message-insert-header header
(mapconcat #'identity refs
" "))))
6381 (defun message-position-point ()
6382 "Move point to where the user probably wants to find it."
6383 (message-narrow-to-headers)
6385 ((re-search-forward "^[^:]+:[ \t]*$" nil t
)
6386 (search-backward ":" )
6389 (if (eq (char-after) ?
)
6393 (goto-char (point-max))
6396 (unless (looking-at "$")
6400 (defcustom message-beginning-of-line t
6401 "Whether \\<message-mode-map>\\[message-beginning-of-line]\
6402 goes to beginning of header values."
6404 :group
'message-buffers
6405 :link
'(custom-manual "(message)Movement")
6408 (defvar visual-line-mode
)
6409 (declare-function beginning-of-visual-line
"simple" (&optional n
))
6411 (defun message-beginning-of-line (&optional n
)
6412 "Move point to beginning of header value or to beginning of line.
6413 The prefix argument N is passed directly to `beginning-of-line'.
6415 This command is identical to `beginning-of-line' if point is
6416 outside the message header or if the option `message-beginning-of-line'
6419 If point is in the message header and on a (non-continued) header
6420 line, move point to the beginning of the header value or the beginning of line,
6421 whichever is closer. If point is already at beginning of line, move point to
6422 beginning of header value. Therefore, repeated calls will toggle point
6423 between beginning of field and beginning of line."
6425 (let ((zrs 'zmacs-region-stays
))
6426 (when (and (featurep 'xemacs
) (interactive-p) (boundp zrs
))
6428 (if (and message-beginning-of-line
6429 (message-point-in-header-p))
6430 (let* ((here (point))
6431 (bol (progn (beginning-of-line n
) (point)))
6432 (eol (point-at-eol))
6433 (eoh (re-search-forward ": *" eol t
)))
6435 (if (and eoh
(or (< eoh here
) (= bol here
)))
6437 (if (and (boundp 'visual-line-mode
) visual-line-mode
)
6438 (beginning-of-visual-line n
)
6439 (beginning-of-line n
))))
6441 (defun message-buffer-name (type &optional to group
)
6442 "Return a new (unique) buffer name based on TYPE and TO."
6444 ;; Generate a new buffer name The Message Way.
6445 ((memq message-generate-new-buffers
'(unique t
))
6446 (generate-new-buffer-name
6450 (or (car (mail-extract-address-components to
))
6453 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6455 ;; Check whether `message-generate-new-buffers' is a function,
6456 ;; and if so, call it.
6457 ((functionp message-generate-new-buffers
)
6458 (funcall message-generate-new-buffers type to group
))
6459 ((eq message-generate-new-buffers
'unsent
)
6460 (generate-new-buffer-name
6461 (concat "*unsent " type
6464 (or (car (mail-extract-address-components to
))
6467 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6469 ;; Search for the existing message buffer with the specified name.
6471 (let* ((new (if (eq message-generate-new-buffers
'standard
)
6472 (generate-new-buffer-name (concat "*" type
" message*"))
6473 (let ((message-generate-new-buffers 'unique
))
6474 (message-buffer-name type to group
))))
6475 (regexp (concat "\\`"
6477 (if (string-match "<[0-9]+>\\'" new
)
6478 (substring new
0 (match-beginning 0))
6480 "\\(?:<\\([0-9]+\\)>\\)?\\'"))
6481 (case-fold-search nil
))
6488 (when (and (string-match regexp
(setq b
(buffer-name b
)))
6489 (eq (with-current-buffer b major-mode
)
6491 (cons (string-to-number (or (match-string 1 b
) "1"))
6494 'car-less-than-car
)))
6497 (defun message-pop-to-buffer (name &optional switch-function
)
6498 "Pop to buffer NAME, and warn if it already exists and is modified."
6499 (let ((buffer (get-buffer name
)))
6501 (buffer-name buffer
))
6502 (let ((window (get-buffer-window buffer
0)))
6504 ;; Raise the frame already displaying the message buffer.
6506 (gnus-select-frame-set-input-focus (window-frame window
))
6507 (select-window window
))
6508 (funcall (or switch-function
#'pop-to-buffer
) buffer
)
6509 (set-buffer buffer
))
6510 (when (and (buffer-modified-p)
6513 "Message already being composed; erase? ")
6515 (error "Message being composed")))
6516 (funcall (or switch-function
6517 (if (fboundp #'pop-to-buffer-same-window
)
6518 #'pop-to-buffer-same-window
6525 (defun message-do-send-housekeeping ()
6526 "Kill old message buffers."
6527 ;; We might have sent this buffer already. Delete it from the
6529 (setq message-buffer-list
(delq (current-buffer) message-buffer-list
))
6530 (while (and message-max-buffers
6532 (>= (length message-buffer-list
) message-max-buffers
))
6533 ;; Kill the oldest buffer -- unless it has been changed.
6534 (let ((buffer (pop message-buffer-list
)))
6535 (when (and (buffer-name buffer
)
6536 (not (buffer-modified-p buffer
)))
6537 (kill-buffer buffer
))))
6538 ;; Rename the buffer.
6539 (if message-send-rename-function
6540 (funcall message-send-rename-function
)
6541 (message-default-send-rename-function))
6542 ;; Push the current buffer onto the list.
6543 (when message-max-buffers
6544 (setq message-buffer-list
6545 (nconc message-buffer-list
(list (current-buffer))))))
6547 (defun message-default-send-rename-function ()
6548 ;; Note: mail-abbrevs of XEmacs renames buffer name behind Gnus.
6550 "\\`\\*\\(sent \\|unsent \\)?\\(.+\\)\\*[^\\*]*\\|\\`mail to "
6552 (let ((name (match-string 2 (buffer-name)))
6554 (if (not (or (null name
)
6555 (string-equal name
"mail")
6556 (string-equal name
"posting")))
6557 (setq name
(concat "*sent " name
"*"))
6558 (message-narrow-to-headers)
6559 (setq to
(message-fetch-field "to"))
6560 (setq group
(message-fetch-field "newsgroups"))
6564 (to (concat "*sent mail to "
6565 (or (car (mail-extract-address-components to
))
6567 ((and group
(not (string= group
"")))
6568 (concat "*sent posting on " group
"*"))
6569 (t "*sent mail*"))))
6570 (unless (string-equal name
(buffer-name))
6571 (rename-buffer name t
)))))
6573 (defun message-mail-user-agent ()
6575 ((not message-mail-user-agent
) nil
)
6576 ((eq message-mail-user-agent t
) mail-user-agent
)
6577 (t message-mail-user-agent
))))
6578 (if (memq mua
'(message-user-agent gnus-user-agent
))
6582 ;; YANK-ACTION, if non-nil, can be a buffer or a yank action of the
6583 ;; form (FUNCTION . ARGS).
6584 (defun message-setup (headers &optional yank-action actions
6585 continue switch-function return-action
)
6586 (let ((mua (message-mail-user-agent))
6588 (if (not (and message-this-is-mail mua
))
6589 (message-setup-1 headers yank-action actions return-action
)
6590 (setq headers
(copy-sequence headers
))
6591 (setq field
(assq 'Subject headers
))
6593 (setq subject
(cdr field
))
6594 (setq headers
(delq field headers
)))
6595 (setq field
(assq 'To headers
))
6597 (setq to
(cdr field
))
6598 (setq headers
(delq field headers
)))
6599 (let ((mail-user-agent mua
))
6600 (compose-mail to subject
6601 (mapcar (lambda (item)
6603 (format "%s" (car item
))
6606 continue switch-function
6607 (if (bufferp yank-action
)
6608 (list 'insert-buffer yank-action
)
6612 (defun message-headers-to-generate (headers included-headers excluded-headers
)
6613 "Return a list that includes all headers from HEADERS.
6614 If INCLUDED-HEADERS is a list, just include those headers. If it is
6615 t, include all headers. In any case, headers from EXCLUDED-HEADERS
6619 (dolist (header headers
)
6620 (setq header-name
(cond
6621 ((and (consp header
)
6622 (eq (car header
) 'optional
))
6623 ;; On the form (optional . Header)
6626 ;; On the form (Header . function)
6631 (when (and (not (memq header-name excluded-headers
))
6632 (or (eq included-headers t
)
6633 (memq header-name included-headers
)))
6634 (push header result
)))
6637 (defun message-setup-1 (headers &optional yank-action actions return-action
)
6638 (dolist (action actions
)
6640 (add-to-list 'message-send-actions
6641 `(apply ',(car action
) ',(cdr action
)))))
6642 (setq message-return-action return-action
)
6643 (setq message-reply-buffer
6644 (if (and (consp yank-action
)
6645 (eq (car yank-action
) 'insert-buffer
))
6648 (goto-char (point-min))
6649 ;; Insert all the headers.
6652 (alist message-header-format-alist
))
6654 (unless (assq (caar h
) message-header-format-alist
)
6655 (push (list (caar h
)) alist
))
6659 (delete-region (point) (progn (forward-line -
1) (point)))
6660 (when message-default-headers
6662 (if (functionp message-default-headers
)
6663 (funcall message-default-headers
)
6664 message-default-headers
))
6665 (or (bolp) (insert ?
\n)))
6666 (insert (concat mail-header-separator
"\n"))
6668 ;; If a crash happens while replying, the auto-save file would *not* have a
6669 ;; `References:' header if `message-generate-headers-first' was nil.
6670 ;; Therefore, always generate it first.
6671 (let ((message-generate-headers-first
6672 (if (eq message-generate-headers-first t
)
6674 (append message-generate-headers-first
'(References)))))
6675 (when (message-news-p)
6676 (when message-default-news-headers
6677 (insert message-default-news-headers
)
6678 (or (bolp) (insert ?
\n)))
6679 (message-generate-headers
6680 (message-headers-to-generate
6681 (append message-required-news-headers
6682 message-required-headers
)
6683 message-generate-headers-first
6685 (when (message-mail-p)
6686 (when message-default-mail-headers
6687 (insert message-default-mail-headers
)
6688 (or (bolp) (insert ?
\n)))
6689 (message-generate-headers
6690 (message-headers-to-generate
6691 (append message-required-mail-headers
6692 message-required-headers
)
6693 message-generate-headers-first
6694 '(Lines Subject
)))))
6695 (run-hooks 'message-signature-setup-hook
)
6696 (message-insert-signature)
6698 (message-narrow-to-headers)
6699 (run-hooks 'message-header-setup-hook
))
6700 (setq buffer-undo-list nil
)
6701 (when message-generate-hashcash
6702 ;; Generate hashcash headers for recipients already known
6703 (mail-add-payment-async))
6704 ;; Gnus posting styles are applied via buffer-local `message-setup-hook'
6706 (run-hooks 'message-setup-hook
)
6707 ;; Do this last to give it precedence over posting styles, etc.
6708 (when (message-mail-p)
6710 (message-narrow-to-headers)
6711 (if message-alternative-emails
6712 (message-use-alternative-email-as-from))))
6713 (message-position-point)
6714 ;; Allow correct handling of `message-checksum' in `message-yank-original':
6715 (set-buffer-modified-p nil
)
6717 ;; rmail-start-mail expects message-mail to return t (Bug#9392)
6720 (defun message-set-auto-save-file-name ()
6721 "Associate the message buffer with a file in the drafts directory."
6722 (when message-auto-save-directory
6723 (unless (file-directory-p
6724 (directory-file-name message-auto-save-directory
))
6725 (make-directory message-auto-save-directory t
))
6727 (setq message-draft-article
6728 (nndraft-request-associate-buffer "drafts"))
6730 ;; If Gnus were alive, draft messages would be saved in the drafts folder.
6731 ;; But Gnus is not alive, so arrange to save the draft message in a
6732 ;; regular file in message-auto-save-directory. Append a unique
6733 ;; time-based suffix to the filename to allow multiple drafts to be saved
6734 ;; simultaneously without overwriting each other (which mimics the
6735 ;; functionality of the Gnus drafts folder).
6736 (setq buffer-file-name
(expand-file-name
6738 (if (memq system-type
6739 '(ms-dos windows-nt cygwin
))
6742 (format-time-string "-%Y%m%d-%H%M%S"))
6743 message-auto-save-directory
))
6744 (setq buffer-auto-save-file-name
(make-auto-save-file-name)))
6745 (clear-visited-file-modtime)
6746 (setq buffer-file-coding-system message-draft-coding-system
)))
6748 (defun message-disassociate-draft ()
6749 "Disassociate the message buffer from the drafts directory."
6750 (when message-draft-article
6751 (nndraft-request-expire-articles
6752 (list message-draft-article
) "drafts" nil t
)))
6754 (defun message-insert-headers ()
6755 "Generate the headers for the article."
6759 (message-narrow-to-headers)
6760 (when (message-news-p)
6761 (message-generate-headers
6764 (copy-sequence message-required-news-headers
)))))
6765 (when (message-mail-p)
6766 (message-generate-headers
6769 (copy-sequence message-required-mail-headers
))))))))
6774 ;;; Commands for interfacing with message
6778 (defun message-mail (&optional to subject other-headers continue
6779 switch-function yank-action send-actions
6780 return-action
&rest ignored
)
6781 "Start editing a mail message to be sent.
6782 OTHER-HEADERS is an alist of header/value pairs. CONTINUE says whether
6783 to continue editing a message already being composed. SWITCH-FUNCTION
6784 is a function used to switch to and display the mail buffer."
6786 (let ((message-this-is-mail t
))
6787 (unless (message-mail-user-agent)
6788 (message-pop-to-buffer
6789 ;; Search for the existing message buffer if `continue' is non-nil.
6790 (let ((message-generate-new-buffers
6791 (when (or (not continue
)
6792 (eq message-generate-new-buffers
'standard
)
6793 (functionp message-generate-new-buffers
))
6794 message-generate-new-buffers
)))
6795 (message-buffer-name "mail" to
))
6799 `((To .
,(or to
"")) (Subject .
,(or subject
"")))
6800 ;; C-h f compose-mail says that headers should be specified as
6801 ;; (string . value); however all the rest of message expects
6802 ;; headers to be symbols, not strings (eg message-header-format-alist).
6803 ;; http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html
6804 ;; We need to convert any string input, eg from rmail-start-mail.
6805 (dolist (h other-headers other-headers
)
6806 (if (stringp (car h
)) (setcar h
(intern (capitalize (car h
)))))))
6807 yank-action send-actions continue switch-function
6811 (defun message-news (&optional newsgroups subject
)
6812 "Start editing a news article to be sent."
6814 (let ((message-this-is-news t
))
6815 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
))
6816 (message-setup `((Newsgroups .
,(or newsgroups
""))
6817 (Subject .
,(or subject
""))))))
6819 (defun message-alter-recipients-discard-bogus-full-name (addrcell)
6820 "Discard mail address in full names.
6821 When the full name in reply headers contains the mail
6822 address (e.g. \"foo@bar <foo@bar>\"), discard full name.
6823 ADDRCELL is a cons cell where the car is the mail address and the
6824 cdr is the complete address (full name and mail address)."
6825 (if (string-match (concat (regexp-quote (car addrcell
)) ".*"
6826 (regexp-quote (car addrcell
)))
6828 (cons (car addrcell
) (car addrcell
))
6831 (defcustom message-alter-recipients-function nil
6832 "Function called to allow alteration of reply header structures.
6833 It is called in `message-get-reply-headers' for each recipient.
6834 The function is called with one parameter, a cons cell ..."
6835 :type
'(choice (const :tag
"None" nil
)
6836 (const :tag
"Discard bogus full name"
6837 message-alter-recipients-discard-bogus-full-name
)
6839 :version
"23.1" ;; No Gnus
6840 :group
'message-headers
)
6842 (defun message-get-reply-headers (wide &optional to-address address-headers
)
6843 (let (follow-to mct never-mct to cc author mft recipients extra
)
6844 ;; Find all relevant headers we need.
6846 (message-narrow-to-headers-or-head)
6847 ;; Gmane renames "To". Look at "Original-To", too, if it is present in
6848 ;; message-header-synonyms.
6849 (setq to
(or (message-fetch-field "to")
6850 (and (loop for synonym in message-header-synonyms
6851 when
(memq 'Original-To synonym
)
6853 (message-fetch-field "original-to")))
6854 cc
(message-fetch-field "cc")
6855 extra
(when message-extra-wide-headers
6856 (mapconcat 'identity
6857 (mapcar 'message-fetch-field
6858 message-extra-wide-headers
)
6860 mct
(message-fetch-field "mail-copies-to")
6861 author
(or (message-fetch-field "mail-reply-to")
6862 (message-fetch-field "reply-to"))
6863 mft
(and message-use-mail-followup-to
6864 (message-fetch-field "mail-followup-to")))
6865 ;; Make sure this message goes to the author if this is a wide
6866 ;; reply, since Reply-To address may be a list address a mailing
6867 ;; list server added.
6868 (when (and wide author
)
6869 (setq cc
(concat author
", " cc
)))
6870 (when (or wide
(not author
))
6871 (setq author
(or (message-fetch-field "from") ""))))
6873 ;; Handle special values of Mail-Copies-To.
6875 (cond ((or (equal (downcase mct
) "never")
6876 (equal (downcase mct
) "nobody"))
6879 ((or (equal (downcase mct
) "always")
6880 (equal (downcase mct
) "poster"))
6881 (setq mct author
))))
6884 ;; Build (textual) list of new recipient addresses.
6887 (setq recipients
(concat ", " to-address
))
6888 ;; If the author explicitly asked for a copy, we don't deny it to them.
6889 (if mct
(setq recipients
(concat recipients
", " mct
))))
6891 (setq recipients
(concat ", " author
)))
6893 (dolist (header address-headers
)
6894 (let ((value (message-fetch-field header
)))
6896 (setq recipients
(concat recipients
", " value
))))))
6898 (string-match "[^ \t,]" mft
)
6899 (or (not (eq message-use-mail-followup-to
'ask
))
6900 (message-y-or-n-p "Obey Mail-Followup-To? " t
"\
6901 You should normally obey the Mail-Followup-To: header. In this
6902 article, it has the value of
6906 which directs your response to " (if (string-match "," mft
)
6907 "the specified addresses"
6908 "that address only") ".
6910 Most commonly, Mail-Followup-To is used by a mailing list poster to
6911 express that responses should be sent to just the list, and not the
6914 If a message is posted to several mailing lists, Mail-Followup-To may
6915 also be used to direct the following discussion to one list only,
6916 because discussions that are spread over several lists tend to be
6917 fragmented and very difficult to follow.
6919 Also, some source/announcement lists are not intended for discussion;
6920 responses here are directed to other addresses.
6922 You may customize the variable `message-use-mail-followup-to', if you
6923 want to get rid of this query permanently.")))
6924 (setq recipients
(concat ", " mft
)))
6926 (setq recipients
(if never-mct
"" (concat ", " author
)))
6927 (if to
(setq recipients
(concat recipients
", " to
)))
6928 (if cc
(setq recipients
(concat recipients
", " cc
)))
6929 (if extra
(setq recipients
(concat recipients
", " extra
)))
6930 (if mct
(setq recipients
(concat recipients
", " mct
)))))
6931 (if (>= (length recipients
) 2)
6932 ;; Strip the leading ", ".
6933 (setq recipients
(substring recipients
2)))
6934 ;; Squeeze whitespace.
6935 (while (string-match "[ \t][ \t]+" recipients
)
6936 (setq recipients
(replace-match " " t t recipients
)))
6937 ;; Remove addresses that match `mail-dont-reply-to-names'.
6938 (let ((mail-dont-reply-to-names (message-dont-reply-to-names)))
6939 (setq recipients
(mail-dont-reply-to recipients
)))
6940 ;; Perhaps "Mail-Copies-To: never" removed the only address?
6941 (if (string-equal recipients
"")
6942 (setq recipients author
))
6943 ;; Convert string to a list of (("foo@bar" . "Name <Foo@BAR>") ...).
6947 (if message-alter-recipients-function
6948 (funcall message-alter-recipients-function
6949 (cons (downcase (mail-strip-quoted-names addr
))
6951 (cons (downcase (mail-strip-quoted-names addr
)) addr
)))
6952 (message-tokenize-header recipients
)))
6953 ;; Remove all duplicates.
6954 (let ((s recipients
))
6956 (let ((address (car (pop s
))))
6957 (while (assoc address s
)
6958 (setq recipients
(delq (assoc address s
) recipients
)
6959 s
(delq (assoc address s
) s
))))))
6961 ;; Remove hierarchical lists that are contained within each other,
6962 ;; if message-hierarchical-addresses is defined.
6963 (when message-hierarchical-addresses
6964 (let ((plain-addrs (mapcar 'car recipients
))
6967 (setq subaddrs
(assoc (car plain-addrs
)
6968 message-hierarchical-addresses
)
6969 plain-addrs
(cdr plain-addrs
))
6971 (setq subaddrs
(cdr subaddrs
))
6973 (setq recip
(assoc (car subaddrs
) recipients
)
6974 subaddrs
(cdr subaddrs
))
6976 (setq recipients
(delq recip recipients
))))))))
6978 (setq recipients
(message-prune-recipients recipients
))
6980 ;; Build the header alist. Allow the user to be asked whether
6981 ;; or not to reply to all recipients in a wide reply.
6982 (setq follow-to
(list (cons 'To
(cdr (pop recipients
)))))
6983 (when (and recipients
6984 (or (not message-wide-reply-confirm-recipients
)
6985 (y-or-n-p "Reply to all recipients? ")))
6986 (setq recipients
(mapconcat
6987 (lambda (addr) (cdr addr
)) recipients
", "))
6988 (if (string-match "^ +" recipients
)
6989 (setq recipients
(substring recipients
(match-end 0))))
6990 (push (cons 'Cc recipients
) follow-to
)))
6993 (defun message-prune-recipients (recipients)
6994 (dolist (rule message-prune-recipient-rules
)
6995 (let ((match (car rule
))
6998 (dolist (recipient recipients
)
6999 (setq address
(car recipient
))
7000 (when (string-match match address
)
7001 (setq dup-match
(replace-match (cadr rule
) nil nil address
))
7002 (dolist (recipient recipients
)
7003 ;; Don't delete the address that triggered this.
7004 (when (and (not (eq address
(car recipient
)))
7005 (string-match dup-match
(car recipient
)))
7006 (setq recipients
(delq recipient recipients
))))))))
7009 (defcustom message-simplify-subject-functions
7010 '(message-strip-list-identifiers
7011 message-strip-subject-re
7012 message-strip-subject-trailing-was
7013 message-strip-subject-encoded-words
)
7014 "List of functions taking a string argument that simplify subjects.
7015 The functions are applied when replying to a message.
7017 Useful functions to put in this list include:
7018 `message-strip-list-identifiers', `message-strip-subject-re',
7019 `message-strip-subject-trailing-was', and
7020 `message-strip-subject-encoded-words'."
7021 :version
"22.1" ;; Gnus 5.10.9
7022 :group
'message-various
7023 :type
'(repeat function
))
7025 (defun message-simplify-subject (subject &optional functions
)
7026 "Return simplified SUBJECT."
7029 (setq functions message-simplify-subject-functions
))
7030 (when (and (memq 'message-strip-list-identifiers functions
)
7031 gnus-list-identifiers
)
7032 (setq subject
(message-strip-list-identifiers subject
)))
7033 (when (memq 'message-strip-subject-re functions
)
7034 (setq subject
(concat "Re: " (message-strip-subject-re subject
))))
7035 (when (and (memq 'message-strip-subject-trailing-was functions
)
7036 message-subject-trailing-was-query
)
7037 (setq subject
(message-strip-subject-trailing-was subject
)))
7038 (when (memq 'message-strip-subject-encoded-words functions
)
7039 (setq subject
(message-strip-subject-encoded-words subject
)))
7043 (defun message-reply (&optional to-address wide switch-function
)
7044 "Start editing a reply to the article in the current buffer."
7046 (require 'gnus-sum
) ; for gnus-list-identifiers
7047 (let ((cur (current-buffer))
7049 references message-id follow-to
7050 (inhibit-point-motion-hooks t
)
7051 (message-this-is-mail t
)
7054 (message-narrow-to-head-1)
7055 ;; Allow customizations to have their say.
7057 ;; This is a regular reply.
7058 (when (functionp message-reply-to-function
)
7060 (setq follow-to
(funcall message-reply-to-function
))))
7061 ;; This is a followup.
7062 (when (functionp message-wide-reply-to-function
)
7065 (funcall message-wide-reply-to-function
)))))
7066 (setq message-id
(message-fetch-field "message-id" t
)
7067 references
(message-fetch-field "references")
7068 date
(message-fetch-field "date")
7069 from
(or (message-fetch-field "from") "nobody")
7070 subject
(or (message-fetch-field "subject") "none"))
7072 ;; Strip list identifiers, "Re: ", and "was:"
7073 (setq subject
(message-simplify-subject subject
))
7075 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
7076 (string-match "<[^>]+>" gnus-warning
))
7077 (setq message-id
(match-string 0 gnus-warning
)))
7080 (setq follow-to
(message-get-reply-headers wide to-address
))))
7083 `((Subject .
,subject
)
7085 (unless (message-mail-user-agent)
7086 (message-pop-to-buffer
7087 (message-buffer-name
7088 (if wide
"wide reply" "reply") from
7089 (if wide to-address nil
))
7091 (setq message-reply-headers
7092 (vector 0 (cdr (assq 'Subject headers
))
7093 from date message-id references
0 0 ""))
7094 (message-setup headers cur
))))
7097 (defun message-wide-reply (&optional to-address
)
7098 "Make a \"wide\" reply to the message in the current buffer."
7100 (message-reply to-address t
))
7103 (defun message-followup (&optional to-newsgroups
)
7104 "Follow up to the message in the current buffer.
7105 If TO-NEWSGROUPS, use that as the new Newsgroups line."
7107 (require 'gnus-sum
) ; for gnus-list-identifiers
7108 (let ((cur (current-buffer))
7109 from subject date reply-to mrt mct
7110 references message-id follow-to
7111 (inhibit-point-motion-hooks t
)
7112 (message-this-is-news t
)
7113 followup-to distribution newsgroups gnus-warning posted-to
)
7116 (goto-char (point-min))
7117 (if (search-forward "\n\n" nil t
)
7120 (when (functionp message-followup-to-function
)
7122 (funcall message-followup-to-function
)))
7123 (setq from
(message-fetch-field "from")
7124 date
(message-fetch-field "date")
7125 subject
(or (message-fetch-field "subject") "none")
7126 references
(message-fetch-field "references")
7127 message-id
(message-fetch-field "message-id" t
)
7128 followup-to
(message-fetch-field "followup-to")
7129 newsgroups
(message-fetch-field "newsgroups")
7130 posted-to
(message-fetch-field "posted-to")
7131 reply-to
(message-fetch-field "reply-to")
7132 mrt
(message-fetch-field "mail-reply-to")
7133 distribution
(message-fetch-field "distribution")
7134 mct
(message-fetch-field "mail-copies-to"))
7135 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
7136 (string-match "<[^>]+>" gnus-warning
))
7137 (setq message-id
(match-string 0 gnus-warning
)))
7138 ;; Remove bogus distribution.
7139 (when (and (stringp distribution
)
7140 (let ((case-fold-search t
))
7141 (string-match "world" distribution
)))
7142 (setq distribution nil
))
7143 ;; Strip list identifiers, "Re: ", and "was:"
7144 (setq subject
(message-simplify-subject subject
))
7147 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups
))
7149 (setq message-reply-headers
7150 (vector 0 subject from date message-id references
0 0 ""))
7153 `((Subject .
,subject
)
7156 (list (cons 'Newsgroups to-newsgroups
)))
7157 (follow-to follow-to
)
7158 ((and followup-to message-use-followup-to
)
7161 ((equal (downcase followup-to
) "poster")
7162 (if (or (eq message-use-followup-to
'use
)
7163 (message-y-or-n-p "Obey Followup-To: poster? " t
"\
7164 You should normally obey the Followup-To: header.
7166 `Followup-To: poster' sends your response via e-mail instead of news.
7168 A typical situation where `Followup-To: poster' is used is when the poster
7169 does not read the newsgroup, so he wouldn't see any replies sent to it.
7171 You may customize the variable `message-use-followup-to', if you
7172 want to get rid of this query permanently."))
7174 (setq message-this-is-news nil
)
7175 (cons 'To
(or mrt reply-to from
"")))
7176 (cons 'Newsgroups newsgroups
)))
7178 (if (or (equal followup-to newsgroups
)
7179 (not (eq message-use-followup-to
'ask
))
7181 (concat "Obey Followup-To: " followup-to
"? ") t
"\
7182 You should normally obey the Followup-To: header.
7184 `Followup-To: " followup-to
"'
7185 directs your response to " (if (string-match "," followup-to
)
7186 "the specified newsgroups"
7187 "that newsgroup only") ".
7189 If a message is posted to several newsgroups, Followup-To is often
7190 used to direct the following discussion to one newsgroup only,
7191 because discussions that are spread over several newsgroup tend to
7192 be fragmented and very difficult to follow.
7194 Also, some source/announcement newsgroups are not intended for discussion;
7195 responses here are directed to other newsgroups.
7197 You may customize the variable `message-use-followup-to', if you
7198 want to get rid of this query permanently."))
7199 (cons 'Newsgroups followup-to
)
7200 (cons 'Newsgroups newsgroups
))))))
7202 `((Newsgroups .
,posted-to
)))
7204 `((Newsgroups .
,newsgroups
))))
7205 ,@(and distribution
(list (cons 'Distribution distribution
)))
7207 (not (or (equal (downcase mct
) "never")
7208 (equal (downcase mct
) "nobody"))))
7209 (list (cons 'Cc
(if (or (equal (downcase mct
) "always")
7210 (equal (downcase mct
) "poster"))
7211 (or mrt reply-to from
"")
7216 (defun message-is-yours-p ()
7217 "Non-nil means current article is yours.
7218 If you have added `cancel-messages' to `message-shoot-gnksa-feet', all articles
7219 are yours except those that have Cancel-Lock header not belonging to you.
7220 Instead of shooting GNKSA feet, you should modify `message-alternative-emails'
7221 regexp to match all of yours addresses."
7222 ;; Canlock-logic as suggested by Per Abrahamsen
7223 ;; <abraham@dina.kvl.dk>
7225 ;; IF article has cancel-lock THEN
7226 ;; IF we can verify it THEN
7229 ;; error: cancellock: article is not yours
7231 ;; Use old rules, comparing sender...
7234 (message-narrow-to-head-1)
7235 (if (and (message-fetch-field "Cancel-Lock")
7236 (message-gnksa-enable-p 'canlock-verify
))
7237 (if (null (canlock-verify))
7239 (error "Failed to verify Cancel-lock: This article is not yours"))
7242 (message-gnksa-enable-p 'cancel-messages
)
7243 (and (setq sender
(message-fetch-field "sender"))
7244 (string-equal (downcase sender
)
7245 (downcase (message-make-sender))))
7246 ;; Email address in From field equals to our address
7247 (and (setq from
(message-fetch-field "from"))
7249 (downcase (car (mail-header-parse-address from
)))
7250 (downcase (car (mail-header-parse-address
7251 (message-make-from))))))
7252 ;; Email address in From field matches
7253 ;; 'message-alternative-emails' regexp
7255 message-alternative-emails
7257 message-alternative-emails
7258 (car (mail-header-parse-address from
))))))))))
7261 (defun message-cancel-news (&optional arg
)
7262 "Cancel an article you posted.
7263 If ARG, allow editing of the cancellation message."
7265 (unless (message-news-p)
7266 (error "This is not a news article; canceling is impossible"))
7267 (let (from newsgroups message-id distribution buf
)
7269 ;; Get header info from original article.
7271 (message-narrow-to-head-1)
7272 (setq from
(message-fetch-field "from")
7273 newsgroups
(message-fetch-field "newsgroups")
7274 message-id
(message-fetch-field "message-id" t
)
7275 distribution
(message-fetch-field "distribution")))
7276 ;; Make sure that this article was written by the user.
7277 (unless (message-is-yours-p)
7278 (error "This article is not yours"))
7279 (when (yes-or-no-p "Do you really want to cancel this article? ")
7280 ;; Make control message.
7283 (setq buf
(set-buffer (get-buffer-create " *message cancel*"))))
7285 (insert "Newsgroups: " newsgroups
"\n"
7287 "Subject: cancel " message-id
"\n"
7288 "Control: cancel " message-id
"\n"
7290 (concat "Distribution: " distribution
"\n")
7292 mail-header-separator
"\n"
7293 message-cancel-message
)
7294 (run-hooks 'message-cancel-hook
)
7296 (message "Canceling your article...")
7297 (if (let ((message-syntax-checks
7298 'dont-check-for-anything-just-trust-me
))
7299 (funcall message-send-news-function
))
7300 (message "Canceling your article...done"))
7301 (kill-buffer buf
))))))
7304 (defun message-supersede ()
7305 "Start composing a message to supersede the current message.
7306 This is done simply by taking the old article and adding a Supersedes
7307 header line with the old Message-ID."
7309 (let ((cur (current-buffer)))
7310 ;; Check whether the user owns the article that is to be superseded.
7311 (unless (message-is-yours-p)
7312 (error "This article is not yours"))
7313 ;; Get a normal message buffer.
7314 (message-pop-to-buffer (message-buffer-name "supersede"))
7315 (insert-buffer-substring cur
)
7317 (message-narrow-to-head-1)
7318 ;; Remove unwanted headers.
7319 (when message-ignored-supersedes-headers
7320 (message-remove-header message-ignored-supersedes-headers t
))
7321 (goto-char (point-min))
7322 (if (not (re-search-forward "^Message-ID: " nil t
))
7323 (error "No Message-ID in this article")
7324 (replace-match "Supersedes: " t t
))
7325 (goto-char (point-max))
7326 (insert mail-header-separator
)
7331 (defun message-recover ()
7332 "Reread contents of current buffer from its last auto-save file."
7334 (let ((file-name (make-auto-save-file-name)))
7335 (cond ((save-window-excursion
7336 (with-output-to-temp-buffer "*Directory*"
7337 (with-current-buffer standard-output
7338 (fundamental-mode)) ; for Emacs 20.4+
7339 (buffer-disable-undo standard-output
)
7340 (let ((default-directory "/"))
7342 "ls" nil standard-output nil
"-l" file-name
)))
7343 (yes-or-no-p (format "Recover auto save file %s? " file-name
)))
7344 (let ((buffer-read-only nil
))
7346 (insert-file-contents file-name nil
)))
7347 (t (error "message-recover canceled")))))
7349 ;;; Washing Subject:
7351 (defun message-wash-subject (subject)
7352 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT.
7353 Previous forwarders, repliers, etc. may add it."
7356 (goto-char (point-min))
7357 ;; strip Re/Fwd stuff off the beginning
7358 (while (re-search-forward
7359 "\\([Rr][Ee]:\\|[Ff][Ww][Dd]\\(\\[[0-9]*\\]\\)?:\\|[Ff][Ww]:\\)" nil t
)
7362 ;; and gnus-style forwards [foo@bar.com] subject
7363 (goto-char (point-min))
7364 (while (re-search-forward "\\[[^ \t]*\\(@\\|\\.\\)[^ \t]*\\]" nil t
)
7368 (goto-char (point-max))
7369 (while (re-search-backward "([Ff][Ww][Dd])" nil t
)
7372 ;; and finally, any whitespace that was left-over
7373 (goto-char (point-min))
7374 (while (re-search-forward "^[ \t]+" nil t
)
7376 (goto-char (point-max))
7377 (while (re-search-backward "[ \t]+$" nil t
)
7382 ;;; Forwarding messages.
7384 (defvar message-forward-decoded-p nil
7385 "Non-nil means the original message is decoded.")
7387 (defun message-forward-subject-name-subject (subject)
7388 "Generate a SUBJECT for a forwarded message.
7389 The form is: [Source] Subject, where if the original message was mail,
7390 Source is the name of the sender, and if the original message was
7391 news, Source is the list of newsgroups is was posted to."
7392 (let* ((group (message-fetch-field "newsgroups"))
7393 (from (message-fetch-field "from"))
7396 (gnus-group-decoded-name group
)
7398 (car (gnus-extract-address-components from
))
7399 (cadr (gnus-extract-address-components from
))))
7402 (if message-forward-decoded-p
7404 (mail-decode-encoded-word-string prefix
))
7407 (defun message-forward-subject-author-subject (subject)
7408 "Generate a SUBJECT for a forwarded message.
7409 The form is: [Source] Subject, where if the original message was mail,
7410 Source is the sender, and if the original message was news, Source is
7411 the list of newsgroups is was posted to."
7412 (let* ((group (message-fetch-field "newsgroups"))
7415 (gnus-group-decoded-name group
)
7416 (or (message-fetch-field "from")
7419 (if message-forward-decoded-p
7421 (mail-decode-encoded-word-string prefix
))
7424 (defun message-forward-subject-fwd (subject)
7425 "Generate a SUBJECT for a forwarded message.
7426 The form is: Fwd: Subject, where Subject is the original subject of
7428 (if (string-match "^Fwd: " subject
)
7430 (concat "Fwd: " subject
)))
7432 (defun message-make-forward-subject ()
7433 "Return a Subject header suitable for the message in the current buffer."
7436 (message-narrow-to-head-1)
7437 (let ((funcs message-make-forward-subject-function
)
7438 (subject (message-fetch-field "Subject")))
7441 (if message-forward-decoded-p
7443 (mail-decode-encoded-word-string subject
))
7445 (when message-wash-forwarded-subjects
7446 (setq subject
(message-wash-subject subject
)))
7447 ;; Make sure funcs is a list.
7450 (setq funcs
(list funcs
)))
7451 ;; Apply funcs in order, passing subject generated by previous
7452 ;; func to the next one.
7453 (dolist (func funcs
)
7454 (when (functionp func
)
7455 (setq subject
(funcall func subject
))))
7458 (defvar gnus-article-decoded-p
)
7462 (defun message-forward (&optional news digest
)
7463 "Forward the current message via mail.
7464 Optional NEWS will use news to forward instead of mail.
7465 Optional DIGEST will use digest to forward."
7467 (let* ((cur (current-buffer))
7468 (message-forward-decoded-p
7469 (if (local-variable-p 'gnus-article-decoded-p
(current-buffer))
7470 gnus-article-decoded-p
;; In an article buffer.
7471 message-forward-decoded-p
))
7472 (subject (message-make-forward-subject)))
7474 (message-news nil subject
)
7475 (message-mail nil subject
))
7476 (message-forward-make-body cur digest
)))
7478 (defun message-forward-make-body-plain (forward-buffer)
7480 "\n-------------------- Start of forwarded message --------------------\n")
7482 (contents (with-current-buffer forward-buffer
(buffer-string)))
7484 (unless (featurep 'xemacs
)
7485 (unless (mm-multibyte-string-p contents
)
7486 (error "Attempt to insert unibyte string from the buffer \"%s\"\
7487 to the multibyte buffer \"%s\""
7488 (if (bufferp forward-buffer
)
7489 (buffer-name forward-buffer
)
7492 (insert (mm-with-multibyte-buffer
7495 (goto-char (point-min))
7496 (when (looking-at "From ")
7497 (replace-match "X-From-Line: "))
7499 (unless (bolp) (insert "\n"))
7502 "-------------------- End of forwarded message --------------------\n")
7503 (message-remove-ignored-headers b e
)))
7505 (defun message-remove-ignored-headers (b e
)
7506 (when (or message-forward-ignored-headers
7507 message-forward-included-headers
)
7509 (narrow-to-region b e
)
7511 (narrow-to-region (point)
7512 (or (search-forward "\n\n" nil t
) (point)))
7513 (when message-forward-ignored-headers
7514 (let ((ignored (if (stringp message-forward-ignored-headers
)
7515 (list message-forward-ignored-headers
)
7516 message-forward-ignored-headers
)))
7517 (dolist (elem ignored
)
7518 (message-remove-header elem t
))))
7519 (when message-forward-included-headers
7520 (message-remove-header
7521 (if (listp message-forward-included-headers
)
7522 (regexp-opt message-forward-included-headers
)
7523 message-forward-included-headers
)
7526 (defun message-forward-make-body-mime (forward-buffer &optional beg end
)
7528 (insert "\n\n<#part type=message/rfc822 disposition=inline raw=t>\n")
7530 (narrow-to-region (point) (point))
7531 (insert-buffer-substring forward-buffer beg end
)
7532 (mml-quote-region (point-min) (point-max))
7533 (goto-char (point-min))
7534 (when (looking-at "From ")
7535 (replace-match "X-From-Line: "))
7536 (goto-char (point-max)))
7537 (insert "<#/part>\n")
7538 ;; Consider there is no illegible text.
7539 (add-text-properties
7541 `(no-illegible-text t rear-nonsticky t start-open t
))))
7543 (defun message-forward-make-body-mml (forward-buffer)
7544 (insert "\n\n<#mml type=message/rfc822 disposition=inline>\n")
7545 (let ((b (point)) e
)
7546 (if (not message-forward-decoded-p
)
7547 (let ((contents (with-current-buffer forward-buffer
(buffer-string))))
7548 (unless (featurep 'xemacs
)
7549 (unless (mm-multibyte-string-p contents
)
7550 (error "Attempt to insert unibyte string from the buffer \"%s\"\
7551 to the multibyte buffer \"%s\""
7552 (if (bufferp forward-buffer
)
7553 (buffer-name forward-buffer
)
7556 (insert (mm-with-multibyte-buffer
7559 (goto-char (point-min))
7560 (when (looking-at "From ")
7561 (replace-match "X-From-Line: "))
7564 (narrow-to-region (point) (point))
7565 (mml-insert-buffer forward-buffer
)
7566 (goto-char (point-min))
7567 (when (looking-at "From ")
7568 (replace-match "X-From-Line: "))
7569 (goto-char (point-max))))
7571 (insert "<#/mml>\n")
7572 (when (not message-forward-decoded-p
)
7573 (message-remove-ignored-headers b e
))))
7575 (defun message-forward-make-body-digest-plain (forward-buffer)
7577 "\n-------------------- Start of forwarded message --------------------\n")
7578 (mml-insert-buffer forward-buffer
)
7580 "\n-------------------- End of forwarded message --------------------\n"))
7582 (defun message-forward-make-body-digest-mime (forward-buffer)
7583 (insert "\n<#multipart type=digest>\n")
7584 (let ((b (point)) e
)
7585 (insert-buffer-substring forward-buffer
)
7587 (insert "<#/multipart>\n")
7589 (narrow-to-region b e
)
7591 (narrow-to-region (point)
7592 (or (search-forward "\n\n" nil t
) (point)))
7593 (delete-region (point-min) (point-max)))))
7595 (defun message-forward-make-body-digest (forward-buffer)
7596 (if message-forward-as-mime
7597 (message-forward-make-body-digest-mime forward-buffer
)
7598 (message-forward-make-body-digest-plain forward-buffer
)))
7600 (autoload 'mm-uu-dissect-text-parts
"mm-uu")
7601 (autoload 'mm-uu-dissect
"mm-uu")
7603 (defun message-signed-or-encrypted-p (&optional dont-emulate-mime handles
)
7604 "Say whether the current buffer contains signed or encrypted message.
7605 If DONT-EMULATE-MIME is nil, this function does the MIME emulation on
7606 messages that don't conform to PGP/MIME described in RFC2015. HANDLES
7607 is for the internal use."
7609 (let ((mm-decrypt-option 'never
)
7610 (mm-verify-option 'never
))
7611 (if (setq handles
(mm-dissect-buffer nil t
))
7612 (unless dont-emulate-mime
7613 (mm-uu-dissect-text-parts handles
))
7614 (unless dont-emulate-mime
7615 (setq handles
(mm-uu-dissect))))))
7616 ;; Check text/plain message in which there is a signed or encrypted
7617 ;; body that has been encoded by B or Q.
7618 (unless (or handles dont-emulate-mime
)
7619 (let ((cur (current-buffer))
7620 (mm-decrypt-option 'never
)
7621 (mm-verify-option 'never
))
7623 (insert-buffer-substring cur
)
7624 (when (setq handles
(mm-dissect-buffer t t
))
7625 (if (and (bufferp (car handles
))
7626 (equal (mm-handle-media-type handles
) "text/plain"))
7629 (insert-buffer-substring (car handles
))
7630 (mm-decode-content-transfer-encoding
7631 (mm-handle-encoding handles
))
7632 (mm-destroy-parts handles
)
7633 (setq handles
(mm-uu-dissect)))
7634 (mm-destroy-parts handles
)
7635 (setq handles nil
))))))
7639 (dolist (handle (if (stringp (car handles
))
7640 (if (member (car handles
)
7641 '("multipart/signed"
7642 "multipart/encrypted"))
7646 (if (stringp (car handle
))
7647 (when (message-signed-or-encrypted-p dont-emulate-mime handle
)
7649 (when (and (bufferp (car handle
))
7650 (equal (mm-handle-media-type handle
)
7652 (with-current-buffer (mm-handle-buffer handle
)
7653 (when (message-signed-or-encrypted-p dont-emulate-mime
)
7654 (throw 'found t
)))))))
7655 (mm-destroy-parts handles
))))
7658 (defun message-forward-make-body (forward-buffer &optional digest
)
7659 ;; Put point where we want it before inserting the forwarded
7661 (if message-forward-before-signature
7663 (goto-char (point-max)))
7665 (message-forward-make-body-digest forward-buffer
)
7666 (if message-forward-as-mime
7667 (if (and message-forward-show-mml
7668 (not (and (eq message-forward-show-mml
'best
)
7669 ;; Use the raw form in the body if it contains
7670 ;; signed or encrypted message so as not to be
7671 ;; destroyed by re-encoding.
7672 (with-current-buffer forward-buffer
7674 (message-signed-or-encrypted-p)
7676 (message-forward-make-body-mml forward-buffer
)
7677 (message-forward-make-body-mime forward-buffer
))
7678 (message-forward-make-body-plain forward-buffer
)))
7679 (message-position-point))
7681 (declare-function rmail-toggle-header
"rmail" (&optional arg
))
7684 (defun message-forward-rmail-make-body (forward-buffer)
7685 (save-window-excursion
7686 (set-buffer forward-buffer
)
7687 (if (rmail-msg-is-pruned)
7688 (if (fboundp 'rmail-msg-restore-non-pruned-header
)
7689 (rmail-msg-restore-non-pruned-header) ; Emacs 22
7690 (rmail-toggle-header 0)))) ; Emacs 23
7691 (message-forward-make-body forward-buffer
))
7693 ;; Fixme: Should have defcustom.
7695 (defun message-insinuate-rmail ()
7696 "Let RMAIL use message to forward."
7698 (setq rmail-enable-mime-composing t
)
7699 (setq rmail-insert-mime-forwarded-message-function
7700 'message-forward-rmail-make-body
))
7702 (defvar message-inhibit-body-encoding nil
)
7705 (defun message-resend (address)
7706 "Resend the current article to ADDRESS."
7708 (list (message-read-from-minibuffer "Resend message to: ")))
7709 (message "Resending message to %s..." address
)
7711 (let ((cur (current-buffer))
7713 ;; We first set up a normal mail buffer.
7714 (unless (message-mail-user-agent)
7715 (set-buffer (get-buffer-create " *message resend*"))
7716 (let ((inhibit-read-only t
))
7718 (let ((message-this-is-mail t
)
7719 message-generate-hashcash
7721 (message-setup `((To .
,address
))))
7722 ;; Insert our usual headers.
7723 (message-generate-headers '(From Date To Message-ID
))
7724 (message-narrow-to-headers)
7725 (when (setq gcc
(mail-fetch-field "gcc" nil t
))
7726 (message-remove-header "gcc"))
7727 ;; Remove X-Draft-From header etc.
7728 (message-remove-header message-ignored-mail-headers t
)
7729 ;; Rename them all to "Resent-*".
7730 (goto-char (point-min))
7731 (while (re-search-forward "^[A-Za-z]" nil t
)
7736 (let ((inhibit-read-only t
))
7737 (delete-region (point) (point-max)))
7739 ;; Insert the message to be resent.
7740 (insert-buffer-substring cur
)
7741 (goto-char (point-min))
7742 (search-forward "\n\n")
7745 (narrow-to-region beg
(point))
7746 (message-remove-header message-ignored-resent-headers t
)
7747 (goto-char (point-max)))
7748 (insert mail-header-separator
)
7749 ;; Rename all old ("Also-")Resent headers.
7750 (while (re-search-backward "^\\(Also-\\)*Resent-" beg t
)
7753 ;; Quote any "From " lines at the beginning.
7755 (when (looking-at "From ")
7756 (replace-match "X-From-Line: "))
7758 (let ((message-inhibit-body-encoding
7759 ;; Don't do any further encoding if it looks like the
7760 ;; message has already been encoded.
7761 (let ((case-fold-search t
))
7762 (re-search-forward "^mime-version:" nil t
)))
7763 (message-inhibit-ecomplete t
)
7764 message-required-mail-headers
7765 message-generate-hashcash
7766 rfc2047-encode-encoded-words
)
7767 (message-send-mail))
7770 (insert "Gcc: " gcc
"\n"))
7771 (run-hooks 'message-sent-hook
)
7772 (kill-buffer (current-buffer)))
7773 (message "Resending message to %s...done" address
)))
7776 (defun message-bounce ()
7777 "Re-mail the current message.
7778 This only makes sense if the current message is a bounce message that
7779 contains some mail you have written which has been bounced back to
7782 (let ((handles (mm-dissect-buffer t
))
7784 (message-pop-to-buffer (message-buffer-name "bounce"))
7785 (if (stringp (car handles
))
7786 ;; This is a MIME bounce.
7787 (mm-insert-part (car (last handles
)))
7788 ;; This is a non-MIME bounce, so we try to remove things
7790 (mm-insert-part handles
)
7792 (goto-char (point-min))
7793 (re-search-forward "\n\n+" nil t
)
7794 (setq boundary
(point))
7795 ;; We remove everything before the bounced mail.
7796 (if (or (re-search-forward message-unsent-separator nil t
)
7798 (search-forward "\n\n" nil
'move
)
7799 (re-search-backward "^Return-Path:.*\n" boundary t
)))
7802 (delete-region (point-min)
7803 (if (re-search-forward "^[^ \n\t]+:" nil t
)
7806 (goto-char boundary
)
7807 (when (re-search-backward "^.?From .*\n" nil t
)
7808 (delete-region (match-beginning 0) (match-end 0)))))
7811 (message-narrow-to-head-1)
7812 (message-remove-header message-ignored-bounced-headers t
)
7813 (goto-char (point-max))
7814 (insert mail-header-separator
))
7815 (message-position-point)))
7818 ;;; Interactive entry points for new message buffers.
7822 (defun message-mail-other-window (&optional to subject
)
7823 "Like `message-mail' command, but display mail buffer in another window."
7825 (unless (message-mail-user-agent)
7826 (message-pop-to-buffer (message-buffer-name "mail" to
)
7827 'switch-to-buffer-other-window
))
7828 (let ((message-this-is-mail t
))
7829 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7830 nil nil nil
'switch-to-buffer-other-window
)))
7833 (defun message-mail-other-frame (&optional to subject
)
7834 "Like `message-mail' command, but display mail buffer in another frame."
7836 (unless (message-mail-user-agent)
7837 (message-pop-to-buffer (message-buffer-name "mail" to
)
7838 'switch-to-buffer-other-frame
))
7839 (let ((message-this-is-mail t
))
7840 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7841 nil nil nil
'switch-to-buffer-other-frame
)))
7844 (defun message-news-other-window (&optional newsgroups subject
)
7845 "Start editing a news article to be sent."
7847 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)
7848 'switch-to-buffer-other-window
)
7849 (let ((message-this-is-news t
))
7850 (message-setup `((Newsgroups .
,(or newsgroups
""))
7851 (Subject .
,(or subject
""))))))
7854 (defun message-news-other-frame (&optional newsgroups subject
)
7855 "Start editing a news article to be sent."
7857 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)
7858 'switch-to-buffer-other-frame
)
7859 (let ((message-this-is-news t
))
7860 (message-setup `((Newsgroups .
,(or newsgroups
""))
7861 (Subject .
,(or subject
""))))))
7865 ;; This code should be moved to underline.el (from which it is stolen).
7868 (defun message-bold-region (start end
)
7869 "Bold all nonblank characters in the region.
7870 Works by overstriking characters.
7871 Called from program, takes two arguments START and END
7872 which specify the range to operate on."
7875 (let ((end1 (make-marker)))
7876 (move-marker end1
(max start end
))
7877 (goto-char (min start end
))
7878 (while (< (point) end1
)
7879 (or (looking-at "[_\^@- ]")
7880 (insert (char-after) "\b"))
7881 (forward-char 1)))))
7884 (defun message-unbold-region (start end
)
7885 "Remove all boldness (overstruck characters) in the region.
7886 Called from program, takes two arguments START and END
7887 which specify the range to operate on."
7890 (let ((end1 (make-marker)))
7891 (move-marker end1
(max start end
))
7892 (goto-char (min start end
))
7893 (while (search-forward "\b" end1 t
)
7894 (if (eq (char-after) (char-after (- (point) 2)))
7895 (delete-char -
2))))))
7897 (defun message-exchange-point-and-mark ()
7898 "Exchange point and mark, but don't activate region if it was inactive."
7899 (goto-char (prog1 (mark t
)
7900 (set-marker (mark-marker) (point)))))
7902 ;; Support for toolbar
7903 (defvar tool-bar-mode
)
7905 ;; Note: The :set function in the `message-tool-bar*' variables will only
7906 ;; affect _new_ message buffers. We might add a function that walks thru all
7907 ;; message-mode buffers and force the update.
7908 (defun message-tool-bar-update (&optional symbol value
)
7909 "Update message mode toolbar.
7910 Setter function for custom variables."
7911 (setq-default message-tool-bar-map nil
)
7913 ;; When used as ":set" function:
7914 (set-default symbol value
)))
7916 (defcustom message-tool-bar
(if (eq gmm-tool-bar-style
'gnome
)
7917 'message-tool-bar-gnome
7918 'message-tool-bar-retro
)
7919 "Specifies the message mode tool bar.
7921 It can be either a list or a symbol referring to a list. See
7922 `gmm-tool-bar-from-list' for the format of the list. The
7923 default key map is `message-mode-map'.
7925 Pre-defined symbols include `message-tool-bar-gnome' and
7926 `message-tool-bar-retro'."
7927 :type
'(repeat gmm-tool-bar-list-item
)
7928 :type
'(choice (const :tag
"GNOME style" message-tool-bar-gnome
)
7929 (const :tag
"Retro look" message-tool-bar-retro
)
7930 (repeat :tag
"User defined list" gmm-tool-bar-item
)
7932 :version
"23.1" ;; No Gnus
7933 :initialize
'custom-initialize-default
7934 :set
'message-tool-bar-update
7937 (defcustom message-tool-bar-gnome
7938 '((ispell-message "spell" nil
7940 :visible
(or (not (boundp 'flyspell-mode
))
7941 (not flyspell-mode
)))
7942 (flyspell-buffer "spell" t
7944 :visible
(and (boundp 'flyspell-mode
)
7946 :help
"Flyspell whole buffer")
7947 (message-send-and-exit "mail/send" t
:label
"Send")
7948 (message-dont-send "mail/save-draft")
7949 (mml-attach-file "attach" mml-mode-map
:vert-only t
)
7950 (mml-preview "mail/preview" mml-mode-map
)
7951 (mml-secure-message-sign-encrypt "lock" mml-mode-map
:visible nil
)
7952 (message-insert-importance-high "important" nil
:visible nil
)
7953 (message-insert-importance-low "unimportant" nil
:visible nil
)
7954 (message-insert-disposition-notification-to "receipt" nil
:visible nil
))
7955 "List of items for the message tool bar (GNOME style).
7957 See `gmm-tool-bar-from-list' for details on the format of the list."
7958 :type
'(repeat gmm-tool-bar-item
)
7959 :version
"23.1" ;; No Gnus
7960 :initialize
'custom-initialize-default
7961 :set
'message-tool-bar-update
7964 (defcustom message-tool-bar-retro
7965 '(;; Old Emacs 21 icon for consistency.
7966 (message-send-and-exit "gnus/mail-send")
7967 (message-kill-buffer "close")
7968 (message-dont-send "cancel")
7969 (mml-attach-file "attach" mml-mode-map
)
7970 (ispell-message "spell")
7971 (mml-preview "preview" mml-mode-map
)
7972 (message-insert-importance-high "gnus/important")
7973 (message-insert-importance-low "gnus/unimportant")
7974 (message-insert-disposition-notification-to "gnus/receipt"))
7975 "List of items for the message tool bar (retro style).
7977 See `gmm-tool-bar-from-list' for details on the format of the list."
7978 :type
'(repeat gmm-tool-bar-item
)
7979 :version
"23.1" ;; No Gnus
7980 :initialize
'custom-initialize-default
7981 :set
'message-tool-bar-update
7984 (defcustom message-tool-bar-zap-list
7985 '(new-file open-file dired kill-buffer write-file
7986 print-buffer customize help
)
7987 "List of icon items from the global tool bar.
7988 These items are not displayed on the message mode tool bar.
7990 See `gmm-tool-bar-from-list' for the format of the list."
7991 :type
'gmm-tool-bar-zap-list
7992 :version
"23.1" ;; No Gnus
7993 :initialize
'custom-initialize-default
7994 :set
'message-tool-bar-update
7997 (defvar image-load-path
)
7999 (defun message-make-tool-bar (&optional force
)
8000 "Make a message mode tool bar from `message-tool-bar-list'.
8001 When FORCE, rebuild the tool bar."
8002 (when (and (not (featurep 'xemacs
))
8003 (boundp 'tool-bar-mode
)
8005 (or (not message-tool-bar-map
) force
))
8006 (setq message-tool-bar-map
8008 (gmm-image-load-path-for-library "message"
8009 "mail/save-draft.xpm"
8011 (image-load-path (cons (car load-path
)
8012 (when (boundp 'image-load-path
)
8014 (gmm-tool-bar-from-list message-tool-bar
8015 message-tool-bar-zap-list
8016 'message-mode-map
))))
8017 message-tool-bar-map
)
8019 ;;; Group name completion.
8021 (defcustom message-newgroups-header-regexp
8022 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
8023 "Regexp that match headers that lists groups."
8027 (defcustom message-completion-alist
8028 (list (cons message-newgroups-header-regexp
'message-expand-group
)
8029 '("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . message-expand-name
)
8030 '("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
8031 . message-expand-name
)
8032 '("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):"
8033 . message-expand-name
))
8034 "Alist of (RE . FUN). Use FUN for completion on header lines matching RE."
8037 :type
'(alist :key-type regexp
:value-type function
))
8039 (defcustom message-expand-name-databases
8041 "List of databases to try for name completion (`message-expand-name').
8042 Each element is a symbol and can be `bbdb' or `eudc'."
8044 :type
'(set (const bbdb
) (const eudc
)))
8046 (defcustom message-tab-body-function nil
8047 "*Function to execute when `message-tab' (TAB) is executed in the body.
8048 If nil, the function bound in `text-mode-map' or `global-map' is executed."
8051 :link
'(custom-manual "(message)Various Commands")
8052 :type
'(choice (const nil
)
8055 (declare-function mail-abbrev-in-expansion-header-p
"mailabbrev" ())
8057 (defun message-tab ()
8058 "Complete names according to `message-completion-alist'.
8059 Execute function specified by `message-tab-body-function' when
8060 not in those headers. If that variable is nil, indent with the
8061 regular text mode tabbing command."
8064 ((if (and (boundp 'completion-fail-discreetly
)
8065 (fboundp 'completion-at-point
))
8066 (let ((completion-fail-discreetly t
)) (completion-at-point))
8067 (funcall (or (message-completion-function) #'ignore
)))
8068 ;; Completion was performed; nothing else to do.
8070 (message-tab-body-function (funcall message-tab-body-function
))
8071 (t (funcall (or (lookup-key text-mode-map
"\t")
8072 (lookup-key global-map
"\t")
8073 'indent-relative
)))))
8075 (defvar mail-abbrev-mode-regexp
)
8077 (defun message-completion-function ()
8078 (let ((alist message-completion-alist
))
8080 (let ((mail-abbrev-mode-regexp (caar alist
)))
8081 (not (mail-abbrev-in-expansion-header-p))))
8082 (setq alist
(cdr alist
)))
8084 (lexical-let ((fun (cdar alist
)))
8085 ;; Even if completion fails, return a non-nil value, so as to avoid
8086 ;; falling back to message-tab-body-function.
8087 (lambda () (funcall fun
) 'completion-attempted
)))))
8089 (defun message-expand-group ()
8090 "Expand the group name under point."
8091 (let ((b (save-excursion
8096 (skip-chars-forward "^:")
8099 (skip-chars-backward "^, \t\n") (point))))
8100 (completion-ignore-case t
)
8101 (e (progn (skip-chars-forward "^,\t\n ") (point)))
8103 (when (and (boundp 'gnus-active-hashtb
)
8107 (setq group
(symbol-name symbol
))
8108 (push (if (string-match "[^\000-\177]" group
)
8109 (gnus-group-decoded-name group
)
8112 gnus-active-hashtb
))
8113 (message-completion-in-region b e collection
)))
8115 (defalias 'message-completion-in-region
8116 (if (fboundp 'completion-in-region
)
8117 'completion-in-region
8118 (lambda (b e hashtb
)
8119 (let* ((string (buffer-substring b e
))
8120 (completions (all-completions string hashtb
))
8122 (delete-region b
(point))
8124 ((= (length completions
) 1)
8125 (if (string= (car completions
) string
)
8128 (message "Only matching group"))
8129 (insert (car completions
))))
8130 ((and (setq comp
(try-completion string hashtb
))
8131 (not (string= comp string
)))
8136 (message "No matching groups")
8137 (save-selected-window
8138 (pop-to-buffer "*Completions*")
8139 (buffer-disable-undo)
8140 (let ((buffer-read-only nil
))
8142 (let ((standard-output (current-buffer)))
8143 (display-completion-list (sort completions
'string
<)))
8144 (setq buffer-read-only nil
)
8145 (goto-char (point-min))
8146 (delete-region (point)
8147 (progn (forward-line 3) (point))))))))))))
8149 (defun message-expand-name ()
8150 (cond ((and (memq 'eudc message-expand-name-databases
)
8151 (boundp 'eudc-protocol
)
8153 (eudc-expand-inline))
8154 ((and (memq 'bbdb message-expand-name-databases
)
8155 (fboundp 'bbdb-complete-name
))
8156 (let ((starttick (buffer-modified-tick)))
8157 (or (bbdb-complete-name)
8158 ;; Apparently, bbdb-complete-name can return nil even when
8159 ;; completion took place. So let's double check the buffer was
8161 (/= starttick
(buffer-modified-tick)))))
8167 (defun message-talkative-question (ask question show
&rest text
)
8168 "Call FUNCTION with argument QUESTION; optionally display TEXT... args.
8169 If SHOW is non-nil, the arguments TEXT... are displayed in a temp buffer.
8170 The following arguments may contain lists of values."
8172 (setq text
(message-flatten-list text
)))
8173 (save-window-excursion
8174 (with-output-to-temp-buffer " *MESSAGE information message*"
8175 (with-current-buffer " *MESSAGE information message*"
8176 (fundamental-mode) ; for Emacs 20.4+
8178 (goto-char (point-min))))
8179 (funcall ask question
))
8180 (funcall ask question
)))
8182 (defun message-flatten-list (list)
8183 "Return a new, flat list that contains all elements of LIST.
8185 \(message-flatten-list \\='(1 (2 3 (4 5 (6))) 7))
8188 (apply 'append
(mapcar 'message-flatten-list list
)))
8192 (defun message-generate-new-buffer-clone-locals (name &optional varstr
)
8193 "Create and return a buffer with name based on NAME using `generate-new-buffer'.
8194 Then clone the local variables and values from the old buffer to the
8195 new one, cloning only the locals having a substring matching the
8197 (let ((oldbuf (current-buffer)))
8198 (with-current-buffer (generate-new-buffer name
)
8199 (message-clone-locals oldbuf varstr
)
8202 (defun message-clone-locals (buffer &optional varstr
)
8203 "Clone the local variables from BUFFER to the current buffer."
8204 (let ((locals (with-current-buffer buffer
(buffer-local-variables)))
8205 (regexp "^gnus\\|^nn\\|^message\\|^sendmail\\|^smtp\\|^user-mail-address"))
8208 (when (and (consp local
)
8210 (string-match regexp
(symbol-name (car local
)))
8212 (string-match varstr
(symbol-name (car local
)))))
8214 (set (make-local-variable (car local
))
8222 (defun message-encode-message-body ()
8223 (unless message-inhibit-body-encoding
8224 (let ((mail-parse-charset (or mail-parse-charset
8225 message-default-charset
))
8226 (case-fold-search t
)
8227 lines content-type-p
)
8230 (narrow-to-region (point) (point-max))
8231 (let ((new (mml-generate-mime)))
8233 (delete-region (point-min) (point-max))
8235 (goto-char (point-min))
8236 (if (eq (aref new
0) ?
\n)
8238 (search-forward "\n\n")
8239 (setq lines
(buffer-substring (point-min) (1- (point))))
8240 (delete-region (point-min) (point))))))
8242 (message-narrow-to-headers-or-head)
8243 (message-remove-header "Mime-Version")
8244 (goto-char (point-max))
8245 (insert "MIME-Version: 1.0\n")
8248 (setq content-type-p
8250 (re-search-backward "^Content-Type:" nil t
))))
8252 (message-narrow-to-headers-or-head)
8253 (message-remove-first-header "Content-Type")
8254 (message-remove-first-header "Content-Transfer-Encoding"))
8255 ;; We always make sure that the message has a Content-Type
8256 ;; header. This is because some broken MTAs and MUAs get
8257 ;; awfully confused when confronted with a message with a
8258 ;; MIME-Version header and without a Content-Type header. For
8259 ;; instance, Solaris' /usr/bin/mail.
8260 (unless content-type-p
8261 (goto-char (point-min))
8262 ;; For unknown reason, MIME-Version doesn't exist.
8263 (when (re-search-forward "^MIME-Version:" nil t
)
8265 (insert "Content-Type: text/plain; charset=us-ascii\n"))))))
8267 (defun message-read-from-minibuffer (prompt &optional initial-contents
)
8268 "Read from the minibuffer while providing abbrev expansion."
8269 (if (fboundp 'mail-abbrevs-setup
)
8270 (let ((minibuffer-setup-hook 'mail-abbrevs-setup
)
8271 (minibuffer-local-map message-minibuffer-local-map
))
8272 (read-from-minibuffer prompt initial-contents
))
8273 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook
)
8274 (minibuffer-local-map message-minibuffer-local-map
))
8275 (read-string prompt initial-contents
))))
8277 (defun message-use-alternative-email-as-from ()
8278 "Set From field of the outgoing message to the first matching
8279 address in `message-alternative-emails', looking at To, Cc and
8280 From headers in the original article."
8281 (require 'mail-utils
)
8282 (let* ((fields '("To" "Cc" "From"))
8285 (mail-strip-quoted-names
8286 (mapconcat 'message-fetch-reply-field fields
","))
8290 (if (string-match message-alternative-emails
(car emails
))
8291 (setq email
(car emails
)
8294 (unless (or (not email
) (equal email user-mail-address
))
8295 (message-remove-header "From")
8296 (goto-char (point-max))
8297 (insert "From: " (let ((user-mail-address email
)) (message-make-from))
8300 (defun message-options-get (symbol)
8301 (cdr (assq symbol message-options
)))
8303 (defun message-options-set (symbol value
)
8304 (let ((the-cons (assq symbol message-options
)))
8307 (setcdr the-cons value
)
8308 (setq message-options
(delq the-cons message-options
)))
8310 (push (cons symbol value
) message-options
))))
8313 (defun message-options-set-recipient ()
8315 (message-narrow-to-headers-or-head)
8316 (message-options-set 'message-sender
8317 (mail-strip-quoted-names
8318 (message-fetch-field "from")))
8319 (message-options-set 'message-recipients
8320 (mail-strip-quoted-names
8321 (let ((to (message-fetch-field "to"))
8322 (cc (message-fetch-field "cc"))
8323 (bcc (message-fetch-field "bcc")))
8326 (if (and to cc
) ", ")
8328 (if (and (or to cc
) bcc
) ", ")
8331 (defun message-hide-headers ()
8332 "Hide headers based on the `message-hidden-headers' variable."
8333 (let ((regexps (if (stringp message-hidden-headers
)
8334 (list message-hidden-headers
)
8335 message-hidden-headers
))
8336 (inhibit-point-motion-hooks t
)
8337 (inhibit-modification-hooks t
)
8338 (end-of-headers (point-min)))
8342 (message-narrow-to-headers)
8343 (goto-char (point-min))
8345 (if (not (message-hide-header-p regexps
))
8346 (message-next-header)
8347 (let ((begin (point))
8349 (message-next-header)
8350 (setq header
(buffer-substring begin
(point))
8351 header-len
(- (point) begin
))
8352 (delete-region begin
(point))
8353 (goto-char end-of-headers
)
8355 (setq end-of-headers
8356 (+ end-of-headers header-len
))))))))
8357 (narrow-to-region end-of-headers
(point-max))))
8359 (defun message-hide-header-p (regexps)
8362 (when (eq (car regexps
) 'not
)
8365 (dolist (regexp regexps
)
8366 (setq result
(or result
(looking-at regexp
))))
8371 (declare-function ecomplete-add-item
"ecomplete" (type key text
))
8372 (declare-function ecomplete-save
"ecomplete" ())
8374 (defun message-put-addresses-in-ecomplete ()
8375 (require 'ecomplete
)
8376 (dolist (header '("to" "cc" "from" "reply-to"))
8377 (let ((value (message-field-value header
)))
8378 (dolist (string (mail-header-parse-addresses value
'raw
))
8380 (gnus-replace-in-string
8381 (gnus-replace-in-string string
"^ +\\| +$" "") "\n" ""))
8382 (ecomplete-add-item 'mail
(car (mail-header-parse-address string
))
8386 (autoload 'ecomplete-display-matches
"ecomplete")
8388 (defun message-display-abbrev (&optional choose
)
8389 "Display the next possible abbrev for the text before point."
8390 (interactive (list t
))
8391 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?
\t ?
))
8392 (message-point-in-header-p)
8395 (while (and (memq (char-after) '(?
\t ?
))
8396 (zerop (forward-line -
1))))
8397 (looking-at "To:\\|Cc:")))
8398 (let* ((end (point))
8399 (start (save-excursion
8400 (and (re-search-backward "[\n\t ]" nil t
)
8402 (word (when start
(buffer-substring start end
)))
8403 (match (when (and word
8404 (not (zerop (length word
))))
8405 (ecomplete-display-matches 'mail word choose
))))
8406 (when (and choose match
)
8407 (delete-region start end
)
8410 ;; To send pre-formatted letters like the example below, you can use
8411 ;; `message-send-form-letter':
8412 ;; --8<---------------cut here---------------start------------->8---
8413 ;; To: alice@invalid.invalid
8414 ;; Subject: Verification of your contact information
8415 ;; From: Contact verification <admin@foo.invalid>
8416 ;; --text follows this line--
8418 ;; please verify that your contact information is still valid:
8419 ;; Alice A, A avenue 11, 1111 A town, Austria
8420 ;; ----------next form letter message follows this line----------
8421 ;; To: bob@invalid.invalid
8422 ;; Subject: Verification of your contact information
8423 ;; From: Contact verification <admin@foo.invalid>
8424 ;; --text follows this line--
8426 ;; please verify that your contact information is still valid:
8427 ;; Bob, B street 22, 22222 Be town, Belgium
8428 ;; ----------next form letter message follows this line----------
8429 ;; To: charlie@invalid.invalid
8430 ;; Subject: Verification of your contact information
8431 ;; From: Contact verification <admin@foo.invalid>
8432 ;; --text follows this line--
8434 ;; please verify that your contact information is still valid:
8435 ;; Charlie Chaplin, C plaza 33, 33333 C town, Chile
8436 ;; --8<---------------cut here---------------end--------------->8---
8438 ;; FIXME: What is the most common term (circular letter, form letter, serial
8439 ;; letter, standard letter) for such kind of letter? See also
8440 ;; <http://en.wikipedia.org/wiki/Form_letter>
8442 ;; FIXME: Maybe extent message-mode's font-lock support to recognize
8443 ;; `message-form-letter-separator', i.e. highlight each message like a single
8446 (defcustom message-form-letter-separator
8447 "\n----------next form letter message follows this line----------\n"
8448 "Separator for `message-send-form-letter'."
8449 ;; :group 'message-form-letter
8450 :group
'message-various
8451 :version
"23.1" ;; No Gnus
8454 (defcustom message-send-form-letter-delay
1
8455 "Delay in seconds when sending a message with `message-send-form-letter'.
8456 Only used when `message-send-form-letter' is called with non-nil
8458 ;; :group 'message-form-letter
8459 :group
'message-various
8460 :version
"23.1" ;; No Gnus
8463 (defun message-send-form-letter (&optional force
)
8464 "Sent all form letter messages from current buffer.
8465 Unless FORCE, prompt before sending.
8467 The messages are separated by `message-form-letter-separator'.
8468 Header and body are separated by `mail-header-separator'."
8470 (let ((sent 0) (skipped 0)
8474 (goto-char (point-min))
8477 end
(if (search-forward message-form-letter-separator nil t
)
8478 (- (point) (length message-form-letter-separator
) -
1)
8482 (buffer-substring-no-properties start end
))
8483 (setq buff
(generate-new-buffer "*mail - form letter*"))
8484 (with-current-buffer buff
8487 (setq to
(message-fetch-field "To"))
8488 (switch-to-buffer buff
)
8490 (sit-for message-send-form-letter-delay
))
8492 (y-or-n-p (gnus-format-message "Send message to `%s'? " to
)))
8494 (setq sent
(1+ sent
))
8495 (message-send-and-exit))
8496 (message "Message to `%s' skipped." to
)
8497 (setq skipped
(1+ skipped
)))
8498 (when (buffer-live-p buff
)
8499 (kill-buffer buff
))))
8500 (message "%s message(s) sent, %s skipped." sent skipped
)))
8502 (defun message-replace-header (header new-value
&optional after force
)
8503 "Remove HEADER and insert the NEW-VALUE.
8504 If AFTER, insert after this header. If FORCE, insert new field
8505 even if NEW-VALUE is empty."
8506 ;; Similar to `nnheader-replace-header' but for message buffers.
8509 (message-narrow-to-headers)
8510 (message-remove-header header
))
8511 (when (or force
(> (length new-value
) 0))
8513 (message-position-on-field header after
)
8514 (message-position-on-field header
))
8515 (insert new-value
))))
8517 (defcustom message-recipients-without-full-name
8518 (list "ding@gnus.org"
8520 "emacs-devel@gnu.org"
8521 "emacs-pretest-bug@gnu.org"
8522 "bug-gnu-emacs@gnu.org")
8523 "Mail addresses that have no full name.
8524 Used in `message-simplify-recipients'."
8525 ;; Maybe the addresses could be extracted from
8526 ;; `gnus-parameter-to-list-alist'?
8527 :type
'(choice (const :tag
"None" nil
)
8529 :version
"23.1" ;; No Gnus
8530 :group
'message-headers
)
8532 (defun message-simplify-recipients ()
8534 (dolist (hdr '("Cc" "To"))
8535 (message-replace-header
8539 (if (and message-recipients-without-full-name
8541 (regexp-opt message-recipients-without-full-name
)
8545 (message-make-from (car addrcomp
) (cadr addrcomp
))
8547 (when (message-fetch-field hdr
)
8548 (mail-extract-address-components
8549 (message-fetch-field hdr
) t
))
8552 ;;; multipart/related and HTML support.
8554 (defun message-make-html-message-with-image-files (files)
8555 "Make a message containing the current dired-marked image files."
8556 (interactive (list (dired-get-marked-files nil current-prefix-arg
)))
8559 (insert "<#part type=text/html>\n\n")
8560 (dolist (file files
)
8561 (insert (format "<img src=%S>\n\n" file
)))
8562 (message-toggle-image-thumbnails)
8565 (defun message-toggle-image-thumbnails ()
8566 "For any included image files, insert a thumbnail of that image."
8568 (let ((overlays (overlays-in (point-min) (point-max)))
8571 (let ((overlay (car overlays
)))
8572 (when (overlay-get overlay
'put-image
)
8573 (delete-overlay overlay
)
8574 (setq displayed t
)))
8575 (setq overlays
(cdr overlays
)))
8578 (goto-char (point-min))
8579 (while (re-search-forward "<img.*src=\"\\([^\"]+\\)" nil t
)
8580 (let ((file (match-string 1))
8581 (edges (message-window-inside-pixel-edges
8582 (get-buffer-window (current-buffer)))))
8585 file
'imagemagick nil
8586 :max-width
(truncate
8587 (* 0.7 (- (nth 2 edges
) (nth 0 edges
))))
8588 :max-height
(truncate
8589 (* 0.5 (- (nth 3 edges
) (nth 1 edges
)))))
8593 (when (featurep 'xemacs
)
8594 (require 'messagexmas
)
8595 (message-xmas-redefine))
8599 (run-hooks 'message-load-hook
)
8605 ;;; message.el ends here