1 ;;; message.el --- composing mail and news messages
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This mode provides mail-sending facilities from within Emacs. It
27 ;; consists mainly of large chunks of code from the sendmail.el,
28 ;; gnus-msg.el and rnewspost.el files.
33 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
42 ;; This is apparently necessary even though things are autoloaded.
43 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
44 ;; require mailabbrev here.
45 (if (featurep 'xemacs
)
46 (require 'mail-abbrevs
)
47 (require 'mailabbrev
))
53 (autoload 'mailclient-send-it
"mailclient") ;; Emacs 22 or contrib/
55 (defvar gnus-message-group-art
)
56 (defvar gnus-list-identifiers
) ; gnus-sum is required where necessary
57 (defvar rmail-enable-mime-composing
)
59 (defgroup message
'((user-mail-address custom-variable
)
60 (user-full-name custom-variable
))
61 "Mail and news message composing."
62 :link
'(custom-manual "(message)Top")
66 (put 'user-mail-address
'custom-type
'string
)
67 (put 'user-full-name
'custom-type
'string
)
69 (defgroup message-various nil
70 "Various Message Variables."
71 :link
'(custom-manual "(message)Various Message Variables")
74 (defgroup message-buffers nil
76 :link
'(custom-manual "(message)Message Buffers")
79 (defgroup message-sending nil
81 :link
'(custom-manual "(message)Sending Variables")
84 (defgroup message-interface nil
86 :link
'(custom-manual "(message)Interface")
89 (defgroup message-forwarding nil
91 :link
'(custom-manual "(message)Forwarding")
92 :group
'message-interface
)
94 (defgroup message-insertion nil
96 :link
'(custom-manual "(message)Insertion")
99 (defgroup message-headers nil
101 :link
'(custom-manual "(message)Message Headers")
104 (defgroup message-news nil
105 "Composing News Messages."
108 (defgroup message-mail nil
109 "Composing Mail Messages."
112 (defgroup message-faces nil
113 "Faces used for message composing."
117 (defcustom message-directory
"~/Mail/"
118 "*Directory from which all other mail file variables are derived."
119 :group
'message-various
122 (defcustom message-max-buffers
10
123 "*How many buffers to keep before starting to kill them off."
124 :group
'message-buffers
127 (defcustom message-send-rename-function nil
128 "Function called to rename the buffer after sending it."
129 :group
'message-buffers
130 :type
'(choice function
(const nil
)))
132 (defcustom message-fcc-handler-function
'message-output
133 "*A function called to save outgoing articles.
134 This function will be called with the name of the file to store the
135 article in. The default function is `message-output' which saves in Unix
137 :type
'(radio (function-item message-output
)
138 (function :tag
"Other"))
139 :group
'message-sending
)
141 (defcustom message-fcc-externalize-attachments nil
142 "If non-nil, attachments are included as external parts in Fcc copies."
145 :group
'message-sending
)
147 (defcustom message-courtesy-message
148 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
149 "*This is inserted at the start of a mailed copy of a posted message.
150 If the string contains the format spec \"%s\", the Newsgroups
151 the article has been posted to will be inserted there.
152 If this variable is nil, no such courtesy message will be added."
153 :group
'message-sending
154 :type
'(radio string
(const nil
)))
156 (defcustom message-ignored-bounced-headers
157 "^\\(Received\\|Return-Path\\|Delivered-To\\):"
158 "*Regexp that matches headers to be removed in resent bounced mail."
159 :group
'message-interface
162 (defcustom message-from-style
'default
163 "*Specifies how \"From\" headers look.
165 If nil, they contain just the return address like:
167 If `parens', they look like:
168 king@grassland.com (Elvis Parsley)
169 If `angles', they look like:
170 Elvis Parsley <king@grassland.com>
172 Otherwise, most addresses look like `angles', but they look like
173 `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-deletable-headers
'(Message-ID Date Lines
)
250 "Headers to be deleted if they already exist and were generated by message previously."
251 :group
'message-headers
252 :link
'(custom-manual "(message)Message Headers")
255 (defcustom message-ignored-news-headers
256 "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
257 "*Regexp of headers to be removed unconditionally before posting."
259 :group
'message-headers
260 :link
'(custom-manual "(message)Message Headers")
261 :type
'(repeat :value-to-internal
(lambda (widget value
)
262 (custom-split-regexp-maybe value
))
263 :match
(lambda (widget value
)
265 (widget-editable-list-match widget value
)))
268 (defcustom message-ignored-mail-headers
269 "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
270 "*Regexp of headers to be removed unconditionally before mailing."
272 :group
'message-headers
273 :link
'(custom-manual "(message)Mail Headers")
276 (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:"
277 "*Header lines matching this regexp will be deleted before posting.
278 It's best to delete old Path and Date headers before posting to avoid
280 :group
'message-interface
281 :link
'(custom-manual "(message)Superseding")
282 :type
'(repeat :value-to-internal
(lambda (widget value
)
283 (custom-split-regexp-maybe value
))
284 :match
(lambda (widget value
)
286 (widget-editable-list-match widget value
)))
289 (defcustom message-subject-re-regexp
290 "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
291 "*Regexp matching \"Re: \" in the subject line."
292 :group
'message-various
293 :link
'(custom-manual "(message)Message Headers")
296 ;;; Start of variables adopted from `message-utils.el'.
298 (defcustom message-subject-trailing-was-query
'ask
299 "*What to do with trailing \"(was: <old subject>)\" in subject lines.
300 If nil, leave the subject unchanged. If it is the symbol `ask', query
301 the user what do do. In this case, the subject is matched against
302 `message-subject-trailing-was-ask-regexp'. If
303 `message-subject-trailing-was-query' is t, always strip the trailing
304 old subject. In this case, `message-subject-trailing-was-regexp' is
307 :type
'(choice (const :tag
"never" nil
)
308 (const :tag
"always strip" t
)
310 :link
'(custom-manual "(message)Message Headers")
311 :group
'message-various
)
313 (defcustom message-subject-trailing-was-ask-regexp
314 "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
315 "*Regexp matching \"(was: <old subject>)\" in the subject line.
317 The function `message-strip-subject-trailing-was' uses this regexp if
318 `message-subject-trailing-was-query' is set to the symbol `ask'. If
319 the variable is t instead of `ask', use
320 `message-subject-trailing-was-regexp' instead.
322 It is okay to create some false positives here, as the user is asked."
324 :group
'message-various
325 :link
'(custom-manual "(message)Message Headers")
328 (defcustom message-subject-trailing-was-regexp
329 "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
330 "*Regexp matching \"(was: <old subject>)\" in the subject line.
332 If `message-subject-trailing-was-query' is set to t, the subject is
333 matched against `message-subject-trailing-was-regexp' in
334 `message-strip-subject-trailing-was'. You should use a regexp creating very
335 few false positives here."
337 :group
'message-various
338 :link
'(custom-manual "(message)Message Headers")
341 ;;; marking inserted text
343 (defcustom message-mark-insert-begin
344 "--8<---------------cut here---------------start------------->8---\n"
345 "How to mark the beginning of some inserted text."
348 :link
'(custom-manual "(message)Insertion Variables")
349 :group
'message-various
)
351 (defcustom message-mark-insert-end
352 "--8<---------------cut here---------------end--------------->8---\n"
353 "How to mark the end of some inserted text."
356 :link
'(custom-manual "(message)Insertion Variables")
357 :group
'message-various
)
359 (defcustom message-archive-header
"X-No-Archive: Yes\n"
360 "Header to insert when you don't want your article to be archived.
361 Archives \(such as groups.google.com\) respect this header."
364 :link
'(custom-manual "(message)Header Commands")
365 :group
'message-various
)
367 (defcustom message-archive-note
368 "X-No-Archive: Yes - save http://groups.google.com/"
369 "Note to insert why you wouldn't want this posting archived.
370 If nil, don't insert any text in the body."
372 :type
'(radio string
(const nil
))
373 :link
'(custom-manual "(message)Header Commands")
374 :group
'message-various
)
376 ;;; Crossposts and Followups
377 ;; inspired by JoH-followup-to by Jochem Huhman <joh at gmx.de>
378 ;; new suggestions by R. Weikusat <rw at another.de>
380 (defvar message-cross-post-old-target nil
381 "Old target for cross-posts or follow-ups.")
382 (make-variable-buffer-local 'message-cross-post-old-target
)
384 (defcustom message-cross-post-default t
385 "When non-nil `message-cross-post-followup-to' will perform a crosspost.
386 If nil, `message-cross-post-followup-to' will only do a followup. Note that
387 you can explicitly override this setting by calling
388 `message-cross-post-followup-to' with a prefix."
391 :group
'message-various
)
393 (defcustom message-cross-post-note
"Crosspost & Followup-To: "
394 "Note to insert before signature to notify of cross-post and follow-up."
397 :group
'message-various
)
399 (defcustom message-followup-to-note
"Followup-To: "
400 "Note to insert before signature to notify of follow-up only."
403 :group
'message-various
)
405 (defcustom message-cross-post-note-function
'message-cross-post-insert-note
406 "Function to use to insert note about Crosspost or Followup-To.
407 The function will be called with four arguments. The function should not only
408 insert a note, but also ensure old notes are deleted. See the documentation
409 for `message-cross-post-insert-note'."
412 :group
'message-various
)
414 ;;; End of variables adopted from `message-utils.el'.
416 (defcustom message-signature-separator
"^-- $"
417 "Regexp matching the signature separator.
418 This variable is used to strip off the signature from quoted text
419 when `message-cite-function' is
420 `message-cite-original-without-signature'. Most useful values
421 are \"^-- $\" (strict) and \"^-- *$\" (loose; allow missing
423 :type
'(choice (const :tag
"strict" "^-- $")
424 (const :tag
"loose" "^-- *$")
426 :version
"22.3" ;; Gnus 5.10.12 (changed default)
427 :link
'(custom-manual "(message)Various Message Variables")
428 :group
'message-various
)
430 (defcustom message-elide-ellipsis
"\n[...]\n\n"
431 "*The string which is inserted for elided text."
433 :link
'(custom-manual "(message)Various Commands")
434 :group
'message-various
)
436 (defcustom message-interactive t
437 "Non-nil means when sending a message wait for and display errors.
438 nil means let mailer mail back a message to report errors."
439 :group
'message-sending
441 :link
'(custom-manual "(message)Sending Variables")
444 (defcustom message-confirm-send nil
445 "When non-nil, ask for confirmation when sending a message."
446 :group
'message-sending
448 :version
"23.1" ;; No Gnus
449 :link
'(custom-manual "(message)Sending Variables")
452 (defcustom message-generate-new-buffers
'unique
453 "*Say whether to create a new message buffer to compose a message.
454 Valid values include:
457 Generate the buffer name in the Message way (e.g., *mail*, *news*,
458 *mail to whom*, *news on group*, etc.) and continue editing in the
459 existing buffer of that name. If there is no such buffer, it will
463 Create the new buffer with the name generated in the Message way.
466 Similar to `unique' but the buffer name begins with \"*unsent \".
469 Similar to nil but the buffer name is simpler like *mail message*.
472 If this is a function, call that function with three parameters:
473 The type, the To address and the group name (any of these may be nil).
474 The function should return the new buffer name."
475 :group
'message-buffers
476 :link
'(custom-manual "(message)Message Buffers")
477 :type
'(choice (const nil
)
478 (sexp :tag
"unique" :format
"unique\n" :value unique
479 :match
(lambda (widget value
) (memq value
'(unique t
))))
482 (function :format
"\n %{%t%}: %v")))
484 (defcustom message-kill-buffer-on-exit nil
485 "*Non-nil means that the message buffer will be killed after sending a message."
486 :group
'message-buffers
487 :link
'(custom-manual "(message)Message Buffers")
490 (defcustom message-kill-buffer-query t
491 "*Non-nil means that killing a modified message buffer has to be confirmed.
492 This is used by `message-kill-buffer'."
493 :version
"23.1" ;; No Gnus
494 :group
'message-buffers
497 (defvar gnus-local-organization
)
498 (defcustom message-user-organization
499 (or (and (boundp 'gnus-local-organization
)
500 (stringp gnus-local-organization
)
501 gnus-local-organization
)
502 (getenv "ORGANIZATION")
504 "*String to be used as an Organization header.
505 If t, use `message-user-organization-file'."
506 :group
'message-headers
507 :type
'(choice string
508 (const :tag
"consult file" t
)))
510 (defcustom message-user-organization-file
512 (dolist (f (list "/etc/organization"
513 "/etc/news/organization"
514 "/usr/lib/news/organization"))
515 (when (file-readable-p f
)
518 "*Local news organization file."
520 :link
'(custom-manual "(message)News Headers")
521 :group
'message-headers
)
523 (defcustom message-make-forward-subject-function
524 #'message-forward-subject-name-subject
525 "*List of functions called to generate subject headers for forwarded messages.
526 The subject generated by the previous function is passed into each
529 The provided functions are:
531 * `message-forward-subject-author-subject' Source of article (author or
532 newsgroup), in brackets followed by the subject
533 * `message-forward-subject-name-subject' Source of article (name of author
534 or newsgroup), in brackets followed by the subject
535 * `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
537 :group
'message-forwarding
538 :link
'(custom-manual "(message)Forwarding")
539 :type
'(radio (function-item message-forward-subject-author-subject
)
540 (function-item message-forward-subject-fwd
)
541 (function-item message-forward-subject-name-subject
)
542 (repeat :tag
"List of functions" function
)))
544 (defcustom message-forward-as-mime t
545 "*Non-nil means forward messages as an inline/rfc822 MIME section.
546 Otherwise, directly inline the old message in the forwarded message."
548 :group
'message-forwarding
549 :link
'(custom-manual "(message)Forwarding")
552 (defcustom message-forward-show-mml
'best
553 "*Non-nil means show forwarded messages as MML (decoded from MIME).
554 Otherwise, forwarded messages are unchanged.
555 Can also be the symbol `best' to indicate that MML should be
556 used, except when it is a bad idea to use MML. One example where
557 it is a bad idea is when forwarding a signed or encrypted
558 message, because converting MIME to MML would invalidate the
561 :group
'message-forwarding
562 :type
'(choice (const :tag
"use MML" t
)
563 (const :tag
"don't use MML " nil
)
564 (const :tag
"use MML when appropriate" best
)))
566 (defcustom message-forward-before-signature t
567 "*Non-nil means put forwarded message before signature, else after."
568 :group
'message-forwarding
571 (defcustom message-wash-forwarded-subjects nil
572 "*Non-nil means try to remove as much cruft as possible from the subject.
573 Done before generating the new subject of a forward."
574 :group
'message-forwarding
575 :link
'(custom-manual "(message)Forwarding")
578 (defcustom message-ignored-resent-headers
579 ;; `Delivered-To' needs to be removed because some mailers use it to
580 ;; detect loops, so if you resend a message to an address that ultimately
581 ;; comes back to you (e.g. a mailing-list to which you subscribe, in which
582 ;; case you may be removed from the list on the grounds that mail to you
583 ;; bounced with a "mailing loop" error).
584 "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From \\|^Delivered-To:"
585 "*All headers that match this regexp will be deleted when resending a message."
586 :group
'message-interface
587 :link
'(custom-manual "(message)Resending")
588 :type
'(repeat :value-to-internal
(lambda (widget value
)
589 (custom-split-regexp-maybe value
))
590 :match
(lambda (widget value
)
592 (widget-editable-list-match widget value
)))
595 (defcustom message-forward-ignored-headers
"^Content-Transfer-Encoding:\\|^X-Gnus"
596 "*All headers that match this regexp will be deleted when forwarding a message."
598 :group
'message-forwarding
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-ignored-cited-headers
"."
607 "*Delete these headers from the messages you yank."
608 :group
'message-insertion
609 :link
'(custom-manual "(message)Insertion Variables")
612 (defcustom message-cite-prefix-regexp
613 (if (string-match "[[:digit:]]" "1")
614 ;; Support POSIX? XEmacs 21.5.27 doesn't.
615 "\\([ \t]*[_.[:word:]]+>+\\|[ \t]*[]>|}]\\)+"
616 ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
617 (let (non-word-constituents)
618 (with-syntax-table text-mode-syntax-table
619 (setq non-word-constituents
621 (if (string-match "\\w" "_") "" "_")
622 (if (string-match "\\w" ".") "" "."))))
623 (if (equal non-word-constituents
"")
624 "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}]\\)+"
625 (concat "\\([ \t]*\\(\\w\\|["
626 non-word-constituents
627 "]\\)+>+\\|[ \t]*[]>|}]\\)+"))))
628 "*Regexp matching the longest possible citation prefix on a line."
630 :group
'message-insertion
631 :link
'(custom-manual "(message)Insertion Variables")
633 :set
(lambda (symbol value
)
635 (custom-set-default symbol value
)
636 (if (boundp 'gnus-message-cite-prefix-regexp
)
637 (setq gnus-message-cite-prefix-regexp
638 (concat "^\\(?:" value
"\\)"))))))
640 (defcustom message-cancel-message
"I am canceling my own article.\n"
641 "Message to be inserted in the cancel message."
642 :group
'message-interface
643 :link
'(custom-manual "(message)Canceling News")
646 (defvar smtpmail-default-smtp-server
)
648 (defun message-send-mail-function ()
649 "Return suitable value for the variable `message-send-mail-function'."
650 (cond ((and (require 'sendmail
)
651 (boundp 'sendmail-program
)
653 (executable-find sendmail-program
))
654 'message-send-mail-with-sendmail
)
655 ((and (locate-library "smtpmail")
657 smtpmail-default-smtp-server
)
658 'message-smtpmail-send-it
)
659 ((locate-library "mailclient")
660 'message-send-mail-with-mailclient
)
663 (error "Don't know how to send mail. Please customize `message-send-mail-function'")))))
665 ;; Useful to set in site-init.el
666 (defcustom message-send-mail-function
(message-send-mail-function)
667 "Function to call to send the current buffer as mail.
668 The headers should be delimited by a line whose contents match the
669 variable `mail-header-separator'.
671 Valid values include `message-send-mail-with-sendmail'
672 `message-send-mail-with-mh', `message-send-mail-with-qmail',
673 `message-smtpmail-send-it', `smtpmail-send-it',
674 `feedmail-send-it' and `message-send-mail-with-mailclient'. The
675 default is system dependent and determined by the function
676 `message-send-mail-function'.
678 See also `send-mail-function'."
679 :type
'(radio (function-item message-send-mail-with-sendmail
)
680 (function-item message-send-mail-with-mh
)
681 (function-item message-send-mail-with-qmail
)
682 (function-item message-smtpmail-send-it
)
683 (function-item smtpmail-send-it
)
684 (function-item feedmail-send-it
)
685 (function-item message-send-mail-with-mailclient
686 :tag
"Use Mailclient package")
687 (function :tag
"Other"))
688 :group
'message-sending
689 :version
"23.1" ;; No Gnus
690 :initialize
'custom-initialize-default
691 :link
'(custom-manual "(message)Mail Variables")
692 :group
'message-mail
)
694 (defcustom message-send-news-function
'message-send-news
695 "Function to call to send the current buffer as news.
696 The headers should be delimited by a line whose contents match the
697 variable `mail-header-separator'."
698 :group
'message-sending
700 :link
'(custom-manual "(message)News Variables")
703 (defcustom message-reply-to-function nil
704 "If non-nil, function that should return a list of headers.
705 This function should pick out addresses from the To, Cc, and From headers
706 and respond with new To and Cc headers."
707 :group
'message-interface
708 :link
'(custom-manual "(message)Reply")
709 :type
'(choice function
(const nil
)))
711 (defcustom message-wide-reply-to-function nil
712 "If non-nil, function that should return a list of headers.
713 This function should pick out addresses from the To, Cc, and From headers
714 and respond with new To and Cc headers."
715 :group
'message-interface
716 :link
'(custom-manual "(message)Wide Reply")
717 :type
'(choice function
(const nil
)))
719 (defcustom message-followup-to-function nil
720 "If non-nil, function that should return a list of headers.
721 This function should pick out addresses from the To, Cc, and From headers
722 and respond with new To and Cc headers."
723 :group
'message-interface
724 :link
'(custom-manual "(message)Followup")
725 :type
'(choice function
(const nil
)))
727 (defcustom message-extra-wide-headers nil
728 "If non-nil, a list of additional address headers.
729 These are used when composing a wide reply."
730 :group
'message-sending
731 :type
'(repeat string
))
733 (defcustom message-use-followup-to
'ask
734 "*Specifies what to do with Followup-To header.
735 If nil, always ignore the header. If it is t, use its value, but
736 query before using the \"poster\" value. If it is the symbol `ask',
737 always query the user whether to use the value. If it is the symbol
738 `use', always use the value."
739 :group
'message-interface
740 :link
'(custom-manual "(message)Followup")
741 :type
'(choice (const :tag
"ignore" nil
)
742 (const :tag
"use & query" t
)
746 (defcustom message-use-mail-followup-to
'use
747 "*Specifies what to do with Mail-Followup-To header.
748 If nil, always ignore the header. If it is the symbol `ask', always
749 query the user whether to use the value. If it is the symbol `use',
750 always use the value."
752 :group
'message-interface
753 :link
'(custom-manual "(message)Mailing Lists")
754 :type
'(choice (const :tag
"ignore" nil
)
758 (defcustom message-subscribed-address-functions nil
759 "*Specifies functions for determining list subscription.
760 If nil, do not attempt to determine list subscription with functions.
761 If non-nil, this variable contains a list of functions which return
762 regular expressions to match lists. These functions can be used in
763 conjunction with `message-subscribed-regexps' and
764 `message-subscribed-addresses'."
766 :group
'message-interface
767 :link
'(custom-manual "(message)Mailing Lists")
768 :type
'(repeat sexp
))
770 (defcustom message-subscribed-address-file nil
771 "*A file containing addresses the user is subscribed to.
772 If nil, do not look at any files to determine list subscriptions. If
773 non-nil, each line of this file should be a mailing list address."
775 :group
'message-interface
776 :link
'(custom-manual "(message)Mailing Lists")
777 :type
'(radio file
(const nil
)))
779 (defcustom message-subscribed-addresses nil
780 "*Specifies a list of addresses the user is subscribed to.
781 If nil, do not use any predefined list subscriptions. This list of
782 addresses can be used in conjunction with
783 `message-subscribed-address-functions' and `message-subscribed-regexps'."
785 :group
'message-interface
786 :link
'(custom-manual "(message)Mailing Lists")
787 :type
'(repeat string
))
789 (defcustom message-subscribed-regexps nil
790 "*Specifies a list of addresses the user is subscribed to.
791 If nil, do not use any predefined list subscriptions. This list of
792 regular expressions can be used in conjunction with
793 `message-subscribed-address-functions' and `message-subscribed-addresses'."
795 :group
'message-interface
796 :link
'(custom-manual "(message)Mailing Lists")
797 :type
'(repeat regexp
))
799 (defcustom message-allow-no-recipients
'ask
800 "Specifies what to do when there are no recipients other than Gcc/Fcc.
801 If it is the symbol `always', the posting is allowed. If it is the
802 symbol `never', the posting is not allowed. If it is the symbol
803 `ask', you are prompted."
805 :group
'message-interface
806 :link
'(custom-manual "(message)Message Headers")
807 :type
'(choice (const always
)
811 (defcustom message-sendmail-f-is-evil nil
812 "*Non-nil means don't add \"-f username\" to the sendmail command line.
813 Doing so would be even more evil than leaving it out."
814 :group
'message-sending
815 :link
'(custom-manual "(message)Mail Variables")
818 (defcustom message-sendmail-envelope-from nil
819 "*Envelope-from when sending mail with sendmail.
820 If this is nil, use `user-mail-address'. If it is the symbol
821 `header', use the From: header of the message."
823 :type
'(choice (string :tag
"From name")
824 (const :tag
"Use From: header from message" header
)
825 (const :tag
"Use `user-mail-address'" nil
))
826 :link
'(custom-manual "(message)Mail Variables")
827 :group
'message-sending
)
829 (defcustom message-sendmail-extra-arguments nil
830 "Additional arguments to `sendmail-program'."
831 ;; E.g. '("-a" "account") for msmtp
832 :version
"23.1" ;; No Gnus
833 :type
'(repeat string
)
834 ;; :link '(custom-manual "(message)Mail Variables")
835 :group
'message-sending
)
837 ;; qmail-related stuff
838 (defcustom message-qmail-inject-program
"/var/qmail/bin/qmail-inject"
839 "Location of the qmail-inject program."
840 :group
'message-sending
841 :link
'(custom-manual "(message)Mail Variables")
844 (defcustom message-qmail-inject-args nil
845 "Arguments passed to qmail-inject programs.
846 This should be a list of strings, one string for each argument. It
847 may also be a function.
849 For e.g., if you wish to set the envelope sender address so that bounces
850 go to the right place or to deal with listserv's usage of that address, you
851 might set this variable to '(\"-f\" \"you@some.where\")."
852 :group
'message-sending
853 :link
'(custom-manual "(message)Mail Variables")
854 :type
'(choice (function)
857 (defvar gnus-post-method
)
858 (defvar gnus-select-method
)
859 (defcustom message-post-method
860 (cond ((and (boundp 'gnus-post-method
)
861 (listp gnus-post-method
)
864 ((boundp 'gnus-select-method
)
867 "*Method used to post news.
868 Note that when posting from inside Gnus, for instance, this
869 variable isn't used."
871 :group
'message-sending
872 ;; This should be the `gnus-select-method' widget, but that might
873 ;; create a dependence to `gnus.el'.
876 ;; FIXME: This should be a temporary workaround until someone implements a
877 ;; proper solution. If a crash happens while replying, the auto-save file
878 ;; will *not* have a `References:' header if `message-generate-headers-first'
879 ;; is nil. See: http://article.gmane.org/gmane.emacs.gnus.general/51138
880 (defcustom message-generate-headers-first
'(references)
881 "Which headers should be generated before starting to compose a message.
882 If t, generate all required headers. This can also be a list of headers to
883 generate. The variables `message-required-news-headers' and
884 `message-required-mail-headers' specify which headers to generate.
886 Note that the variable `message-deletable-headers' specifies headers which
887 are to be deleted and then re-generated before sending, so this variable
888 will not have a visible effect for those headers."
889 :group
'message-headers
890 :link
'(custom-manual "(message)Message Headers")
891 :type
'(choice (const :tag
"None" nil
)
892 (const :tag
"References" '(references))
894 (repeat (sexp :tag
"Header"))))
896 (defcustom message-fill-column
72
897 "Column beyond which automatic line-wrapping should happen.
898 Local value for message buffers. If non-nil, also turn on
899 auto-fill in message buffers."
900 :group
'message-various
901 ;; :link '(custom-manual "(message)Message Headers")
902 :type
'(choice (const :tag
"Don't turn on auto fill" nil
)
905 (defcustom message-setup-hook nil
906 "Normal hook, run each time a new outgoing message is initialized.
907 The function `message-setup' runs this hook."
908 :group
'message-various
909 :link
'(custom-manual "(message)Various Message Variables")
912 (defcustom message-cancel-hook nil
913 "Hook run when cancelling articles."
914 :group
'message-various
915 :link
'(custom-manual "(message)Various Message Variables")
918 (defcustom message-signature-setup-hook nil
919 "Normal hook, run each time a new outgoing message is initialized.
920 It is run after the headers have been inserted and before
921 the signature is inserted."
922 :group
'message-various
923 :link
'(custom-manual "(message)Various Message Variables")
926 (defcustom message-mode-hook nil
927 "Hook run in message mode buffers."
928 :group
'message-various
931 (defcustom message-header-hook nil
932 "Hook run in a message mode buffer narrowed to the headers."
933 :group
'message-various
936 (defcustom message-header-setup-hook nil
937 "Hook called narrowed to the headers when setting up a message buffer."
938 :group
'message-various
939 :link
'(custom-manual "(message)Various Message Variables")
942 (defcustom message-minibuffer-local-map
943 (let ((map (make-sparse-keymap 'message-minibuffer-local-map
)))
944 (set-keymap-parent map minibuffer-local-map
)
946 "Keymap for `message-read-from-minibuffer'."
948 :group
'message-various
)
950 (defcustom message-citation-line-function
'message-insert-citation-line
951 "*Function called to insert the \"Whomever writes:\" line.
953 Predefined functions include `message-insert-citation-line' and
954 `message-insert-formatted-citation-line' (see the variable
955 `message-citation-line-format').
957 Note that Gnus provides a feature where the reader can click on
958 `writes:' to hide the cited text. If you change this line too much,
959 people who read your message will have to change their Gnus
960 configuration. See the variable `gnus-cite-attribution-suffix'."
962 (function-item :tag
"plain" message-insert-citation-line
)
963 (function-item :tag
"formatted" message-insert-formatted-citation-line
)
964 (function :tag
"Other"))
965 :link
'(custom-manual "(message)Insertion Variables")
966 :group
'message-insertion
)
968 (defcustom message-citation-line-format
"On %a, %b %d %Y, %N wrote:\n"
969 "Format of the \"Whomever writes:\" line.
971 The string is formatted using `format-spec'. The following
972 constructs are replaced:
974 %f The full From, e.g. \"John Doe <john.doe@example.invalid>\".
975 %n The mail address, e.g. \"john.doe@example.invalid\".
976 %N The real name if present, e.g.: \"John Doe\", else fall
977 back to the mail address.
978 %F The first name if present, e.g.: \"John\".
979 %L The last name if present, e.g.: \"Doe\".
981 All other format specifiers are passed to `format-time-string'
982 which is called using the date from the article your replying to.
983 Extracting the first (%F) and last name (%L) is done
984 heuristically, so you should always check it yourself.
986 Please also read the note in the documentation of
987 `message-citation-line-function'."
988 :type
'(choice (const :tag
"Plain" "%f writes:")
989 (const :tag
"Include date" "On %a, %b %d %Y, %n wrote:")
991 :link
'(custom-manual "(message)Insertion Variables")
992 :version
"23.1" ;; No Gnus
993 :group
'message-insertion
)
995 (defcustom message-yank-prefix
"> "
996 "*Prefix inserted on the lines of yanked messages.
997 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
998 See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
1000 :link
'(custom-manual "(message)Insertion Variables")
1001 :group
'message-insertion
)
1003 (defcustom message-yank-cited-prefix
">"
1004 "*Prefix inserted on cited lines of yanked messages.
1005 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
1006 See also `message-yank-prefix' and `message-yank-empty-prefix'."
1009 :link
'(custom-manual "(message)Insertion Variables")
1010 :group
'message-insertion
)
1012 (defcustom message-yank-empty-prefix
">"
1013 "*Prefix inserted on empty lines of yanked messages.
1014 See also `message-yank-prefix' and `message-yank-cited-prefix'."
1017 :link
'(custom-manual "(message)Insertion Variables")
1018 :group
'message-insertion
)
1020 (defcustom message-indentation-spaces
3
1021 "*Number of spaces to insert at the beginning of each cited line.
1022 Used by `message-yank-original' via `message-yank-cite'."
1023 :group
'message-insertion
1024 :link
'(custom-manual "(message)Insertion Variables")
1027 (defcustom message-cite-function
'message-cite-original-without-signature
1028 "*Function for citing an original message.
1029 Predefined functions include `message-cite-original' and
1030 `message-cite-original-without-signature'.
1031 Note that these functions use `mail-citation-hook' if that is non-nil."
1032 :type
'(radio (function-item message-cite-original
)
1033 (function-item message-cite-original-without-signature
)
1034 (function-item sc-cite-original
)
1035 (function :tag
"Other"))
1036 :link
'(custom-manual "(message)Insertion Variables")
1037 :version
"22.3" ;; Gnus 5.10.12 (changed default)
1038 :group
'message-insertion
)
1040 (defcustom message-indent-citation-function
'message-indent-citation
1041 "*Function for modifying a citation just inserted in the mail buffer.
1042 This can also be a list of functions. Each function can find the
1043 citation between (point) and (mark t). And each function should leave
1044 point and mark around the citation text as modified."
1046 :link
'(custom-manual "(message)Insertion Variables")
1047 :group
'message-insertion
)
1049 (defcustom message-signature t
1050 "*String to be inserted at the end of the message buffer.
1051 If t, the `message-signature-file' file will be inserted instead.
1052 If a function, the result from the function will be used instead.
1053 If a form, the result from the form will be used instead."
1055 :link
'(custom-manual "(message)Insertion Variables")
1056 :group
'message-insertion
)
1058 (defcustom message-signature-file
"~/.signature"
1059 "*Name of file containing the text inserted at end of message buffer.
1060 Ignored if the named file doesn't exist.
1061 If nil, don't insert a signature.
1062 If a path is specified, the value of `message-signature-directory' is ignored,
1064 :type
'(choice file
(const :tags
"None" nil
))
1065 :link
'(custom-manual "(message)Insertion Variables")
1066 :group
'message-insertion
)
1068 (defcustom message-signature-directory nil
1069 "*Name of directory containing signature files.
1070 Comes in handy if you have many such files, handled via posting styles for
1072 If nil, `message-signature-file' is expected to specify the directory if
1074 :type
'(choice string
(const :tags
"None" nil
))
1075 :link
'(custom-manual "(message)Insertion Variables")
1076 :group
'message-insertion
)
1078 (defcustom message-signature-insert-empty-line t
1079 "*If non-nil, insert an empty line before the signature separator."
1082 :link
'(custom-manual "(message)Insertion Variables")
1083 :group
'message-insertion
)
1085 (defcustom message-distribution-function nil
1086 "*Function called to return a Distribution header."
1087 :group
'message-news
1088 :group
'message-headers
1089 :link
'(custom-manual "(message)News Headers")
1090 :type
'(choice function
(const nil
)))
1092 (defcustom message-expires
14
1093 "Number of days before your article expires."
1094 :group
'message-news
1095 :group
'message-headers
1096 :link
'(custom-manual "(message)News Headers")
1099 (defcustom message-user-path nil
1100 "If nil, use the NNTP server name in the Path header.
1101 If stringp, use this; if non-nil, use no host name (user name only)."
1102 :group
'message-news
1103 :group
'message-headers
1104 :link
'(custom-manual "(message)News Headers")
1105 :type
'(choice (const :tag
"nntp" nil
)
1106 (string :tag
"name")
1107 (sexp :tag
"none" :format
"%t" t
)))
1109 (defvar message-reply-buffer nil
)
1110 (defvar message-reply-headers nil
1111 "The headers of the current replied article.
1112 It is a vector of the following headers:
1113 \[number subject from date id references chars lines xref extra].")
1114 (defvar message-newsreader nil
)
1115 (defvar message-mailer nil
)
1116 (defvar message-sent-message-via nil
)
1117 (defvar message-checksum nil
)
1118 (defvar message-send-actions nil
1119 "A list of actions to be performed upon successful sending of a message.")
1120 (defvar message-exit-actions nil
1121 "A list of actions to be performed upon exiting after sending a message.")
1122 (defvar message-kill-actions nil
1123 "A list of actions to be performed before killing a message buffer.")
1124 (defvar message-postpone-actions nil
1125 "A list of actions to be performed after postponing a message.")
1127 (define-widget 'message-header-lines
'text
1128 "All header lines must be LFD terminated."
1129 :format
"%{%t%}:%n%v"
1130 :valid-regexp
"^\\'"
1131 :error
"All header lines must be newline terminated")
1133 (defcustom message-default-headers
""
1134 "*A string containing header lines to be inserted in outgoing messages.
1135 It is inserted before you edit the message, so you can edit or delete
1137 :group
'message-headers
1138 :link
'(custom-manual "(message)Message Headers")
1139 :type
'message-header-lines
)
1141 (defcustom message-default-mail-headers
""
1142 "*A string of header lines to be inserted in outgoing mails."
1143 :group
'message-headers
1144 :group
'message-mail
1145 :link
'(custom-manual "(message)Mail Headers")
1146 :type
'message-header-lines
)
1148 (defcustom message-default-news-headers
""
1149 "*A string of header lines to be inserted in outgoing news articles."
1150 :group
'message-headers
1151 :group
'message-news
1152 :link
'(custom-manual "(message)News Headers")
1153 :type
'message-header-lines
)
1155 ;; Note: could use /usr/ucb/mail instead of sendmail;
1156 ;; options -t, and -v if not interactive.
1157 (defcustom message-mailer-swallows-blank-line
1158 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
1159 system-configuration
)
1160 (file-readable-p "/etc/sendmail.cf")
1161 (let ((buffer (get-buffer-create " *temp*")))
1163 (with-current-buffer buffer
1164 (insert-file-contents "/etc/sendmail.cf")
1165 (goto-char (point-min))
1166 (let ((case-fold-search nil
))
1167 (re-search-forward "^OR\\>" nil t
)))
1168 (kill-buffer buffer
))))
1169 ;; According to RFC822, "The field-name must be composed of printable
1170 ;; ASCII characters (i. e., characters that have decimal values between
1171 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
1173 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1174 "*Set this non-nil if the system's mailer runs the header and body together.
1175 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
1176 The value should be an expression to test whether the problem will
1178 :group
'message-sending
1179 :link
'(custom-manual "(message)Mail Variables")
1183 (define-mail-user-agent 'message-user-agent
1184 'message-mail
'message-send-and-exit
1185 'message-kill-buffer
'message-send-hook
)
1187 (defvar message-mh-deletable-headers
'(Message-ID Date Lines Sender
)
1188 "If non-nil, delete the deletable headers before feeding to mh.")
1190 (defvar message-send-method-alist
1191 '((news message-news-p message-send-via-news
)
1192 (mail message-mail-p message-send-via-mail
))
1193 "Alist of ways to send outgoing messages.
1194 Each element has the form
1196 \(TYPE PREDICATE FUNCTION)
1198 where TYPE is a symbol that names the method; PREDICATE is a function
1199 called without any parameters to determine whether the message is
1200 a message of type TYPE; and FUNCTION is a function to be called if
1201 PREDICATE returns non-nil. FUNCTION is called with one parameter --
1204 (defcustom message-mail-alias-type
'abbrev
1205 "*What alias expansion type to use in Message buffers.
1206 The default is `abbrev', which uses mailabbrev. `ecomplete' uses
1207 an electric completion mode. nil switches mail aliases off.
1208 This can also be a list of values."
1210 :link
'(custom-manual "(message)Mail Aliases")
1211 :type
'(choice (const :tag
"Use Mailabbrev" abbrev
)
1212 (const :tag
"Use ecomplete" ecomplete
)
1213 (const :tag
"No expansion" nil
)))
1215 (defcustom message-self-insert-commands
'(self-insert-command)
1216 "List of `self-insert-command's used to trigger ecomplete.
1217 When one of those commands is invoked to enter a character in To or Cc
1218 header, ecomplete will suggest the candidates of recipients (see also
1219 `message-mail-alias-type'). If you use some tool to enter non-ASCII
1220 text and it replaces `self-insert-command' with the other command, e.g.
1221 `egg-self-insert-command', you may want to add it to this list."
1222 :group
'message-various
1223 :type
'(repeat function
))
1225 (defcustom message-auto-save-directory
1226 (file-name-as-directory (nnheader-concat message-directory
"drafts"))
1227 "*Directory where Message auto-saves buffers if Gnus isn't running.
1228 If nil, Message won't auto-save."
1229 :group
'message-buffers
1230 :link
'(custom-manual "(message)Various Message Variables")
1231 :type
'(choice directory
(const :tag
"Don't auto-save" nil
)))
1233 (defcustom message-default-charset
1234 (and (not (mm-multibyte-p)) 'iso-8859-1
)
1235 "Default charset used in non-MULE Emacsen.
1236 If nil, you might be asked to input the charset."
1239 :link
'(custom-manual "(message)Various Message Variables")
1242 (defcustom message-dont-reply-to-names
1243 (and (boundp 'rmail-dont-reply-to-names
) rmail-dont-reply-to-names
)
1244 "*Addresses to prune when doing wide replies.
1245 This can be a regexp or a list of regexps. Also, a value of nil means
1246 exclude your own user name only."
1249 :link
'(custom-manual "(message)Wide Reply")
1250 :type
'(choice (const :tag
"Yourself" nil
)
1252 (repeat :tag
"Regexp List" regexp
)))
1254 (defsubst message-dont-reply-to-names
()
1255 (gmm-regexp-concat message-dont-reply-to-names
))
1257 (defvar message-shoot-gnksa-feet nil
1258 "*A list of GNKSA feet you are allowed to shoot.
1259 Gnus gives you all the opportunity you could possibly want for
1260 shooting yourself in the foot. Also, Gnus allows you to shoot the
1261 feet of Good Net-Keeping Seal of Approval. The following are foot
1263 `empty-article' Allow you to post an empty article;
1264 `quoted-text-only' Allow you to post quoted text only;
1265 `multiple-copies' Allow you to post multiple copies;
1266 `cancel-messages' Allow you to cancel or supersede messages from
1267 your other email addresses.")
1269 (defsubst message-gnksa-enable-p
(feature)
1270 (or (not (listp message-shoot-gnksa-feet
))
1271 (memq feature message-shoot-gnksa-feet
)))
1273 (defcustom message-hidden-headers
'("^References:" "^Face:" "^X-Face:"
1275 "Regexp of headers to be hidden when composing new messages.
1276 This can also be a list of regexps to match headers. Or a list
1277 starting with `not' and followed by regexps."
1280 :link
'(custom-manual "(message)Message Headers")
1282 :format
"%{%t%}: %[Value Type%] %v"
1283 (regexp :menu-tag
"regexp" :format
"regexp\n%t: %v")
1284 (repeat :menu-tag
"(regexp ...)" :format
"(regexp ...)\n%v%i"
1285 (regexp :format
"%t: %v"))
1286 (cons :menu-tag
"(not regexp ...)" :format
"(not regexp ...)\n%v"
1288 (repeat :format
"%v%i"
1289 (regexp :format
"%t: %v")))))
1291 (defcustom message-cite-articles-with-x-no-archive t
1292 "If non-nil, cite text from articles that has X-No-Archive set."
1296 ;;; Internal variables.
1297 ;;; Well, not really internal.
1299 (defvar message-mode-syntax-table
1300 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1301 (modify-syntax-entry ?%
". " table
)
1302 (modify-syntax-entry ?
> ". " table
)
1303 (modify-syntax-entry ?
< ". " table
)
1305 "Syntax table used while in Message mode.")
1307 (defface message-header-to
1310 (:foreground
"DarkOliveGreen1" :bold t
))
1313 (:foreground
"MidnightBlue" :bold t
))
1315 (:bold t
:italic t
)))
1316 "Face used for displaying From headers."
1317 :group
'message-faces
)
1318 ;; backward-compatibility alias
1319 (put 'message-header-to-face
'face-alias
'message-header-to
)
1321 (defface message-header-cc
1324 (:foreground
"chartreuse1" :bold t
))
1327 (:foreground
"MidnightBlue"))
1330 "Face used for displaying Cc headers."
1331 :group
'message-faces
)
1332 ;; backward-compatibility alias
1333 (put 'message-header-cc-face
'face-alias
'message-header-cc
)
1335 (defface message-header-subject
1338 (:foreground
"OliveDrab1"))
1341 (:foreground
"navy blue" :bold t
))
1344 "Face used for displaying subject headers."
1345 :group
'message-faces
)
1346 ;; backward-compatibility alias
1347 (put 'message-header-subject-face
'face-alias
'message-header-subject
)
1349 (defface message-header-newsgroups
1352 (:foreground
"yellow" :bold t
:italic t
))
1355 (:foreground
"blue4" :bold t
:italic t
))
1357 (:bold t
:italic t
)))
1358 "Face used for displaying newsgroups headers."
1359 :group
'message-faces
)
1360 ;; backward-compatibility alias
1361 (put 'message-header-newsgroups-face
'face-alias
'message-header-newsgroups
)
1363 (defface message-header-other
1366 (:foreground
"VioletRed1"))
1369 (:foreground
"steel blue"))
1371 (:bold t
:italic t
)))
1372 "Face used for displaying newsgroups headers."
1373 :group
'message-faces
)
1374 ;; backward-compatibility alias
1375 (put 'message-header-other-face
'face-alias
'message-header-other
)
1377 (defface message-header-name
1380 (:foreground
"green"))
1383 (:foreground
"cornflower blue"))
1386 "Face used for displaying header names."
1387 :group
'message-faces
)
1388 ;; backward-compatibility alias
1389 (put 'message-header-name-face
'face-alias
'message-header-name
)
1391 (defface message-header-xheader
1394 (:foreground
"DeepSkyBlue1"))
1397 (:foreground
"blue"))
1400 "Face used for displaying X-Header headers."
1401 :group
'message-faces
)
1402 ;; backward-compatibility alias
1403 (put 'message-header-xheader-face
'face-alias
'message-header-xheader
)
1405 (defface message-separator
1408 (:foreground
"LightSkyBlue1"))
1411 (:foreground
"brown"))
1414 "Face used for displaying the separator."
1415 :group
'message-faces
)
1416 ;; backward-compatibility alias
1417 (put 'message-separator-face
'face-alias
'message-separator
)
1419 (defface message-cited-text
1422 (:foreground
"LightPink1"))
1425 (:foreground
"red"))
1428 "Face used for displaying cited text names."
1429 :group
'message-faces
)
1430 ;; backward-compatibility alias
1431 (put 'message-cited-text-face
'face-alias
'message-cited-text
)
1433 (defface message-mml
1436 (:foreground
"MediumSpringGreen"))
1439 (:foreground
"ForestGreen"))
1442 "Face used for displaying MML."
1443 :group
'message-faces
)
1444 ;; backward-compatibility alias
1445 (put 'message-mml-face
'face-alias
'message-mml
)
1447 (defun message-font-lock-make-header-matcher (regexp)
1450 (let ((start (point)))
1453 (goto-char (point-min))
1454 (if (re-search-forward
1455 (concat "^" (regexp-quote mail-header-separator
) "$")
1457 (setq limit
(min limit
(match-beginning 0))))
1459 (and (< start limit
)
1460 (re-search-forward ,regexp limit t
))))))
1461 (if (featurep 'bytecomp
)
1465 (defvar message-font-lock-keywords
1466 (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
1467 `((,(message-font-lock-make-header-matcher
1468 (concat "^\\([Tt]o:\\)" content
))
1469 (1 'message-header-name
)
1470 (2 'message-header-to nil t
))
1471 (,(message-font-lock-make-header-matcher
1472 (concat "^\\(^[GBF]?[Cc][Cc]:\\|^[Rr]eply-[Tt]o:\\)" content
))
1473 (1 'message-header-name
)
1474 (2 'message-header-cc nil t
))
1475 (,(message-font-lock-make-header-matcher
1476 (concat "^\\([Ss]ubject:\\)" content
))
1477 (1 'message-header-name
)
1478 (2 'message-header-subject nil t
))
1479 (,(message-font-lock-make-header-matcher
1480 (concat "^\\([Nn]ewsgroups:\\|Followup-[Tt]o:\\)" content
))
1481 (1 'message-header-name
)
1482 (2 'message-header-newsgroups nil t
))
1483 (,(message-font-lock-make-header-matcher
1484 (concat "^\\(X-[A-Za-z0-9-]+:\\|In-Reply-To:\\)" content
))
1485 (1 'message-header-name
)
1486 (2 'message-header-xheader
))
1487 (,(message-font-lock-make-header-matcher
1488 (concat "^\\([A-Z][^: \n\t]+:\\)" content
))
1489 (1 'message-header-name
)
1490 (2 'message-header-other nil t
))
1491 ,@(if (and mail-header-separator
1492 (not (equal mail-header-separator
"")))
1493 `((,(concat "^\\(" (regexp-quote mail-header-separator
) "\\)$")
1494 1 'message-separator
))
1497 (re-search-forward (concat "^\\("
1498 message-cite-prefix-regexp
1501 (0 'message-cited-text
))
1502 ("<#/?\\(multipart\\|part\\|external\\|mml\\|secure\\)[^>]*>"
1504 "Additional expressions to highlight in Message mode.")
1507 ;; XEmacs does it like this. For Emacs, we have to set the
1508 ;; `font-lock-defaults' buffer-local variable.
1509 (put 'message-mode
'font-lock-defaults
'(message-font-lock-keywords t
))
1511 (defvar message-face-alist
1512 '((bold . message-bold-region
)
1513 (underline . underline-region
)
1514 (default .
(lambda (b e
)
1515 (message-unbold-region b e
)
1516 (ununderline-region b e
))))
1517 "Alist of mail and news faces for facemenu.
1518 The cdr of each entry is a function for applying the face to a region.")
1520 (defcustom message-send-hook nil
1521 "Hook run before sending messages.
1522 This hook is run quite early when sending."
1523 :group
'message-various
1524 :options
'(ispell-message)
1525 :link
'(custom-manual "(message)Various Message Variables")
1528 (defcustom message-send-mail-hook nil
1529 "Hook run before sending mail messages.
1530 This hook is run very late -- just before the message is sent as
1532 :group
'message-various
1533 :link
'(custom-manual "(message)Various Message Variables")
1536 (defcustom message-send-news-hook nil
1537 "Hook run before sending news messages.
1538 This hook is run very late -- just before the message is sent as
1540 :group
'message-various
1541 :link
'(custom-manual "(message)Various Message Variables")
1544 (defcustom message-sent-hook nil
1545 "Hook run after sending messages."
1546 :group
'message-various
1549 (defvar message-send-coding-system
'binary
1550 "Coding system to encode outgoing mail.")
1552 (defvar message-draft-coding-system
1553 mm-auto-save-coding-system
1554 "*Coding system to compose mail.
1555 If you'd like to make it possible to share draft files between XEmacs
1556 and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
1557 Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
1559 (defcustom message-send-mail-partially-limit
1000000
1560 "The limitation of messages sent as message/partial.
1561 The lower bound of message size in characters, beyond which the message
1562 should be sent in several parts. If it is nil, the size is unlimited."
1564 :group
'message-buffers
1565 :link
'(custom-manual "(message)Mail Variables")
1566 :type
'(choice (const :tag
"unlimited" nil
)
1569 (defcustom message-alternative-emails nil
1570 "*Regexp matching alternative email addresses.
1571 The first address in the To, Cc or From headers of the original
1572 article matching this variable is used as the From field of
1575 This variable has precedence over posting styles and anything that runs
1576 off `message-setup-hook'."
1577 :group
'message-headers
1578 :link
'(custom-manual "(message)Message Headers")
1579 :type
'(choice (const :tag
"Always use primary" nil
)
1582 (defcustom message-hierarchical-addresses nil
1583 "A list of hierarchical mail address definitions.
1585 Inside each entry, the first address is the \"top\" address, and
1586 subsequent addresses are subaddresses; this is used to indicate that
1587 mail sent to the first address will automatically be delivered to the
1588 subaddresses. So if the first address appears in the recipient list
1589 for a message, the subaddresses will be removed (if present) before
1590 the mail is sent. All addresses in this structure should be
1593 :group
'message-headers
1594 :type
'(repeat (repeat string
)))
1596 (defcustom message-mail-user-agent nil
1597 "Like `mail-user-agent'.
1598 Except if it is nil, use Gnus native MUA; if it is t, use
1601 :type
'(radio (const :tag
"Gnus native"
1604 (const :tag
"`mail-user-agent'"
1607 (function-item :tag
"Default Emacs mail"
1609 sendmail-user-agent
)
1610 (function-item :tag
"Emacs interface to MH"
1613 (function :tag
"Other"))
1617 (defcustom message-wide-reply-confirm-recipients nil
1618 "Whether to confirm a wide reply to multiple email recipients.
1619 If this variable is nil, don't ask whether to reply to all recipients.
1620 If this variable is non-nil, pose the question \"Reply to all
1621 recipients?\" before a wide reply to multiple recipients. If the user
1622 answers yes, reply to all recipients as usual. If the user answers
1623 no, only reply back to the author."
1625 :group
'message-headers
1626 :link
'(custom-manual "(message)Wide Reply")
1629 (defcustom message-user-fqdn nil
1630 "*Domain part of Message-Ids."
1632 :group
'message-headers
1633 :link
'(custom-manual "(message)News Headers")
1634 :type
'(radio (const :format
"%v " nil
)
1635 (string :format
"FQDN: %v")))
1637 (defcustom message-use-idna
(and (condition-case nil
(require 'idna
)
1639 (mm-coding-system-p 'utf-8
)
1640 (executable-find idna-program
)
1641 (string= (idna-to-ascii "räksmörgås")
1642 "xn--rksmrgs-5wao1o")
1644 "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
1645 GNU Libidn, and in particular the elisp package \"idna.el\" and
1646 the external program \"idn\", must be installed for this
1647 functionality to work."
1649 :group
'message-headers
1650 :link
'(custom-manual "(message)IDNA")
1651 :type
'(choice (const :tag
"Ask" ask
)
1652 (const :tag
"Never" nil
)
1653 (const :tag
"Always" t
)))
1655 (defcustom message-generate-hashcash
(if (executable-find "hashcash") t
)
1656 "*Whether to generate X-Hashcash: headers.
1657 If t, always generate hashcash headers. If `opportunistic',
1658 only generate hashcash headers if it can be done without the user
1659 waiting (i.e., only asynchronously).
1661 You must have the \"hashcash\" binary installed, see `hashcash-path'."
1662 :group
'message-headers
1663 :link
'(custom-manual "(message)Mail Headers")
1664 :type
'(choice (const :tag
"Always" t
)
1665 (const :tag
"Never" nil
)
1666 (const :tag
"Opportunistic" opportunistic
)))
1668 ;;; Internal variables.
1670 (defvar message-sending-message
"Sending...")
1671 (defvar message-buffer-list nil
)
1672 (defvar message-this-is-news nil
)
1673 (defvar message-this-is-mail nil
)
1674 (defvar message-draft-article nil
)
1675 (defvar message-mime-part nil
)
1676 (defvar message-posting-charset nil
)
1677 (defvar message-inserted-headers nil
)
1679 ;; Byte-compiler warning
1680 (defvar gnus-active-hashtb
)
1681 (defvar gnus-read-active-file
)
1683 ;;; Regexp matching the delimiter of messages in UNIX mail format
1684 ;;; (UNIX From lines), minus the initial ^. It should be a copy
1685 ;;; of rmail.el's rmail-unix-mail-delimiter.
1686 (defvar message-unix-mail-delimiter
1687 (let ((time-zone-regexp
1688 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1689 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1695 ;; Many things can happen to an RFC 822 mailbox before it is put into
1696 ;; a `From' line. The leading phrase can be stripped, e.g.
1697 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
1698 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
1699 ;; can be removed, e.g.
1700 ;; From: joe@y.z (Joe K
1702 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
1705 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1706 ;; The mailbox can be removed or be replaced by white space, e.g.
1707 ;; From: "Joe User"{space}{tab}
1709 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1710 ;; where {space} and {tab} represent the Ascii space and tab characters.
1711 ;; We want to match the results of any of these manglings.
1712 ;; The following regexp rejects names whose first characters are
1713 ;; obviously bogus, but after that anything goes.
1714 "\\([^\0-\b\n-\r\^?].*\\)?"
1716 ;; The time the message was sent.
1717 "\\([^\0-\r \^?]+\\) +" ; day of the week
1718 "\\([^\0-\r \^?]+\\) +" ; month
1719 "\\([0-3]?[0-9]\\) +" ; day of month
1720 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
1722 ;; Perhaps a time zone, specified by an abbreviation, or by a
1727 " \\([0-9][0-9]+\\) *"
1729 ;; On some systems the time zone can appear after the year, too.
1733 "\\(remote from .*\\)?"
1736 "Regexp matching the delimiter of messages in UNIX mail format.")
1738 (defvar message-unsent-separator
1739 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1740 "^ *---+ +Returned message +---+ *$\\|"
1741 "^Start of returned message$\\|"
1742 "^ *---+ +Original message +---+ *$\\|"
1743 "^ *--+ +begin message +--+ *$\\|"
1744 "^ *---+ +Original message follows +---+ *$\\|"
1745 "^ *---+ +Undelivered message follows +---+ *$\\|"
1746 "^------ This is a copy of the message, including all the headers. ------ *$\\|"
1747 "^|? *---+ +Message text follows: +---+ *|?$")
1748 "A regexp that matches the separator before the text of a failed message.")
1750 (defvar message-field-fillers
1751 '((To message-fill-field-address
)
1752 (Cc message-fill-field-address
)
1753 (From message-fill-field-address
))
1754 "Alist of header names/filler functions.")
1756 (defvar message-header-format-alist
1771 (References . message-shorten-references
)
1773 "Alist used for formatting headers.")
1775 (defvar message-options nil
1776 "Some saved answers when sending message.")
1778 (defvar message-send-mail-real-function nil
1779 "Internal send mail function.")
1781 (defvar message-bogus-system-names
"^localhost\\.\\|\\.local$"
1782 "The regexp of bogus system names.")
1784 (defcustom message-valid-fqdn-regexp
1785 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
1787 "\\([a-z][a-z]\\|" ;; two letter country TDLs
1788 "aero\\|arpa\\|bitnet\\|biz\\|bofh\\|"
1789 "cat\\|com\\|coop\\|edu\\|gov\\|"
1790 "info\\|int\\|jobs\\|"
1791 "mil\\|mobi\\|museum\\|name\\|net\\|"
1792 "org\\|pro\\|travel\\|uucp\\)")
1793 ;; http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
1794 ;; http://en.wikipedia.org/wiki/GTLD
1795 ;; `in the process of being approved': .asia .post .tel .sex
1796 ;; "dead" nato bitnet uucp
1797 "Regular expression that matches a valid FQDN."
1798 ;; see also: gnus-button-valid-fqdn-regexp
1800 :group
'message-headers
1803 (autoload 'gnus-alive-p
"gnus-util")
1804 (autoload 'gnus-delay-article
"gnus-delay")
1805 (autoload 'gnus-extract-address-components
"gnus-util")
1806 (autoload 'gnus-find-method-for-group
"gnus")
1807 (autoload 'gnus-group-decoded-name
"gnus-group")
1808 (autoload 'gnus-group-name-charset
"gnus-group")
1809 (autoload 'gnus-group-name-decode
"gnus-group")
1810 (autoload 'gnus-groups-from-server
"gnus")
1811 (autoload 'gnus-make-local-hook
"gnus-util")
1812 (autoload 'gnus-open-server
"gnus-int")
1813 (autoload 'gnus-output-to-mail
"gnus-util")
1814 (autoload 'gnus-output-to-rmail
"gnus-util")
1815 (autoload 'gnus-request-post
"gnus-int")
1816 (autoload 'gnus-select-frame-set-input-focus
"gnus-util")
1817 (autoload 'gnus-server-string
"gnus")
1818 (autoload 'idna-to-ascii
"idna")
1819 (autoload 'message-setup-toolbar
"messagexmas")
1820 (autoload 'mh-new-draft-name
"mh-comp")
1821 (autoload 'mh-send-letter
"mh-comp")
1822 (autoload 'nndraft-request-associate-buffer
"nndraft")
1823 (autoload 'nndraft-request-expire-articles
"nndraft")
1824 (autoload 'nnvirtual-find-group-art
"nnvirtual")
1825 (autoload 'rmail-dont-reply-to
"mail-utils")
1826 (autoload 'rmail-msg-is-pruned
"rmail")
1827 (autoload 'rmail-msg-restore-non-pruned-header
"rmail")
1828 (autoload 'rmail-output
"rmailout")
1833 ;;; Utility functions.
1836 (defmacro message-y-or-n-p
(question show
&rest text
)
1837 "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW."
1838 `(message-talkative-question 'y-or-n-p
,question
,show
,@text
))
1840 (defmacro message-delete-line
(&optional n
)
1841 "Delete the current line (and the next N lines)."
1842 `(delete-region (progn (beginning-of-line) (point))
1843 (progn (forward-line ,(or n
1)) (point))))
1845 (defun message-mark-active-p ()
1846 "Non-nil means the mark and region are currently active in this buffer."
1849 (defun message-unquote-tokens (elems)
1850 "Remove double quotes (\") from strings in list ELEMS."
1851 (mapcar (lambda (item)
1852 (while (string-match "^\\(.*\\)\"\\(.*\\)$" item
)
1853 (setq item
(concat (match-string 1 item
)
1854 (match-string 2 item
))))
1858 (defun message-tokenize-header (header &optional separator
)
1859 "Split HEADER into a list of header elements.
1860 SEPARATOR is a string of characters to be used as separators. \",\"
1861 is used by default."
1864 (let ((regexp (format "[%s]+" (or separator
",")))
1866 beg quoted elems paren
)
1868 (mm-enable-multibyte)
1869 (setq beg
(point-min))
1871 (goto-char (point-min))
1876 (cond ((and (> (point) beg
)
1878 (and (looking-at regexp
)
1881 (push (buffer-substring beg
(point)) elems
)
1882 (setq beg
(match-end 0)))
1883 ((eq (char-after) ?
\")
1884 (setq quoted
(not quoted
)))
1885 ((and (eq (char-after) ?\
()
1888 ((and (eq (char-after) ?\
))
1891 (nreverse elems
)))))
1893 (defun message-mail-file-mbox-p (file)
1894 "Say whether FILE looks like a Unix mbox file."
1895 (when (and (file-exists-p file
)
1896 (file-readable-p file
)
1897 (file-regular-p file
))
1899 (nnheader-insert-file-contents file
)
1900 (goto-char (point-min))
1901 (looking-at message-unix-mail-delimiter
))))
1903 (defun message-fetch-field (header &optional not-all
)
1904 "The same as `mail-fetch-field', only remove all newlines.
1905 The buffer is expected to be narrowed to just the header of the message;
1906 see `message-narrow-to-headers-or-head'."
1907 (let* ((inhibit-point-motion-hooks t
)
1908 (value (mail-fetch-field header nil
(not not-all
))))
1910 (while (string-match "\n[\t ]+" value
)
1911 (setq value
(replace-match " " t t value
)))
1914 (defun message-field-value (header &optional not-all
)
1915 "The same as `message-fetch-field', only narrow to the headers first."
1918 (message-narrow-to-headers-or-head)
1919 (message-fetch-field header not-all
))))
1921 (defun message-narrow-to-field ()
1922 "Narrow the buffer to the header on the current line."
1924 (while (looking-at "[ \t]")
1930 (if (re-search-forward "^[^ \n\t]" nil t
)
1933 (goto-char (point-min)))
1935 (defun message-add-header (&rest headers
)
1936 "Add the HEADERS to the message header, skipping those already present."
1939 (unless (string-match "^\\([^:]+\\):[ \t]*[^ \t]" (car headers
))
1940 (error "Invalid header `%s'" (car headers
)))
1941 (setq hclean
(match-string 1 (car headers
)))
1943 (message-narrow-to-headers)
1944 (unless (re-search-forward (concat "^" (regexp-quote hclean
) ":") nil t
)
1945 (goto-char (point-max))
1946 (if (string-match "\n$" (car headers
))
1947 (insert (car headers
))
1948 (insert (car headers
) ?
\n)))))
1949 (setq headers
(cdr headers
))))
1951 (defmacro message-with-reply-buffer
(&rest forms
)
1952 "Evaluate FORMS in the reply buffer, if it exists."
1953 `(when (and message-reply-buffer
1954 (buffer-name message-reply-buffer
))
1955 (with-current-buffer message-reply-buffer
1958 (put 'message-with-reply-buffer
'lisp-indent-function
0)
1959 (put 'message-with-reply-buffer
'edebug-form-spec
'(body))
1961 (defun message-fetch-reply-field (header)
1962 "Fetch field HEADER from the message we're replying to."
1963 (message-with-reply-buffer
1965 (mail-narrow-to-head)
1966 (message-fetch-field header
))))
1968 (defun message-strip-list-identifiers (subject)
1969 "Remove list identifiers in `gnus-list-identifiers' from string SUBJECT."
1970 (require 'gnus-sum
) ; for gnus-list-identifiers
1971 (let ((regexp (if (stringp gnus-list-identifiers
)
1972 gnus-list-identifiers
1973 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
1974 (if (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
1975 " *\\)\\)+\\(Re: +\\)?\\)") subject
)
1976 (concat (substring subject
0 (match-beginning 1))
1977 (or (match-string 3 subject
)
1978 (match-string 5 subject
))
1983 (defun message-strip-subject-re (subject)
1984 "Remove \"Re:\" from subject lines in string SUBJECT."
1985 (if (string-match message-subject-re-regexp subject
)
1986 (substring subject
(match-end 0))
1989 (defcustom message-replacement-char
"."
1990 "Replacement character used instead of unprintable or not decodable chars."
1991 :group
'message-various
1992 :version
"22.1" ;; Gnus 5.10.9
1993 :type
'(choice string
1997 ;; FIXME: We also should call `message-strip-subject-encoded-words'
1998 ;; when forwarding. Probably in `message-make-forward-subject' and
1999 ;; `message-forward-make-body'.
2001 (defun message-strip-subject-encoded-words (subject)
2002 "Fix non-decodable words in SUBJECT."
2003 ;; Cf. `gnus-simplify-subject-fully'.
2004 (let* ((case-fold-search t
)
2005 (replacement-chars (format "[%s%s%s]"
2006 message-replacement-char
2007 message-replacement-char
2008 message-replacement-char
))
2009 (enc-word-re "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?\\([^?]+\\)\\(\\?=\\)")
2014 (goto-char (point-min))
2015 (when (re-search-forward enc-word-re nil t
)
2016 (setq cs-string
(match-string 1)))))
2017 cs-coding q-or-b word-beg word-end
)
2018 (if (or (not have-marker
) ;; No encoded word found...
2019 ;; ... or double encoding was correct:
2020 (and (stringp cs-string
)
2021 (setq cs-string
(downcase cs-string
))
2022 (mm-coding-system-p (intern cs-string
))
2026 Decoded Subject \"%s\"
2027 contains a valid encoded word. Decode again? "
2029 (setq cs-coding
(intern cs-string
))))))
2033 (goto-char (point-min))
2034 (while (re-search-forward enc-word-re nil t
)
2035 (setq cs-string
(downcase (match-string 1))
2036 q-or-b
(match-string 2)
2037 word-beg
(match-beginning 0)
2038 word-end
(match-end 0))
2040 (if (mm-coding-system-p (intern cs-string
))
2041 (setq cs-coding
(intern cs-string
))
2043 ;; No double encoded subject? => bogus charset.
2046 (mm-read-coding-system
2048 Decoded Subject \"%s\"
2049 contains an encoded word. The charset `%s' is unknown or invalid.
2050 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
2052 subject cs-string message-replacement-char
)))
2054 (replace-match (concat "=?" (symbol-name cs-coding
)
2057 (goto-char word-beg
)
2058 (re-search-forward "=\\?\\([^?]+\\)\\?\\([QB]\\)\\?" word-end t
)
2061 (if (string-match "\\`Q\\'" q-or-b
)
2064 (message "Replacing non-decodable characters with \"%s\"."
2065 message-replacement-char
)
2066 (while (re-search-forward "\\(=[A-F0-9][A-F0-9]\\)+"
2068 (replace-match message-replacement-char
)))
2070 (message "Replacing non-decodable characters with \"%s\"."
2072 (re-search-forward "[^?]+" word-end t
)
2073 (replace-match replacement-chars
))
2074 (re-search-forward "\\?=")
2075 (replace-match "")))))
2076 (rfc2047-decode-region (point-min) (point-max))
2079 ;;; Start of functions adopted from `message-utils.el'.
2081 (defun message-strip-subject-trailing-was (subject)
2082 "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
2083 Leading \"Re: \" is not stripped by this function. Use the function
2084 `message-strip-subject-re' for this."
2085 (let* ((query message-subject-trailing-was-query
)
2090 message-subject-trailing-was-ask-regexp
2091 message-subject-trailing-was-regexp
)
2094 (setq new
(substring subject
0 (match-beginning 0))))
2095 (if (or (not found
) (eq query nil
))
2098 (if (message-y-or-n-p
2099 "Strip `(was: <old subject>)' in subject? " t
2101 "Strip `(was: <old subject>)' in subject "
2102 "and use the new one instead?\n\n"
2103 "Current subject is: \""
2105 "New subject would be: \""
2107 "See the variable `message-subject-trailing-was-query' "
2108 "to get rid of this query."
2113 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
2115 (defun message-change-subject (new-subject)
2116 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)."
2117 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged>
2120 (read-from-minibuffer "New subject: ")))
2121 (cond ((and (not (or (null new-subject
) ; new subject not empty
2122 (zerop (string-width new-subject
))
2123 (string-match "^[ \t]*$" new-subject
))))
2127 (message-narrow-to-headers)
2128 (message-fetch-field "Subject"))))
2129 (cond ((not old-subject
)
2130 (error "No current subject"))
2133 (regexp-quote new-subject
)
2135 old-subject
)) ; yes, it really is a new subject
2136 ;; delete eventual Re: prefix
2138 (message-strip-subject-re old-subject
))
2139 (message-goto-subject)
2140 (message-delete-line)
2141 (insert (concat "Subject: "
2144 old-subject
")\n")))))))))
2146 (defun message-mark-inserted-region (beg end
&optional verbatim
)
2147 "Mark some region in the current article with enclosing tags.
2148 See `message-mark-insert-begin' and `message-mark-insert-end'.
2149 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2150 (interactive "r\nP")
2152 ;; add to the end of the region first, otherwise end would be invalid
2154 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2156 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2158 (defun message-mark-insert-file (file &optional verbatim
)
2159 "Insert FILE at point, marking it with enclosing tags.
2160 See `message-mark-insert-begin' and `message-mark-insert-end'.
2161 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
2162 (interactive "fFile to insert: \nP")
2163 ;; reverse insertion to get correct result.
2165 (insert (if verbatim
"#v-\n" message-mark-insert-end
))
2167 (insert-file-contents file
)
2169 (insert (if verbatim
"#v+\n" message-mark-insert-begin
))))
2171 (defun message-add-archive-header ()
2172 "Insert \"X-No-Archive: Yes\" in the header and a note in the body.
2173 The note can be customized using `message-archive-note'. When called with a
2174 prefix argument, ask for a text to insert. If you don't want the note in the
2175 body, set `message-archive-note' to nil."
2177 (if current-prefix-arg
2178 (setq message-archive-note
2179 (read-from-minibuffer "Reason for No-Archive: "
2180 (cons message-archive-note
0))))
2182 (if (message-goto-signature)
2183 (re-search-backward message-signature-separator
))
2184 (when message-archive-note
2185 (insert message-archive-note
)
2187 (message-add-header message-archive-header
)
2188 (message-sort-headers)))
2190 (defun message-cross-post-followup-to-header (target-group)
2191 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP.
2192 With prefix-argument just set Follow-Up, don't cross-post."
2194 (list ; Completion based on Gnus
2195 (completing-read "Followup To: "
2196 (if (boundp 'gnus-newsrc-alist
)
2198 nil nil
'("poster" .
0)
2199 (if (boundp 'gnus-group-history
)
2200 'gnus-group-history
))))
2201 (message-remove-header "Follow[Uu]p-[Tt]o" t
)
2202 (message-goto-newsgroups)
2204 ;; if we already did a crosspost before, kill old target
2205 (if (and message-cross-post-old-target
2207 (regexp-quote (concat "," message-cross-post-old-target
))
2210 ;; unless (followup is to poster or user explicitly asked not
2211 ;; to cross-post, or target-group is already in Newsgroups)
2212 ;; add target-group to Newsgroups line.
2214 ;; def: cross-post, req:no
2215 (and message-cross-post-default
(not current-prefix-arg
))
2216 ;; def: no-cross-post, req:yes
2217 (and (not message-cross-post-default
) current-prefix-arg
))
2218 (not (string-match "poster" target-group
))
2219 (not (string-match (regexp-quote target-group
)
2220 (message-fetch-field "Newsgroups"))))
2222 (insert (concat "," target-group
))))
2223 (end-of-line) ; ensure Followup: comes after Newsgroups:
2224 ;; unless new followup would be identical to Newsgroups line
2225 ;; make a new Followup-To line
2226 (if (not (string-match (concat "^[ \t]*"
2229 (message-fetch-field "Newsgroups")))
2230 (insert (concat "\nFollowup-To: " target-group
)))
2231 (setq message-cross-post-old-target target-group
))
2233 (defun message-cross-post-insert-note (target-group cross-post in-old
2235 "Insert a in message body note about a set Followup or Crosspost.
2236 If there have been previous notes, delete them. TARGET-GROUP specifies the
2237 group to Followup-To. When CROSS-POST is t, insert note about
2238 crossposting. IN-OLD specifies whether TARGET-GROUP is a member of
2239 OLD-GROUPS. OLD-GROUPS lists the old-groups the posting would have
2240 been made to before the user asked for a Crosspost."
2241 ;; start scanning body for previous uses
2242 (message-goto-signature)
2243 (let ((head (re-search-backward
2244 (concat "^" mail-header-separator
)
2245 nil t
))) ; just search in body
2246 (message-goto-signature)
2247 (while (re-search-backward
2248 (concat "^" (regexp-quote message-cross-post-note
) ".*")
2250 (message-delete-line))
2251 (message-goto-signature)
2252 (while (re-search-backward
2253 (concat "^" (regexp-quote message-followup-to-note
) ".*")
2255 (message-delete-line))
2257 (if (message-goto-signature)
2258 (re-search-backward message-signature-separator
))
2261 (string-match "^[ \t]*poster[ \t]*$" target-group
))
2262 (insert (concat message-followup-to-note target-group
"\n"))
2263 (insert (concat message-cross-post-note target-group
"\n")))))
2265 (defun message-cross-post-followup-to (target-group)
2266 "Crossposts message and set Followup-To to TARGET-GROUP.
2267 With prefix-argument just set Follow-Up, don't cross-post."
2269 (list ; Completion based on Gnus
2270 (completing-read "Followup To: "
2271 (if (boundp 'gnus-newsrc-alist
)
2273 nil nil
'("poster" .
0)
2274 (if (boundp 'gnus-group-history
)
2275 'gnus-group-history
))))
2276 (cond ((not (or (null target-group
) ; new subject not empty
2277 (zerop (string-width target-group
))
2278 (string-match "^[ \t]*$" target-group
)))
2280 (let* ((old-groups (message-fetch-field "Newsgroups"))
2281 (in-old (string-match
2282 (regexp-quote target-group
)
2283 (or old-groups
""))))
2284 ;; check whether target exactly matches old Newsgroups
2285 (cond ((not old-groups
)
2286 (error "No current newsgroup"))
2290 (regexp-quote target-group
)
2293 ;; yes, Newsgroups line must change
2294 (message-cross-post-followup-to-header target-group
)
2295 ;; insert note whether we do cross-post or followup-to
2296 (funcall message-cross-post-note-function
2298 (if (or (and message-cross-post-default
2299 (not current-prefix-arg
))
2300 (and (not message-cross-post-default
)
2301 current-prefix-arg
)) t
)
2302 in-old old-groups
))))))))
2304 ;;; Reduce To: to Cc: or Bcc: header
2306 (defun message-reduce-to-to-cc ()
2307 "Replace contents of To: header with contents of Cc: or Bcc: header."
2310 (save-restriction (message-narrow-to-headers)
2311 (message-fetch-field "cc")))
2313 (if (and (not cc-content
)
2316 (message-narrow-to-headers)
2317 (message-fetch-field "bcc"))))
2322 (message-delete-line)
2323 (insert (concat "To: " cc-content
"\n"))
2325 (message-narrow-to-headers)
2326 (message-remove-header (if bcc
2330 ;;; End of functions adopted from `message-utils.el'.
2332 (defun message-remove-header (header &optional is-regexp first reverse
)
2333 "Remove HEADER in the narrowed buffer.
2334 If IS-REGEXP, HEADER is a regular expression.
2335 If FIRST, only remove the first instance of the header.
2336 Return the number of headers removed."
2337 (goto-char (point-min))
2338 (let ((regexp (if is-regexp header
(concat "^" (regexp-quote header
) ":")))
2340 (case-fold-search t
)
2342 (while (and (not (eobp))
2345 (not (looking-at regexp
))
2346 (looking-at regexp
))
2353 ;; There might be a continuation header, so we have to search
2354 ;; until we find a new non-continuation line.
2357 (if (re-search-forward "^[^ \t]" nil t
)
2358 (goto-char (match-beginning 0))
2361 (if (re-search-forward "^[^ \t]" nil t
)
2362 (goto-char (match-beginning 0))
2363 (goto-char (point-max)))))
2366 (defun message-remove-first-header (header)
2367 "Remove the first instance of HEADER if there is more than one."
2369 (regexp (concat "^" (regexp-quote header
) ":")))
2371 (goto-char (point-min))
2372 (while (re-search-forward regexp nil t
)
2375 (message-remove-header header nil t
)
2378 (defun message-narrow-to-headers ()
2379 "Narrow the buffer to the head of the message."
2382 (goto-char (point-min))
2383 (if (re-search-forward
2384 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
)
2387 (goto-char (point-min)))
2389 (defun message-narrow-to-head-1 ()
2390 "Like `message-narrow-to-head'. Don't widen."
2392 (goto-char (point-min))
2393 (if (search-forward "\n\n" nil
1)
2396 (goto-char (point-min)))
2398 (defun message-narrow-to-head ()
2399 "Narrow the buffer to the head of the message.
2400 Point is left at the beginning of the narrowed-to region."
2402 (message-narrow-to-head-1))
2404 (defun message-narrow-to-headers-or-head ()
2405 "Narrow the buffer to the head of the message."
2408 (goto-char (point-min))
2409 (if (re-search-forward (concat "\\(\n\\)\n\\|^\\("
2410 (regexp-quote mail-header-separator
)
2413 (or (match-end 1) (match-beginning 2))
2415 (goto-char (point-min)))
2417 (defun message-news-p ()
2418 "Say whether the current buffer contains a news message."
2419 (and (not message-this-is-mail
)
2420 (or message-this-is-news
2423 (message-narrow-to-headers)
2424 (and (message-fetch-field "newsgroups")
2425 (not (message-fetch-field "posted-to"))))))))
2427 (defun message-mail-p ()
2428 "Say whether the current buffer contains a mail message."
2429 (and (not message-this-is-news
)
2430 (or message-this-is-mail
2433 (message-narrow-to-headers)
2434 (or (message-fetch-field "to")
2435 (message-fetch-field "cc")
2436 (message-fetch-field "bcc")))))))
2438 (defun message-subscribed-p ()
2439 "Say whether we need to insert a MFT header."
2440 (or message-subscribed-regexps
2441 message-subscribed-addresses
2442 message-subscribed-address-file
2443 message-subscribed-address-functions
))
2445 (defun message-next-header ()
2446 "Go to the beginning of the next header."
2448 (or (eobp) (forward-char 1))
2449 (not (if (re-search-forward "^[^ \t]" nil t
)
2451 (goto-char (point-max)))))
2453 (defun message-sort-headers-1 ()
2454 "Sort the buffer as headers using `message-rank' text props."
2455 (goto-char (point-min))
2458 nil
'message-next-header
2460 (message-next-header)
2464 (or (get-text-property (point) 'message-rank
)
2467 (defun message-sort-headers ()
2468 "Sort the headers of the current message according to `message-header-format-alist'."
2472 (let ((max (1+ (length message-header-format-alist
)))
2474 (message-narrow-to-headers)
2475 (while (re-search-forward "^[^ \n]+:" nil t
)
2477 (match-beginning 0) (1+ (match-beginning 0))
2479 (if (setq rank
(length (memq (assq (intern (buffer-substring
2481 (1- (match-end 0))))
2482 message-header-format-alist
)
2483 message-header-format-alist
)))
2486 (message-sort-headers-1))))
2488 (defun message-kill-address ()
2489 "Kill the address under point."
2491 (let ((start (point)))
2492 (message-skip-to-next-address)
2493 (kill-region start
(point))))
2496 (autoload 'Info-goto-node
"info")
2497 (defvar mml2015-use
)
2499 (defun message-info (&optional arg
)
2500 "Display the Message manual.
2502 Prefixed with one \\[universal-argument], display the Emacs MIME
2503 manual. With two \\[universal-argument]'s, display the EasyPG or
2504 PGG manual, depending on the value of `mml2015-use'."
2506 ;; Why not `info', which is in loaddefs.el?
2507 (Info-goto-node (format "(%s)Top"
2511 ((eq arg
4) 'emacs-mime
)
2512 ;; `booleanp' only available in Emacs 22+
2513 ((and (not (memq arg
'(nil t
)))
2527 (defvar message-mode-map nil
)
2529 (unless message-mode-map
2530 (setq message-mode-map
(make-keymap))
2531 (set-keymap-parent message-mode-map text-mode-map
)
2532 (define-key message-mode-map
"\C-c?" 'describe-mode
)
2534 (define-key message-mode-map
"\C-c\C-f\C-t" 'message-goto-to
)
2535 (define-key message-mode-map
"\C-c\C-f\C-o" 'message-goto-from
)
2536 (define-key message-mode-map
"\C-c\C-f\C-b" 'message-goto-bcc
)
2537 (define-key message-mode-map
"\C-c\C-f\C-w" 'message-goto-fcc
)
2538 (define-key message-mode-map
"\C-c\C-f\C-c" 'message-goto-cc
)
2539 (define-key message-mode-map
"\C-c\C-f\C-s" 'message-goto-subject
)
2540 (define-key message-mode-map
"\C-c\C-f\C-r" 'message-goto-reply-to
)
2541 (define-key message-mode-map
"\C-c\C-f\C-n" 'message-goto-newsgroups
)
2542 (define-key message-mode-map
"\C-c\C-f\C-d" 'message-goto-distribution
)
2543 (define-key message-mode-map
"\C-c\C-f\C-f" 'message-goto-followup-to
)
2544 (define-key message-mode-map
"\C-c\C-f\C-m" 'message-goto-mail-followup-to
)
2545 (define-key message-mode-map
"\C-c\C-f\C-k" 'message-goto-keywords
)
2546 (define-key message-mode-map
"\C-c\C-f\C-u" 'message-goto-summary
)
2547 (define-key message-mode-map
"\C-c\C-f\C-i"
2548 'message-insert-or-toggle-importance
)
2549 (define-key message-mode-map
"\C-c\C-f\C-a"
2550 'message-generate-unsubscribed-mail-followup-to
)
2552 ;; modify headers (and insert notes in body)
2553 (define-key message-mode-map
"\C-c\C-fs" 'message-change-subject
)
2555 (define-key message-mode-map
"\C-c\C-fx" 'message-cross-post-followup-to
)
2556 ;; prefix+message-cross-post-followup-to = same w/o cross-post
2557 (define-key message-mode-map
"\C-c\C-ft" 'message-reduce-to-to-cc
)
2558 (define-key message-mode-map
"\C-c\C-fa" 'message-add-archive-header
)
2559 ;; mark inserted text
2560 (define-key message-mode-map
"\C-c\M-m" 'message-mark-inserted-region
)
2561 (define-key message-mode-map
"\C-c\M-f" 'message-mark-insert-file
)
2563 (define-key message-mode-map
"\C-c\C-b" 'message-goto-body
)
2564 (define-key message-mode-map
"\C-c\C-i" 'message-goto-signature
)
2566 (define-key message-mode-map
"\C-c\C-t" 'message-insert-to
)
2567 (define-key message-mode-map
"\C-c\C-fw" 'message-insert-wide-reply
)
2568 (define-key message-mode-map
"\C-c\C-n" 'message-insert-newsgroups
)
2569 (define-key message-mode-map
"\C-c\C-l" 'message-to-list-only
)
2570 (define-key message-mode-map
"\C-c\C-f\C-e" 'message-insert-expires
)
2572 (define-key message-mode-map
"\C-c\C-u" 'message-insert-or-toggle-importance
)
2573 (define-key message-mode-map
"\C-c\M-n"
2574 'message-insert-disposition-notification-to
)
2576 (define-key message-mode-map
"\C-c\C-y" 'message-yank-original
)
2577 (define-key message-mode-map
"\C-c\M-\C-y" 'message-yank-buffer
)
2578 (define-key message-mode-map
"\C-c\C-q" 'message-fill-yanked-message
)
2579 (define-key message-mode-map
"\C-c\C-w" 'message-insert-signature
)
2580 (define-key message-mode-map
"\C-c\M-h" 'message-insert-headers
)
2581 (define-key message-mode-map
"\C-c\C-r" 'message-caesar-buffer-body
)
2582 (define-key message-mode-map
"\C-c\C-o" 'message-sort-headers
)
2583 (define-key message-mode-map
"\C-c\M-r" 'message-rename-buffer
)
2585 (define-key message-mode-map
"\C-c\C-c" 'message-send-and-exit
)
2586 (define-key message-mode-map
"\C-c\C-s" 'message-send
)
2587 (define-key message-mode-map
"\C-c\C-k" 'message-kill-buffer
)
2588 (define-key message-mode-map
"\C-c\C-d" 'message-dont-send
)
2589 (define-key message-mode-map
"\C-c\n" 'gnus-delay-article
)
2591 (define-key message-mode-map
"\C-c\M-k" 'message-kill-address
)
2592 (define-key message-mode-map
"\C-c\C-e" 'message-elide-region
)
2593 (define-key message-mode-map
"\C-c\C-v" 'message-delete-not-region
)
2594 (define-key message-mode-map
"\C-c\C-z" 'message-kill-to-signature
)
2595 (define-key message-mode-map
"\M-\r" 'message-newline-and-reformat
)
2596 (define-key message-mode-map
[remap split-line
] 'message-split-line
)
2598 (define-key message-mode-map
"\C-c\C-a" 'mml-attach-file
)
2600 (define-key message-mode-map
"\C-a" 'message-beginning-of-line
)
2601 (define-key message-mode-map
"\t" 'message-tab
)
2602 (define-key message-mode-map
"\M-;" 'comment-region
)
2604 (define-key message-mode-map
"\M-n" 'message-display-abbrev
))
2607 message-mode-menu message-mode-map
"Message Menu."
2609 ["Yank Original" message-yank-original message-reply-buffer
]
2610 ["Fill Yanked Message" message-fill-yanked-message t
]
2611 ["Insert Signature" message-insert-signature t
]
2612 ["Caesar (rot13) Message" message-caesar-buffer-body t
]
2613 ["Caesar (rot13) Region" message-caesar-region
(message-mark-active-p)]
2614 ["Elide Region" message-elide-region
2615 :active
(message-mark-active-p)
2616 ,@(if (featurep 'xemacs
) nil
2617 '(:help
"Replace text in region with an ellipsis"))]
2618 ["Delete Outside Region" message-delete-not-region
2619 :active
(message-mark-active-p)
2620 ,@(if (featurep 'xemacs
) nil
2621 '(:help
"Delete all quoted text outside region"))]
2622 ["Kill To Signature" message-kill-to-signature t
]
2623 ["Newline and Reformat" message-newline-and-reformat t
]
2624 ["Rename buffer" message-rename-buffer t
]
2625 ["Spellcheck" ispell-message
2626 ,@(if (featurep 'xemacs
) '(t)
2627 '(:help
"Spellcheck this message"))]
2629 ["Insert Region Marked" message-mark-inserted-region
2630 :active
(message-mark-active-p)
2631 ,@(if (featurep 'xemacs
) nil
2632 '(:help
"Mark region with enclosing tags"))]
2633 ["Insert File Marked..." message-mark-insert-file
2634 ,@(if (featurep 'xemacs
) '(t)
2635 '(:help
"Insert file at point marked with enclosing tags"))]
2637 ["Send Message" message-send-and-exit
2638 ,@(if (featurep 'xemacs
) '(t)
2639 '(:help
"Send this message"))]
2640 ["Postpone Message" message-dont-send
2641 ,@(if (featurep 'xemacs
) '(t)
2642 '(:help
"File this draft message and exit"))]
2643 ["Send at Specific Time..." gnus-delay-article
2644 ,@(if (featurep 'xemacs
) '(t)
2645 '(:help
"Ask, then arrange to send message at that time"))]
2646 ["Kill Message" message-kill-buffer
2647 ,@(if (featurep 'xemacs
) '(t)
2648 '(:help
"Delete this message without sending"))]
2650 ["Message manual" message-info
2651 ,@(if (featurep 'xemacs
) '(t)
2652 '(:help
"Display the Message manual"))]))
2655 message-mode-field-menu message-mode-map
""
2657 ["To" message-goto-to t
]
2658 ["From" message-goto-from t
]
2659 ["Subject" message-goto-subject t
]
2660 ["Change subject..." message-change-subject t
]
2661 ["Cc" message-goto-cc t
]
2662 ["Bcc" message-goto-bcc t
]
2663 ["Fcc" message-goto-fcc t
]
2664 ["Reply-To" message-goto-reply-to t
]
2665 ["Flag As Important" message-insert-importance-high
2666 ,@(if (featurep 'xemacs
) '(t)
2667 '(:help
"Mark this message as important"))]
2668 ["Flag As Unimportant" message-insert-importance-low
2669 ,@(if (featurep 'xemacs
) '(t)
2670 '(:help
"Mark this message as unimportant"))]
2672 message-insert-disposition-notification-to
2673 ,@(if (featurep 'xemacs
) '(t)
2674 '(:help
"Request a receipt notification"))]
2676 ;; (typical) news stuff
2677 ["Summary" message-goto-summary t
]
2678 ["Keywords" message-goto-keywords t
]
2679 ["Newsgroups" message-goto-newsgroups t
]
2680 ["Fetch Newsgroups" message-insert-newsgroups t
]
2681 ["Followup-To" message-goto-followup-to t
]
2682 ;; ["Followup-To (with note in body)" message-cross-post-followup-to t]
2683 ["Crosspost / Followup-To..." message-cross-post-followup-to t
]
2684 ["Distribution" message-goto-distribution t
]
2685 ["Expires" message-insert-expires t
]
2686 ["X-No-Archive" message-add-archive-header t
]
2688 ;; (typical) mailing-lists stuff
2689 ["Fetch To" message-insert-to
2690 ,@(if (featurep 'xemacs
) '(t)
2691 '(:help
"Insert a To header that points to the author."))]
2692 ["Fetch To and Cc" message-insert-wide-reply
2693 ,@(if (featurep 'xemacs
) '(t)
2695 "Insert To and Cc headers as if you were doing a wide reply."))]
2697 ["Send to list only" message-to-list-only t
]
2698 ["Mail-Followup-To" message-goto-mail-followup-to t
]
2699 ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
2700 ,@(if (featurep 'xemacs
) '(t)
2701 '(:help
"Insert a reasonable `Mail-Followup-To:' header."))]
2702 ["Reduce To: to Cc:" message-reduce-to-to-cc t
]
2704 ["Sort Headers" message-sort-headers t
]
2705 ["Encode non-ASCII domain names" message-idna-to-ascii-rhs t
]
2706 ;; We hide `message-hidden-headers' by narrowing the buffer.
2707 ["Show Hidden Headers" widen t
]
2708 ["Goto Body" message-goto-body t
]
2709 ["Goto Signature" message-goto-signature t
]))
2711 (defvar message-tool-bar-map nil
)
2713 (defvar facemenu-add-face-function
)
2714 (defvar facemenu-remove-face-function
)
2716 ;;; Forbidden properties
2718 ;; We use `after-change-functions' to keep special text properties
2719 ;; that interfer with the normal function of message mode out of the
2722 (defcustom message-strip-special-text-properties t
2723 "Strip special properties from the message buffer.
2725 Emacs has a number of special text properties which can break message
2726 composing in various ways. If this option is set, message will strip
2727 these properties from the message composition buffer. However, some
2728 packages requires these properties to be present in order to work.
2729 If you use one of these packages, turn this option off, and hope the
2730 message composition doesn't break too bad."
2732 :group
'message-various
2733 :link
'(custom-manual "(message)Various Message Variables")
2736 (defconst message-forbidden-properties
2737 ;; No reason this should be clutter up customize. We make it a
2738 ;; property list (rather than a list of property symbols), to be
2739 ;; directly useful for `remove-text-properties'.
2740 '(field nil read-only nil invisible nil intangible nil
2741 mouse-face nil modification-hooks nil insert-in-front-hooks nil
2742 insert-behind-hooks nil point-entered nil point-left nil
)
2743 ;; Other special properties:
2744 ;; category, face, display: probably doesn't do any harm.
2745 ;; fontified: is used by font-lock.
2746 ;; syntax-table, local-map: I dunno.
2747 ;; We need to add XEmacs names to the list.
2748 "Property list of with properties forbidden in message buffers.
2749 The values of the properties are ignored, only the property names are used.")
2751 (defun message-tamago-not-in-use-p (pos)
2752 "Return t when tamago version 4 is not in use at the cursor position.
2753 Tamago version 4 is a popular input method for writing Japanese text.
2754 It uses the properties `intangible', `invisible', `modification-hooks'
2755 and `read-only' when translating ascii or kana text to kanji text.
2756 These properties are essential to work, so we should never strip them."
2757 (not (and (boundp 'egg-modefull-mode
)
2758 (symbol-value 'egg-modefull-mode
)
2759 (or (memq (get-text-property pos
'intangible
)
2760 '(its-part-1 its-part-2
))
2761 (get-text-property pos
'egg-end
)
2762 (get-text-property pos
'egg-lang
)
2763 (get-text-property pos
'egg-start
)))))
2765 (defsubst message-mail-alias-type-p
(type)
2766 (if (atom message-mail-alias-type
)
2767 (eq message-mail-alias-type type
)
2768 (memq type message-mail-alias-type
)))
2770 (defun message-strip-forbidden-properties (begin end
&optional old-length
)
2771 "Strip forbidden properties between BEGIN and END, ignoring the third arg.
2772 This function is intended to be called from `after-change-functions'.
2773 See also `message-forbidden-properties'."
2774 (when (and (message-mail-alias-type-p 'ecomplete
)
2775 (memq this-command message-self-insert-commands
))
2776 (message-display-abbrev))
2777 (when (and message-strip-special-text-properties
2778 (message-tamago-not-in-use-p begin
))
2779 (let ((buffer-read-only nil
)
2780 (inhibit-read-only t
))
2781 (remove-text-properties begin end message-forbidden-properties
))))
2784 (define-derived-mode message-mode text-mode
"Message"
2785 "Major mode for editing mail and news to be sent.
2786 Like Text Mode but with these additional commands:\\<message-mode-map>
2787 C-c C-s `message-send' (send the message) C-c C-c `message-send-and-exit'
2788 C-c C-d Postpone sending the message C-c C-k Kill the message
2789 C-c C-f move to a header field (and create it if there isn't):
2790 C-c C-f C-t move to To C-c C-f C-s move to Subject
2791 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
2792 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
2793 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
2794 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
2795 C-c C-f C-o move to From (\"Originator\")
2796 C-c C-f C-f move to Followup-To
2797 C-c C-f C-m move to Mail-Followup-To
2798 C-c C-f C-e move to Expires
2799 C-c C-f C-i cycle through Importance values
2800 C-c C-f s change subject and append \"(was: <Old Subject>)\"
2801 C-c C-f x crossposting with FollowUp-To header and note in body
2802 C-c C-f t replace To: header with contents of Cc: or Bcc:
2803 C-c C-f a Insert X-No-Archive: header and a note in the body
2804 C-c C-t `message-insert-to' (add a To header to a news followup)
2805 C-c C-l `message-to-list-only' (removes all but list address in to/cc)
2806 C-c C-n `message-insert-newsgroups' (add a Newsgroup header to a news reply)
2807 C-c C-b `message-goto-body' (move to beginning of message text).
2808 C-c C-i `message-goto-signature' (move to the beginning of the signature).
2809 C-c C-w `message-insert-signature' (insert `message-signature-file' file).
2810 C-c C-y `message-yank-original' (insert current message, if any).
2811 C-c C-q `message-fill-yanked-message' (fill what was yanked).
2812 C-c C-e `message-elide-region' (elide the text between point and mark).
2813 C-c C-v `message-delete-not-region' (remove the text outside the region).
2814 C-c C-z `message-kill-to-signature' (kill the text up to the signature).
2815 C-c C-r `message-caesar-buffer-body' (rot13 the message body).
2816 C-c C-a `mml-attach-file' (attach a file as MIME).
2817 C-c C-u `message-insert-or-toggle-importance' (insert or cycle importance).
2818 C-c M-n `message-insert-disposition-notification-to' (request receipt).
2819 C-c M-m `message-mark-inserted-region' (mark region with enclosing tags).
2820 C-c M-f `message-mark-insert-file' (insert file marked with enclosing tags).
2821 M-RET `message-newline-and-reformat' (break the line and reformat)."
2822 (setq local-abbrev-table text-mode-abbrev-table
)
2823 (set (make-local-variable 'message-reply-buffer
) nil
)
2824 (set (make-local-variable 'message-inserted-headers
) nil
)
2825 (set (make-local-variable 'message-send-actions
) nil
)
2826 (set (make-local-variable 'message-exit-actions
) nil
)
2827 (set (make-local-variable 'message-kill-actions
) nil
)
2828 (set (make-local-variable 'message-postpone-actions
) nil
)
2829 (set (make-local-variable 'message-draft-article
) nil
)
2830 (setq buffer-offer-save t
)
2831 (set (make-local-variable 'facemenu-add-face-function
)
2833 (let ((face-fun (cdr (assq face message-face-alist
))))
2835 (funcall face-fun
(point) end
)
2836 (error "Face %s not configured for %s mode" face mode-name
)))
2838 (set (make-local-variable 'facemenu-remove-face-function
) t
)
2839 (set (make-local-variable 'message-reply-headers
) nil
)
2840 (make-local-variable 'message-newsreader
)
2841 (make-local-variable 'message-mailer
)
2842 (make-local-variable 'message-post-method
)
2843 (set (make-local-variable 'message-sent-message-via
) nil
)
2844 (set (make-local-variable 'message-checksum
) nil
)
2845 (set (make-local-variable 'message-mime-part
) 0)
2846 (message-setup-fill-variables)
2847 (when message-fill-column
2848 (setq fill-column message-fill-column
)
2849 (turn-on-auto-fill))
2850 ;; Allow using comment commands to add/remove quoting.
2851 ;; (set (make-local-variable 'comment-start) message-yank-prefix)
2852 (when message-yank-prefix
2853 (set (make-local-variable 'comment-start
) message-yank-prefix
)
2854 (set (make-local-variable 'comment-start-skip
)
2855 (concat "^" (regexp-quote message-yank-prefix
) "[ \t]*")))
2856 (if (featurep 'xemacs
)
2857 (message-setup-toolbar)
2858 (set (make-local-variable 'font-lock-defaults
)
2859 '(message-font-lock-keywords t
))
2860 (if (boundp 'tool-bar-map
)
2861 (set (make-local-variable 'tool-bar-map
) (message-make-tool-bar))))
2862 (easy-menu-add message-mode-menu message-mode-map
)
2863 (easy-menu-add message-mode-field-menu message-mode-map
)
2864 (gnus-make-local-hook 'after-change-functions
)
2865 ;; Mmmm... Forbidden properties...
2866 (add-hook 'after-change-functions
'message-strip-forbidden-properties
2868 ;; Allow mail alias things.
2870 ((message-mail-alias-type-p 'abbrev
)
2871 (if (fboundp 'mail-abbrevs-setup
)
2872 (mail-abbrevs-setup)
2873 (if (fboundp 'mail-aliases-setup
) ; warning avoidance
2874 (mail-aliases-setup))))
2875 ((message-mail-alias-type-p 'ecomplete
)
2877 (unless buffer-file-name
2878 (message-set-auto-save-file-name))
2879 (unless (buffer-base-buffer)
2880 ;; Don't enable multibyte on an indirect buffer. Maybe enabling
2881 ;; multibyte is not necessary at all. -- zsh
2882 (mm-enable-multibyte))
2883 (set (make-local-variable 'indent-tabs-mode
) nil
) ;No tabs for indentation.
2886 (defun message-setup-fill-variables ()
2887 "Setup message fill variables."
2888 (set (make-local-variable 'fill-paragraph-function
)
2889 'message-fill-paragraph
)
2890 (make-local-variable 'paragraph-separate
)
2891 (make-local-variable 'paragraph-start
)
2892 (make-local-variable 'adaptive-fill-regexp
)
2893 (unless (boundp 'adaptive-fill-first-line-regexp
)
2894 (setq adaptive-fill-first-line-regexp nil
))
2895 (make-local-variable 'adaptive-fill-first-line-regexp
)
2896 (let ((quote-prefix-regexp
2897 ;; User should change message-cite-prefix-regexp if
2898 ;; message-yank-prefix is set to an abnormal value.
2899 (concat "\\(" message-cite-prefix-regexp
"\\)[ \t]*")))
2900 (setq paragraph-start
2902 (regexp-quote mail-header-separator
) "$\\|"
2903 "[ \t]*$\\|" ; blank lines
2904 "-- $\\|" ; signature delimiter
2905 "---+$\\|" ; delimiters for forwarded messages
2906 page-delimiter
"$\\|" ; spoiler warnings
2907 ".*wrote:$\\|" ; attribution lines
2908 quote-prefix-regexp
"$\\|" ; empty lines in quoted text
2910 "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
2911 (setq paragraph-separate paragraph-start
)
2912 (setq adaptive-fill-regexp
2913 (concat quote-prefix-regexp
"\\|" adaptive-fill-regexp
))
2914 (setq adaptive-fill-first-line-regexp
2915 (concat quote-prefix-regexp
"\\|"
2916 adaptive-fill-first-line-regexp
)))
2917 (make-local-variable 'auto-fill-inhibit-regexp
)
2918 ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
2919 (setq auto-fill-inhibit-regexp nil
)
2920 (make-local-variable 'normal-auto-fill-function
)
2921 (setq normal-auto-fill-function
'message-do-auto-fill
)
2922 ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
2923 ;; In that case, ensure that it uses the right function. The real
2924 ;; solution would be not to use `define-derived-mode', and run
2925 ;; `text-mode-hook' ourself at the end of the mode.
2926 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
2927 ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
2928 ;; now careful to run parent hooks after the body. --Stef
2929 (when auto-fill-function
2930 (setq auto-fill-function normal-auto-fill-function
)))
2935 ;;; Message mode commands
2938 ;;; Movement commands
2940 (defun message-goto-to ()
2941 "Move point to the To header."
2943 (message-position-on-field "To"))
2945 (defun message-goto-from ()
2946 "Move point to the From header."
2948 (message-position-on-field "From"))
2950 (defun message-goto-subject ()
2951 "Move point to the Subject header."
2953 (message-position-on-field "Subject"))
2955 (defun message-goto-cc ()
2956 "Move point to the Cc header."
2958 (message-position-on-field "Cc" "To"))
2960 (defun message-goto-bcc ()
2961 "Move point to the Bcc header."
2963 (message-position-on-field "Bcc" "Cc" "To"))
2965 (defun message-goto-fcc ()
2966 "Move point to the Fcc header."
2968 (message-position-on-field "Fcc" "To" "Newsgroups"))
2970 (defun message-goto-reply-to ()
2971 "Move point to the Reply-To header."
2973 (message-position-on-field "Reply-To" "Subject"))
2975 (defun message-goto-newsgroups ()
2976 "Move point to the Newsgroups header."
2978 (message-position-on-field "Newsgroups"))
2980 (defun message-goto-distribution ()
2981 "Move point to the Distribution header."
2983 (message-position-on-field "Distribution"))
2985 (defun message-goto-followup-to ()
2986 "Move point to the Followup-To header."
2988 (message-position-on-field "Followup-To" "Newsgroups"))
2990 (defun message-goto-mail-followup-to ()
2991 "Move point to the Mail-Followup-To header."
2993 (message-position-on-field "Mail-Followup-To" "To"))
2995 (defun message-goto-keywords ()
2996 "Move point to the Keywords header."
2998 (message-position-on-field "Keywords" "Subject"))
3000 (defun message-goto-summary ()
3001 "Move point to the Summary header."
3003 (message-position-on-field "Summary" "Subject"))
3005 (defun message-goto-body (&optional interactivep
)
3006 "Move point to the beginning of the message body."
3007 (interactive (list t
))
3008 (when (and interactivep
3009 (looking-at "[ \t]*\n"))
3011 (goto-char (point-min))
3012 (or (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3013 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t
)))
3015 (defun message-in-body-p ()
3016 "Return t if point is in the message body."
3017 (let ((body (save-excursion (message-goto-body) (point))))
3020 (defun message-goto-eoh ()
3021 "Move point to the end of the headers."
3026 (defun message-goto-signature ()
3027 "Move point to the beginning of the message signature.
3028 If there is no signature in the article, go to the end and
3031 (goto-char (point-min))
3032 (if (re-search-forward message-signature-separator nil t
)
3034 (goto-char (point-max))
3037 (defun message-generate-unsubscribed-mail-followup-to (&optional include-cc
)
3038 "Insert a reasonable MFT header in a post to an unsubscribed list.
3039 When making original posts to a mailing list you are not subscribed to,
3040 you have to type in a MFT header by hand. The contents, usually, are
3041 the addresses of the list and your own address. This function inserts
3042 such a header automatically. It fetches the contents of the To: header
3043 in the current mail buffer, and appends the current `user-mail-address'.
3045 If the optional argument INCLUDE-CC is non-nil, the addresses in the
3046 Cc: header are also put into the MFT."
3051 (message-narrow-to-headers)
3052 (message-remove-header "Mail-Followup-To")
3053 (setq cc
(and include-cc
(message-fetch-field "Cc")))
3055 (concat (message-fetch-field "To") "," cc
)
3056 (message-fetch-field "To"))))
3057 (message-goto-mail-followup-to)
3058 (insert (concat tos
", " user-mail-address
))))
3062 (defun message-insert-to (&optional force
)
3063 "Insert a To header that points to the author of the article being replied to.
3064 If the original author requested not to be sent mail, don't insert unless the
3065 prefix FORCE is given."
3067 (let* ((mct (message-fetch-reply-field "mail-copies-to"))
3068 (dont (and mct
(or (equal (downcase mct
) "never")
3069 (equal (downcase mct
) "nobody"))))
3070 (to (or (message-fetch-reply-field "mail-reply-to")
3071 (message-fetch-reply-field "reply-to")
3072 (message-fetch-reply-field "from"))))
3076 "Ignoring the user request not to have copies sent via mail"
3077 "Complying with the user request not to have copies sent via mail")))
3078 (when (and force
(not to
))
3079 (error "No mail address in the article"))
3080 (when (and to
(or force
(not dont
)))
3081 (message-carefully-insert-headers (list (cons 'To to
))))))
3083 (defun message-insert-wide-reply ()
3084 "Insert To and Cc headers as if you were doing a wide reply."
3086 (let ((headers (message-with-reply-buffer
3087 (message-get-reply-headers t
))))
3088 (message-carefully-insert-headers headers
)))
3090 (defcustom message-header-synonyms
3093 "List of lists of header synonyms.
3094 E.g., if this list contains a member list with elements `Cc' and `To',
3095 then `message-carefully-insert-headers' will not insert a `To' header
3096 when the message is already `Cc'ed to the recipient."
3098 :group
'message-headers
3099 :link
'(custom-manual "(message)Message Headers")
3100 :type
'(repeat sexp
))
3102 (defun message-carefully-insert-headers (headers)
3103 "Insert the HEADERS, an alist, into the message buffer.
3104 Does not insert the headers when they are already present there
3105 or in the synonym headers, defined by `message-header-synonyms'."
3106 ;; FIXME: Should compare only the address and not the full name. Comparison
3107 ;; should be done case-folded (and with `string=' rather than
3109 ;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
3110 (dolist (header headers
)
3111 (let* ((header-name (symbol-name (car header
)))
3112 (new-header (cdr header
))
3113 (synonyms (loop for synonym in message-header-synonyms
3114 when
(memq (car header
) synonym
) return synonym
))
3116 (loop for synonym in synonyms
3117 for old-header
= (mail-fetch-field (symbol-name synonym
))
3118 when
(and old-header
(string-match new-header old-header
))
3121 (message "already have `%s' in `%s'" new-header old-header
)
3122 (when (and (message-position-on-field header-name
)
3123 (setq old-header
(mail-fetch-field header-name
))
3124 (not (string-match "\\` *\\'" old-header
)))
3126 (insert new-header
)))))
3128 (defun message-widen-reply ()
3129 "Widen the reply to include maximum recipients."
3132 (and message-reply-buffer
3133 (buffer-name message-reply-buffer
)
3134 (with-current-buffer message-reply-buffer
3135 (message-get-reply-headers t
)))))
3138 (message-narrow-to-headers)
3139 (dolist (elem follow-to
)
3140 (message-remove-header (symbol-name (car elem
)))
3141 (goto-char (point-min))
3142 (insert (symbol-name (car elem
)) ": "
3143 (cdr elem
) "\n"))))))
3145 (defun message-insert-newsgroups ()
3146 "Insert the Newsgroups header from the article being replied to."
3148 (when (and (message-position-on-field "Newsgroups")
3149 (mail-fetch-field "newsgroups")
3150 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
3152 (insert (or (message-fetch-reply-field "newsgroups") "")))
3156 ;;; Various commands
3158 (defun message-delete-not-region (beg end
)
3159 "Delete everything in the body of the current message outside of the region."
3164 ;; snarf citation prefix, if appropriate
3165 (unless (eq (point) (progn (beginning-of-line) (point)))
3166 (when (looking-at message-cite-prefix-regexp
)
3167 (setq citeprefix
(match-string 0))))
3169 (delete-region (point) (if (not (message-goto-signature))
3175 (delete-region beg
(progn (message-goto-body)
3179 (insert citeprefix
))))
3180 (when (message-goto-signature)
3183 (defun message-kill-to-signature (&optional arg
)
3184 "Kill all text up to the signature.
3185 If a numberic argument or prefix arg is given, leave that number
3186 of lines before the signature intact."
3190 (let ((point (point)))
3191 (narrow-to-region point
(point-max))
3192 (message-goto-signature)
3194 (if (and arg
(numberp arg
))
3195 (forward-line (- -
1 arg
))
3197 (unless (= point
(point))
3198 (kill-region point
(point))
3202 (defun message-newline-and-reformat (&optional arg not-break
)
3203 "Insert four newlines, and then reformat if inside quoted text.
3204 Prefix arg means justify as well."
3205 (interactive (list (if current-prefix-arg
'full
)))
3206 (let (quoted point beg end leading-space bolp fill-paragraph-function
)
3207 (setq point
(point))
3210 (setq bolp
(= beg point
))
3211 ;; Find first line of the paragraph.
3213 (while (and (not (eobp))
3214 (not (looking-at message-cite-prefix-regexp
))
3215 (looking-at paragraph-start
))
3218 (when (looking-at message-cite-prefix-regexp
)
3219 (setq quoted
(match-string 0))
3220 (goto-char (match-end 0))
3221 (looking-at "[ \t]*")
3222 (setq leading-space
(match-string 0)))
3226 (< (- point beg
) (length quoted
)))
3227 ;; break inside the cite prefix.
3233 (while (and (not (eobp))
3234 (not (looking-at paragraph-separate
))
3235 (looking-at message-cite-prefix-regexp
)
3236 (equal quoted
(match-string 0)))
3237 (goto-char (match-end 0))
3238 (looking-at "[ \t]*")
3239 (if (> (length leading-space
) (length (match-string 0)))
3240 (setq leading-space
(match-string 0)))
3244 (while (and (if (bobp) nil
(forward-line -
1) t
)
3245 (not (looking-at paragraph-start
))
3246 (looking-at message-cite-prefix-regexp
)
3247 (equal quoted
(match-string 0)))
3249 (goto-char (match-end 0))
3250 (looking-at "[ \t]*")
3251 (if (> (length leading-space
) (length (match-string 0)))
3252 (setq leading-space
(match-string 0)))))
3253 (while (and (not (eobp))
3254 (not (looking-at paragraph-separate
))
3255 (not (looking-at message-cite-prefix-regexp
)))
3259 (while (and (if (bobp) nil
(forward-line -
1) t
)
3260 (not (looking-at paragraph-start
))
3261 (not (looking-at message-cite-prefix-regexp
)))
3262 (setq beg
(point))))
3265 (narrow-to-region beg end
)
3272 (setq point
(point))
3273 ;; (newline 2) doesn't mark both newline's as hard, so call
3274 ;; newline twice. -jas
3277 (delete-region (point) (re-search-forward "[ \t]*"))
3278 (when (and quoted
(not bolp
))
3279 (insert quoted leading-space
)))
3282 (let* ((adaptive-fill-regexp
3283 (regexp-quote (concat quoted leading-space
)))
3284 (adaptive-fill-first-line-regexp
3285 adaptive-fill-regexp
))
3286 (fill-paragraph arg
))
3287 (fill-paragraph arg
))
3288 (if point
(goto-char point
)))))
3290 (defun message-fill-paragraph (&optional arg
)
3291 "Message specific function to fill a paragraph.
3292 This function is used as the value of `fill-paragraph-function' in
3293 Message buffers and is not meant to be called directly."
3294 (interactive (list (if current-prefix-arg
'full
)))
3295 (if (if (boundp 'filladapt-mode
) filladapt-mode
)
3297 (if (message-point-in-header-p)
3298 (message-fill-field)
3299 (message-newline-and-reformat arg t
))
3302 (defun message-point-in-header-p ()
3303 "Return t if point is in the header."
3305 (not (re-search-backward
3306 (concat "^" (regexp-quote mail-header-separator
) "\n") nil t
))))
3308 (defun message-do-auto-fill ()
3309 "Like `do-auto-fill', but don't fill in message header."
3310 (unless (message-point-in-header-p)
3313 (defun message-insert-signature (&optional force
)
3314 "Insert a signature. See documentation for variable `message-signature'."
3315 (interactive (list 0))
3318 ((and (null message-signature
)
3321 (goto-char (point-max))
3322 (not (re-search-backward message-signature-separator nil t
))))
3323 ((and (null message-signature
)
3326 ((functionp message-signature
)
3327 (funcall message-signature
))
3328 ((listp message-signature
)
3329 (eval message-signature
))
3330 (t message-signature
)))
3333 (cond ((stringp signature
)
3335 ((and (eq t signature
) message-signature-file
)
3336 (setq signature-file
3337 (if (and message-signature-directory
3338 ;; don't actually use the signature directory
3339 ;; if message-signature-file contains a path.
3340 (not (file-name-directory
3341 message-signature-file
)))
3342 (nnheader-concat message-signature-directory
3343 message-signature-file
)
3344 message-signature-file
))
3345 (file-exists-p signature-file
))))
3347 (goto-char (point-max))
3348 ;; Insert the signature.
3351 (when message-signature-insert-empty-line
3354 (if (eq signature t
)
3355 (insert-file-contents signature-file
)
3357 (goto-char (point-max))
3358 (or (bolp) (insert "\n")))))
3360 (defun message-insert-importance-high ()
3361 "Insert header to mark message as important."
3365 (message-narrow-to-headers)
3366 (message-remove-header "Importance"))
3368 (insert "Importance: high\n")))
3370 (defun message-insert-importance-low ()
3371 "Insert header to mark message as unimportant."
3375 (message-narrow-to-headers)
3376 (message-remove-header "Importance"))
3378 (insert "Importance: low\n")))
3380 (defun message-insert-or-toggle-importance ()
3381 "Insert a \"Importance: high\" header, or cycle through the header values.
3382 The three allowed values according to RFC 1327 are `high', `normal'
3389 (message-narrow-to-headers)
3390 (when (setq cur
(message-fetch-field "Importance"))
3391 (message-remove-header "Importance")
3392 (setq new
(cond ((string= cur
"high")
3394 ((string= cur
"low")
3399 (insert (format "Importance: %s\n" new
)))))
3401 (defun message-insert-disposition-notification-to ()
3402 "Request a disposition notification (return receipt) to this message.
3403 Note that this should not be used in newsgroups."
3407 (message-narrow-to-headers)
3408 (message-remove-header "Disposition-Notification-To"))
3410 (insert (format "Disposition-Notification-To: %s\n"
3411 (or (message-field-value "Reply-to")
3412 (message-field-value "From")
3413 (message-make-from))))))
3415 (defun message-elide-region (b e
)
3416 "Elide the text in the region.
3417 An ellipsis (from `message-elide-ellipsis') will be inserted where the
3421 (insert message-elide-ellipsis
))
3423 (defvar message-caesar-translation-table nil
)
3425 (defun message-caesar-region (b e
&optional n
)
3426 "Caesar rotate region B to E by N, default 13, for decrypting netnews."
3429 (min (point) (or (mark t
) (point)))
3430 (max (point) (or (mark t
) (point)))
3431 (when current-prefix-arg
3432 (prefix-numeric-value current-prefix-arg
))))
3434 (setq n
(if (numberp n
) (mod n
26) 13)) ;canonize N
3435 (unless (or (zerop n
) ; no action needed for a rot of 0
3436 (= b e
)) ; no region to rotate
3437 ;; We build the table, if necessary.
3438 (when (or (not message-caesar-translation-table
)
3439 (/= (aref message-caesar-translation-table ?a
) (+ ?a n
)))
3440 (setq message-caesar-translation-table
3441 (message-make-caesar-translation-table n
)))
3442 (translate-region b e message-caesar-translation-table
)))
3444 (defun message-make-caesar-translation-table (n)
3445 "Create a rot table with offset N."
3447 (table (make-string 256 0)))
3448 (while (< (incf i
) 256)
3451 (substring table
0 ?A
)
3452 (substring table
(+ ?A n
) (+ ?A n
(- 26 n
)))
3453 (substring table ?A
(+ ?A n
))
3454 (substring table
(+ ?A
26) ?a
)
3455 (substring table
(+ ?a n
) (+ ?a n
(- 26 n
)))
3456 (substring table ?a
(+ ?a n
))
3457 (substring table
(+ ?a
26) 255))))
3459 (defun message-caesar-buffer-body (&optional rotnum wide
)
3460 "Caesar rotate all letters in the current buffer by 13 places.
3461 Used to encode/decode possibly offensive messages (commonly in rec.humor).
3462 With prefix arg, specifies the number of places to rotate each letter forward.
3463 Mail and USENET news headers are not rotated unless WIDE is non-nil."
3464 (interactive (if current-prefix-arg
3465 (list (prefix-numeric-value current-prefix-arg
))
3469 (when (and (not wide
) (message-goto-body))
3470 (narrow-to-region (point) (point-max)))
3471 (message-caesar-region (point-min) (point-max) rotnum
))))
3473 (defun message-pipe-buffer-body (program)
3474 "Pipe the message body in the current buffer through PROGRAM."
3477 (when (message-goto-body)
3478 (narrow-to-region (point) (point-max)))
3479 (shell-command-on-region
3480 (point-min) (point-max) program nil t
))))
3482 (defun message-rename-buffer (&optional enter-string
)
3483 "Rename the *message* buffer to \"*message* RECIPIENT\".
3484 If the function is run with a prefix, it will ask for a new buffer
3485 name, rather than giving an automatic name."
3486 (interactive "Pbuffer name: ")
3489 (goto-char (point-min))
3490 (narrow-to-region (point)
3491 (search-forward mail-header-separator nil
'end
))
3493 (if (message-news-p) (message-fetch-field "Newsgroups")
3494 (message-fetch-field "To"))
3497 (if (string-match "," mail-to
)
3498 (concat (substring mail-to
0 (match-beginning 0)) ", ...")
3500 (name-default (concat "*message* " mail-trimmed-to
))
3501 (name (if enter-string
3502 (read-string "New buffer name: " name-default
)
3504 (rename-buffer name t
)))))
3506 (defun message-fill-yanked-message (&optional justifyp
)
3507 "Fill the paragraphs of a message yanked into this one.
3508 Numeric argument means justify as well."
3511 (goto-char (point-min))
3512 (search-forward (concat "\n" mail-header-separator
"\n") nil t
)
3513 (let ((fill-prefix message-yank-prefix
))
3514 (fill-individual-paragraphs (point) (point-max) justifyp
))))
3516 (defun message-indent-citation (&optional start end yank-only
)
3517 "Modify text just inserted from a message to be cited.
3518 The inserted text should be the region.
3519 When this function returns, the region is again around the modified text.
3521 Normally, indent each nonblank line `message-indentation-spaces' spaces.
3522 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
3523 (unless start
(setq start
(point)))
3525 ;; Remove unwanted headers.
3526 (when message-ignored-cited-headers
3531 (if (search-forward "\n\n" nil t
)
3534 (message-remove-header message-ignored-cited-headers t
)
3535 (when (= (point-min) (point-max))
3536 (setq all-removed t
))
3537 (goto-char (point-max)))
3541 ;; Delete blank lines at the start of the buffer.
3542 (while (and (point-min)
3545 (message-delete-line))
3546 ;; Delete blank lines at the end of the buffer.
3547 (goto-char (point-max))
3550 (while (and (zerop (forward-line -
1))
3552 (message-delete-line)))
3553 ;; Do the indentation.
3554 (if (null message-yank-prefix
)
3555 (indent-rigidly start
(or end
(mark t
)) message-indentation-spaces
)
3558 (while (< (point) (or end
(mark t
)))
3559 (cond ((looking-at ">")
3560 (insert message-yank-cited-prefix
))
3562 (insert message-yank-empty-prefix
))
3564 (insert message-yank-prefix
)))
3568 (defun message-remove-blank-cited-lines (&optional remove
)
3569 "Remove cited lines containing only blanks.
3570 If REMOVE is non-nil, remove newlines, too.
3572 To use this automatically, you may add this function to
3573 `gnus-message-setup-hook'."
3578 (when (boundp 'message-yank-cited-prefix
)
3579 (concat message-yank-cited-prefix
"\\|"))
3583 (gnus-message 8 "removing `%s'" citexp
)
3586 (while (re-search-forward citexp nil t
)
3587 (replace-match (if remove
"" "\n"))))))
3589 (defvar message-cite-reply-above nil
3590 "If non-nil, start own text above the quote.
3592 Note: Top posting is bad netiquette. Don't use it unless you
3593 really must. You probably want to set variable only for specific
3594 groups, e.g. using `gnus-posting-styles':
3596 (eval (set (make-local-variable 'message-cite-reply-above) t))
3598 This variable has no effect in news postings.")
3600 (defun message-yank-original (&optional arg
)
3601 "Insert the message being replied to, if any.
3602 Puts point before the text and mark after.
3603 Normally indents each nonblank line ARG spaces (default 3). However,
3604 if `message-yank-prefix' is non-nil, insert that prefix on each line.
3606 This function uses `message-cite-function' to do the actual citing.
3608 Just \\[universal-argument] as argument means don't indent, insert no
3609 prefix, and don't delete any headers."
3611 (let ((modified (buffer-modified-p))
3613 (when (and message-reply-buffer
3614 message-cite-function
)
3615 (when message-cite-reply-above
3616 (if (and (not (message-news-p))
3617 (or (eq message-cite-reply-above
'is-evil
)
3619 Top posting is bad netiquette. Please don't top post unless you really must.
3620 Really top post? ")))
3623 (buffer-substring (message-goto-body)
3625 (delete-region (message-goto-body) (point-max)))
3626 (set (make-local-variable 'message-cite-reply-above
) nil
)))
3627 (delete-windows-on message-reply-buffer t
)
3628 (push-mark (save-excursion
3629 (insert-buffer-substring message-reply-buffer
)
3634 (funcall message-cite-function
)
3635 (unless (eq (char-before (mark t
)) ?
\n)
3637 (goto-char (mark t
))
3638 (insert-before-markers ?
\n)
3640 (when message-cite-reply-above
3643 (insert (if (bolp) "\n" "\n\n"))
3644 (message-goto-body))
3645 ;; Add a `message-setup-very-last-hook' here?
3646 ;; Add `gnus-article-highlight-citation' here?
3648 (setq message-checksum
(message-checksum))))))
3650 (defun message-yank-buffer (buffer)
3651 "Insert BUFFER into the current buffer and quote it."
3652 (interactive "bYank buffer: ")
3653 (let ((message-reply-buffer (get-buffer buffer
)))
3654 (save-window-excursion
3655 (message-yank-original))))
3657 (defun message-buffers ()
3658 "Return a list of active message buffers."
3660 (save-current-buffer
3661 (dolist (buffer (buffer-list t
))
3663 (when (and (eq major-mode
'message-mode
)
3664 (null message-sent-message-via
))
3665 (push (buffer-name buffer
) buffers
))))
3666 (nreverse buffers
)))
3668 (defun message-cite-original-1 (strip-signature)
3669 "Cite an original message.
3670 If STRIP-SIGNATURE is non-nil, strips off the signature from the
3673 This function uses `mail-citation-hook' if that is non-nil."
3674 (if (and (boundp 'mail-citation-hook
)
3676 (run-hooks 'mail-citation-hook
)
3677 (let* ((start (point))
3681 (when message-indent-citation-function
3682 (if (listp message-indent-citation-function
)
3683 message-indent-citation-function
3684 (list message-indent-citation-function
))))
3685 ;; This function may be called by `gnus-summary-yank-message' and
3686 ;; may insert a different article from the original. So, we will
3687 ;; modify the value of `message-reply-headers' with that article.
3688 (message-reply-headers
3690 (narrow-to-region start end
)
3691 (message-narrow-to-head-1)
3692 (setq x-no-archive
(message-fetch-field "x-no-archive"))
3694 (or (message-fetch-field "subject") "none")
3695 (or (message-fetch-field "from") "nobody")
3696 (message-fetch-field "date")
3697 (message-fetch-field "message-id" t
)
3698 (message-fetch-field "references")
3700 (mml-quote-region start end
)
3701 (when strip-signature
3705 (when (re-search-backward message-signature-separator start t
)
3706 ;; Also peel off any blank lines before the signature.
3708 (while (looking-at "^[ \t]*$")
3711 (delete-region (point) end
)
3712 (unless (search-backward "\n\n" start t
)
3713 ;; Insert a blank line if it is peeled off.
3716 (mapc 'funcall functions
)
3717 (when message-citation-line-function
3720 (funcall message-citation-line-function
))
3721 (when (and x-no-archive
3722 (not message-cite-articles-with-x-no-archive
)
3723 (string-match "yes" x-no-archive
))
3725 (delete-region (point) (mark t
))
3726 (insert "> [Quoted text removed due to X-No-Archive]\n")
3728 (forward-line -
1)))))
3730 (defun message-cite-original ()
3731 "Cite function in the standard Message manner."
3732 (message-cite-original-1 nil
))
3734 (defvar gnus-extract-address-components
)
3736 (autoload 'format-spec
"format-spec")
3738 (defun message-insert-formatted-citation-line (&optional from date
)
3739 "Function that inserts a formatted citation line.
3741 See `message-citation-line-format'."
3742 ;; The optional args are for testing/debugging. They will disappear later.
3744 ;; (with-temp-buffer
3745 ;; (message-insert-formatted-citation-line
3746 ;; "John Doe <john.doe@example.invalid>"
3749 (when (or message-reply-headers
(and from date
))
3751 (setq from
(mail-header-from message-reply-headers
)))
3752 (let* ((data (condition-case ()
3753 (funcall (if (boundp gnus-extract-address-components
)
3754 gnus-extract-address-components
3755 'mail-extract-address-components
)
3761 (net (car (cdr data
)))
3762 (name-or-net (or (car data
)
3763 (car (cdr data
)) from
))
3767 ;; We need Gnus functionality if the user wants date or time from
3768 ;; the original article:
3769 (when (string-match "%[^fnNFL]" message-citation-line-format
)
3770 (autoload 'gnus-date-get-time
"gnus-util")
3771 (gnus-date-get-time (mail-header-date message-reply-headers
)))))
3774 (when (stringp name
)
3775 ;; Guess first name and last name:
3776 (cond ((string-match
3777 "\\`\\(\\w\\|[-.]\\)+ \\(\\w\\|[-.]\\)+\\'" name
)
3778 (setq fname
(nth 0 (split-string name
"[ \t]+"))
3779 lname
(nth 1 (split-string name
"[ \t]+"))))
3781 "\\`\\(\\w\\|[-.]\\)+, \\(\\w\\|[-.]\\)+\\'" name
)
3782 (setq fname
(nth 1 (split-string name
"[ \t,]+"))
3783 lname
(nth 0 (split-string name
"[ \t,]+"))))
3785 "\\`\\(\\w\\|[-.]\\)+\\'" name
)
3788 ;; The following letters are not used in `format-time-string':
3789 (push ?E lst
) (push "<E>" lst
)
3790 (push ?F lst
) (push fname lst
)
3791 ;; We might want to use "" instead of "<X>" later.
3792 (push ?J lst
) (push "<J>" lst
)
3793 (push ?K lst
) (push "<K>" lst
)
3794 (push ?L lst
) (push lname lst
)
3795 (push ?N lst
) (push name-or-net lst
)
3796 (push ?O lst
) (push "<O>" lst
)
3797 (push ?P lst
) (push "<P>" lst
)
3798 (push ?Q lst
) (push "<Q>" lst
)
3799 (push ?f lst
) (push from lst
)
3800 (push ?i lst
) (push "<i>" lst
)
3801 (push ?n lst
) (push net lst
)
3802 (push ?o lst
) (push "<o>" lst
)
3803 (push ?q lst
) (push "<q>" lst
)
3804 (push ?t lst
) (push "<t>" lst
)
3805 (push ?v lst
) (push "<v>" lst
)
3806 ;; Delegate the rest to `format-time-string':
3808 (when (and (not (memq i lst
))
3813 (push (condition-case nil
3814 (progn (format-time-string (format "%%%c" i
)
3820 (spec (apply 'format-spec-make flist
)))
3821 (insert (format-spec message-citation-line-format spec
)))
3824 (defun message-cite-original-without-signature ()
3825 "Cite function in the standard Message manner.
3826 This function strips off the signature from the original message."
3827 (message-cite-original-1 t
))
3829 (defun message-insert-citation-line ()
3830 "Insert a simple citation line."
3831 (when message-reply-headers
3832 (insert (mail-header-from message-reply-headers
) " writes:")
3836 (defun message-position-on-field (header &rest afters
)
3837 (let ((case-fold-search t
))
3840 (goto-char (point-min))
3843 (concat "^" (regexp-quote mail-header-separator
) "$"))
3844 (match-beginning 0)))
3845 (goto-char (point-min))
3846 (if (re-search-forward (concat "^" (regexp-quote header
) ":") nil t
)
3848 (re-search-forward "^[^ \t]" nil
'move
)
3850 (skip-chars-backward "\n")
3853 (not (re-search-forward
3854 (concat "^" (regexp-quote (car afters
)) ":")
3858 (re-search-forward "^[^ \t]" nil
'move
)
3859 (beginning-of-line))
3860 (insert header
": \n")
3864 (defun message-remove-signature ()
3865 "Remove the signature from the text between point and mark.
3866 The text will also be indented the normal way."
3868 (let ((start (point))
3870 (if (not (re-search-forward message-signature-separator
(mark t
) t
))
3871 ;; No signature here, so we just indent the cited text.
3872 (message-indent-citation)
3873 ;; Find the last non-empty line.
3875 (while (looking-at "[ \t]*$")
3878 (setq mark
(set-marker (make-marker) (point)))
3880 (message-indent-citation)
3881 ;; Enable undoing the deletion.
3883 (delete-region mark
(mark t
))
3884 (set-marker mark nil
)))))
3889 ;;; Sending messages
3892 (defun message-send-and-exit (&optional arg
)
3893 "Send message like `message-send', then, if no errors, exit from mail buffer."
3895 (let ((buf (current-buffer))
3896 (actions message-exit-actions
))
3897 (when (and (message-send arg
)
3899 (if message-kill-buffer-on-exit
3902 (when (eq buf
(current-buffer))
3903 (message-bury buf
)))
3904 (message-do-actions actions
)
3907 (defun message-dont-send ()
3908 "Don't send the message you have been editing.
3909 Instead, just auto-save the buffer and then bury it."
3911 (set-buffer-modified-p t
)
3913 (let ((actions message-postpone-actions
))
3914 (message-bury (current-buffer))
3915 (message-do-actions actions
)))
3917 (defun message-kill-buffer ()
3918 "Kill the current buffer."
3920 (when (or (not (buffer-modified-p))
3921 (not message-kill-buffer-query
)
3922 (yes-or-no-p "Message modified; kill anyway? "))
3923 (let ((actions message-kill-actions
)
3924 (draft-article message-draft-article
)
3925 (auto-save-file-name buffer-auto-save-file-name
)
3926 (file-name buffer-file-name
)
3927 (modified (buffer-modified-p)))
3928 (setq buffer-file-name nil
)
3929 (kill-buffer (current-buffer))
3930 (when (and (or (and auto-save-file-name
3931 (file-exists-p auto-save-file-name
))
3933 (file-exists-p file-name
)))
3935 ;; If the message buffer has lived in a dedicated window,
3936 ;; `kill-buffer' has killed the frame. Thus the
3937 ;; `yes-or-no-p' may show up in a lowered frame. Make sure
3938 ;; that the user can see the question by raising the
3941 (yes-or-no-p (format "Remove the backup file%s? "
3942 (if modified
" too" "")))))
3944 (delete-file auto-save-file-name
))
3945 (let ((message-draft-article draft-article
))
3946 (message-disassociate-draft)))
3947 (message-do-actions actions
))))
3949 (defun message-bury (buffer)
3950 "Bury this mail BUFFER."
3951 (let ((newbuf (other-buffer buffer
)))
3952 (bury-buffer buffer
)
3953 (if (and (window-dedicated-p (selected-window))
3954 (not (null (delq (selected-frame) (visible-frame-list)))))
3955 (delete-frame (selected-frame))
3956 (switch-to-buffer newbuf
))))
3958 (defun message-send (&optional arg
)
3959 "Send the message in the current buffer.
3960 If `message-interactive' is non-nil, wait for success indication or
3961 error messages, and inform user.
3962 Otherwise any failure is reported in a message back to the user from
3964 The usage of ARG is defined by the instance that called Message.
3965 It should typically alter the sending method in some way or other."
3967 ;; Make it possible to undo the coming changes.
3969 (let ((inhibit-read-only t
))
3970 (put-text-property (point-min) (point-max) 'read-only nil
))
3971 (message-fix-before-sending)
3972 (run-hooks 'message-send-hook
)
3973 (when message-confirm-send
3974 (or (y-or-n-p "Send message? ")
3976 (message message-sending-message
)
3977 (let ((alist message-send-method-alist
)
3979 elem sent dont-barf-on-no-method
3980 (message-options message-options
))
3981 (message-options-set-recipient)
3983 (setq elem
(pop alist
)))
3984 (when (funcall (cadr elem
))
3985 (when (and (or (not (memq (car elem
)
3986 message-sent-message-via
))
3987 (message-fetch-field "supersedes")
3988 (if (or (message-gnksa-enable-p 'multiple-copies
)
3989 (not (eq (car elem
) 'news
)))
3992 "Already sent message via %s; resend? "
3994 (error "Denied posting -- multiple copies")))
3995 (setq success
(funcall (caddr elem
) arg
)))
3999 (let ((fcc (message-fetch-field "Fcc"))
4000 (gcc (message-fetch-field "Gcc")))
4002 (or (eq message-allow-no-recipients
'always
)
4003 (and (not (eq message-allow-no-recipients
'never
))
4004 (setq dont-barf-on-no-method
4006 (format "No receiver, perform %s anyway? "
4007 (cond ((and fcc gcc
) "Fcc and Gcc")
4010 (error "No methods specified to send by"))
4011 (when (or dont-barf-on-no-method
4015 (run-hooks 'message-sent-hook
))
4016 (message "Sending...done")
4017 ;; Do ecomplete address snarfing.
4018 (when (message-mail-alias-type-p 'ecomplete
)
4019 (message-put-addresses-in-ecomplete))
4020 ;; Mark the buffer as unmodified and delete auto-save.
4021 (set-buffer-modified-p nil
)
4022 (delete-auto-save-file-if-necessary t
)
4023 (message-disassociate-draft)
4024 ;; Delete other mail buffers and stuff.
4025 (message-do-send-housekeeping)
4026 (message-do-actions message-send-actions
)
4030 (defun message-send-via-mail (arg)
4031 "Send the current message via mail."
4032 (message-send-mail arg
))
4034 (defun message-send-via-news (arg)
4035 "Send the current message via news."
4036 (funcall message-send-news-function arg
))
4038 (defmacro message-check
(type &rest forms
)
4039 "Eval FORMS if TYPE is to be checked."
4040 `(or (message-check-element ,type
)
4044 (put 'message-check
'lisp-indent-function
1)
4045 (put 'message-check
'edebug-form-spec
'(form body
))
4047 (defun message-text-with-property (prop &optional start end reverse
)
4048 "Return a list of start and end positions where the text has PROP.
4049 START and END bound the search, they default to `point-min' and
4050 `point-max' respectively. If REVERSE is non-nil, find text which does
4053 (setq start
(point-min)))
4055 (setq end
(point-max)))
4059 (setq start
(text-property-any start end prop nil
)))
4060 (setq next
(next-single-property-change start prop nil end
))
4061 (push (cons start
(or next end
)) regions
)
4064 (or (get-text-property start prop
)
4065 (and (setq start
(next-single-property-change
4066 start prop nil end
))
4067 (get-text-property start prop
))))
4068 (setq next
(text-property-any start end prop nil
))
4069 (push (cons start
(or next end
)) regions
)
4071 (nreverse regions
)))
4073 (defcustom message-bogus-addresses
4074 ;; '("noreply" "nospam" "invalid")
4075 '("noreply" "nospam" "invalid" "@@" "[^[:ascii:]].*@" "[ \t]")
4076 "List of regexps of potentially bogus mail addresses.
4077 See `message-check-recipients' how to setup checking.
4079 This list should make it possible to catch typos or warn about
4080 spam-trap addresses. It doesn't aim to verify strict RFC
4082 :version
"23.1" ;; No Gnus
4083 :group
'message-headers
4085 (const :tag
"None" nil
)
4091 (const :tag
"duplicate @" "@@")
4092 (const :tag
"non-ascii local part" "[^[:ascii:]].*@")
4093 ;; Already caught by `message-valid-fqdn-regexp'
4094 ;; (const :tag "`_' in domain part" "@.*_")
4095 (const :tag
"whitespace" "[ \t]"))
4100 (defun message-fix-before-sending ()
4101 "Do various things to make the message nice before sending it."
4102 ;; Make sure there's a newline at the end of the message.
4103 (goto-char (point-max))
4106 ;; Make the hidden headers visible.
4108 ;; Sort headers before sending the message.
4109 (message-sort-headers)
4110 ;; Make invisible text visible.
4111 ;; It doesn't seem as if this is useful, since the invisible property
4112 ;; is clobbered by an after-change hook anyhow.
4113 (message-check 'invisible-text
4114 (let ((regions (message-text-with-property 'invisible
))
4118 (setq from
(caar regions
)
4120 regions
(cdr regions
))
4121 (put-text-property from to
'invisible nil
)
4122 (message-overlay-put (message-make-overlay from to
)
4124 (unless (yes-or-no-p
4125 "Invisible text found and made visible; continue sending? ")
4126 (error "Invisible text found and made visible")))))
4127 (message-check 'illegible-text
4128 (let (char found choice
)
4131 (skip-chars-forward mm-7bit-chars
)
4132 (when (get-text-property (point) 'no-illegible-text
)
4133 ;; There is a signed or encrypted raw message part
4134 ;; that is considered to be safe.
4135 (goto-char (or (next-single-property-change
4136 (point) 'no-illegible-text
)
4138 (setq char
(char-after)))
4139 (when (or (< (mm-char-int char
) 128)
4140 (and (mm-multibyte-p)
4141 (memq (char-charset char
)
4142 '(eight-bit-control eight-bit-graphic
4144 (not (get-text-property
4145 (point) 'untranslated-utf-8
))))
4146 (message-overlay-put (message-make-overlay (point) (1+ (point)))
4152 (gnus-multiple-choice
4153 "Non-printable characters found. Continue sending?"
4154 `((?d
"Remove non-printable characters and send")
4156 "Replace non-printable characters with \"%s\" and send"
4157 message-replacement-char
))
4158 (?i
"Ignore non-printable characters and send")
4159 (?e
"Continue editing"))))
4161 (error "Non-printable characters"))
4163 (skip-chars-forward mm-7bit-chars
)
4165 (when (let ((char (char-after)))
4166 (or (< (mm-char-int char
) 128)
4167 (and (mm-multibyte-p)
4168 ;; FIXME: Wrong for Emacs 23 (unicode) and for
4169 ;; things like undecable utf-8. Should at least
4170 ;; use find-coding-systems-region.
4171 (memq (char-charset char
)
4172 '(eight-bit-control eight-bit-graphic
4174 (not (get-text-property
4175 (point) 'untranslated-utf-8
)))))
4177 (message-kill-all-overlays)
4179 (when (eq choice ?r
)
4180 (insert message-replacement-char
))))
4182 (skip-chars-forward mm-7bit-chars
)))))
4183 (message-check 'bogus-recipient
4184 ;; Warn before sending a mail to an invalid address.
4185 (message-check-recipients)))
4187 (defun message-bogus-recipient-p (recipients)
4188 "Check if a mail address in RECIPIENTS looks bogus.
4190 RECIPIENTS is a mail header. Return a list of potentially bogus
4191 addresses. If none is found, return nil.
4193 An address might be bogus if the domain part is not fully
4194 qualified, see `message-valid-fqdn-regexp', or if there's a
4195 matching entry in `message-bogus-addresses'."
4196 ;; FIXME: How about "foo@subdomain", when the MTA adds ".domain.tld"?
4198 (mapc (lambda (address)
4199 (setq address
(cadr address
))
4203 (not (string-match "@" address
))
4206 message-valid-fqdn-regexp
"\\)\\'") address
)))
4207 (and message-bogus-addresses
4209 (if (listp message-bogus-addresses
)
4210 (mapconcat 'identity
4211 message-bogus-addresses
4213 message-bogus-addresses
)))
4214 (string-match re address
))))
4215 (push address found
)))
4217 (mail-extract-address-components recipients t
))
4220 (defun message-check-recipients ()
4221 "Warn before composing or sending a mail to an invalid address.
4223 This function could be useful in `message-setup-hook'."
4226 (message-narrow-to-headers)
4227 (dolist (hdr '("To" "Cc" "Bcc"))
4228 (let ((addr (message-fetch-field hdr
)))
4229 (when (stringp addr
)
4230 (dolist (bog (message-bogus-recipient-p addr
))
4234 "Address `%s' might be bogus. Continue? " bog
)))
4235 (error "Bogus address."))))))))
4237 (custom-add-option 'message-setup-hook
'message-check-recipients
)
4239 (defun message-add-action (action &rest types
)
4240 "Add ACTION to be performed when doing an exit of type TYPES."
4242 (add-to-list (intern (format "message-%s-actions" (pop types
)))
4245 (defun message-delete-action (action &rest types
)
4246 "Delete ACTION from lists of actions performed when doing an exit of type TYPES."
4249 (set (setq var
(intern (format "message-%s-actions" (pop types
))))
4250 (delq action
(symbol-value var
))))))
4252 (defun message-do-actions (actions)
4253 "Perform all actions in ACTIONS."
4254 ;; Now perform actions on successful sending.
4255 (dolist (action actions
)
4258 ;; A simple function.
4261 ;; Something to be evaled.
4265 (defun message-send-mail-partially ()
4266 "Send mail as message/partial."
4267 ;; replace the header delimiter with a blank line
4268 (goto-char (point-min))
4270 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4271 (replace-match "\n")
4272 (run-hooks 'message-send-mail-hook
)
4273 (let ((p (goto-char (point-min)))
4274 (tembuf (message-generate-new-buffer-clone-locals " message temp"))
4275 (curbuf (current-buffer))
4276 (id (message-make-message-id)) (n 1)
4277 plist total header required-mail-headers
)
4279 (if (< (point-max) (+ p message-send-mail-partially-limit
))
4280 (goto-char (point-max))
4281 (goto-char (+ p message-send-mail-partially-limit
))
4283 (if (<= (point) p
) (forward-line 1))) ;; In case of bad message.
4286 (setq total
(length plist
))
4287 (push (point-max) plist
)
4288 (setq plist
(nreverse plist
))
4291 (setq p
(pop plist
))
4294 (copy-to-buffer tembuf p
(car plist
))
4296 (goto-char (point-min))
4299 (goto-char (point-min))
4300 (narrow-to-region (point) (point))
4303 (setq header
(buffer-substring (point-min) (point)))
4304 (goto-char (point-min))
4305 (narrow-to-region (point) (point))
4307 (message-remove-header "Mime-Version")
4308 (message-remove-header "Content-Type")
4309 (message-remove-header "Content-Transfer-Encoding")
4310 (message-remove-header "Message-ID")
4311 (message-remove-header "Lines")
4312 (goto-char (point-max))
4313 (insert "Mime-Version: 1.0\n")
4314 (setq header
(buffer-string)))
4315 (goto-char (point-max))
4316 (insert (format "Content-Type: message/partial; id=\"%s\"; number=%d; total=%d\n\n"
4319 (let ((mail-header-separator ""))
4320 (when (memq 'Message-ID message-required-mail-headers
)
4321 (insert "Message-ID: " (message-make-message-id) "\n"))
4322 (when (memq 'Lines message-required-mail-headers
)
4323 (insert "Lines: " (message-make-lines) "\n"))
4324 (message-goto-subject)
4326 (insert (format " (%d/%d)" n total
))
4328 (mm-with-unibyte-current-buffer
4329 (funcall (or message-send-mail-real-function
4330 message-send-mail-function
))))
4332 (setq p
(pop plist
))
4334 (kill-buffer tembuf
))))
4336 (defun message-send-mail (&optional arg
)
4337 (require 'mail-utils
)
4338 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
4339 (case-fold-search nil
)
4340 (news (message-news-p))
4341 (mailbuf (current-buffer))
4342 (message-this-is-mail t
)
4343 (message-posting-charset
4344 (if (fboundp 'gnus-setup-posting-charset
)
4345 (gnus-setup-posting-charset nil
)
4346 message-posting-charset
))
4347 (headers message-required-mail-headers
))
4348 (when (and message-generate-hashcash
4349 (not (eq message-generate-hashcash
'opportunistic
)))
4350 (message "Generating hashcash...")
4351 ;; Wait for calculations already started to finish...
4352 (hashcash-wait-async)
4353 ;; ...and do calculations not already done. mail-add-payment
4354 ;; will leave existing X-Hashcash headers alone.
4356 (message "Generating hashcash...done"))
4358 (message-narrow-to-headers)
4359 ;; Generate the Mail-Followup-To header if the header is not there...
4360 (if (and (message-subscribed-p)
4361 (not (mail-fetch-field "mail-followup-to")))
4364 (cons "Mail-Followup-To" (message-make-mail-followup-to))
4365 message-required-mail-headers
))
4366 ;; otherwise, delete the MFT header if the field is empty
4367 (when (equal "" (mail-fetch-field "mail-followup-to"))
4368 (message-remove-header "^Mail-Followup-To:")))
4369 ;; Insert some headers.
4370 (let ((message-deletable-headers
4371 (if news nil message-deletable-headers
)))
4372 (message-generate-headers headers
))
4373 ;; Check continuation headers.
4374 (message-check 'continuation-headers
4375 (goto-char (point-min))
4376 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4377 (goto-char (match-beginning 0))
4378 (if (y-or-n-p "Fix continuation lines? ")
4381 (unless (y-or-n-p "Send anyway? ")
4382 (error "Failed to send the message")))))
4383 ;; Let the user do all of the above.
4384 (run-hooks 'message-header-hook
))
4386 (with-current-buffer tembuf
4388 ;; Avoid copying text props (except hard newlines).
4389 (insert (with-current-buffer mailbuf
4390 (mml-buffer-substring-no-properties-except-hard-newlines
4391 (point-min) (point-max))))
4392 ;; Remove some headers.
4393 (message-encode-message-body)
4395 (message-narrow-to-headers)
4396 ;; We (re)generate the Lines header.
4397 (when (memq 'Lines message-required-mail-headers
)
4398 (message-generate-headers '(Lines)))
4399 ;; Remove some headers.
4400 (message-remove-header message-ignored-mail-headers t
)
4401 (let ((mail-parse-charset message-default-charset
))
4402 (mail-encode-encoded-word-buffer)))
4403 (goto-char (point-max))
4404 ;; require one newline at the end.
4405 (or (= (preceding-char) ?
\n)
4407 (message-cleanup-headers)
4408 ;; FIXME: we're inserting the courtesy copy after encoding.
4409 ;; This is wrong if the courtesy copy string contains
4410 ;; non-ASCII characters. -- jh
4413 (message-narrow-to-headers)
4415 (or (message-fetch-field "cc")
4416 (message-fetch-field "bcc")
4417 (message-fetch-field "to"))
4418 (let ((content-type (message-fetch-field
4423 (string= "text/plain"
4425 (mail-header-parse-content-type
4429 (message-fetch-field
4430 "content-transfer-encoding")))))))
4431 (message-insert-courtesy-copy))
4432 (if (or (not message-send-mail-partially-limit
)
4433 (< (buffer-size) message-send-mail-partially-limit
)
4434 (not (message-y-or-n-p
4435 "The message size is too large, split? "
4439 (/ (buffer-size) 1000) "KB, is too large.
4441 Some mail gateways (MTA's) bounce large messages. To avoid the
4442 problem, answer `y', and the message will be split into several
4443 smaller pieces, the size of each is about "
4444 (/ message-send-mail-partially-limit
1000)
4448 However, some mail readers (MUA's) can't read split messages, i.e.,
4449 mails in message/partially format. Answer `n', and the message will be
4452 The size limit is controlled by `message-send-mail-partially-limit'.
4453 If you always want Gnus to send messages in one piece, set
4454 `message-send-mail-partially-limit' to nil.
4456 (mm-with-unibyte-current-buffer
4457 (message "Sending via mail...")
4458 (funcall (or message-send-mail-real-function
4459 message-send-mail-function
)))
4460 (message-send-mail-partially)))
4461 (kill-buffer tembuf
))
4462 (set-buffer mailbuf
)
4463 (push 'mail message-sent-message-via
)))
4465 (defun message-send-mail-with-sendmail ()
4466 "Send off the prepared buffer with sendmail."
4467 (let ((errbuf (if message-interactive
4468 (message-generate-new-buffer-clone-locals
4471 resend-to-addresses delimline
)
4474 (let ((case-fold-search t
))
4476 (message-narrow-to-headers)
4477 (setq resend-to-addresses
(message-fetch-field "resent-to")))
4478 ;; Change header-delimiter to be what sendmail expects.
4479 (goto-char (point-min))
4481 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4482 (replace-match "\n")
4484 (setq delimline
(point-marker))
4485 (run-hooks 'message-send-mail-hook
)
4486 ;; Insert an extra newline if we need it to work around
4487 ;; Sun's bug that swallows newlines.
4488 (goto-char (1+ delimline
))
4489 (when (eval message-mailer-swallows-blank-line
)
4491 (when message-interactive
4492 (with-current-buffer errbuf
4494 (let* ((default-directory "/")
4495 (coding-system-for-write message-send-coding-system
)
4497 'call-process-region
4499 (list (point-min) (point-max)
4500 (cond ((boundp 'sendmail-program
)
4502 ((file-exists-p "/usr/sbin/sendmail")
4503 "/usr/sbin/sendmail")
4504 ((file-exists-p "/usr/lib/sendmail")
4505 "/usr/lib/sendmail")
4506 ((file-exists-p "/usr/ucblib/sendmail")
4507 "/usr/ucblib/sendmail")
4509 nil errbuf nil
"-oi")
4510 message-sendmail-extra-arguments
4511 ;; Always specify who from,
4512 ;; since some systems have broken sendmails.
4513 ;; But some systems are more broken with -f, so
4514 ;; we'll let users override this.
4515 (if (null message-sendmail-f-is-evil
)
4516 (list "-f" (message-sendmail-envelope-from)))
4517 ;; These mean "report errors by mail"
4518 ;; and "deliver in background".
4519 (if (null message-interactive
) '("-oem" "-odb"))
4520 ;; Get the addresses from the message
4521 ;; unless this is a resend.
4522 ;; We must not do that for a resend
4523 ;; because we would find the original addresses.
4524 ;; For a resend, include the specific addresses.
4525 (if resend-to-addresses
4526 (list resend-to-addresses
)
4528 (unless (or (null cpr
) (and (numberp cpr
) (zerop cpr
)))
4529 (if errbuf
(pop-to-buffer errbuf
))
4530 (error "Sending...failed with exit value %d" cpr
)))
4531 (when message-interactive
4532 (with-current-buffer errbuf
4533 (goto-char (point-min))
4534 (while (re-search-forward "\n+ *" nil t
)
4535 (replace-match "; "))
4536 (if (not (zerop (buffer-size)))
4537 (error "Sending...failed to %s"
4538 (buffer-string))))))
4539 (when (bufferp errbuf
)
4540 (kill-buffer errbuf
)))))
4542 (defun message-send-mail-with-qmail ()
4543 "Pass the prepared message buffer to qmail-inject.
4544 Refer to the documentation for the variable `message-send-mail-function'
4545 to find out how to use this."
4546 ;; replace the header delimiter with a blank line
4547 (goto-char (point-min))
4549 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4550 (replace-match "\n")
4551 (run-hooks 'message-send-mail-hook
)
4554 (let ((coding-system-for-write message-send-coding-system
))
4556 'call-process-region
(point-min) (point-max)
4557 message-qmail-inject-program nil nil nil
4558 ;; qmail-inject's default behavior is to look for addresses on the
4559 ;; command line; if there're none, it scans the headers.
4560 ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
4562 ;; in general, ALL of qmail-inject's defaults are perfect for simply
4563 ;; reading a formatted (i. e., at least a To: or Resent-To header)
4564 ;; message from stdin.
4566 ;; qmail also has the advantage of not having been raped by
4567 ;; various vendors, so we don't have to allow for that, either --
4568 ;; compare this with message-send-mail-with-sendmail and weep
4569 ;; for sendmail's lost innocence.
4571 ;; all this is way cool coz it lets us keep the arguments entirely
4572 ;; free for -inject-arguments -- a big win for the user and for us
4573 ;; since we don't have to play that double-guessing game and the user
4574 ;; gets full control (no gestapo'ish -f's, for instance). --sj
4575 (if (functionp message-qmail-inject-args
)
4576 (funcall message-qmail-inject-args
)
4577 message-qmail-inject-args
)))
4578 ;; qmail-inject doesn't say anything on it's stdout/stderr,
4579 ;; we have to look at the retval instead
4581 (100 (error "qmail-inject reported permanent failure"))
4582 (111 (error "qmail-inject reported transient failure"))
4583 ;; should never happen
4584 (t (error "qmail-inject reported unknown failure"))))
4586 (defun message-send-mail-with-mh ()
4587 "Send the prepared message buffer with mh."
4588 (let ((mh-previous-window-config nil
)
4589 (name (mh-new-draft-name)))
4590 (setq buffer-file-name name
)
4591 ;; MH wants to generate these headers itself.
4592 (when message-mh-deletable-headers
4593 (let ((headers message-mh-deletable-headers
))
4595 (goto-char (point-min))
4596 (and (re-search-forward
4597 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
4598 (message-delete-line))
4600 (run-hooks 'message-send-mail-hook
)
4601 ;; Pass it on to mh.
4604 (defun message-smtpmail-send-it ()
4605 "Send the prepared message buffer with `smtpmail-send-it'.
4606 This only differs from `smtpmail-send-it' that this command evaluates
4607 `message-send-mail-hook' just before sending a message. It is useful
4608 if your ISP requires the POP-before-SMTP authentication. See the Gnus
4609 manual for details."
4610 (run-hooks 'message-send-mail-hook
)
4613 (defun message-send-mail-with-mailclient ()
4614 "Send the prepared message buffer with `mailclient-send-it'.
4615 This only differs from `smtpmail-send-it' that this command evaluates
4616 `message-send-mail-hook' just before sending a message."
4617 (run-hooks 'message-send-mail-hook
)
4618 (mailclient-send-it))
4620 (defun message-canlock-generate ()
4621 "Return a string that is non-trivial to guess.
4622 Do not use this for anything important, it is cryptographically weak."
4624 (let (sha1-maximum-internal-length)
4625 (sha1 (concat (message-unique-id)
4626 (format "%x%x%x" (random) (random t
) (random))
4627 (prin1-to-string (recent-keys))
4628 (prin1-to-string (garbage-collect))))))
4630 (defun message-canlock-password ()
4631 "The password used by message for cancel locks.
4632 This is the value of `canlock-password', if that option is non-nil.
4633 Otherwise, generate and save a value for `canlock-password' first."
4634 (unless canlock-password
4635 (customize-save-variable 'canlock-password
(message-canlock-generate))
4636 (setq canlock-password-for-verify canlock-password
))
4639 (defun message-insert-canlock ()
4640 (when message-insert-canlock
4641 (message-canlock-password)
4642 (canlock-insert-header)))
4644 (defun message-send-news (&optional arg
)
4645 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*"))
4646 (case-fold-search nil
)
4647 (method (if (functionp message-post-method
)
4648 (funcall message-post-method arg
)
4649 message-post-method
))
4650 (newsgroups-field (save-restriction
4651 (message-narrow-to-headers-or-head)
4652 (message-fetch-field "Newsgroups")))
4653 (followup-field (save-restriction
4654 (message-narrow-to-headers-or-head)
4655 (message-fetch-field "Followup-To")))
4656 ;; BUG: We really need to get the charset for each name in the
4657 ;; Newsgroups and Followup-To lines to allow crossposting
4658 ;; between group namess with incompatible character sets.
4659 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
4660 (group-field-charset
4661 (gnus-group-name-charset method newsgroups-field
))
4662 (followup-field-charset
4663 (gnus-group-name-charset method
(or followup-field
"")))
4664 (rfc2047-header-encoding-alist
4665 (append (when group-field-charset
4666 (list (cons "Newsgroups" group-field-charset
)))
4667 (when followup-field-charset
4668 (list (cons "Followup-To" followup-field-charset
)))
4669 rfc2047-header-encoding-alist
))
4670 (messbuf (current-buffer))
4671 (message-syntax-checks
4673 (listp message-syntax-checks
))
4674 (cons '(existing-newsgroups . disabled
)
4675 message-syntax-checks
)
4676 message-syntax-checks
))
4677 (message-this-is-news t
)
4678 (message-posting-charset
4679 (gnus-setup-posting-charset newsgroups-field
))
4681 (if (not (message-check-news-body-syntax))
4684 (message-narrow-to-headers)
4685 ;; Insert some headers.
4686 (message-generate-headers message-required-news-headers
)
4687 (message-insert-canlock)
4688 ;; Let the user do all of the above.
4689 (run-hooks 'message-header-hook
))
4690 ;; Note: This check will be disabled by the ".*" default value for
4691 ;; gnus-group-name-charset-group-alist. -- Pa 2001-10-07.
4692 (when (and group-field-charset
4693 (listp message-syntax-checks
))
4694 (setq message-syntax-checks
4695 (cons '(valid-newsgroups . disabled
)
4696 message-syntax-checks
)))
4697 (message-cleanup-headers)
4698 (if (not (let ((message-post-method method
))
4699 (message-check-news-syntax)))
4702 (with-current-buffer tembuf
4703 (buffer-disable-undo)
4705 ;; Avoid copying text props (except hard newlines).
4707 (with-current-buffer messbuf
4708 (mml-buffer-substring-no-properties-except-hard-newlines
4709 (point-min) (point-max))))
4710 (message-encode-message-body)
4711 ;; Remove some headers.
4713 (message-narrow-to-headers)
4714 ;; We (re)generate the Lines header.
4715 (when (memq 'Lines message-required-mail-headers
)
4716 (message-generate-headers '(Lines)))
4717 ;; Remove some headers.
4718 (message-remove-header message-ignored-news-headers t
)
4719 (let ((mail-parse-charset message-default-charset
))
4720 (mail-encode-encoded-word-buffer)))
4721 (goto-char (point-max))
4722 ;; require one newline at the end.
4723 (or (= (preceding-char) ?
\n)
4725 (let ((case-fold-search t
))
4726 ;; Remove the delimiter.
4727 (goto-char (point-min))
4729 (concat "^" (regexp-quote mail-header-separator
) "\n"))
4730 (replace-match "\n")
4732 (run-hooks 'message-send-news-hook
)
4733 (gnus-open-server method
)
4734 (message "Sending news via %s..." (gnus-server-string method
))
4735 (setq result
(let ((mail-header-separator ""))
4736 (gnus-request-post method
))))
4737 (kill-buffer tembuf
))
4738 (set-buffer messbuf
)
4740 (push 'news message-sent-message-via
)
4741 (message "Couldn't send message via news: %s"
4742 (nnheader-get-report (car method
)))
4746 ;;; Header generation & syntax checking.
4749 (defun message-check-element (type)
4750 "Return non-nil if this TYPE is not to be checked."
4751 (if (eq message-syntax-checks
'dont-check-for-anything-just-trust-me
)
4753 (let ((able (assq type message-syntax-checks
)))
4755 (eq (cdr able
) 'disabled
)))))
4757 (defun message-check-news-syntax ()
4758 "Check the syntax of the message."
4762 ;; We narrow to the headers and check them first.
4765 (message-narrow-to-headers)
4766 (message-check-news-header-syntax))))))
4768 (defun message-check-news-header-syntax ()
4770 ;; Check Newsgroups header.
4771 (message-check 'newsgroups
4772 (let ((group (message-fetch-field "newsgroups")))
4775 (not (string-match "\\`[ \t]*\\'" group
)))
4778 "The newsgroups field is empty or missing. Posting is denied.")))))
4779 ;; Check the Subject header.
4780 (message-check 'subject
4781 (let* ((case-fold-search t
)
4782 (subject (message-fetch-field "subject")))
4785 (not (string-match "\\`[ \t]*\\'" subject
)))
4788 "The subject field is empty or missing. Posting is denied.")))))
4789 ;; Check for commands in Subject.
4790 (message-check 'subject-cmsg
4791 (if (string-match "^cmsg " (message-fetch-field "subject"))
4793 "The control code \"cmsg\" is in the subject. Really post? ")
4795 ;; Check long header lines.
4796 (message-check 'long-header-lines
4797 (let ((start (point))
4801 (while (and (not found
)
4802 (re-search-forward "^\\([^ \t:]+\\): " nil t
))
4803 (if (> (- (point) (match-beginning 0)) 998)
4805 length
(- (point) (match-beginning 0)))
4806 (setq header
(match-string-no-properties 1)))
4807 (setq start
(match-beginning 0))
4810 (y-or-n-p (format "Your %s header is too long (%d). Really post? "
4813 ;; Check for multiple identical headers.
4814 (message-check 'multiple-headers
4816 (while (and (not found
)
4817 (re-search-forward "^[^ \t:]+: " nil t
))
4819 (or (re-search-forward
4824 (match-beginning 0) (- (match-end 0) 2))))
4829 (y-or-n-p (format "Multiple %s headers. Really post? " found
))
4831 ;; Check for Version and Sendsys.
4832 (message-check 'sendsys
4833 (if (re-search-forward "^Sendsys:\\|^Version:" nil t
)
4835 (format "The article contains a %s command. Really post? "
4836 (buffer-substring (match-beginning 0)
4837 (1- (match-end 0)))))
4839 ;; See whether we can shorten Followup-To.
4840 (message-check 'shorten-followup-to
4841 (let ((newsgroups (message-fetch-field "newsgroups"))
4842 (followup-to (message-fetch-field "followup-to"))
4844 (when (and newsgroups
4845 (string-match "," newsgroups
)
4850 (setq to
(completing-read
4851 "Followups to (default no Followup-To header): "
4854 (message-tokenize-header
4856 (goto-char (point-min))
4857 (insert "Followup-To: " to
"\n"))
4859 ;; Check "Shoot me".
4860 (message-check 'shoot
4861 (if (re-search-forward
4862 "Message-ID.*.i-did-not-set--mail-host-address--so-tickle-me" nil t
)
4863 (y-or-n-p "You appear to have a misconfigured system. Really post? ")
4865 ;; Check for Approved.
4866 (message-check 'approved
4867 (if (re-search-forward "^Approved:" nil t
)
4868 (y-or-n-p "The article contains an Approved header. Really post? ")
4870 ;; Check the Message-ID header.
4871 (message-check 'message-id
4872 (let* ((case-fold-search t
)
4873 (message-id (message-fetch-field "message-id" t
)))
4874 (or (not message-id
)
4875 ;; Is there an @ in the ID?
4876 (and (string-match "@" message-id
)
4877 ;; Is there a dot in the ID?
4878 (string-match "@[^.]*\\." message-id
)
4879 ;; Does the ID end with a dot?
4880 (not (string-match "\\.>" message-id
)))
4882 (format "The Message-ID looks strange: \"%s\". Really post? "
4884 ;; Check the Newsgroups & Followup-To headers.
4885 (message-check 'existing-newsgroups
4886 (let* ((case-fold-search t
)
4887 (newsgroups (message-fetch-field "newsgroups"))
4888 (followup-to (message-fetch-field "followup-to"))
4889 (groups (message-tokenize-header
4891 (concat newsgroups
"," followup-to
)
4893 (post-method (if (functionp message-post-method
)
4894 (funcall message-post-method
)
4895 message-post-method
))
4896 ;; KLUDGE to handle nnvirtual groups. Doing this right
4897 ;; would probably involve a new nnoo function.
4898 ;; -- Per Abrahamsen <abraham@dina.kvl.dk>, 2001-10-17.
4899 (method (if (and (consp post-method
)
4900 (eq (car post-method
) 'nnvirtual
)
4901 gnus-message-group-art
)
4902 (let ((group (car (nnvirtual-find-group-art
4903 (car gnus-message-group-art
)
4904 (cdr gnus-message-group-art
)))))
4905 (gnus-find-method-for-group group
))
4909 (gnus-group-name-decode
4910 (gnus-group-real-name n
)
4911 (gnus-group-name-charset method n
)))
4912 (gnus-groups-from-server method
)))
4915 (when (and (not (equal (car groups
) "poster"))
4916 (not (member (car groups
) known-groups
))
4917 (not (member (car groups
) errors
)))
4918 (push (car groups
) errors
))
4921 ;; Gnus is not running.
4922 ((or (not (and (boundp 'gnus-active-hashtb
)
4923 gnus-active-hashtb
))
4924 (not (boundp 'gnus-read-active-file
)))
4926 ;; We don't have all the group names.
4927 ((and (or (not gnus-read-active-file
)
4928 (eq gnus-read-active-file
'some
))
4932 "Really use %s possibly unknown group%s: %s? "
4933 (if (= (length errors
) 1) "this" "these")
4934 (if (= (length errors
) 1) "" "s")
4935 (mapconcat 'identity errors
", "))))
4936 ;; There were no errors.
4939 ;; There are unknown groups.
4943 "Really post to %s unknown group%s: %s? "
4944 (if (= (length errors
) 1) "this" "these")
4945 (if (= (length errors
) 1) "" "s")
4946 (mapconcat 'identity errors
", ")))))))
4947 ;; Check continuation headers.
4948 (message-check 'continuation-headers
4949 (goto-char (point-min))
4950 (let ((do-posting t
))
4951 (while (re-search-forward "^[^ \t\n][^ \t\n:]*[ \t\n]" nil t
)
4952 (goto-char (match-beginning 0))
4953 (if (y-or-n-p "Fix continuation lines? ")
4956 (unless (y-or-n-p "Send anyway? ")
4957 (setq do-posting nil
))))
4959 ;; Check the Newsgroups & Followup-To headers for syntax errors.
4960 (message-check 'valid-newsgroups
4961 (let ((case-fold-search t
)
4962 (headers '("Newsgroups" "Followup-To"))
4964 (while (and headers
(not error
))
4965 (when (setq header
(mail-fetch-field (car headers
)))
4969 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-+_&.a-zA-Z0-9]+\\)*\\'"
4974 (not (string-match "\\.\\'\\|\\.\\." g
)))
4975 (message-tokenize-header header
","))))
4982 (format "The %s header looks odd: \"%s\". Really post? "
4983 (car headers
) header
)))))
4984 (message-check 'repeated-newsgroups
4985 (let ((case-fold-search t
)
4986 (headers '("Newsgroups" "Followup-To"))
4987 header error groups group
)
4990 (when (setq header
(mail-fetch-field (pop headers
)))
4991 (setq groups
(message-tokenize-header header
","))
4992 (while (setq group
(pop groups
))
4993 (when (member group groups
)
4999 (format "Group %s is repeated in headers. Really post? " error
)))))
5000 ;; Check the From header.
5001 (message-check 'from
5002 (let* ((case-fold-search t
)
5003 (from (message-fetch-field "from"))
5007 (message "There is no From line. Posting is denied.")
5009 ((or (not (string-match
5011 (setq ad
(nth 1 (mail-extract-address-components
5012 from
))))) ;larsi@ifi
5013 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5014 (string-match "@\\." ad
) ;larsi@.ifi.uio
5015 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5016 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5017 (string-match "(.*).*(.*)" from
)) ;(lars) (lars)
5019 "Denied posting -- the From looks strange: \"%s\"." from
)
5021 ((let ((addresses (rfc822-addresses from
)))
5022 (while (and addresses
5023 (not (eq (string-to-char (car addresses
)) ?\
()))
5024 (setq addresses
(cdr addresses
)))
5027 "Denied posting -- bad From address: \"%s\"." from
)
5030 ;; Check the Reply-To header.
5031 (message-check 'reply-to
5032 (let* ((case-fold-search t
)
5033 (reply-to (message-fetch-field "reply-to"))
5038 ((string-match "," reply-to
)
5040 (format "Multiple Reply-To addresses: \"%s\". Really post? "
5042 ((or (not (string-match
5044 (setq ad
(nth 1 (mail-extract-address-components
5045 reply-to
))))) ;larsi@ifi
5046 (string-match "\\.\\." ad
) ;larsi@ifi..uio
5047 (string-match "@\\." ad
) ;larsi@.ifi.uio
5048 (string-match "\\.$" ad
) ;larsi@ifi.uio.
5049 (not (string-match "^[^@]+@[^@]+$" ad
)) ;larsi.ifi.uio
5050 (string-match "(.*).*(.*)" reply-to
)) ;(lars) (lars)
5053 "The Reply-To looks strange: \"%s\". Really post? "
5057 (defun message-check-news-body-syntax ()
5059 ;; Check for long lines.
5060 (message-check 'long-lines
5061 (goto-char (point-min))
5063 (concat "^" (regexp-quote mail-header-separator
) "$"))
5067 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)")
5070 (< (- (point) p
) 80)))
5071 (zerop (forward-line 1))))
5075 "You have lines longer than 79 characters. Really post? ")))
5076 ;; Check whether the article is empty.
5077 (message-check 'empty
5078 (goto-char (point-min))
5080 (concat "^" (regexp-quote mail-header-separator
) "$"))
5083 (goto-char (point-max))
5084 (re-search-backward message-signature-separator nil t
)
5086 (or (re-search-backward "[^ \n\t]" b t
)
5087 (if (message-gnksa-enable-p 'empty-article
)
5088 (y-or-n-p "Empty article. Really post? ")
5089 (message "Denied posting -- Empty article.")
5091 ;; Check for control characters.
5092 (message-check 'control-chars
5093 (if (re-search-forward
5094 (mm-string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
5097 "The article contains control characters. Really post? ")
5099 ;; Check excessive size.
5100 (message-check 'size
5101 (if (> (buffer-size) 60000)
5103 (format "The article is %d octets long. Really post? "
5106 ;; Check whether any new text has been added.
5107 (message-check 'new-text
5109 (not message-checksum
)
5110 (not (eq (message-checksum) message-checksum
))
5111 (if (message-gnksa-enable-p 'quoted-text-only
)
5113 "It looks like no new text has been added. Really post? ")
5114 (message "Denied posting -- no new text has been added.")
5116 ;; Check the length of the signature.
5117 (message-check 'signature
5118 (goto-char (point-max))
5119 (if (not (re-search-backward message-signature-separator nil t
))
5121 (if (>= (count-lines (1+ (point-at-eol)) (point-max)) 5)
5122 (if (message-gnksa-enable-p 'signature
)
5124 (format "Signature is excessively long (%d lines). Really post? "
5125 (count-lines (1+ (point-at-eol)) (point-max))))
5126 (message "Denied posting -- Excessive signature.")
5129 ;; Ensure that text follows last quoted portion.
5130 (message-check 'quoting-style
5131 (goto-char (point-max))
5132 (let ((no-problem t
))
5133 (when (search-backward-regexp "^>[^\n]*\n" nil t
)
5134 (setq no-problem
(search-forward-regexp "^[ \t]*[^>\n]" nil t
)))
5137 (if (message-gnksa-enable-p 'quoted-text-only
)
5138 (y-or-n-p "Your text should follow quoted text. Really post? ")
5140 (goto-char (point-min))
5142 (concat "^" (regexp-quote mail-header-separator
) "$"))
5143 (if (search-forward-regexp "^[ \t]*[^>\n]" nil t
)
5144 (y-or-n-p "Your text should follow quoted text. Really post? ")
5145 (message "Denied posting -- only quoted text.")
5148 (defun message-checksum ()
5149 "Return a \"checksum\" for the current buffer."
5152 (goto-char (point-min))
5154 (concat "^" (regexp-quote mail-header-separator
) "$"))
5156 (when (not (looking-at "[ \t\n]"))
5157 (setq sum
(logxor (ash sum
1) (if (natnump sum
) 0 1)
5162 (defun message-do-fcc ()
5163 "Process Fcc headers in the current buffer."
5164 (let ((case-fold-search t
)
5165 (buf (current-buffer))
5167 (mml-externalize-attachments message-fcc-externalize-attachments
))
5170 (message-narrow-to-headers)
5171 (setq file
(message-fetch-field "fcc" t
)))
5173 (set-buffer (get-buffer-create " *message temp*"))
5175 (insert-buffer-substring buf
)
5176 (message-encode-message-body)
5178 (message-narrow-to-headers)
5179 (while (setq file
(message-fetch-field "fcc" t
))
5181 (message-remove-header "fcc" nil t
))
5182 (let ((mail-parse-charset message-default-charset
)
5183 (rfc2047-header-encoding-alist
5184 (cons '("Newsgroups" . default
)
5185 rfc2047-header-encoding-alist
)))
5186 (mail-encode-encoded-word-buffer)))
5187 (goto-char (point-min))
5188 (when (re-search-forward
5189 (concat "^" (regexp-quote mail-header-separator
) "$")
5191 (replace-match "" t t
))
5192 ;; Process FCC operations.
5194 (setq file
(pop list
))
5195 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file
)
5196 ;; Pipe the article to the program in question.
5197 (call-process-region (point-min) (point-max) shell-file-name
5198 nil nil nil shell-command-switch
5199 (match-string 1 file
))
5200 ;; Save the article.
5201 (setq file
(expand-file-name file
))
5202 (unless (file-exists-p (file-name-directory file
))
5203 (make-directory (file-name-directory file
) t
))
5204 (if (and message-fcc-handler-function
5205 (not (eq message-fcc-handler-function
'rmail-output
)))
5206 (funcall message-fcc-handler-function file
)
5207 (if (and (file-readable-p file
) (mail-file-babyl-p file
))
5208 (rmail-output file
1 nil t
)
5209 (let ((mail-use-rfc822 t
))
5210 (rmail-output file
1 t t
))))))
5211 (kill-buffer (current-buffer))))))
5213 (defun message-output (filename)
5214 "Append this article to Unix/babyl mail file FILENAME."
5215 (if (and (file-readable-p filename
)
5216 (mail-file-babyl-p filename
))
5217 (gnus-output-to-rmail filename t
)
5218 (gnus-output-to-mail filename t
)))
5220 (defun message-cleanup-headers ()
5221 "Do various automatic cleanups of the headers."
5222 ;; Remove empty lines in the header.
5224 (message-narrow-to-headers)
5225 ;; Remove blank lines.
5226 (while (re-search-forward "^[ \t]*\n" nil t
)
5227 (replace-match "" t t
))
5229 ;; Correct Newsgroups and Followup-To headers: Change sequence of
5230 ;; spaces to comma and eliminate spaces around commas. Eliminate
5231 ;; embedded line breaks.
5232 (goto-char (point-min))
5233 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t
)
5237 (if (re-search-forward "^[^ \t]" nil t
)
5241 (goto-char (point-min))
5242 (while (re-search-forward "\n[ \t]+" nil t
)
5243 (replace-match " " t t
)) ;No line breaks (too confusing)
5244 (goto-char (point-min))
5245 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t
)
5246 (replace-match "," t t
))
5247 (goto-char (point-min))
5248 ;; Remove trailing commas.
5249 (when (re-search-forward ",+$" nil t
)
5250 (replace-match "" t t
))))))
5252 (defun message-make-date (&optional now
)
5253 "Make a valid data header.
5254 If NOW, use that time instead."
5255 (let ((system-time-locale "C"))
5256 (format-time-string "%a, %d %b %Y %T %z" now
)))
5258 (defun message-insert-expires (days)
5259 "Insert the Expires header. Expiry in DAYS days."
5260 (interactive "NExpire article in how many days? ")
5262 (message-position-on-field "Expires" "X-Draft-From")
5263 (insert (message-make-expires-date days
))))
5265 (defun message-make-expires-date (days)
5266 "Make date string for the Expires header. Expiry in DAYS days.
5268 In posting styles use `(\"Expires\" (make-expires-date 30))'."
5269 (let* ((cur (decode-time (current-time)))
5270 (nday (+ days
(nth 3 cur
))))
5271 (setf (nth 3 cur
) nday
)
5272 (message-make-date (apply 'encode-time cur
))))
5274 (defun message-make-message-id ()
5275 "Make a unique Message-ID."
5276 (concat "<" (message-unique-id)
5277 (let ((psubject (save-excursion (message-fetch-field "subject")))
5279 (save-excursion (message-fetch-field "supersedes"))))
5281 (and message-reply-headers
5282 (mail-header-references message-reply-headers
)
5283 (mail-header-subject message-reply-headers
)
5286 (message-strip-subject-re
5287 (mail-header-subject message-reply-headers
))
5288 (message-strip-subject-re psubject
))))
5290 (string-match "_-_@" psupersedes
)))
5292 "@" (message-make-fqdn) ">"))
5294 (defvar message-unique-id-char nil
)
5296 ;; If you ever change this function, make sure the new version
5297 ;; cannot generate IDs that the old version could.
5298 ;; You might for example insert a "." somewhere (not next to another dot
5299 ;; or string boundary), or modify the "fsf" string.
5300 (defun message-unique-id ()
5301 ;; Don't use microseconds from (current-time), they may be unsupported.
5302 ;; Instead we use this randomly inited counter.
5303 (setq message-unique-id-char
5304 (%
(1+ (or message-unique-id-char
(logand (random t
) (1- (lsh 1 20)))))
5305 ;; (current-time) returns 16-bit ints,
5306 ;; and 2^16*25 just fits into 4 digits i base 36.
5308 (let ((tm (current-time)))
5310 (if (or (memq system-type
'(ms-dos emx
))
5311 ;; message-number-base36 doesn't handle bigints.
5312 (floatp (user-uid)))
5313 (let ((user (downcase (user-login-name))))
5314 (while (string-match "[^a-z0-9_]" user
)
5315 (aset user
(match-beginning 0) ?_
))
5317 (message-number-base36 (user-uid) -
1))
5318 (message-number-base36 (+ (car tm
)
5319 (lsh (% message-unique-id-char
25) 16)) 4)
5320 (message-number-base36 (+ (nth 1 tm
)
5321 (lsh (/ message-unique-id-char
25) 16)) 4)
5322 ;; Append a given name, because while the generated ID is unique
5323 ;; to this newsreader, other newsreaders might otherwise generate
5324 ;; the same ID via another algorithm.
5327 (defun message-number-base36 (num len
)
5332 (concat (message-number-base36 (/ num
36) (1- len
))
5333 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
5336 (defun message-make-organization ()
5337 "Make an Organization header."
5338 (let* ((organization
5339 (when message-user-organization
5340 (if (functionp message-user-organization
)
5341 (funcall message-user-organization
)
5342 message-user-organization
))))
5344 (mm-enable-multibyte)
5345 (cond ((stringp organization
)
5346 (insert organization
))
5347 ((and (eq t organization
)
5348 message-user-organization-file
5349 (file-exists-p message-user-organization-file
))
5350 (insert-file-contents message-user-organization-file
)))
5351 (goto-char (point-min))
5352 (while (re-search-forward "[\t\n]+" nil t
)
5353 (replace-match "" t t
))
5354 (unless (zerop (buffer-size))
5357 (defun message-make-lines ()
5358 "Count the number of lines and return numeric string."
5363 (int-to-string (count-lines (point) (point-max))))))
5365 (defun message-make-references ()
5366 "Return the References header for this message."
5367 (when message-reply-headers
5368 (let ((message-id (mail-header-message-id message-reply-headers
))
5369 (references (mail-header-references message-reply-headers
)))
5370 (if (or references message-id
)
5371 (concat (or references
"") (and references
" ")
5375 (defun message-make-in-reply-to ()
5376 "Return the In-Reply-To header for this message."
5377 (when message-reply-headers
5378 (let ((from (mail-header-from message-reply-headers
))
5379 (date (mail-header-date message-reply-headers
))
5380 (msg-id (mail-header-message-id message-reply-headers
)))
5382 (let ((name (mail-extract-address-components from
)))
5384 msg-id
(if msg-id
" (")
5386 (if (string-match "[^\000-\177]" (car name
))
5387 ;; Quote a string containing non-ASCII characters.
5388 ;; It will make the RFC2047 encoder cause an error
5389 ;; if there are special characters.
5390 (mm-with-multibyte-buffer
5392 (goto-char (point-min))
5393 (while (search-forward "\"" nil t
)
5396 (zerop (%
(skip-chars-backward "\\\\") 2))
5397 (goto-char (match-beginning 0)))
5400 ;; Those quotes will be removed by the RFC2047 encoder.
5401 (concat "\"" (buffer-string) "\""))
5405 (if (or (not date
) (string= date
""))
5406 "(unknown date)" date
)
5407 "\"" (if msg-id
")")))))))
5409 (defun message-make-distribution ()
5410 "Make a Distribution header."
5411 (let ((orig-distribution (message-fetch-reply-field "distribution")))
5412 (cond ((functionp message-distribution-function
)
5413 (funcall message-distribution-function
))
5414 (t orig-distribution
))))
5416 (defun message-make-expires ()
5417 "Return an Expires header based on `message-expires'."
5418 (let ((current (current-time))
5419 (future (* 1.0 message-expires
60 60 24)))
5420 ;; Add the future to current.
5421 (setcar current
(+ (car current
) (round (/ future
(expt 2 16)))))
5422 (setcar (cdr current
) (+ (nth 1 current
) (%
(round future
) (expt 2 16))))
5423 (message-make-date current
)))
5425 (defun message-make-path ()
5427 (let ((login-name (user-login-name)))
5428 (cond ((null message-user-path
)
5429 (concat (system-name) "!" login-name
))
5430 ((stringp message-user-path
)
5431 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
5432 (concat message-user-path
"!" login-name
))
5435 (defun message-make-from (&optional name address
)
5436 "Make a From header."
5437 (let* ((style message-from-style
)
5438 (login (or address
(message-make-address)))
5440 (and (boundp 'user-full-name
)
5443 (when (string= fullname
"&")
5444 (setq fullname
(user-login-name)))
5446 (mm-enable-multibyte)
5449 (equal fullname
""))
5451 ((or (eq style
'angles
)
5452 (and (not (eq style
'parens
))
5453 ;; Use angles if no quoting is needed, or if parens would
5454 ;; need quoting too.
5455 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname
))
5456 (let ((tmp (concat fullname nil
)))
5457 (while (string-match "([^()]*)" tmp
)
5458 (aset tmp
(match-beginning 0) ?-
)
5459 (aset tmp
(1- (match-end 0)) ?-
))
5460 (string-match "[\\()]" tmp
)))))
5462 (goto-char (point-min))
5463 ;; Look for a character that cannot appear unquoted
5464 ;; according to RFC 822.
5465 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil
1)
5466 ;; Quote fullname, escaping specials.
5467 (goto-char (point-min))
5469 (while (re-search-forward "[\"\\]" nil
1)
5470 (replace-match "\\\\\\&" t
))
5472 (insert " <" login
">"))
5473 (t ; 'parens or default
5475 (let ((fullname-start (point)))
5477 (goto-char fullname-start
)
5478 ;; RFC 822 says \ and nonmatching parentheses
5479 ;; must be escaped in comments.
5480 ;; Escape every instance of ()\ ...
5481 (while (re-search-forward "[()\\]" nil
1)
5482 (replace-match "\\\\\\&" t
))
5483 ;; ... then undo escaping of matching parentheses,
5484 ;; including matching nested parentheses.
5485 (goto-char fullname-start
)
5486 (while (re-search-forward
5487 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
5489 (replace-match "\\1(\\3)" t
)
5490 (goto-char fullname-start
)))
5494 (defun message-make-sender ()
5495 "Return the \"real\" user address.
5496 This function tries to ignore all user modifications, and
5497 give as trustworthy answer as possible."
5498 (concat (user-login-name) "@" (system-name)))
5500 (defun message-make-address ()
5501 "Make the address of the user."
5502 (or (message-user-mail-address)
5503 (concat (user-login-name) "@" (message-make-domain))))
5505 (defun message-user-mail-address ()
5506 "Return the pertinent part of `user-mail-address'."
5507 (when (and user-mail-address
5508 (string-match "@.*\\." user-mail-address
))
5509 (if (string-match " " user-mail-address
)
5510 (nth 1 (mail-extract-address-components user-mail-address
))
5511 user-mail-address
)))
5513 (defun message-sendmail-envelope-from ()
5514 "Return the envelope from."
5515 (cond ((eq message-sendmail-envelope-from
'header
)
5516 (nth 1 (mail-extract-address-components
5517 (message-fetch-field "from"))))
5518 ((stringp message-sendmail-envelope-from
)
5519 message-sendmail-envelope-from
)
5521 (message-make-address))))
5523 (defun message-make-fqdn ()
5524 "Return user's fully qualified domain name."
5525 (let* ((system-name (system-name))
5526 (user-mail (message-user-mail-address))
5529 (string-match "@\\(.*\\)\\'" user-mail
))
5530 (match-string 1 user-mail
)))
5531 (case-fold-search t
))
5533 ((and message-user-fqdn
5534 (stringp message-user-fqdn
)
5535 (string-match message-valid-fqdn-regexp message-user-fqdn
)
5536 (not (string-match message-bogus-system-names message-user-fqdn
)))
5537 ;; `message-user-fqdn' seems to be valid
5539 ((and (string-match message-valid-fqdn-regexp system-name
)
5540 (not (string-match message-bogus-system-names system-name
)))
5541 ;; `system-name' returned the right result.
5543 ;; Try `mail-host-address'.
5544 ((and (boundp 'mail-host-address
)
5545 (stringp mail-host-address
)
5546 (string-match message-valid-fqdn-regexp mail-host-address
)
5547 (not (string-match message-bogus-system-names mail-host-address
)))
5549 ;; We try `user-mail-address' as a backup.
5551 (stringp user-domain
)
5552 (string-match message-valid-fqdn-regexp user-domain
)
5553 (not (string-match message-bogus-system-names user-domain
)))
5555 ;; Default to this bogus thing.
5558 ".i-did-not-set--mail-host-address--so-tickle-me")))))
5560 (defun message-make-host-name ()
5561 "Return the name of the host."
5562 (let ((fqdn (message-make-fqdn)))
5563 (string-match "^[^.]+\\." fqdn
)
5564 (substring fqdn
0 (1- (match-end 0)))))
5566 (defun message-make-domain ()
5567 "Return the domain name."
5568 (or mail-host-address
5569 (message-make-fqdn)))
5571 (defun message-to-list-only ()
5572 "Send a message to the list only.
5573 Remove all addresses but the list address from To and Cc headers."
5575 (let ((listaddr (message-make-mail-followup-to t
)))
5578 (message-remove-header "to")
5579 (message-remove-header "cc")
5580 (message-position-on-field "To" "X-Draft-From")
5581 (insert listaddr
)))))
5583 (defun message-make-mail-followup-to (&optional only-show-subscribed
)
5584 "Return the Mail-Followup-To header.
5585 If passed the optional argument ONLY-SHOW-SUBSCRIBED only return the
5586 subscribed address (and not the additional To and Cc header contents)."
5587 (let* ((case-fold-search t
)
5588 (to (message-fetch-field "To"))
5589 (cc (message-fetch-field "cc"))
5590 (msg-recipients (concat to
(and to cc
", ") cc
))
5592 (mapcar 'mail-strip-quoted-names
5593 (message-tokenize-header msg-recipients
)))
5595 (if message-subscribed-address-file
5596 (let (begin end item re
)
5599 (insert-file-contents message-subscribed-address-file
)
5601 (setq begin
(point))
5604 (if (bolp) (setq end
(1- end
)))
5605 (setq item
(regexp-quote (buffer-substring begin end
)))
5606 (if re
(setq re
(concat re
"\\|" item
))
5607 (setq re
(concat "\\`\\(" item
))))
5608 (and re
(list (concat re
"\\)\\'"))))))))
5609 (mft-regexps (apply 'append message-subscribed-regexps
5610 (mapcar 'regexp-quote
5611 message-subscribed-addresses
)
5614 message-subscribed-address-functions
))))
5617 (loop for recipient in recipients
5618 when
(loop for regexp in mft-regexps
5619 when
(string-match regexp recipient
) return t
)
5622 (if only-show-subscribed
5624 msg-recipients
))))))
5626 (defun message-idna-to-ascii-rhs-1 (header)
5627 "Interactively potentially IDNA encode domain names in HEADER."
5628 (let ((field (message-fetch-field header
))
5632 (mm-delete-duplicates
5633 (mapcar (lambda (rhs) (or (cadr (split-string rhs
"@")) ""))
5637 (mail-extract-address-components field t
))))))
5638 (setq ace
(if (string-match "\\`[[:ascii:]]+\\'" rhs
)
5640 (downcase (idna-to-ascii rhs
))))
5641 (when (and (not (equal rhs ace
))
5642 (or (not (eq message-use-idna
'ask
))
5643 (y-or-n-p (format "Replace %s with %s in %s:? "
5645 (goto-char (point-min))
5646 (while (re-search-forward (concat "^" header
":") nil t
)
5647 (message-narrow-to-field)
5648 (while (search-forward (concat "@" rhs
) nil t
)
5649 (replace-match (concat "@" ace
) t t
))
5650 (goto-char (point-max))
5653 (defun message-idna-to-ascii-rhs ()
5654 "Possibly IDNA encode non-ASCII domain names in From:, To: and Cc: headers.
5655 See `message-idna-encode'."
5657 (when message-use-idna
5660 (message-narrow-to-head)
5661 (message-idna-to-ascii-rhs-1 "From")
5662 (message-idna-to-ascii-rhs-1 "To")
5663 (message-idna-to-ascii-rhs-1 "Reply-To")
5664 (message-idna-to-ascii-rhs-1 "Mail-Reply-To")
5665 (message-idna-to-ascii-rhs-1 "Mail-Followup-To")
5666 (message-idna-to-ascii-rhs-1 "Cc")))))
5668 (defun message-generate-headers (headers)
5669 "Prepare article HEADERS.
5670 Headers already prepared in the buffer are not modified."
5671 (setq headers
(append headers message-required-headers
))
5673 (message-narrow-to-headers)
5674 (let* ((Date (message-make-date))
5675 (Message-ID (message-make-message-id))
5676 (Organization (message-make-organization))
5677 (From (message-make-from))
5678 (Path (message-make-path))
5681 (In-Reply-To (message-make-in-reply-to))
5682 (References (message-make-references))
5684 (Distribution (message-make-distribution))
5685 (Lines (message-make-lines))
5686 (User-Agent message-newsreader
)
5687 (Expires (message-make-expires))
5688 (case-fold-search t
)
5690 header value elem header-string
)
5691 ;; First we remove any old generated headers.
5692 (let ((headers message-deletable-headers
))
5693 (unless (buffer-modified-p)
5694 (setq headers
(delq 'Message-ID
(copy-sequence headers
))))
5696 (goto-char (point-min))
5697 (and (re-search-forward
5698 (concat "^" (symbol-name (car headers
)) ": *") nil t
)
5699 (get-text-property (1+ (match-beginning 0)) 'message-deletable
)
5700 (message-delete-line))
5702 ;; Go through all the required headers and see if they are in the
5703 ;; articles already. If they are not, or are empty, they are
5704 ;; inserted automatically - except for Subject, Newsgroups and
5707 (goto-char (point-min))
5708 (setq elem
(pop headers
))
5710 (if (eq (car elem
) 'optional
)
5711 (setq header
(cdr elem
)
5713 (setq header
(car elem
)))
5715 (setq header-string
(if (stringp header
)
5717 (symbol-name header
)))
5718 (when (or (not (re-search-forward
5720 (regexp-quote (downcase header-string
))
5724 ;; The header was found. We insert a space after the
5725 ;; colon, if there is none.
5726 (if (/= (char-after) ?
) (insert " ") (forward-char 1))
5727 ;; Find out whether the header is empty.
5728 (looking-at "[ \t]*\n[^ \t]")))
5729 ;; So we find out what value we should insert.
5733 (eq (car elem
) 'optional
)
5734 (not (member header-string message-inserted-headers
)))
5735 ;; This is an optional header. If the cdr of this
5736 ;; is something that is nil, then we do not insert
5738 (setq header
(cdr elem
))
5739 (or (and (functionp (cdr elem
))
5740 (funcall (cdr elem
)))
5741 (and (boundp (cdr elem
))
5742 (symbol-value (cdr elem
)))))
5744 ;; The element is a cons. Either the cdr is a
5745 ;; string to be inserted verbatim, or it is a
5746 ;; function, and we insert the value returned from
5748 (or (and (stringp (cdr elem
))
5750 (and (functionp (cdr elem
))
5751 (funcall (cdr elem
)))))
5752 ((and (boundp header
)
5753 (symbol-value header
))
5754 ;; The element is a symbol. We insert the value
5755 ;; of this symbol, if any.
5756 (symbol-value header
))
5757 ((not (message-check-element
5758 (intern (downcase (symbol-name header
)))))
5759 ;; We couldn't generate a value for this header,
5760 ;; so we just ask the user.
5761 (read-from-minibuffer
5762 (format "Empty header for %s; enter value: " header
)))))
5763 ;; Finally insert the header.
5765 (not (equal value
"")))
5769 ;; This header didn't exist, so we insert it.
5770 (goto-char (point-max))
5772 (cdr (assq header message-header-format-alist
))))
5774 (funcall formatter header value
)
5775 (insert header-string
": " value
))
5776 (goto-char (message-fill-field))
5777 ;; We check whether the value was ended by a
5778 ;; newline. If not, we insert one.
5782 ;; The value of this header was empty, so we clear
5783 ;; totally and insert the new value.
5784 (delete-region (point) (point-at-eol))
5785 ;; If the header is optional, and the header was
5786 ;; empty, we can't insert it anyway.
5788 (push header-string message-inserted-headers
)
5790 (message-fill-field)))
5791 ;; Add the deletable property to the headers that require it.
5792 (and (memq header message-deletable-headers
)
5793 (progn (beginning-of-line) (looking-at "[^:]+: "))
5794 (add-text-properties
5795 (point) (match-end 0)
5796 '(message-deletable t face italic
) (current-buffer)))))))
5797 ;; Insert new Sender if the From is strange.
5798 (let ((from (message-fetch-field "from"))
5799 (sender (message-fetch-field "sender"))
5800 (secure-sender (message-make-sender)))
5802 (not (message-check-element 'sender
))
5805 (cadr (mail-extract-address-components from
)))
5806 (downcase secure-sender
)))
5811 (cadr (mail-extract-address-components sender
)))
5812 (downcase secure-sender
)))))
5813 (goto-char (point-min))
5814 ;; Rename any old Sender headers to Original-Sender.
5815 (when (re-search-forward "^\\(Original-\\)*Sender:" nil t
)
5817 (insert "Original-")
5818 (beginning-of-line))
5819 (when (or (message-news-p)
5820 (string-match "@.+\\.." secure-sender
))
5821 (insert "Sender: " secure-sender
"\n"))))
5823 (message-idna-to-ascii-rhs))))
5825 (defun message-insert-courtesy-copy ()
5826 "Insert a courtesy message in mail copies of combined messages."
5830 (message-narrow-to-headers)
5831 (when (setq newsgroups
(message-fetch-field "newsgroups"))
5832 (goto-char (point-max))
5833 (insert "Posted-To: " newsgroups
"\n")))
5835 (when message-courtesy-message
5837 ((string-match "%s" message-courtesy-message
)
5838 (insert (format message-courtesy-message newsgroups
)))
5840 (insert message-courtesy-message
)))))))
5843 ;;; Setting up a message buffer
5846 (defun message-skip-to-next-address ()
5847 (let ((end (save-excursion
5848 (message-next-header)
5851 (when (looking-at ",")
5853 (while (and (not (= (point) end
))
5854 (or (not (eq char ?
,))
5856 (skip-chars-forward "^,\"" (point-max))
5857 (when (eq (setq char
(following-char)) ?
\")
5858 (setq quoted
(not quoted
)))
5859 (unless (= (point) end
)
5861 (skip-chars-forward " \t\n")))
5863 (defun message-fill-address (header value
)
5864 (insert (capitalize (symbol-name header
))
5866 (if (consp value
) (car value
) value
)
5868 (message-fill-field-address))
5870 (defun message-split-line ()
5871 "Split current line, moving portion beyond point vertically down.
5872 If the current line has `message-yank-prefix', insert it on the new line."
5875 (split-line message-yank-prefix
) ;; Emacs 22.1+ supports arg.
5879 (defun message-insert-header (header value
)
5880 (insert (capitalize (symbol-name header
))
5882 (if (consp value
) (car value
) value
)))
5884 (defun message-field-name ()
5886 (goto-char (point-min))
5887 (when (looking-at "\\([^:]+\\):")
5888 (intern (capitalize (match-string 1))))))
5890 (defun message-fill-field ()
5893 (message-narrow-to-field)
5894 (let ((field-name (message-field-name)))
5895 (funcall (or (cadr (assq field-name message-field-fillers
))
5896 'message-fill-field-general
)))
5899 (defun message-fill-field-address ()
5901 (message-skip-to-next-address)
5903 (if (and (> (current-column) 78)
5909 (setq last
(1+ (point))))
5910 (setq last
(1+ (point)))))))
5912 (defun message-fill-field-general ()
5913 (let ((begin (point))
5916 (while (and (search-forward "\n" nil t
)
5918 (replace-match " " t t
))
5919 (fill-region-as-paragraph begin
(point-max))
5920 ;; Tapdance around looong Message-IDs.
5922 (when (looking-at "[ \t]*$")
5923 (message-delete-line))
5925 (search-forward ":" nil t
)
5926 (when (looking-at "\n[ \t]+")
5927 (replace-match " " t t
))
5928 (goto-char (point-max))))
5930 (defun message-shorten-1 (list cut surplus
)
5931 "Cut SURPLUS elements out of LIST, beginning with CUTth one."
5932 (setcdr (nthcdr (- cut
2) list
)
5933 (nthcdr (+ (- cut
2) surplus
1) list
)))
5935 (defun message-shorten-references (header references
)
5936 "Trim REFERENCES to be 21 Message-ID long or less, and fold them.
5937 When sending via news, also check that the REFERENCES are less
5938 than 988 characters long, and if they are not, trim them until
5946 (goto-char (point-min))
5947 ;; Cons a list of valid references. GNKSA says we must not include MIDs
5948 ;; with whitespace or missing brackets (7.a "Does not propagate broken
5949 ;; Message-IDs in original References").
5950 (while (re-search-forward "<[^ <]+@[^ <]+>" nil t
)
5951 (push (match-string 0) refs
))
5952 (setq refs
(nreverse refs
)
5953 count
(length refs
)))
5955 ;; If the list has more than MAXCOUNT elements, trim it by
5956 ;; removing the CUTth element and the required number of
5957 ;; elements that follow.
5958 (when (> count maxcount
)
5959 (let ((surplus (- count maxcount
)))
5960 (message-shorten-1 refs cut surplus
)
5961 (decf count surplus
)))
5963 ;; When sending via news, make sure the total folded length will
5964 ;; be less than 998 characters. This is to cater to broken INN
5965 ;; 2.3 which counts the total number of characters in a header
5966 ;; rather than the physical line length of each line, as it should.
5968 ;; This hack should be removed when it's believed than INN 2.3 is
5969 ;; no longer widely used.
5971 ;; At this point the headers have not been generated, thus we use
5972 ;; message-this-is-news directly.
5973 (when message-this-is-news
5976 (message-insert-header
5977 header
(mapconcat #'identity refs
" "))
5979 (message-shorten-1 refs cut
1)))
5980 ;; Finally, collect the references back into a string and insert
5981 ;; it into the buffer.
5982 (message-insert-header header
(mapconcat #'identity refs
" "))))
5984 (defun message-position-point ()
5985 "Move point to where the user probably wants to find it."
5986 (message-narrow-to-headers)
5988 ((re-search-forward "^[^:]+:[ \t]*$" nil t
)
5989 (search-backward ":" )
5992 (if (eq (char-after) ?
)
5996 (goto-char (point-max))
5999 (unless (looking-at "$")
6003 (defcustom message-beginning-of-line t
6004 "Whether \\<message-mode-map>\\[message-beginning-of-line]\
6005 goes to beginning of header values."
6007 :group
'message-buffers
6008 :link
'(custom-manual "(message)Movement")
6011 (defun message-beginning-of-line (&optional n
)
6012 "Move point to beginning of header value or to beginning of line.
6013 The prefix argument N is passed directly to `beginning-of-line'.
6015 This command is identical to `beginning-of-line' if point is
6016 outside the message header or if the option `message-beginning-of-line'
6019 If point is in the message header and on a (non-continued) header
6020 line, move point to the beginning of the header value or the beginning of line,
6021 whichever is closer. If point is already at beginning of line, move point to
6022 beginning of header value. Therefore, repeated calls will toggle point
6023 between beginning of field and beginning of line."
6025 (let ((zrs 'zmacs-region-stays
))
6026 (when (and (featurep 'xemacs
) (interactive-p) (boundp zrs
))
6028 (if (and message-beginning-of-line
6029 (message-point-in-header-p))
6030 (let* ((here (point))
6031 (bol (progn (beginning-of-line n
) (point)))
6032 (eol (point-at-eol))
6033 (eoh (re-search-forward ": *" eol t
)))
6035 (if (and eoh
(or (< eoh here
) (= bol here
)))
6037 (beginning-of-line n
)))
6039 (defun message-buffer-name (type &optional to group
)
6040 "Return a new (unique) buffer name based on TYPE and TO."
6042 ;; Generate a new buffer name The Message Way.
6043 ((memq message-generate-new-buffers
'(unique t
))
6044 (generate-new-buffer-name
6048 (or (car (mail-extract-address-components to
))
6051 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6053 ;; Check whether `message-generate-new-buffers' is a function,
6054 ;; and if so, call it.
6055 ((functionp message-generate-new-buffers
)
6056 (funcall message-generate-new-buffers type to group
))
6057 ((eq message-generate-new-buffers
'unsent
)
6058 (generate-new-buffer-name
6059 (concat "*unsent " type
6062 (or (car (mail-extract-address-components to
))
6065 (if (and group
(not (string= group
""))) (concat " on " group
) "")
6067 ;; Search for the existing message buffer with the specified name.
6069 (let* ((new (if (eq message-generate-new-buffers
'standard
)
6070 (generate-new-buffer-name (concat "*" type
" message*"))
6071 (let ((message-generate-new-buffers 'unique
))
6072 (message-buffer-name type to group
))))
6073 (regexp (concat "\\`"
6075 (if (string-match "<[0-9]+>\\'" new
)
6076 (substring new
0 (match-beginning 0))
6078 "\\(?:<\\([0-9]+\\)>\\)?\\'"))
6079 (case-fold-search nil
))
6086 (when (and (string-match regexp
(setq b
(buffer-name b
)))
6087 (eq (with-current-buffer b major-mode
)
6089 (cons (string-to-number (or (match-string 1 b
) "1"))
6092 'car-less-than-car
)))
6095 (defun message-pop-to-buffer (name &optional switch-function
)
6096 "Pop to buffer NAME, and warn if it already exists and is modified."
6097 (let ((buffer (get-buffer name
)))
6099 (buffer-name buffer
))
6100 (let ((window (get-buffer-window buffer
0)))
6102 ;; Raise the frame already displaying the message buffer.
6104 (gnus-select-frame-set-input-focus (window-frame window
))
6105 (select-window window
))
6106 (funcall (or switch-function
'pop-to-buffer
) buffer
)
6107 (set-buffer buffer
))
6108 (when (and (buffer-modified-p)
6111 "Message already being composed; erase? ")
6113 (error "Message being composed")))
6114 (funcall (or switch-function
'pop-to-buffer
) name
)
6119 (defun message-do-send-housekeeping ()
6120 "Kill old message buffers."
6121 ;; We might have sent this buffer already. Delete it from the
6123 (setq message-buffer-list
(delq (current-buffer) message-buffer-list
))
6124 (while (and message-max-buffers
6126 (>= (length message-buffer-list
) message-max-buffers
))
6127 ;; Kill the oldest buffer -- unless it has been changed.
6128 (let ((buffer (pop message-buffer-list
)))
6129 (when (and (buffer-name buffer
)
6130 (not (buffer-modified-p buffer
)))
6131 (kill-buffer buffer
))))
6132 ;; Rename the buffer.
6133 (if message-send-rename-function
6134 (funcall message-send-rename-function
)
6135 ;; Note: mail-abbrevs of XEmacs renames buffer name behind Gnus.
6137 "\\`\\*\\(sent \\|unsent \\)?\\(.+\\)\\*[^\\*]*\\|\\`mail to "
6139 (let ((name (match-string 2 (buffer-name)))
6141 (if (not (or (null name
)
6142 (string-equal name
"mail")
6143 (string-equal name
"posting")))
6144 (setq name
(concat "*sent " name
"*"))
6145 (message-narrow-to-headers)
6146 (setq to
(message-fetch-field "to"))
6147 (setq group
(message-fetch-field "newsgroups"))
6151 (to (concat "*sent mail to "
6152 (or (car (mail-extract-address-components to
))
6154 ((and group
(not (string= group
"")))
6155 (concat "*sent posting on " group
"*"))
6156 (t "*sent mail*"))))
6157 (unless (string-equal name
(buffer-name))
6158 (rename-buffer name t
)))))
6159 ;; Push the current buffer onto the list.
6160 (when message-max-buffers
6161 (setq message-buffer-list
6162 (nconc message-buffer-list
(list (current-buffer))))))
6164 (defun message-mail-user-agent ()
6166 ((not message-mail-user-agent
) nil
)
6167 ((eq message-mail-user-agent t
) mail-user-agent
)
6168 (t message-mail-user-agent
))))
6169 (if (memq mua
'(message-user-agent gnus-user-agent
))
6173 (defun message-setup (headers &optional replybuffer actions
6174 continue switch-function
)
6175 (let ((mua (message-mail-user-agent))
6176 subject to field yank-action
)
6177 (if (not (and message-this-is-mail mua
))
6178 (message-setup-1 headers replybuffer actions
)
6180 (setq yank-action
(list 'insert-buffer replybuffer
)))
6181 (setq headers
(copy-sequence headers
))
6182 (setq field
(assq 'Subject headers
))
6184 (setq subject
(cdr field
))
6185 (setq headers
(delq field headers
)))
6186 (setq field
(assq 'To headers
))
6188 (setq to
(cdr field
))
6189 (setq headers
(delq field headers
)))
6190 (let ((mail-user-agent mua
))
6191 (compose-mail to subject
6192 (mapcar (lambda (item)
6194 (format "%s" (car item
))
6197 continue switch-function yank-action actions
)))))
6199 (defun message-headers-to-generate (headers included-headers excluded-headers
)
6200 "Return a list that includes all headers from HEADERS.
6201 If INCLUDED-HEADERS is a list, just include those headers. If it is
6202 t, include all headers. In any case, headers from EXCLUDED-HEADERS
6206 (dolist (header headers
)
6207 (setq header-name
(cond
6208 ((and (consp header
)
6209 (eq (car header
) 'optional
))
6210 ;; On the form (optional . Header)
6213 ;; On the form (Header . function)
6218 (when (and (not (memq header-name excluded-headers
))
6219 (or (eq included-headers t
)
6220 (memq header-name included-headers
)))
6221 (push header result
)))
6224 (defun message-setup-1 (headers &optional replybuffer actions
)
6225 (dolist (action actions
)
6227 (add-to-list 'message-send-actions
6228 `(apply ',(car action
) ',(cdr action
)))))
6229 (setq message-reply-buffer replybuffer
)
6230 (goto-char (point-min))
6231 ;; Insert all the headers.
6234 (alist message-header-format-alist
))
6236 (unless (assq (caar h
) message-header-format-alist
)
6237 (push (list (caar h
)) alist
))
6241 (delete-region (point) (progn (forward-line -
1) (point)))
6242 (when message-default-headers
6243 (insert message-default-headers
)
6244 (or (bolp) (insert ?
\n)))
6245 (insert mail-header-separator
"\n")
6247 (when (message-news-p)
6248 (when message-default-news-headers
6249 (insert message-default-news-headers
)
6250 (or (bolp) (insert ?
\n)))
6251 (when message-generate-headers-first
6252 (message-generate-headers
6253 (message-headers-to-generate
6254 (append message-required-news-headers
6255 message-required-headers
)
6256 message-generate-headers-first
6257 '(Lines Subject
)))))
6258 (when (message-mail-p)
6259 (when message-default-mail-headers
6260 (insert message-default-mail-headers
)
6261 (or (bolp) (insert ?
\n)))
6262 (when message-generate-headers-first
6263 (message-generate-headers
6264 (message-headers-to-generate
6265 (append message-required-mail-headers
6266 message-required-headers
)
6267 message-generate-headers-first
6268 '(Lines Subject
)))))
6269 (run-hooks 'message-signature-setup-hook
)
6270 (message-insert-signature)
6272 (message-narrow-to-headers)
6273 (run-hooks 'message-header-setup-hook
))
6274 (setq buffer-undo-list nil
)
6275 (when message-generate-hashcash
6276 ;; Generate hashcash headers for recipients already known
6277 (mail-add-payment-async))
6278 ;; Gnus posting styles are applied via buffer-local `message-setup-hook'
6280 (run-hooks 'message-setup-hook
)
6281 ;; Do this last to give it precedence over posting styles, etc.
6282 (when (message-mail-p)
6284 (message-narrow-to-headers)
6285 (if message-alternative-emails
6286 (message-use-alternative-email-as-from))))
6287 (message-position-point)
6288 ;; Allow correct handling of `message-checksum' in `message-yank-original':
6289 (set-buffer-modified-p nil
)
6292 (defun message-set-auto-save-file-name ()
6293 "Associate the message buffer with a file in the drafts directory."
6294 (when message-auto-save-directory
6295 (unless (file-directory-p
6296 (directory-file-name message-auto-save-directory
))
6297 (make-directory message-auto-save-directory t
))
6299 (setq message-draft-article
6300 (nndraft-request-associate-buffer "drafts"))
6302 ;; If Gnus were alive, draft messages would be saved in the drafts folder.
6303 ;; But Gnus is not alive, so arrange to save the draft message in a
6304 ;; regular file in message-auto-save-directory. Append a unique
6305 ;; time-based suffix to the filename to allow multiple drafts to be saved
6306 ;; simultaneously without overwriting each other (which mimics the
6307 ;; functionality of the Gnus drafts folder).
6308 (setq buffer-file-name
(expand-file-name
6310 (if (memq system-type
6311 '(ms-dos ms-windows windows-nt
6312 cygwin cygwin32 win32 w32
6316 (format-time-string "-%Y%m%d-%H%M%S"))
6317 message-auto-save-directory
))
6318 (setq buffer-auto-save-file-name
(make-auto-save-file-name)))
6319 (clear-visited-file-modtime)
6320 (setq buffer-file-coding-system message-draft-coding-system
)))
6322 (defun message-disassociate-draft ()
6323 "Disassociate the message buffer from the drafts directory."
6324 (when message-draft-article
6325 (nndraft-request-expire-articles
6326 (list message-draft-article
) "drafts" nil t
)))
6328 (defun message-insert-headers ()
6329 "Generate the headers for the article."
6333 (message-narrow-to-headers)
6334 (when (message-news-p)
6335 (message-generate-headers
6338 (copy-sequence message-required-news-headers
)))))
6339 (when (message-mail-p)
6340 (message-generate-headers
6343 (copy-sequence message-required-mail-headers
))))))))
6348 ;;; Commands for interfacing with message
6352 (defun message-mail (&optional to subject
6353 other-headers continue switch-function
6354 yank-action send-actions
)
6355 "Start editing a mail message to be sent.
6356 OTHER-HEADERS is an alist of header/value pairs. CONTINUE says whether
6357 to continue editing a message already being composed. SWITCH-FUNCTION
6358 is a function used to switch to and display the mail buffer."
6360 (let ((message-this-is-mail t
) replybuffer
)
6361 (unless (message-mail-user-agent)
6362 (message-pop-to-buffer
6363 ;; Search for the existing message buffer if `continue' is non-nil.
6364 (let ((message-generate-new-buffers
6365 (when (or (not continue
)
6366 (eq message-generate-new-buffers
'standard
)
6367 (functionp message-generate-new-buffers
))
6368 message-generate-new-buffers
)))
6369 (message-buffer-name "mail" to
))
6371 ;; FIXME: message-mail should do something if YANK-ACTION is not
6373 (and (consp yank-action
) (eq (car yank-action
) 'insert-buffer
)
6374 (setq replybuffer
(nth 1 yank-action
)))
6377 `((To .
,(or to
"")) (Subject .
,(or subject
"")))
6378 (when other-headers other-headers
))
6379 replybuffer send-actions continue switch-function
)
6380 ;; FIXME: Should return nil if failure.
6384 (defun message-news (&optional newsgroups subject
)
6385 "Start editing a news article to be sent."
6387 (let ((message-this-is-news t
))
6388 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
))
6389 (message-setup `((Newsgroups .
,(or newsgroups
""))
6390 (Subject .
,(or subject
""))))))
6392 (defun message-alter-recipients-discard-bogus-full-name (addrcell)
6393 "Discard mail address in full names.
6394 When the full name in reply headers contains the mail
6395 address (e.g. \"foo@bar <foo@bar>\"), discard full name.
6396 ADDRCELL is a cons cell where the car is the mail address and the
6397 cdr is the complete address (full name and mail address)."
6398 (if (string-match (concat (regexp-quote (car addrcell
)) ".*"
6399 (regexp-quote (car addrcell
)))
6401 (cons (car addrcell
) (car addrcell
))
6404 (defcustom message-alter-recipients-function nil
6405 "Function called to allow alteration of reply header structures.
6406 It is called in `message-get-reply-headers' for each recipient.
6407 The function is called with one parameter, a cons cell ..."
6408 :type
'(choice (const :tag
"None" nil
)
6409 (const :tag
"Discard bogus full name"
6410 message-alter-recipients-discard-bogus-full-name
)
6412 :version
"23.1" ;; No Gnus
6413 :group
'message-headers
)
6415 (defun message-get-reply-headers (wide &optional to-address address-headers
)
6416 (let (follow-to mct never-mct to cc author mft recipients extra
)
6417 ;; Find all relevant headers we need.
6419 (message-narrow-to-headers-or-head)
6420 ;; Gmane renames "To". Look at "Original-To", too, if it is present in
6421 ;; message-header-synonyms.
6422 (setq to
(or (message-fetch-field "to")
6423 (and (loop for synonym in message-header-synonyms
6424 when
(memq 'Original-To synonym
)
6426 (message-fetch-field "original-to")))
6427 cc
(message-fetch-field "cc")
6428 extra
(when message-extra-wide-headers
6429 (mapconcat 'identity
6430 (mapcar 'message-fetch-field
6431 message-extra-wide-headers
)
6433 mct
(message-fetch-field "mail-copies-to")
6434 author
(or (message-fetch-field "mail-reply-to")
6435 (message-fetch-field "reply-to")
6436 (message-fetch-field "from")
6438 mft
(and message-use-mail-followup-to
6439 (message-fetch-field "mail-followup-to"))))
6441 ;; Handle special values of Mail-Copies-To.
6443 (cond ((or (equal (downcase mct
) "never")
6444 (equal (downcase mct
) "nobody"))
6447 ((or (equal (downcase mct
) "always")
6448 (equal (downcase mct
) "poster"))
6449 (setq mct author
))))
6452 ;; Build (textual) list of new recipient addresses.
6455 (setq recipients
(concat ", " author
)))
6457 (dolist (header address-headers
)
6458 (let ((value (message-fetch-field header
)))
6460 (setq recipients
(concat recipients
", " value
))))))
6462 (string-match "[^ \t,]" mft
)
6463 (or (not (eq message-use-mail-followup-to
'ask
))
6464 (message-y-or-n-p "Obey Mail-Followup-To? " t
"\
6465 You should normally obey the Mail-Followup-To: header. In this
6466 article, it has the value of
6470 which directs your response to " (if (string-match "," mft
)
6471 "the specified addresses"
6472 "that address only") ".
6474 Most commonly, Mail-Followup-To is used by a mailing list poster to
6475 express that responses should be sent to just the list, and not the
6478 If a message is posted to several mailing lists, Mail-Followup-To may
6479 also be used to direct the following discussion to one list only,
6480 because discussions that are spread over several lists tend to be
6481 fragmented and very difficult to follow.
6483 Also, some source/announcement lists are not intended for discussion;
6484 responses here are directed to other addresses.
6486 You may customize the variable `message-use-mail-followup-to', if you
6487 want to get rid of this query permanently.")))
6488 (setq recipients
(concat ", " mft
)))
6490 (setq recipients
(concat ", " to-address
))
6491 ;; If the author explicitly asked for a copy, we don't deny it to them.
6492 (if mct
(setq recipients
(concat recipients
", " mct
))))
6494 (setq recipients
(if never-mct
"" (concat ", " author
)))
6495 (if to
(setq recipients
(concat recipients
", " to
)))
6496 (if cc
(setq recipients
(concat recipients
", " cc
)))
6497 (if extra
(setq recipients
(concat recipients
", " extra
)))
6498 (if mct
(setq recipients
(concat recipients
", " mct
)))))
6499 (if (>= (length recipients
) 2)
6500 ;; Strip the leading ", ".
6501 (setq recipients
(substring recipients
2)))
6502 ;; Squeeze whitespace.
6503 (while (string-match "[ \t][ \t]+" recipients
)
6504 (setq recipients
(replace-match " " t t recipients
)))
6505 ;; Remove addresses that match `rmail-dont-reply-to-names'.
6506 (let ((rmail-dont-reply-to-names (message-dont-reply-to-names)))
6507 (setq recipients
(rmail-dont-reply-to recipients
)))
6508 ;; Perhaps "Mail-Copies-To: never" removed the only address?
6509 (if (string-equal recipients
"")
6510 (setq recipients author
))
6511 ;; Convert string to a list of (("foo@bar" . "Name <Foo@BAR>") ...).
6515 (if message-alter-recipients-function
6516 (funcall message-alter-recipients-function
6517 (cons (downcase (mail-strip-quoted-names addr
))
6519 (cons (downcase (mail-strip-quoted-names addr
)) addr
)))
6520 (message-tokenize-header recipients
)))
6521 ;; Remove first duplicates. (Why not all duplicates? Is this a bug?)
6522 (let ((s recipients
))
6524 (setq recipients
(delq (assoc (car (pop s
)) s
) recipients
))))
6526 ;; Remove hierarchical lists that are contained within each other,
6527 ;; if message-hierarchical-addresses is defined.
6528 (when message-hierarchical-addresses
6529 (let ((plain-addrs (mapcar 'car recipients
))
6532 (setq subaddrs
(assoc (car plain-addrs
)
6533 message-hierarchical-addresses
)
6534 plain-addrs
(cdr plain-addrs
))
6536 (setq subaddrs
(cdr subaddrs
))
6538 (setq recip
(assoc (car subaddrs
) recipients
)
6539 subaddrs
(cdr subaddrs
))
6541 (setq recipients
(delq recip recipients
))))))))
6543 ;; Build the header alist. Allow the user to be asked whether
6544 ;; or not to reply to all recipients in a wide reply.
6545 (setq follow-to
(list (cons 'To
(cdr (pop recipients
)))))
6546 (when (and recipients
6547 (or (not message-wide-reply-confirm-recipients
)
6548 (y-or-n-p "Reply to all recipients? ")))
6549 (setq recipients
(mapconcat
6550 (lambda (addr) (cdr addr
)) recipients
", "))
6551 (if (string-match "^ +" recipients
)
6552 (setq recipients
(substring recipients
(match-end 0))))
6553 (push (cons 'Cc recipients
) follow-to
)))
6556 (defcustom message-simplify-subject-functions
6557 '(message-strip-list-identifiers
6558 message-strip-subject-re
6559 message-strip-subject-trailing-was
6560 message-strip-subject-encoded-words
)
6561 "List of functions taking a string argument that simplify subjects.
6562 The functions are applied when replying to a message.
6564 Useful functions to put in this list include:
6565 `message-strip-list-identifiers', `message-strip-subject-re',
6566 `message-strip-subject-trailing-was', and
6567 `message-strip-subject-encoded-words'."
6568 :version
"22.1" ;; Gnus 5.10.9
6569 :group
'message-various
6570 :type
'(repeat function
))
6572 (defun message-simplify-subject (subject &optional functions
)
6573 "Return simplified SUBJECT."
6576 (setq functions message-simplify-subject-functions
))
6577 (when (and (memq 'message-strip-list-identifiers functions
)
6578 gnus-list-identifiers
)
6579 (setq subject
(message-strip-list-identifiers subject
)))
6580 (when (memq 'message-strip-subject-re functions
)
6581 (setq subject
(concat "Re: " (message-strip-subject-re subject
))))
6582 (when (and (memq 'message-strip-subject-trailing-was functions
)
6583 message-subject-trailing-was-query
)
6584 (setq subject
(message-strip-subject-trailing-was subject
)))
6585 (when (memq 'message-strip-subject-encoded-words functions
)
6586 (setq subject
(message-strip-subject-encoded-words subject
)))
6590 (defun message-reply (&optional to-address wide
)
6591 "Start editing a reply to the article in the current buffer."
6593 (require 'gnus-sum
) ; for gnus-list-identifiers
6594 (let ((cur (current-buffer))
6595 from subject date reply-to to cc
6596 references message-id follow-to
6597 (inhibit-point-motion-hooks t
)
6598 (message-this-is-mail t
)
6601 (message-narrow-to-head-1)
6602 ;; Allow customizations to have their say.
6604 ;; This is a regular reply.
6605 (when (functionp message-reply-to-function
)
6607 (setq follow-to
(funcall message-reply-to-function
))))
6608 ;; This is a followup.
6609 (when (functionp message-wide-reply-to-function
)
6612 (funcall message-wide-reply-to-function
)))))
6613 (setq message-id
(message-fetch-field "message-id" t
)
6614 references
(message-fetch-field "references")
6615 date
(message-fetch-field "date")
6616 from
(or (message-fetch-field "from") "nobody")
6617 subject
(or (message-fetch-field "subject") "none"))
6619 ;; Strip list identifiers, "Re: ", and "was:"
6620 (setq subject
(message-simplify-subject subject
))
6622 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6623 (string-match "<[^>]+>" gnus-warning
))
6624 (setq message-id
(match-string 0 gnus-warning
)))
6627 (setq follow-to
(message-get-reply-headers wide to-address
))))
6629 (unless (message-mail-user-agent)
6630 (message-pop-to-buffer
6631 (message-buffer-name
6632 (if wide
"wide reply" "reply") from
6633 (if wide to-address nil
))))
6635 (setq message-reply-headers
6636 (vector 0 subject from date message-id references
0 0 ""))
6639 `((Subject .
,subject
)
6644 (defun message-wide-reply (&optional to-address
)
6645 "Make a \"wide\" reply to the message in the current buffer."
6647 (message-reply to-address t
))
6650 (defun message-followup (&optional to-newsgroups
)
6651 "Follow up to the message in the current buffer.
6652 If TO-NEWSGROUPS, use that as the new Newsgroups line."
6654 (require 'gnus-sum
) ; for gnus-list-identifiers
6655 (let ((cur (current-buffer))
6656 from subject date reply-to mrt mct
6657 references message-id follow-to
6658 (inhibit-point-motion-hooks t
)
6659 (message-this-is-news t
)
6660 followup-to distribution newsgroups gnus-warning posted-to
)
6663 (goto-char (point-min))
6664 (if (search-forward "\n\n" nil t
)
6667 (when (functionp message-followup-to-function
)
6669 (funcall message-followup-to-function
)))
6670 (setq from
(message-fetch-field "from")
6671 date
(message-fetch-field "date")
6672 subject
(or (message-fetch-field "subject") "none")
6673 references
(message-fetch-field "references")
6674 message-id
(message-fetch-field "message-id" t
)
6675 followup-to
(message-fetch-field "followup-to")
6676 newsgroups
(message-fetch-field "newsgroups")
6677 posted-to
(message-fetch-field "posted-to")
6678 reply-to
(message-fetch-field "reply-to")
6679 mrt
(message-fetch-field "mail-reply-to")
6680 distribution
(message-fetch-field "distribution")
6681 mct
(message-fetch-field "mail-copies-to"))
6682 (when (and (setq gnus-warning
(message-fetch-field "gnus-warning"))
6683 (string-match "<[^>]+>" gnus-warning
))
6684 (setq message-id
(match-string 0 gnus-warning
)))
6685 ;; Remove bogus distribution.
6686 (when (and (stringp distribution
)
6687 (let ((case-fold-search t
))
6688 (string-match "world" distribution
)))
6689 (setq distribution nil
))
6690 ;; Strip list identifiers, "Re: ", and "was:"
6691 (setq subject
(message-simplify-subject subject
))
6694 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups
))
6696 (setq message-reply-headers
6697 (vector 0 subject from date message-id references
0 0 ""))
6700 `((Subject .
,subject
)
6703 (list (cons 'Newsgroups to-newsgroups
)))
6704 (follow-to follow-to
)
6705 ((and followup-to message-use-followup-to
)
6708 ((equal (downcase followup-to
) "poster")
6709 (if (or (eq message-use-followup-to
'use
)
6710 (message-y-or-n-p "Obey Followup-To: poster? " t
"\
6711 You should normally obey the Followup-To: header.
6713 `Followup-To: poster' sends your response via e-mail instead of news.
6715 A typical situation where `Followup-To: poster' is used is when the poster
6716 does not read the newsgroup, so he wouldn't see any replies sent to it.
6718 You may customize the variable `message-use-followup-to', if you
6719 want to get rid of this query permanently."))
6721 (setq message-this-is-news nil
)
6722 (cons 'To
(or mrt reply-to from
"")))
6723 (cons 'Newsgroups newsgroups
)))
6725 (if (or (equal followup-to newsgroups
)
6726 (not (eq message-use-followup-to
'ask
))
6728 (concat "Obey Followup-To: " followup-to
"? ") t
"\
6729 You should normally obey the Followup-To: header.
6731 `Followup-To: " followup-to
"'
6732 directs your response to " (if (string-match "," followup-to
)
6733 "the specified newsgroups"
6734 "that newsgroup only") ".
6736 If a message is posted to several newsgroups, Followup-To is often
6737 used to direct the following discussion to one newsgroup only,
6738 because discussions that are spread over several newsgroup tend to
6739 be fragmented and very difficult to follow.
6741 Also, some source/announcement newsgroups are not intended for discussion;
6742 responses here are directed to other newsgroups.
6744 You may customize the variable `message-use-followup-to', if you
6745 want to get rid of this query permanently."))
6746 (cons 'Newsgroups followup-to
)
6747 (cons 'Newsgroups newsgroups
))))))
6749 `((Newsgroups .
,posted-to
)))
6751 `((Newsgroups .
,newsgroups
))))
6752 ,@(and distribution
(list (cons 'Distribution distribution
)))
6754 (not (or (equal (downcase mct
) "never")
6755 (equal (downcase mct
) "nobody"))))
6756 (list (cons 'Cc
(if (or (equal (downcase mct
) "always")
6757 (equal (downcase mct
) "poster"))
6758 (or mrt reply-to from
"")
6763 (defun message-is-yours-p ()
6764 "Non-nil means current article is yours.
6765 If you have added 'cancel-messages to `message-shoot-gnksa-feet', all articles
6766 are yours except those that have Cancel-Lock header not belonging to you.
6767 Instead of shooting GNKSA feet, you should modify `message-alternative-emails'
6768 regexp to match all of yours addresses."
6769 ;; Canlock-logic as suggested by Per Abrahamsen
6770 ;; <abraham@dina.kvl.dk>
6772 ;; IF article has cancel-lock THEN
6773 ;; IF we can verify it THEN
6776 ;; error: cancellock: article is not yours
6778 ;; Use old rules, comparing sender...
6781 (message-narrow-to-head-1)
6782 (if (message-fetch-field "Cancel-Lock")
6783 (if (null (canlock-verify))
6785 (error "Failed to verify Cancel-lock: This article is not yours"))
6788 (message-gnksa-enable-p 'cancel-messages
)
6789 (and (setq sender
(message-fetch-field "sender"))
6790 (string-equal (downcase sender
)
6791 (downcase (message-make-sender))))
6792 ;; Email address in From field equals to our address
6793 (and (setq from
(message-fetch-field "from"))
6795 (downcase (car (mail-header-parse-address from
)))
6796 (downcase (car (mail-header-parse-address
6797 (message-make-from))))))
6798 ;; Email address in From field matches
6799 ;; 'message-alternative-emails' regexp
6801 message-alternative-emails
6803 message-alternative-emails
6804 (car (mail-header-parse-address from
))))))))))
6807 (defun message-cancel-news (&optional arg
)
6808 "Cancel an article you posted.
6809 If ARG, allow editing of the cancellation message."
6811 (unless (message-news-p)
6812 (error "This is not a news article; canceling is impossible"))
6813 (let (from newsgroups message-id distribution buf
)
6815 ;; Get header info from original article.
6817 (message-narrow-to-head-1)
6818 (setq from
(message-fetch-field "from")
6819 newsgroups
(message-fetch-field "newsgroups")
6820 message-id
(message-fetch-field "message-id" t
)
6821 distribution
(message-fetch-field "distribution")))
6822 ;; Make sure that this article was written by the user.
6823 (unless (message-is-yours-p)
6824 (error "This article is not yours"))
6825 (when (yes-or-no-p "Do you really want to cancel this article? ")
6826 ;; Make control message.
6829 (setq buf
(set-buffer (get-buffer-create " *message cancel*"))))
6831 (insert "Newsgroups: " newsgroups
"\n"
6833 "Subject: cmsg cancel " message-id
"\n"
6834 "Control: cancel " message-id
"\n"
6836 (concat "Distribution: " distribution
"\n")
6838 mail-header-separator
"\n"
6839 message-cancel-message
)
6840 (run-hooks 'message-cancel-hook
)
6842 (message "Canceling your article...")
6843 (if (let ((message-syntax-checks
6844 'dont-check-for-anything-just-trust-me
))
6845 (funcall message-send-news-function
))
6846 (message "Canceling your article...done"))
6847 (kill-buffer buf
))))))
6850 (defun message-supersede ()
6851 "Start composing a message to supersede the current message.
6852 This is done simply by taking the old article and adding a Supersedes
6853 header line with the old Message-ID."
6855 (let ((cur (current-buffer)))
6856 ;; Check whether the user owns the article that is to be superseded.
6857 (unless (message-is-yours-p)
6858 (error "This article is not yours"))
6859 ;; Get a normal message buffer.
6860 (message-pop-to-buffer (message-buffer-name "supersede"))
6861 (insert-buffer-substring cur
)
6863 (message-narrow-to-head-1)
6864 ;; Remove unwanted headers.
6865 (when message-ignored-supersedes-headers
6866 (message-remove-header message-ignored-supersedes-headers t
))
6867 (goto-char (point-min))
6868 (if (not (re-search-forward "^Message-ID: " nil t
))
6869 (error "No Message-ID in this article")
6870 (replace-match "Supersedes: " t t
))
6871 (goto-char (point-max))
6872 (insert mail-header-separator
)
6877 (defun message-recover ()
6878 "Reread contents of current buffer from its last auto-save file."
6880 (let ((file-name (make-auto-save-file-name)))
6881 (cond ((save-window-excursion
6882 (with-output-to-temp-buffer "*Directory*"
6883 (with-current-buffer standard-output
6884 (fundamental-mode)) ; for Emacs 20.4+
6885 (buffer-disable-undo standard-output
)
6886 (let ((default-directory "/"))
6888 "ls" nil standard-output nil
"-l" file-name
)))
6889 (yes-or-no-p (format "Recover auto save file %s? " file-name
)))
6890 (let ((buffer-read-only nil
))
6892 (insert-file-contents file-name nil
)))
6893 (t (error "message-recover cancelled")))))
6895 ;;; Washing Subject:
6897 (defun message-wash-subject (subject)
6898 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT.
6899 Previous forwarders, replyers, etc. may add it."
6902 (goto-char (point-min))
6903 ;; strip Re/Fwd stuff off the beginning
6904 (while (re-search-forward
6905 "\\([Rr][Ee]:\\|[Ff][Ww][Dd]\\(\\[[0-9]*\\]\\)?:\\|[Ff][Ww]:\\)" nil t
)
6908 ;; and gnus-style forwards [foo@bar.com] subject
6909 (goto-char (point-min))
6910 (while (re-search-forward "\\[[^ \t]*\\(@\\|\\.\\)[^ \t]*\\]" nil t
)
6914 (goto-char (point-max))
6915 (while (re-search-backward "([Ff][Ww][Dd])" nil t
)
6918 ;; and finally, any whitespace that was left-over
6919 (goto-char (point-min))
6920 (while (re-search-forward "^[ \t]+" nil t
)
6922 (goto-char (point-max))
6923 (while (re-search-backward "[ \t]+$" nil t
)
6928 ;;; Forwarding messages.
6930 (defvar message-forward-decoded-p nil
6931 "Non-nil means the original message is decoded.")
6933 (defun message-forward-subject-name-subject (subject)
6934 "Generate a SUBJECT for a forwarded message.
6935 The form is: [Source] Subject, where if the original message was mail,
6936 Source is the name of the sender, and if the original message was
6937 news, Source is the list of newsgroups is was posted to."
6938 (let* ((group (message-fetch-field "newsgroups"))
6939 (from (message-fetch-field "from"))
6942 (gnus-group-decoded-name group
)
6944 (car (gnus-extract-address-components from
))
6945 (cadr (gnus-extract-address-components from
))))
6948 (if message-forward-decoded-p
6950 (mail-decode-encoded-word-string prefix
))
6953 (defun message-forward-subject-author-subject (subject)
6954 "Generate a SUBJECT for a forwarded message.
6955 The form is: [Source] Subject, where if the original message was mail,
6956 Source is the sender, and if the original message was news, Source is
6957 the list of newsgroups is was posted to."
6958 (let* ((group (message-fetch-field "newsgroups"))
6961 (gnus-group-decoded-name group
)
6962 (or (message-fetch-field "from")
6965 (if message-forward-decoded-p
6967 (mail-decode-encoded-word-string prefix
))
6970 (defun message-forward-subject-fwd (subject)
6971 "Generate a SUBJECT for a forwarded message.
6972 The form is: Fwd: Subject, where Subject is the original subject of
6974 (if (string-match "^Fwd: " subject
)
6976 (concat "Fwd: " subject
)))
6978 (defun message-make-forward-subject ()
6979 "Return a Subject header suitable for the message in the current buffer."
6982 (message-narrow-to-head-1)
6983 (let ((funcs message-make-forward-subject-function
)
6984 (subject (message-fetch-field "Subject")))
6987 (if message-forward-decoded-p
6989 (mail-decode-encoded-word-string subject
))
6991 (when message-wash-forwarded-subjects
6992 (setq subject
(message-wash-subject subject
)))
6993 ;; Make sure funcs is a list.
6996 (setq funcs
(list funcs
)))
6997 ;; Apply funcs in order, passing subject generated by previous
6998 ;; func to the next one.
6999 (dolist (func funcs
)
7000 (when (functionp func
)
7001 (setq subject
(funcall func subject
))))
7004 (defvar gnus-article-decoded-p
)
7008 (defun message-forward (&optional news digest
)
7009 "Forward the current message via mail.
7010 Optional NEWS will use news to forward instead of mail.
7011 Optional DIGEST will use digest to forward."
7013 (let* ((cur (current-buffer))
7014 (message-forward-decoded-p
7015 (if (local-variable-p 'gnus-article-decoded-p
(current-buffer))
7016 gnus-article-decoded-p
;; In an article buffer.
7017 message-forward-decoded-p
))
7018 (subject (message-make-forward-subject)))
7020 (message-news nil subject
)
7021 (message-mail nil subject
))
7022 (message-forward-make-body cur digest
)))
7024 (defun message-forward-make-body-plain (forward-buffer)
7026 "\n-------------------- Start of forwarded message --------------------\n")
7027 (let ((b (point)) e
)
7030 (mm-disable-multibyte)
7032 (with-current-buffer forward-buffer
7033 (mm-with-unibyte-current-buffer (buffer-string))))
7034 (mm-enable-multibyte)
7036 (goto-char (point-min))
7037 (when (looking-at "From ")
7038 (replace-match "X-From-Line: "))
7042 "\n-------------------- End of forwarded message --------------------\n")
7043 (message-remove-ignored-headers b e
)))
7045 (defun message-remove-ignored-headers (b e
)
7046 (when message-forward-ignored-headers
7048 (narrow-to-region b e
)
7050 (narrow-to-region (point)
7051 (or (search-forward "\n\n" nil t
) (point)))
7052 (let ((ignored (if (stringp message-forward-ignored-headers
)
7053 (list message-forward-ignored-headers
)
7054 message-forward-ignored-headers
)))
7055 (dolist (elem ignored
)
7056 (message-remove-header elem t
))))))
7058 (defun message-forward-make-body-mime (forward-buffer)
7060 (insert "\n\n<#part type=message/rfc822 disposition=inline raw=t>\n")
7062 (narrow-to-region (point) (point))
7063 (mml-insert-buffer forward-buffer
)
7064 (goto-char (point-min))
7065 (when (looking-at "From ")
7066 (replace-match "X-From-Line: "))
7067 (goto-char (point-max)))
7068 (insert "<#/part>\n")
7069 ;; Consider there is no illegible text.
7070 (add-text-properties
7072 `(no-illegible-text t rear-nonsticky t start-open t
))))
7074 (defun message-forward-make-body-mml (forward-buffer)
7075 (insert "\n\n<#mml type=message/rfc822 disposition=inline>\n")
7076 (let ((b (point)) e
)
7077 (if (not message-forward-decoded-p
)
7080 (mm-disable-multibyte)
7082 (with-current-buffer forward-buffer
7083 (mm-with-unibyte-current-buffer (buffer-string))))
7084 (mm-enable-multibyte)
7086 (goto-char (point-min))
7087 (when (looking-at "From ")
7088 (replace-match "X-From-Line: "))
7091 (narrow-to-region (point) (point))
7092 (mml-insert-buffer forward-buffer
)
7093 (goto-char (point-min))
7094 (when (looking-at "From ")
7095 (replace-match "X-From-Line: "))
7096 (goto-char (point-max))))
7098 (insert "<#/mml>\n")
7099 (when (and (not message-forward-decoded-p
)
7100 message-forward-ignored-headers
)
7101 (message-remove-ignored-headers b e
))))
7103 (defun message-forward-make-body-digest-plain (forward-buffer)
7105 "\n-------------------- Start of forwarded message --------------------\n")
7106 (let ((b (point)) e
)
7107 (mml-insert-buffer forward-buffer
)
7110 "\n-------------------- End of forwarded message --------------------\n")))
7112 (defun message-forward-make-body-digest-mime (forward-buffer)
7113 (insert "\n<#multipart type=digest>\n")
7114 (let ((b (point)) e
)
7115 (insert-buffer-substring forward-buffer
)
7117 (insert "<#/multipart>\n")
7119 (narrow-to-region b e
)
7121 (narrow-to-region (point)
7122 (or (search-forward "\n\n" nil t
) (point)))
7123 (delete-region (point-min) (point-max)))))
7125 (defun message-forward-make-body-digest (forward-buffer)
7126 (if message-forward-as-mime
7127 (message-forward-make-body-digest-mime forward-buffer
)
7128 (message-forward-make-body-digest-plain forward-buffer
)))
7130 (autoload 'mm-uu-dissect-text-parts
"mm-uu")
7131 (autoload 'mm-uu-dissect
"mm-uu")
7133 (defun message-signed-or-encrypted-p (&optional dont-emulate-mime handles
)
7134 "Say whether the current buffer contains signed or encrypted message.
7135 If DONT-EMULATE-MIME is nil, this function does the MIME emulation on
7136 messages that don't conform to PGP/MIME described in RFC2015. HANDLES
7137 is for the internal use."
7139 (let ((mm-decrypt-option 'never
)
7140 (mm-verify-option 'never
))
7141 (if (setq handles
(mm-dissect-buffer nil t
))
7142 (unless dont-emulate-mime
7143 (mm-uu-dissect-text-parts handles
))
7144 (unless dont-emulate-mime
7145 (setq handles
(mm-uu-dissect))))))
7146 ;; Check text/plain message in which there is a signed or encrypted
7147 ;; body that has been encoded by B or Q.
7148 (unless (or handles dont-emulate-mime
)
7149 (let ((cur (current-buffer))
7150 (mm-decrypt-option 'never
)
7151 (mm-verify-option 'never
))
7153 (insert-buffer-substring cur
)
7154 (when (setq handles
(mm-dissect-buffer t t
))
7156 (bufferp (car handles
))
7157 (mm-destroy-parts handles
))
7158 (equal (mm-handle-media-type handles
) "text/plain"))
7160 (mm-decode-content-transfer-encoding
7161 (mm-handle-encoding handles
))
7162 (setq handles
(mm-uu-dissect)))
7163 (setq handles nil
))))))
7167 (dolist (handle (if (stringp (car handles
))
7168 (if (member (car handles
)
7169 '("multipart/signed"
7170 "multipart/encrypted"))
7174 (if (stringp (car handle
))
7175 (when (message-signed-or-encrypted-p dont-emulate-mime handle
)
7177 (when (and (bufferp (car handle
))
7178 (equal (mm-handle-media-type handle
)
7180 (with-current-buffer (mm-handle-buffer handle
)
7181 (when (message-signed-or-encrypted-p dont-emulate-mime
)
7182 (throw 'found t
)))))))
7183 (mm-destroy-parts handles
))))
7186 (defun message-forward-make-body (forward-buffer &optional digest
)
7187 ;; Put point where we want it before inserting the forwarded
7189 (if message-forward-before-signature
7191 (goto-char (point-max)))
7193 (message-forward-make-body-digest forward-buffer
)
7194 (if message-forward-as-mime
7195 (if (and message-forward-show-mml
7196 (not (and (eq message-forward-show-mml
'best
)
7197 ;; Use the raw form in the body if it contains
7198 ;; signed or encrypted message so as not to be
7199 ;; destroyed by re-encoding.
7200 (with-current-buffer forward-buffer
7202 (message-signed-or-encrypted-p)
7204 (message-forward-make-body-mml forward-buffer
)
7205 (message-forward-make-body-mime forward-buffer
))
7206 (message-forward-make-body-plain forward-buffer
)))
7207 (message-position-point))
7210 (defun message-forward-rmail-make-body (forward-buffer)
7211 (save-window-excursion
7212 (set-buffer forward-buffer
)
7213 (if (rmail-msg-is-pruned)
7214 (rmail-msg-restore-non-pruned-header)))
7215 (message-forward-make-body forward-buffer
))
7217 ;; Fixme: Should have defcustom.
7219 (defun message-insinuate-rmail ()
7220 "Let RMAIL use message to forward."
7222 (setq rmail-enable-mime-composing t
)
7223 (setq rmail-insert-mime-forwarded-message-function
7224 'message-forward-rmail-make-body
))
7227 (defun message-resend (address)
7228 "Resend the current article to ADDRESS."
7230 (list (message-read-from-minibuffer "Resend message to: ")))
7231 (message "Resending message to %s..." address
)
7233 (let ((cur (current-buffer))
7235 ;; We first set up a normal mail buffer.
7236 (unless (message-mail-user-agent)
7237 (set-buffer (get-buffer-create " *message resend*"))
7239 (let ((message-this-is-mail t
)
7240 message-generate-hashcash
7242 (message-setup `((To .
,address
))))
7243 ;; Insert our usual headers.
7244 (message-generate-headers '(From Date To Message-ID
))
7245 (message-narrow-to-headers)
7246 ;; Remove X-Draft-From header etc.
7247 (message-remove-header message-ignored-mail-headers t
)
7248 ;; Rename them all to "Resent-*".
7249 (goto-char (point-min))
7250 (while (re-search-forward "^[A-Za-z]" nil t
)
7255 (delete-region (point) (point-max))
7257 ;; Insert the message to be resent.
7258 (insert-buffer-substring cur
)
7259 (goto-char (point-min))
7260 (search-forward "\n\n")
7263 (narrow-to-region beg
(point))
7264 (message-remove-header message-ignored-resent-headers t
)
7265 (goto-char (point-max)))
7266 (insert mail-header-separator
)
7267 ;; Rename all old ("Also-")Resent headers.
7268 (while (re-search-backward "^\\(Also-\\)*Resent-" beg t
)
7271 ;; Quote any "From " lines at the beginning.
7273 (when (looking-at "From ")
7274 (replace-match "X-From-Line: "))
7276 (let ((message-inhibit-body-encoding t
)
7277 message-required-mail-headers
7278 message-generate-hashcash
7279 rfc2047-encode-encoded-words
)
7280 (message-send-mail))
7281 (kill-buffer (current-buffer)))
7282 (message "Resending message to %s...done" address
)))
7285 (defun message-bounce ()
7286 "Re-mail the current message.
7287 This only makes sense if the current message is a bounce message that
7288 contains some mail you have written which has been bounced back to
7291 (let ((handles (mm-dissect-buffer t
))
7293 (message-pop-to-buffer (message-buffer-name "bounce"))
7294 (if (stringp (car handles
))
7295 ;; This is a MIME bounce.
7296 (mm-insert-part (car (last handles
)))
7297 ;; This is a non-MIME bounce, so we try to remove things
7299 (mm-insert-part handles
)
7301 (goto-char (point-min))
7302 (re-search-forward "\n\n+" nil t
)
7303 (setq boundary
(point))
7304 ;; We remove everything before the bounced mail.
7305 (if (or (re-search-forward message-unsent-separator nil t
)
7307 (search-forward "\n\n" nil
'move
)
7308 (re-search-backward "^Return-Path:.*\n" boundary t
)))
7311 (delete-region (point-min)
7312 (if (re-search-forward "^[^ \n\t]+:" nil t
)
7315 (goto-char boundary
)
7316 (when (re-search-backward "^.?From .*\n" nil t
)
7317 (delete-region (match-beginning 0) (match-end 0)))))
7320 (message-narrow-to-head-1)
7321 (message-remove-header message-ignored-bounced-headers t
)
7322 (goto-char (point-max))
7323 (insert mail-header-separator
))
7324 (message-position-point)))
7327 ;;; Interactive entry points for new message buffers.
7331 (defun message-mail-other-window (&optional to subject
)
7332 "Like `message-mail' command, but display mail buffer in another window."
7334 (unless (message-mail-user-agent)
7335 (let ((pop-up-windows t
)
7336 (special-display-buffer-names nil
)
7337 (special-display-regexps nil
)
7338 (same-window-buffer-names nil
)
7339 (same-window-regexps nil
))
7340 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7341 (let ((message-this-is-mail t
))
7342 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7343 nil nil nil
'switch-to-buffer-other-window
)))
7346 (defun message-mail-other-frame (&optional to subject
)
7347 "Like `message-mail' command, but display mail buffer in another frame."
7349 (unless (message-mail-user-agent)
7350 (let ((pop-up-frames t
)
7351 (special-display-buffer-names nil
)
7352 (special-display-regexps nil
)
7353 (same-window-buffer-names nil
)
7354 (same-window-regexps nil
))
7355 (message-pop-to-buffer (message-buffer-name "mail" to
))))
7356 (let ((message-this-is-mail t
))
7357 (message-setup `((To .
,(or to
"")) (Subject .
,(or subject
"")))
7358 nil nil nil
'switch-to-buffer-other-frame
)))
7361 (defun message-news-other-window (&optional newsgroups subject
)
7362 "Start editing a news article to be sent."
7364 (let ((pop-up-windows t
)
7365 (special-display-buffer-names nil
)
7366 (special-display-regexps nil
)
7367 (same-window-buffer-names nil
)
7368 (same-window-regexps nil
))
7369 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7370 (let ((message-this-is-news t
))
7371 (message-setup `((Newsgroups .
,(or newsgroups
""))
7372 (Subject .
,(or subject
""))))))
7375 (defun message-news-other-frame (&optional newsgroups subject
)
7376 "Start editing a news article to be sent."
7378 (let ((pop-up-frames t
)
7379 (special-display-buffer-names nil
)
7380 (special-display-regexps nil
)
7381 (same-window-buffer-names nil
)
7382 (same-window-regexps nil
))
7383 (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups
)))
7384 (let ((message-this-is-news t
))
7385 (message-setup `((Newsgroups .
,(or newsgroups
""))
7386 (Subject .
,(or subject
""))))))
7390 ;; This code should be moved to underline.el (from which it is stolen).
7393 (defun message-bold-region (start end
)
7394 "Bold all nonblank characters in the region.
7395 Works by overstriking characters.
7396 Called from program, takes two arguments START and END
7397 which specify the range to operate on."
7400 (let ((end1 (make-marker)))
7401 (move-marker end1
(max start end
))
7402 (goto-char (min start end
))
7403 (while (< (point) end1
)
7404 (or (looking-at "[_\^@- ]")
7405 (insert (char-after) "\b"))
7406 (forward-char 1)))))
7409 (defun message-unbold-region (start end
)
7410 "Remove all boldness (overstruck characters) in the region.
7411 Called from program, takes two arguments START and END
7412 which specify the range to operate on."
7415 (let ((end1 (make-marker)))
7416 (move-marker end1
(max start end
))
7417 (goto-char (min start end
))
7418 (while (search-forward "\b" end1 t
)
7419 (if (eq (char-after) (char-after (- (point) 2)))
7420 (delete-char -
2))))))
7422 (defun message-exchange-point-and-mark ()
7423 "Exchange point and mark, but don't activate region if it was inactive."
7425 (message-mark-active-p)
7426 (exchange-point-and-mark))
7427 (setq mark-active nil
)))
7429 (defalias 'message-make-overlay
'make-overlay
)
7430 (defalias 'message-delete-overlay
'delete-overlay
)
7431 (defalias 'message-overlay-put
'overlay-put
)
7432 (defun message-kill-all-overlays ()
7433 (if (featurep 'xemacs
)
7434 (map-extents (lambda (extent ignore
) (delete-extent extent
)))
7435 (mapcar #'delete-overlay
(overlays-in (point-min) (point-max)))))
7437 ;; Support for toolbar
7438 (defvar tool-bar-mode
)
7440 ;; Note: The :set function in the `message-tool-bar*' variables will only
7441 ;; affect _new_ message buffers. We might add a function that walks thru all
7442 ;; message-mode buffers and force the update.
7443 (defun message-tool-bar-update (&optional symbol value
)
7444 "Update message mode toolbar.
7445 Setter function for custom variables."
7446 (setq-default message-tool-bar-map nil
)
7448 ;; When used as ":set" function:
7449 (set-default symbol value
)))
7451 (defcustom message-tool-bar
(if (eq gmm-tool-bar-style
'gnome
)
7452 'message-tool-bar-gnome
7453 'message-tool-bar-retro
)
7454 "Specifies the message mode tool bar.
7456 It can be either a list or a symbol refering to a list. See
7457 `gmm-tool-bar-from-list' for the format of the list. The
7458 default key map is `message-mode-map'.
7460 Pre-defined symbols include `message-tool-bar-gnome' and
7461 `message-tool-bar-retro'."
7462 :type
'(repeat gmm-tool-bar-list-item
)
7463 :type
'(choice (const :tag
"GNOME style" message-tool-bar-gnome
)
7464 (const :tag
"Retro look" message-tool-bar-retro
)
7465 (repeat :tag
"User defined list" gmm-tool-bar-item
)
7467 :version
"23.1" ;; No Gnus
7468 :initialize
'custom-initialize-default
7469 :set
'message-tool-bar-update
7472 (defcustom message-tool-bar-gnome
7473 '((ispell-message "spell" nil
7474 :visible
(or (not (boundp 'flyspell-mode
))
7475 (not flyspell-mode
)))
7476 (flyspell-buffer "spell" t
7477 :visible
(and (boundp 'flyspell-mode
)
7479 :help
"Flyspell whole buffer")
7480 (gmm-ignore "separator")
7481 (message-send-and-exit "mail/send")
7482 (message-dont-send "mail/save-draft")
7483 (message-kill-buffer "close") ;; stock_cancel
7484 (mml-attach-file "attach" mml-mode-map
)
7485 (mml-preview "mail/preview" mml-mode-map
)
7486 (mml-secure-message-sign-encrypt "lock" mml-mode-map
:visible nil
)
7487 (message-insert-importance-high "important" nil
:visible nil
)
7488 (message-insert-importance-low "unimportant" nil
:visible nil
)
7489 (message-insert-disposition-notification-to "receipt" nil
:visible nil
)
7490 (gmm-customize-mode "preferences" t
:help
"Edit mode preferences")
7491 (message-info "help" t
:help
"Message manual"))
7492 "List of items for the message tool bar (GNOME style).
7494 See `gmm-tool-bar-from-list' for details on the format of the list."
7495 :type
'(repeat gmm-tool-bar-item
)
7496 :version
"23.1" ;; No Gnus
7497 :initialize
'custom-initialize-default
7498 :set
'message-tool-bar-update
7501 (defcustom message-tool-bar-retro
7502 '(;; Old Emacs 21 icon for consistency.
7503 (message-send-and-exit "gnus/mail-send")
7504 (message-kill-buffer "close")
7505 (message-dont-send "cancel")
7506 (mml-attach-file "attach" mml-mode-map
)
7507 (ispell-message "spell")
7508 (mml-preview "preview" mml-mode-map
)
7509 (message-insert-importance-high "gnus/important")
7510 (message-insert-importance-low "gnus/unimportant")
7511 (message-insert-disposition-notification-to "gnus/receipt"))
7512 "List of items for the message tool bar (retro style).
7514 See `gmm-tool-bar-from-list' for details on the format of the list."
7515 :type
'(repeat gmm-tool-bar-item
)
7516 :version
"23.1" ;; No Gnus
7517 :initialize
'custom-initialize-default
7518 :set
'message-tool-bar-update
7521 (defcustom message-tool-bar-zap-list
7522 '(new-file open-file dired kill-buffer write-file
7523 print-buffer customize help
)
7524 "List of icon items from the global tool bar.
7525 These items are not displayed on the message mode tool bar.
7527 See `gmm-tool-bar-from-list' for the format of the list."
7528 :type
'gmm-tool-bar-zap-list
7529 :version
"23.1" ;; No Gnus
7530 :initialize
'custom-initialize-default
7531 :set
'message-tool-bar-update
7534 (defvar image-load-path
)
7536 (defun message-make-tool-bar (&optional force
)
7537 "Make a message mode tool bar from `message-tool-bar-list'.
7538 When FORCE, rebuild the tool bar."
7539 (when (and (not (featurep 'xemacs
))
7540 (boundp 'tool-bar-mode
)
7542 (or (not message-tool-bar-map
) force
))
7543 (setq message-tool-bar-map
7545 (gmm-image-load-path-for-library "message"
7546 "mail/save-draft.xpm"
7548 (image-load-path (cons (car load-path
)
7549 (when (boundp 'image-load-path
)
7551 (gmm-tool-bar-from-list message-tool-bar
7552 message-tool-bar-zap-list
7553 'message-mode-map
))))
7554 message-tool-bar-map
)
7556 ;;; Group name completion.
7558 (defcustom message-newgroups-header-regexp
7559 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
7560 "Regexp that match headers that lists groups."
7564 (defcustom message-completion-alist
7565 (list (cons message-newgroups-header-regexp
'message-expand-group
)
7566 '("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . message-expand-name
)
7567 '("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
7568 . message-expand-name
)
7569 '("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):"
7570 . message-expand-name
))
7571 "Alist of (RE . FUN). Use FUN for completion on header lines matching RE."
7574 :type
'(alist :key-type regexp
:value-type function
))
7576 (defcustom message-expand-name-databases
7578 "List of databases to try for name completion (`message-expand-name').
7579 Each element is a symbol and can be `bbdb' or `eudc'."
7581 :type
'(set (const bbdb
) (const eudc
)))
7583 (defcustom message-tab-body-function nil
7584 "*Function to execute when `message-tab' (TAB) is executed in the body.
7585 If nil, the function bound in `text-mode-map' or `global-map' is executed."
7588 :link
'(custom-manual "(message)Various Commands")
7589 :type
'(choice (const nil
)
7592 (declare-function mail-abbrev-in-expansion-header-p
"mailabbrev" ())
7594 (defun message-tab ()
7595 "Complete names according to `message-completion-alist'.
7596 Execute function specified by `message-tab-body-function' when not in
7599 (let ((alist message-completion-alist
))
7601 (let ((mail-abbrev-mode-regexp (caar alist
)))
7602 (not (mail-abbrev-in-expansion-header-p))))
7603 (setq alist
(cdr alist
)))
7604 (funcall (or (cdar alist
) message-tab-body-function
7605 (lookup-key text-mode-map
"\t")
7606 (lookup-key global-map
"\t")
7607 'indent-relative
))))
7612 (let ((standard-output (current-buffer)))
7613 (eval '(display-completion-list nil
"")))
7614 (defalias 'message-display-completion-list
'display-completion-list
))
7615 (error ;; Don't use `wrong-number-of-arguments' here because of XEmacs.
7616 (defun message-display-completion-list (completions &optional ignore
)
7617 "Display the list of completions, COMPLETIONS, using `standard-output'."
7618 (display-completion-list completions
)))))
7620 (defun message-expand-group ()
7621 "Expand the group name under point."
7622 (let* ((b (save-excursion
7627 (skip-chars-forward "^:")
7630 (skip-chars-backward "^, \t\n") (point))))
7631 (completion-ignore-case t
)
7632 (string (buffer-substring b
(progn (skip-chars-forward "^,\t\n ")
7634 (hashtb (and (boundp 'gnus-active-hashtb
) gnus-active-hashtb
))
7635 (completions (all-completions string hashtb
))
7637 (delete-region b
(point))
7639 ((= (length completions
) 1)
7640 (if (string= (car completions
) string
)
7643 (message "Only matching group"))
7644 (insert (car completions
))))
7645 ((and (setq comp
(try-completion string hashtb
))
7646 (not (string= comp string
)))
7651 (message "No matching groups")
7652 (save-selected-window
7653 (pop-to-buffer "*Completions*")
7654 (buffer-disable-undo)
7655 (let ((buffer-read-only nil
))
7657 (let ((standard-output (current-buffer)))
7658 (message-display-completion-list (sort completions
'string
<)
7660 (setq buffer-read-only nil
)
7661 (goto-char (point-min))
7662 (delete-region (point) (progn (forward-line 3) (point))))))))))
7664 (defun message-expand-name ()
7665 (cond ((and (memq 'eudc message-expand-name-databases
)
7666 (boundp 'eudc-protocol
)
7668 (eudc-expand-inline))
7669 ((and (memq 'bbdb message-expand-name-databases
)
7670 (fboundp 'bbdb-complete-name
))
7671 (bbdb-complete-name))
7677 (defun message-talkative-question (ask question show
&rest text
)
7678 "Call FUNCTION with argument QUESTION; optionally display TEXT... args.
7679 If SHOW is non-nil, the arguments TEXT... are displayed in a temp buffer.
7680 The following arguments may contain lists of values."
7682 (setq text
(message-flatten-list text
)))
7683 (save-window-excursion
7684 (with-output-to-temp-buffer " *MESSAGE information message*"
7685 (with-current-buffer " *MESSAGE information message*"
7686 (fundamental-mode) ; for Emacs 20.4+
7688 (goto-char (point-min))))
7689 (funcall ask question
))
7690 (funcall ask question
)))
7692 (defun message-flatten-list (list)
7693 "Return a new, flat list that contains all elements of LIST.
7695 \(message-flatten-list '(1 (2 3 (4 5 (6))) 7))
7698 (apply 'append
(mapcar 'message-flatten-list list
)))
7702 (defun message-generate-new-buffer-clone-locals (name &optional varstr
)
7703 "Create and return a buffer with name based on NAME using `generate-new-buffer'.
7704 Then clone the local variables and values from the old buffer to the
7705 new one, cloning only the locals having a substring matching the
7707 (let ((oldbuf (current-buffer)))
7708 (with-current-buffer (generate-new-buffer name
)
7709 (message-clone-locals oldbuf varstr
)
7712 (defun message-clone-locals (buffer &optional varstr
)
7713 "Clone the local variables from BUFFER to the current buffer."
7714 (let ((locals (with-current-buffer buffer
(buffer-local-variables)))
7715 (regexp "^gnus\\|^nn\\|^message\\|^sendmail\\|^smtp\\|^user-mail-address"))
7718 (when (and (consp local
)
7720 (string-match regexp
(symbol-name (car local
)))
7722 (string-match varstr
(symbol-name (car local
)))))
7724 (set (make-local-variable (car local
))
7732 (defvar message-inhibit-body-encoding nil
)
7734 (defun message-encode-message-body ()
7735 (unless message-inhibit-body-encoding
7736 (let ((mail-parse-charset (or mail-parse-charset
7737 message-default-charset
))
7738 (case-fold-search t
)
7739 lines content-type-p
)
7742 (narrow-to-region (point) (point-max))
7743 (let ((new (mml-generate-mime)))
7745 (delete-region (point-min) (point-max))
7747 (goto-char (point-min))
7748 (if (eq (aref new
0) ?
\n)
7750 (search-forward "\n\n")
7751 (setq lines
(buffer-substring (point-min) (1- (point))))
7752 (delete-region (point-min) (point))))))
7754 (message-narrow-to-headers-or-head)
7755 (message-remove-header "Mime-Version")
7756 (goto-char (point-max))
7757 (insert "MIME-Version: 1.0\n")
7760 (setq content-type-p
7762 (re-search-backward "^Content-Type:" nil t
))))
7764 (message-narrow-to-headers-or-head)
7765 (message-remove-first-header "Content-Type")
7766 (message-remove-first-header "Content-Transfer-Encoding"))
7767 ;; We always make sure that the message has a Content-Type
7768 ;; header. This is because some broken MTAs and MUAs get
7769 ;; awfully confused when confronted with a message with a
7770 ;; MIME-Version header and without a Content-Type header. For
7771 ;; instance, Solaris' /usr/bin/mail.
7772 (unless content-type-p
7773 (goto-char (point-min))
7774 ;; For unknown reason, MIME-Version doesn't exist.
7775 (when (re-search-forward "^MIME-Version:" nil t
)
7777 (insert "Content-Type: text/plain; charset=us-ascii\n"))))))
7779 (defun message-read-from-minibuffer (prompt &optional initial-contents
)
7780 "Read from the minibuffer while providing abbrev expansion."
7781 (if (fboundp 'mail-abbrevs-setup
)
7782 (let ((mail-abbrev-mode-regexp "")
7783 (minibuffer-setup-hook 'mail-abbrevs-setup
)
7784 (minibuffer-local-map message-minibuffer-local-map
))
7785 (read-from-minibuffer prompt initial-contents
))
7786 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook
)
7787 (minibuffer-local-map message-minibuffer-local-map
))
7788 (read-string prompt initial-contents
))))
7790 (defun message-use-alternative-email-as-from ()
7791 "Set From field of the outgoing message to the first matching
7792 address in `message-alternative-emails', looking at To, Cc and
7793 From headers in the original article."
7794 (require 'mail-utils
)
7795 (let* ((fields '("To" "Cc" "From"))
7798 (mail-strip-quoted-names
7799 (mapconcat 'message-fetch-reply-field fields
","))
7803 (if (string-match message-alternative-emails
(car emails
))
7804 (setq email
(car emails
)
7807 (unless (or (not email
) (equal email user-mail-address
))
7808 (message-remove-header "From")
7809 (goto-char (point-max))
7810 (insert "From: " (let ((user-mail-address email
)) (message-make-from))
7813 (defun message-options-get (symbol)
7814 (cdr (assq symbol message-options
)))
7816 (defun message-options-set (symbol value
)
7817 (let ((the-cons (assq symbol message-options
)))
7820 (setcdr the-cons value
)
7821 (setq message-options
(delq the-cons message-options
)))
7823 (push (cons symbol value
) message-options
))))
7826 (defun message-options-set-recipient ()
7828 (message-narrow-to-headers-or-head)
7829 (message-options-set 'message-sender
7830 (mail-strip-quoted-names
7831 (message-fetch-field "from")))
7832 (message-options-set 'message-recipients
7833 (mail-strip-quoted-names
7834 (let ((to (message-fetch-field "to"))
7835 (cc (message-fetch-field "cc"))
7836 (bcc (message-fetch-field "bcc")))
7839 (if (and to cc
) ", ")
7841 (if (and (or to cc
) bcc
) ", ")
7844 (defun message-hide-headers ()
7845 "Hide headers based on the `message-hidden-headers' variable."
7846 (let ((regexps (if (stringp message-hidden-headers
)
7847 (list message-hidden-headers
)
7848 message-hidden-headers
))
7849 (inhibit-point-motion-hooks t
)
7850 (after-change-functions nil
)
7851 (end-of-headers (point-min)))
7855 (message-narrow-to-headers)
7856 (goto-char (point-min))
7858 (if (not (message-hide-header-p regexps
))
7859 (message-next-header)
7860 (let ((begin (point))
7862 (message-next-header)
7863 (setq header
(buffer-substring begin
(point))
7864 header-len
(- (point) begin
))
7865 (delete-region begin
(point))
7866 (goto-char end-of-headers
)
7868 (setq end-of-headers
7869 (+ end-of-headers header-len
))))))))
7870 (narrow-to-region end-of-headers
(point-max))))
7872 (defun message-hide-header-p (regexps)
7875 (when (eq (car regexps
) 'not
)
7878 (dolist (regexp regexps
)
7879 (setq result
(or result
(looking-at regexp
))))
7884 (defun message-put-addresses-in-ecomplete ()
7885 (dolist (header '("to" "cc" "from" "reply-to"))
7886 (let ((value (message-field-value header
)))
7887 (dolist (string (mail-header-parse-addresses value
'raw
))
7889 (gnus-replace-in-string
7890 (gnus-replace-in-string string
"^ +\\| +$" "") "\n" ""))
7891 (ecomplete-add-item 'mail
(car (mail-header-parse-address string
))
7895 (defun message-display-abbrev (&optional choose
)
7896 "Display the next possible abbrev for the text before point."
7897 (interactive (list t
))
7898 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?
\t ?
))
7899 (message-point-in-header-p)
7902 (while (and (memq (char-after) '(?
\t ?
))
7903 (zerop (forward-line -
1))))
7904 (looking-at "To:\\|Cc:")))
7905 (let* ((end (point))
7906 (start (save-excursion
7907 (and (re-search-backward "[\n\t ]" nil t
)
7909 (word (when start
(buffer-substring start end
)))
7910 (match (when (and word
7911 (not (zerop (length word
))))
7912 (ecomplete-display-matches 'mail word choose
))))
7913 (when (and choose match
)
7914 (delete-region start end
)
7917 ;; To send pre-formatted letters like the example below, you can use
7918 ;; `message-send-form-letter':
7919 ;; --8<---------------cut here---------------start------------->8---
7920 ;; To: alice@invalid.invalid
7921 ;; Subject: Verification of your contact information
7922 ;; From: Contact verification <admin@foo.invalid>
7923 ;; --text follows this line--
7925 ;; please verify that your contact information is still valid:
7926 ;; Alice A, A avenue 11, 1111 A town, Austria
7927 ;; ----------next form letter message follows this line----------
7928 ;; To: bob@invalid.invalid
7929 ;; Subject: Verification of your contact information
7930 ;; From: Contact verification <admin@foo.invalid>
7931 ;; --text follows this line--
7933 ;; please verify that your contact information is still valid:
7934 ;; Bob, B street 22, 22222 Be town, Belgium
7935 ;; ----------next form letter message follows this line----------
7936 ;; To: charlie@invalid.invalid
7937 ;; Subject: Verification of your contact information
7938 ;; From: Contact verification <admin@foo.invalid>
7939 ;; --text follows this line--
7941 ;; please verify that your contact information is still valid:
7942 ;; Charlie Chaplin, C plaza 33, 33333 C town, Chile
7943 ;; --8<---------------cut here---------------end--------------->8---
7945 ;; FIXME: What is the most common term (circular letter, form letter, serial
7946 ;; letter, standard letter) for such kind of letter? See also
7947 ;; <http://en.wikipedia.org/wiki/Form_letter>
7949 ;; FIXME: Maybe extent message-mode's font-lock support to recognize
7950 ;; `message-form-letter-separator', i.e. highlight each message like a single
7953 (defcustom message-form-letter-separator
7954 "\n----------next form letter message follows this line----------\n"
7955 "Separator for `message-send-form-letter'."
7956 ;; :group 'message-form-letter
7957 :group
'message-various
7958 :version
"23.1" ;; No Gnus
7961 (defcustom message-send-form-letter-delay
1
7962 "Delay in seconds when sending a message with `message-send-form-letter'.
7963 Only used when `message-send-form-letter' is called with non-nil
7965 ;; :group 'message-form-letter
7966 :group
'message-various
7967 :version
"23.1" ;; No Gnus
7970 (defun message-send-form-letter (&optional force
)
7971 "Sent all form letter messages from current buffer.
7972 Unless FORCE, prompt before sending.
7974 The messages are separated by `message-form-letter-separator'.
7975 Header and body are separated by `mail-header-separator'."
7977 (let ((sent 0) (skipped 0)
7981 (goto-char (point-min))
7984 end
(if (search-forward message-form-letter-separator nil t
)
7985 (- (point) (length message-form-letter-separator
) -
1)
7989 (buffer-substring-no-properties start end
))
7990 (setq buff
(generate-new-buffer "*mail - form letter*"))
7991 (with-current-buffer buff
7994 (setq to
(message-fetch-field "To"))
7995 (switch-to-buffer buff
)
7997 (sit-for message-send-form-letter-delay
))
7999 (y-or-n-p (format "Send message to `%s'? " to
)))
8001 (setq sent
(1+ sent
))
8002 (message-send-and-exit))
8003 (message (format "Message to `%s' skipped." to
))
8004 (setq skipped
(1+ skipped
)))
8005 (when (buffer-live-p buff
)
8006 (kill-buffer buff
))))
8007 (message "%s message(s) sent, %s skipped." sent skipped
)))
8009 (defun message-replace-header (header new-value
&optional after force
)
8010 "Remove HEADER and insert the NEW-VALUE.
8011 If AFTER, insert after this header. If FORCE, insert new field
8012 even if NEW-VALUE is empty."
8013 ;; Similar to `nnheader-replace-header' but for message buffers.
8016 (message-narrow-to-headers)
8017 (message-remove-header header
))
8018 (when (or force
(> (length new-value
) 0))
8020 (message-position-on-field header after
)
8021 (message-position-on-field header
))
8022 (insert new-value
))))
8024 (defcustom message-recipients-without-full-name
8025 (list "ding@gnus.org"
8027 "emacs-devel@gnu.org"
8028 "emacs-pretest-bug@gnu.org"
8029 "bug-gnu-emacs@gnu.org")
8030 "Mail addresses that have no full name.
8031 Used in `message-simplify-recipients'."
8032 ;; Maybe the addresses could be extracted from
8033 ;; `gnus-parameter-to-list-alist'?
8034 :type
'(choice (const :tag
"None" nil
)
8036 :version
"23.1" ;; No Gnus
8037 :group
'message-headers
)
8039 (defun message-simplify-recipients ()
8041 (dolist (hdr '("Cc" "To"))
8042 (message-replace-header
8046 (if (and message-recipients-without-full-name
8048 (regexp-opt message-recipients-without-full-name
)
8052 (message-make-from (car addrcomp
) (cadr addrcomp
))
8054 (when (message-fetch-field hdr
)
8055 (mail-extract-address-components
8056 (message-fetch-field hdr
) t
))
8059 (when (featurep 'xemacs
)
8060 (require 'messagexmas
)
8061 (message-xmas-redefine))
8065 (run-hooks 'message-load-hook
)
8068 ;; coding: iso-8859-1
8071 ;; arch-tag: 94b32cac-4504-4b6c-8181-030ebf380ee0
8072 ;;; message.el ends here