1 ;;; sendmail.el --- mail sending commands for Emacs
3 ;; Copyright (C) 1985-1986, 1992-1996, 1998, 2000-2015 Free Software
6 ;; Maintainer: emacs-devel@gnu.org
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 is
27 ;; documented in the Emacs user's manual.
34 (defgroup sendmail nil
35 "Mail sending commands for Emacs."
39 (defcustom mail-setup-with-from t
40 "Non-nil means insert `From:' field when setting up the message."
45 (defcustom sendmail-program
46 (or (executable-find "sendmail")
48 ((file-exists-p "/usr/sbin/sendmail") "/usr/sbin/sendmail")
49 ((file-exists-p "/usr/lib/sendmail") "/usr/lib/sendmail")
50 ((file-exists-p "/usr/ucblib/sendmail") "/usr/ucblib/sendmail")
52 "Program used to send messages."
53 :version
"24.1" ; add executable-find, remove fakemail
58 (defcustom mail-from-style
'default
59 "Specifies how \"From:\" fields look.
61 If nil, they contain just the return address like:
63 If `parens', they look like:
64 king@grassland.com (Elvis Parsley)
65 If `angles', they look like:
66 Elvis Parsley <king@grassland.com>
68 Otherwise, most addresses look like `angles', but they look like
69 `parens' if `angles' would need quoting and `parens' would not."
70 ;; The value `system-default' is now deprecated.
71 :type
'(choice (const :tag
"simple" nil
)
79 (defcustom mail-specify-envelope-from nil
80 "If non-nil, specify the envelope-from address when sending mail.
81 The value used to specify it is whatever is found in
82 the variable `mail-envelope-from', with `user-mail-address' as fallback.
84 On most systems, specifying the envelope-from address is a
85 privileged operation. This variable affects sendmail and
86 smtpmail -- if you use feedmail to send mail, see instead the
87 variable `feedmail-deduce-envelope-from'."
92 (defcustom mail-envelope-from nil
93 "If non-nil, designate the envelope-from address when sending mail.
94 This only has an effect if `mail-specify-envelope-from' is non-nil.
95 The value should be either a string, or the symbol `header' (in
96 which case the contents of the \"From\" header of the message
97 being sent is used), or nil (in which case the value of
98 `user-mail-address' is used)."
100 :type
'(choice (string :tag
"From-name")
101 (const :tag
"Use From: header from message" header
)
102 (const :tag
"Use `user-mail-address'" nil
))
106 (defcustom mail-self-blind nil
107 "Non-nil means insert BCC to self in messages to be sent.
108 This is done when the message is initialized,
109 so you can remove or alter the BCC field to override the default."
114 (defcustom mail-interactive t
115 ;; We used to use a default of nil rather than t, but nowadays it is very
116 ;; common for sendmail to be misconfigured, so one cannot rely on the
117 ;; bounce message to be delivered anywhere, least of all to the
119 "Non-nil means when sending a message wait for and display errors.
120 Otherwise, let mailer send back a message to report errors."
122 :version
"23.1" ; changed from nil to t
125 (defcustom mail-yank-ignored-headers
127 (regexp-opt '("via" "mail-from" "origin" "status" "remailed"
128 "received" "message-id" "summary-line" "to" "subject"
129 "in-reply-to" "return-path" "mail-reply-to"
130 ;; Should really be rmail-attribute-header and
131 ;; rmail-keyword-header, but this file does not
132 ;; require rmail (at run time).
133 "x-rmail-attributes" "x-rmail-keywords"
134 "mail-followup-to") "\\(?:")
136 "Delete these headers from old message when it's inserted in a reply."
141 ;; Useful to set in site-init.el
143 (defcustom send-mail-function
144 ;; Assume smtpmail is the preferred choice if it's already configured.
145 (if (and (boundp 'smtpmail-smtp-server
)
146 smtpmail-smtp-server
)
147 'smtpmail-send-it
'sendmail-query-once
)
148 "Function to call to send the current buffer as mail.
149 The headers should be delimited by a line which is
150 not a valid RFC822 header or continuation line,
151 that matches the variable `mail-header-separator'.
152 This is used by the default mail-sending commands. See also
153 `message-send-mail-function' for use with the Message package."
154 :type
'(radio (function-item sendmail-send-it
:tag
"Use Sendmail package")
155 (function-item sendmail-query-once
:tag
"Query the user")
156 (function-item smtpmail-send-it
:tag
"Use SMTPmail package")
157 (function-item feedmail-send-it
:tag
"Use Feedmail package")
158 (function-item mailclient-send-it
:tag
"Use Mailclient package")
164 (defcustom mail-header-separator
(purecopy "--text follows this line--")
165 "Line used to separate headers from text in messages being composed."
169 ;; Set up mail-header-separator for use as a category text property.
170 (put 'mail-header-separator
'rear-nonsticky
'(category))
171 ;; This was a nice idea, for preventing accidental modification of
172 ;; the separator. But I found it also prevented or obstructed
173 ;; certain deliberate operations, such as copying the separator line
174 ;; up to the top to send myself a copy of an already sent outgoing message
175 ;; and other things. So I turned it off. --rms.
176 ;;(put 'mail-header-separator 'read-only t)
179 (defcustom mail-archive-file-name nil
180 "Name of file to write all outgoing messages in, or nil for none.
181 This is normally an mbox file, but for backwards compatibility may also
183 :type
'(choice file
(const nil
))
187 (defcustom mail-default-reply-to nil
188 "Address to insert as default Reply-to field of outgoing messages.
189 If nil, it will be initialized from the REPLYTO environment variable
190 when you first send mail."
191 :type
'(choice (const nil
) string
)
194 (defcustom mail-alias-file nil
195 "If non-nil, the name of a file to use instead of the sendmail default.
196 This file defines aliases to be expanded by the mailer; this is a different
197 feature from that of defining aliases in `.mailrc' to be expanded in Emacs.
198 This variable has no effect unless your system uses sendmail as its mailer.
199 The default file is defined in sendmail's configuration file, e.g.
201 :type
'(choice (const :tag
"Sendmail default" nil
) file
)
205 (defcustom mail-personal-alias-file
(purecopy "~/.mailrc")
206 "If non-nil, the name of the user's personal mail alias file.
207 This file typically should be in same format as the `.mailrc' file used by
208 the `Mail' or `mailx' program.
209 This file need not actually exist."
210 :type
'(choice (const nil
) file
)
214 (defcustom mail-setup-hook nil
215 "Normal hook, run each time a new outgoing message is initialized."
217 :options
'(fortune-to-signature spook mail-abbrevs-setup
)
221 (defvar mail-aliases t
222 "Alist of mail address aliases,
223 or t meaning should be initialized from your mail aliases file.
224 \(The file's name is normally `~/.mailrc', but `mail-personal-alias-file'
225 can specify a different file name.)
226 The alias definitions in the file have this form:
227 alias ALIAS MEANING")
229 (defvar mail-alias-modtime nil
230 "The modification time of your mail alias file when it was last examined.")
233 (defcustom mail-yank-prefix
"> "
234 "Prefix insert on lines of yanked message being replied to.
235 If this is nil, use indentation, as specified by `mail-indentation-spaces'."
236 :type
'(choice (const nil
) string
)
240 (defcustom mail-indentation-spaces
3
241 "Number of spaces to insert at the beginning of each cited line.
242 Used by `mail-yank-original' via `mail-indent-citation'."
246 (defvar mail-yank-hooks nil
247 "Obsolete hook for modifying a citation just inserted in the mail buffer.
248 Each hook function can find the citation between (point) and (mark t).
249 And each hook function should leave point and mark around the citation
251 This is a normal hook, misnamed for historical reasons.
252 It is obsolete and mail agents should no longer use it.")
253 (make-obsolete-variable 'mail-yank-hooks
'mail-citation-hook
"19.34")
256 (defcustom mail-citation-hook nil
257 "Hook for modifying a citation just inserted in the mail buffer.
258 Each hook function can find the citation between (point) and (mark t),
259 and should leave point and mark around the citation text as modified.
260 The hook functions can find the header of the cited message
261 in the variable `mail-citation-header', whether or not this is included
262 in the cited portion of the message.
264 If this hook is entirely empty (nil), a default action is taken
265 instead of no action."
269 (defvar mail-citation-header nil
270 "While running `mail-citation-hook', this variable holds the message header.
271 This enables the hook functions to see the whole message header
272 regardless of what part of it (if any) is included in the cited text.")
275 (defcustom mail-citation-prefix-regexp
276 (purecopy "\\([ \t]*\\(\\w\\|[_.]\\)+>+\\|[ \t]*[]>|]\\)+")
277 "Regular expression to match a citation prefix plus whitespace.
278 It should match whatever sort of citation prefixes you want to handle,
279 with whitespace before and after; it should also match just whitespace.
280 The default value matches citations like `foo-bar>' plus whitespace."
285 (defvar mail-abbrevs-loaded nil
)
286 (defvar mail-mode-map
287 (let ((map (make-sparse-keymap)))
288 (define-key map
"\M-\t" 'completion-at-point
)
289 (define-key map
"\C-c?" 'describe-mode
)
290 (define-key map
"\C-c\C-f\C-t" 'mail-to
)
291 (define-key map
"\C-c\C-f\C-b" 'mail-bcc
)
292 (define-key map
"\C-c\C-f\C-f" 'mail-fcc
)
293 (define-key map
"\C-c\C-f\C-c" 'mail-cc
)
294 (define-key map
"\C-c\C-f\C-s" 'mail-subject
)
295 (define-key map
"\C-c\C-f\C-r" 'mail-reply-to
)
296 (define-key map
"\C-c\C-f\C-a" 'mail-mail-reply-to
) ; author
297 (define-key map
"\C-c\C-f\C-l" 'mail-mail-followup-to
) ; list
298 (define-key map
"\C-c\C-t" 'mail-text
)
299 (define-key map
"\C-c\C-y" 'mail-yank-original
)
300 (define-key map
"\C-c\C-r" 'mail-yank-region
)
301 (define-key map
[remap split-line
] 'mail-split-line
)
302 (define-key map
"\C-c\C-q" 'mail-fill-yanked-message
)
303 (define-key map
"\C-c\C-w" 'mail-signature
)
304 (define-key map
"\C-c\C-c" 'mail-send-and-exit
)
305 (define-key map
"\C-c\C-s" 'mail-send
)
306 (define-key map
"\C-c\C-i" 'mail-insert-file
)
307 ;; FIXME add this? "b" = bury buffer. It's in the menu-bar.
308 ;;; (define-key map "\C-c\C-b" 'mail-dont-send)
310 (define-key map
[menu-bar mail
]
311 (cons "Mail" (make-sparse-keymap "Mail")))
313 (define-key map
[menu-bar mail attachment
]
314 '("Attach File" . mail-add-attachment
))
316 (define-key map
[menu-bar mail fill
]
317 '("Fill Citation" . mail-fill-yanked-message
))
319 (define-key map
[menu-bar mail yank
]
320 '(menu-item "Cite Original" mail-yank-original
:enable mail-reply-action
))
322 (define-key map
[menu-bar mail signature
]
323 '("Insert Signature" . mail-signature
))
325 (define-key map
[menu-bar mail mail-sep
]
328 (define-key map
[menu-bar mail cancel
]
329 '("Cancel" . mail-dont-send
))
331 (define-key map
[menu-bar mail send-stay
]
332 '("Send, Keep Editing" . mail-send
))
334 (define-key map
[menu-bar mail send
]
335 '("Send Message" . mail-send-and-exit
))
337 (define-key map
[menu-bar headers
]
338 (cons "Headers" (make-sparse-keymap "Move to Header")))
340 (define-key map
[menu-bar headers text
]
341 '("Text" . mail-text
))
343 (define-key map
[menu-bar headers expand-aliases
]
344 '("Expand Aliases" . expand-mail-aliases
))
346 (define-key map
[menu-bar headers mail-reply-to
]
347 '("Mail-Reply-To" . mail-mail-reply-to
))
349 (define-key map
[menu-bar headers mail-followup-to
]
350 '("Mail-Followup-To" . mail-mail-followup-to
))
352 (define-key map
[menu-bar headers reply-to
]
353 '("Reply-To" . mail-reply-to
))
355 (define-key map
[menu-bar headers bcc
]
358 (define-key map
[menu-bar headers fcc
]
361 (define-key map
[menu-bar headers cc
]
364 (define-key map
[menu-bar headers subject
]
365 '("Subject" . mail-subject
))
367 (define-key map
[menu-bar headers to
]
372 (autoload 'build-mail-aliases
"mailalias"
373 "Read mail aliases from personal aliases file and set `mail-aliases'.
374 By default, this is the file specified by `mail-personal-alias-file'." t
)
377 (defcustom mail-signature t
378 "Text inserted at end of mail buffer when a message is initialized.
379 If t, it means to insert the contents of the file `mail-signature-file'.
380 If a string, that string is inserted.
381 (To make a proper signature, the string should begin with \\n\\n-- \\n,
382 which is the standard way to delimit a signature in a message.)
383 Otherwise, it should be an expression; it is evaluated
384 and should insert whatever you want to insert."
385 :type
'(choice (const :tag
"None" nil
)
386 (const :tag
"Use `.signature' file" t
)
387 (string :tag
"String to insert")
388 (sexp :tag
"Expression to evaluate"))
390 (put 'mail-signature
'risky-local-variable t
)
393 (defcustom mail-signature-file
(purecopy "~/.signature")
394 "File containing the text inserted at end of mail buffer."
399 (defcustom mail-default-directory
(purecopy "~/")
400 "Value of `default-directory' for Mail mode buffers.
401 This directory is used for auto-save files of Mail mode buffers.
403 Note that Message mode does not use this variable; it auto-saves
404 in `message-auto-save-directory'."
405 :type
'(directory :tag
"Directory")
409 (defvar mail-reply-action nil
)
410 (defvar mail-send-actions nil
411 "A list of actions to be performed upon successful sending of a message.")
412 (defvar mail-return-action nil
)
415 (defcustom mail-default-headers nil
416 "A string containing header lines, to be inserted in outgoing messages.
417 It can contain newlines, and should end in one. It is inserted
418 before you edit the message, so you can edit or delete the lines."
419 :type
'(choice (const nil
) string
)
422 (defcustom mail-bury-selects-summary t
423 "If non-nil, try to show Rmail summary buffer after returning from mail.
424 The functions \\[mail-send-on-exit] or \\[mail-dont-send] select
425 the Rmail summary buffer before returning, if it exists and this variable
430 (defcustom mail-send-nonascii
'mime
431 "Specify whether to allow sending non-ASCII characters in mail.
432 If t, that means do allow it. nil means don't allow it.
433 `query' means ask the user each time.
434 `mime' means add an appropriate MIME header if none already present.
435 The default is `mime'.
436 Including non-ASCII characters in a mail message can be problematical
437 for the recipient, who may not know how to decode them properly."
438 :type
'(choice (const t
) (const nil
) (const query
) (const mime
))
441 (defcustom mail-use-dsn nil
442 "Ask MTA for notification of failed, delayed or successful delivery.
443 Note that only some MTAs (currently only recent versions of Sendmail)
444 support Delivery Status Notification."
446 :type
'(repeat (radio (const :tag
"Failure" failure
)
447 (const :tag
"Delay" delay
)
448 (const :tag
"Success" success
)))
451 ;; Note: could use /usr/ucb/mail instead of sendmail;
452 ;; options -t, and -v if not interactive.
453 (defvar mail-mailer-swallows-blank-line nil
454 "Set this non-nil if the system's mailer runs the header and body together.
455 The actual value should be an expression to evaluate that returns
456 non-nil if the problem will actually occur.
457 \(As far as we know, this is not an issue on any system still supported
460 (put 'mail-mailer-swallows-blank-line
'risky-local-variable t
) ; gets evalled
461 (make-obsolete-variable 'mail-mailer-swallows-blank-line
462 "no need to set this on any modern system."
465 (defvar mail-mode-syntax-table
466 ;; define-derived-mode will make it inherit from text-mode-syntax-table.
467 (let ((st (make-syntax-table)))
468 ;; FIXME this is probably very obsolete now ("percent hack").
469 ;; sending.texi used to say:
470 ;; Mail mode defines the character `%' as a word separator; this
471 ;; is helpful for using the word commands to edit mail addresses.
472 (modify-syntax-entry ?%
". " st
)
474 "Syntax table used while in `mail-mode'.")
476 (defvar mail-font-lock-keywords
478 (let* ((cite-chars "[>|}]")
479 (cite-prefix "[:alpha:]")
480 (cite-suffix (concat cite-prefix
"0-9_.@-`'\"")))
481 (list '("^\\(To\\|Newsgroups\\):" . font-lock-function-name-face
)
482 '("^\\(B?CC\\|Reply-to\\|Mail-\\(reply\\|followup\\)-to\\):" . font-lock-keyword-face
)
483 '("^\\(Subject:\\)[ \t]*\\(.+\\)?"
484 (1 font-lock-comment-face
)
485 ;; (2 font-lock-type-face nil t)
487 ;; Use EVAL to delay in case `mail-header-separator' gets changed.
489 (let ((separator (if (zerop (length mail-header-separator
))
491 (regexp-quote mail-header-separator
))))
492 (cons (concat "^" separator
"$") 'font-lock-warning-face
)))
493 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
495 (,(concat "\\=[ \t]*"
496 "\\(\\(\\([" cite-prefix
"]+[" cite-suffix
"]*\\)?"
497 "\\(" cite-chars
"[ \t]*\\)\\)+\\)"
499 (beginning-of-line) (end-of-line)
500 (1 font-lock-comment-delimiter-face nil t
)
501 (5 font-lock-comment-face nil t
)))
502 '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\):.*\\(\n[ \t]+.*\\)*$"
503 . font-lock-string-face
))))
504 "Additional expressions to highlight in Mail mode.")
508 (defun sendmail-query-once ()
509 "Query for `send-mail-function' and send mail with it.
510 This also saves the value of `send-mail-function' via Customize."
511 ;; If send-mail-function is already setup, we're incorrectly called
512 ;; a second time, probably because someone's using an old value
513 ;; of send-mail-function.
514 (when (eq send-mail-function
'sendmail-query-once
)
515 (sendmail-query-user-about-smtp))
516 (funcall send-mail-function
))
518 (defun sendmail-query-user-about-smtp ()
519 (let* ((options `(("mail client" . mailclient-send-it
)
520 ,@(when (and sendmail-program
521 (executable-find sendmail-program
))
522 '(("transport" . sendmail-send-it
)))
523 ("smtp" . smtpmail-send-it
)))
527 (rename-buffer "*Emacs Mail Setup Help*" t
)
529 Emacs is about to send an email message, but it has not been
530 configured for sending email. To tell Emacs how to send email:
533 (propertize "mail client" 'face
'bold
)
534 "' to start your default email client and
535 pass it the message text.\n\n")
536 (and sendmail-program
537 (executable-find sendmail-program
)
540 (propertize "transport" 'face
'bold
)
541 "' to invoke the system's mail transport agent
547 (propertize "smtp" 'face
'bold
)
548 "' to send mail directly to an \"outgoing mail\" server.
549 (Emacs may prompt you for SMTP settings).
551 Emacs will record your selection and will use it thereafter.
552 To change it later, customize the option `send-mail-function'.\n")
553 (goto-char (point-min))
554 (display-buffer (current-buffer))
555 (let ((completion-ignore-case t
))
556 (completing-read "Send mail via: "
557 options nil
'require-match
)))))
558 (customize-save-variable 'send-mail-function
559 (cdr (assoc-string choice options t
)))))
561 (defun sendmail-sync-aliases ()
562 (when mail-personal-alias-file
563 (let ((modtime (nth 5 (file-attributes mail-personal-alias-file
))))
564 (or (equal mail-alias-modtime modtime
)
565 (setq mail-alias-modtime modtime
570 (define-mail-user-agent 'sendmail-user-agent
571 'sendmail-user-agent-compose
575 (defun sendmail-user-agent-compose (&optional to subject other-headers
576 continue switch-function yank-action
577 send-actions return-action
580 (funcall switch-function
"*mail*"))
581 (let ((cc (cdr (assoc-string "cc" other-headers t
)))
582 (in-reply-to (cdr (assoc-string "in-reply-to" other-headers t
)))
583 (body (cdr (assoc-string "body" other-headers t
))))
584 (or (mail continue to subject in-reply-to cc yank-action
585 send-actions return-action
)
587 (error "Message aborted"))
591 (unless (member-ignore-case (car (car other-headers
))
592 '("in-reply-to" "cc" "body"))
593 (insert (car (car other-headers
)) ": "
594 (cdr (car other-headers
))
595 (if use-hard-newlines hard-newline
"\n")))
596 (setq other-headers
(cdr other-headers
)))
602 (defun mail-setup (to subject in-reply-to cc replybuffer
603 actions return-action
)
604 (or mail-default-reply-to
605 (setq mail-default-reply-to
(getenv "REPLYTO")))
606 (sendmail-sync-aliases)
607 (when (eq mail-aliases t
)
608 (setq mail-aliases nil
)
609 (and mail-personal-alias-file
610 (file-exists-p mail-personal-alias-file
)
611 (build-mail-aliases)))
612 ;; Don't leave this around from a previous message.
613 (kill-local-variable 'buffer-file-coding-system
)
614 ;; This doesn't work for enable-multibyte-characters.
615 ;; (kill-local-variable 'enable-multibyte-characters)
616 (set-buffer-multibyte (default-value 'enable-multibyte-characters
))
617 (if current-input-method
618 (deactivate-input-method))
620 ;; Local variables for Mail mode.
621 (setq mail-send-actions actions
)
622 (setq mail-reply-action replybuffer
)
623 (setq mail-return-action return-action
)
625 (goto-char (point-min))
626 (if mail-setup-with-from
627 (mail-insert-from-field))
631 ;; Here removed code to extract names from within <...>
632 ;; on the assumption that mail-strip-quoted-names
633 ;; has been called and has done so.
634 (let ((fill-prefix "\t")
635 (address-start (point)))
637 (fill-region-as-paragraph address-start
(point-max))
638 (goto-char (point-max))
643 (let ((fill-prefix "\t")
644 (address-start (progn (insert "CC: ") (point))))
646 (fill-region-as-paragraph address-start
(point-max))
647 (goto-char (point-max))
651 (let ((fill-prefix "\t")
653 (address-start (point)))
654 (insert "In-reply-to: " in-reply-to
"\n")
655 (fill-region-as-paragraph address-start
(point-max))
656 (goto-char (point-max))
659 (insert "Subject: " (or subject
"") "\n")
660 (if mail-default-headers
661 (insert mail-default-headers
))
662 (if mail-default-reply-to
663 (insert "Reply-to: " mail-default-reply-to
"\n"))
665 (insert "BCC: " user-mail-address
"\n"))
666 (if mail-archive-file-name
667 (insert "FCC: " mail-archive-file-name
"\n"))
668 (put-text-property (point)
670 (insert mail-header-separator
"\n")
672 'category
'mail-header-separator
)
673 ;; Insert the signature. But remember the beginning of the message.
674 (if to
(setq to
(point)))
675 (if mail-signature
(mail-signature t
))
676 (goto-char (point-max))
677 (or (bolp) (newline)))
678 (if to
(goto-char to
))
679 (or to subject in-reply-to
680 (set-buffer-modified-p nil
))
681 (run-hooks 'mail-setup-hook
))
683 (defcustom mail-mode-hook nil
684 "Hook run by Mail mode.
685 When composing a mail, this runs immediately after creating, or
686 switching to, the `*mail*' buffer. See also `mail-setup-hook'."
689 :options
'(footnote-mode))
691 (defvar mail-mode-abbrev-table text-mode-abbrev-table
)
692 (defvar mail-encode-mml
)
694 (define-derived-mode mail-mode text-mode
"Mail"
695 "Major mode for editing mail to be sent.
696 Like Text Mode but with these additional commands:
698 \\[mail-send] mail-send (send the message)
699 \\[mail-send-and-exit] mail-send-and-exit (send the message and exit)
701 Here are commands that move to a header field (and create it if there isn't):
702 \\[mail-to] move to To: \\[mail-subject] move to Subj:
703 \\[mail-bcc] move to BCC: \\[mail-cc] move to CC:
704 \\[mail-fcc] move to FCC: \\[mail-reply-to] move to Reply-To:
705 \\[mail-mail-reply-to] move to Mail-Reply-To:
706 \\[mail-mail-followup-to] move to Mail-Followup-To:
707 \\[mail-text] move to message text.
708 \\[mail-signature] mail-signature (insert `mail-signature-file' file).
709 \\[mail-yank-original] mail-yank-original (insert current message, in Rmail).
710 \\[mail-fill-yanked-message] mail-fill-yanked-message (fill what was yanked).
711 \\[mail-insert-file] insert a text file into the message.
712 \\[mail-add-attachment] attach to the message a file as binary attachment.
713 Turning on Mail mode runs the normal hooks `text-mode-hook' and
714 `mail-mode-hook' (in that order)."
715 (make-local-variable 'mail-reply-action
)
716 (make-local-variable 'mail-send-actions
)
717 (make-local-variable 'mail-return-action
)
718 (make-local-variable 'mail-encode-mml
)
719 (setq mail-encode-mml nil
)
720 (setq buffer-offer-save t
)
721 (make-local-variable 'font-lock-defaults
)
722 (setq font-lock-defaults
'(mail-font-lock-keywords t t
))
723 (make-local-variable 'paragraph-separate
)
724 (make-local-variable 'normal-auto-fill-function
)
725 (setq normal-auto-fill-function
'mail-mode-auto-fill
)
726 (make-local-variable 'fill-paragraph-function
)
727 (setq fill-paragraph-function
'mail-mode-fill-paragraph
)
728 ;; Allow using comment commands to add/remove quoting (this only does
729 ;; anything if mail-yank-prefix is set to a non-nil value).
730 (set (make-local-variable 'comment-start
) mail-yank-prefix
)
732 (set (make-local-variable 'comment-start-skip
)
733 (concat "^" (regexp-quote mail-yank-prefix
) "[ \t]*")))
734 (make-local-variable 'adaptive-fill-regexp
)
735 ;; Also update the paragraph-separate entry if you change this.
736 (setq adaptive-fill-regexp
737 (concat "[ \t]*[-[:alnum:]]+>+[ \t]*\\|"
738 adaptive-fill-regexp
))
739 (make-local-variable 'adaptive-fill-first-line-regexp
)
740 (setq adaptive-fill-first-line-regexp
741 (concat "[ \t]*[-[:alnum:]]*>+[ \t]*\\|"
742 adaptive-fill-first-line-regexp
))
743 (add-hook 'completion-at-point-functions
#'mail-completion-at-point-function
745 ;; `-- ' precedes the signature. `-----' appears at the start of the
746 ;; lines that delimit forwarded messages.
747 ;; Lines containing just >= 3 dashes, perhaps after whitespace,
748 ;; are also sometimes used and should be separators.
749 (setq paragraph-separate
750 (concat (regexp-quote mail-header-separator
)
751 ;; This is based on adaptive-fill-regexp (presumably
752 ;; the idea is to allow navigation etc of cited paragraphs).
753 "$\\|\t*[-–!|#%;>*·•‣⁃◦ ]+$"
754 "\\|[ \t]*[-[:alnum:]]*>+[ \t]*$\\|[ \t]*$\\|"
759 (defun mail-header-end ()
760 "Return the buffer location of the end of headers, as a number."
767 (defun mail-text-start ()
768 "Return the buffer location of the start of text, as a number."
776 (defun mail-sendmail-delimit-header ()
777 "Set up whatever header delimiter convention sendmail will use.
778 Concretely: replace the first blank line in the header with the separator."
780 (insert mail-header-separator
)
783 (defun mail-sendmail-undelimit-header ()
784 "Remove header separator to put the message in correct form for sendmail.
785 Leave point at the start of the delimiter line."
787 (delete-region (point) (progn (end-of-line) (point))))
789 (defun mail-mode-auto-fill ()
790 "Carry out Auto Fill for Mail mode.
791 If within the headers, this makes the new lines into continuation lines."
792 (if (< (point) (mail-header-end))
793 (let ((old-line-start (line-beginning-position)))
797 (while (not (eq (point) old-line-start
))
798 ;; Use insert-before-markers in case we're inserting
799 ;; before the saved value of point (which is common).
800 (insert-before-markers " ")
805 (defun mail-mode-fill-paragraph (arg)
806 ;; Do something special only if within the headers.
807 (if (< (point) (mail-header-end))
808 (let (beg end fieldname
)
809 (when (prog1 (re-search-backward "^[-a-zA-Z]+:" nil
'yes
)
812 (downcase (buffer-substring beg
(1- (match-end 0))))))
814 ;; Find continuation lines and get rid of their continuation markers.
815 (while (looking-at "[ \t]")
816 (delete-horizontal-space)
818 (setq end
(point-marker))
820 ;; If this field contains addresses,
821 ;; make sure we can fill after each address.
822 (if (member fieldname
823 '("to" "cc" "bcc" "from" "reply-to"
824 "mail-reply-to" "mail-followup-to"
825 "resent-to" "resent-cc" "resent-bcc"
826 "resent-from" "resent-reply-to"))
827 (while (search-forward "," end t
)
828 (or (looking-at "[ \t]")
830 (fill-region-as-paragraph beg end arg
)
831 ;; Mark all lines except the first as continuations.
834 (while (< (point) end
)
837 (move-marker end nil
)
840 ;; User-level commands for sending.
842 (defun mail-send-and-exit (&optional arg
)
843 "Send message like `mail-send', then, if no errors, exit from mail buffer.
844 Prefix arg means don't delete this window."
849 (defun mail-dont-send (&optional arg
)
850 "Don't send the message you have been editing.
851 Prefix arg means don't delete this window."
855 (defun mail-bury (&optional arg
)
856 "Bury this mail buffer."
857 (let ((newbuf (other-buffer (current-buffer)))
858 (return-action mail-return-action
))
859 (bury-buffer (current-buffer))
860 ;; If there is an Rmail buffer, return to it nicely
861 ;; even if this message was not started by an Rmail command.
862 (unless return-action
863 (dolist (buffer (buffer-list))
864 (if (and (eq (buffer-local-value 'major-mode buffer
) 'rmail-mode
)
866 ;; Don't match message-viewer buffer.
867 (not (string-match "\\` " (buffer-name buffer
))))
868 (setq return-action
`(rmail-mail-return ,buffer
)))))
869 (if (and (null arg
) return-action
)
870 (apply (car return-action
) (cdr return-action
))
871 (switch-to-buffer newbuf
))))
873 (defcustom mail-send-hook nil
874 "Hook run just before sending a message."
876 :options
'(flyspell-mode-off)
880 (defcustom mail-mailing-lists nil
881 "List of mailing list addresses the user is subscribed to.
882 The variable is used to trigger insertion of the \"Mail-Followup-To\"
883 header when sending a message to a mailing list."
884 :type
'(repeat string
)
887 (declare-function mml-to-mime
"mml" ())
890 "Send the message in the current buffer.
891 If `mail-interactive' is non-nil, wait for success indication
892 or error messages, and inform user.
893 Otherwise any failure is reported in a message back to
894 the user from the mailer."
896 (if (if buffer-file-name
897 (y-or-n-p "Send buffer contents as mail message? ")
898 (or (buffer-modified-p)
899 (y-or-n-p "Message already sent; resend? ")))
900 (let ((inhibit-read-only t
)
902 (ml (when mail-mailing-lists
903 ;; The surrounding regexp assumes the use of
904 ;; `mail-strip-quoted-names' on addresses before matching
905 ;; Cannot deal with full RFC 822 freedom, but that is
906 ;; unlikely to be problematic.
907 (concat "\\(?:[[:space:];,]\\|\\`\\)"
908 (regexp-opt mail-mailing-lists t
)
909 "\\(?:[[:space:];,]\\|\\'\\)"))))
910 (mail-combine-fields "To")
911 (mail-combine-fields "CC")
912 ;; If there are mailing lists defined
915 (let* ((to (mail-fetch-field "to" nil t
))
916 (cc (mail-fetch-field "cc" nil t
))
917 (new-header-values ; To: and Cc:
918 (mail-strip-quoted-names
919 (concat to
(when cc
(concat ", " cc
))))))
920 ;; If message goes to known mailing list ...
921 (when (string-match ml new-header-values
)
922 ;; Add Mail-Followup-To if none yet
923 (unless (mail-fetch-field "mail-followup-to")
924 (goto-char (mail-header-end))
925 (insert "Mail-Followup-To: "
932 (split-string new-header-values
934 (mapconcat 'identity l
", "))
936 ;; Add Mail-Reply-To if none yet
937 (unless (mail-fetch-field "mail-reply-to")
938 (goto-char (mail-header-end))
939 (insert "Mail-Reply-To: "
940 (or (mail-fetch-field "reply-to")
943 (unless (memq mail-send-nonascii
'(t mime
))
944 (goto-char (point-min))
945 (skip-chars-forward "\0-\177")
946 (or (= (point) (point-max))
947 (if (eq mail-send-nonascii
'query
)
948 (or (y-or-n-p "Message contains non-ASCII characters; send anyway? ")
950 (error "Message contains non-ASCII characters"))))
951 ;; Complain about any invalid line.
952 (goto-char (point-min))
953 (re-search-forward (regexp-quote mail-header-separator
) (point-max) t
)
954 (let ((header-end (or (match-beginning 0) (point-max))))
955 (goto-char (point-min))
956 (while (< (point) header-end
)
957 (unless (looking-at "[ \t]\\|.*:\\|$")
959 (error "Invalid header line (maybe a continuation line lacks initial whitespace)"))
962 (when mail-encode-mml
964 (setq mail-encode-mml nil
))
965 (run-hooks 'mail-send-hook
)
966 (message "Sending...")
967 (funcall send-mail-function
)
968 ;; Now perform actions on successful sending.
969 (while mail-send-actions
971 (apply (car (car mail-send-actions
))
972 (cdr (car mail-send-actions
)))
974 (setq mail-send-actions
(cdr mail-send-actions
)))
975 (message "Sending...done")
976 ;; If buffer has no file, mark it as unmodified and delete auto-save.
977 (if (not buffer-file-name
)
979 (set-buffer-modified-p nil
)
980 (delete-auto-save-file-if-necessary t
))))))
982 (defun mail-envelope-from ()
983 "Return the envelope mail address to use when sending mail.
984 This function uses `mail-envelope-from'."
985 (if (eq mail-envelope-from
'header
)
986 (nth 1 (mail-extract-address-components
987 (mail-fetch-field "From")))
990 ;; This does the real work of sending a message via sendmail.
991 ;; It is called via the variable send-mail-function.
994 (defvar sendmail-coding-system nil
995 "Coding system for encoding the outgoing mail.
996 This has higher priority than the default `buffer-file-coding-system'
997 and `default-sendmail-coding-system',
998 but lower priority than the local value of `buffer-file-coding-system'.
999 See also the function `select-message-coding-system'.")
1002 (defvar default-sendmail-coding-system
'iso-latin-1
1003 "Default coding system for encoding the outgoing mail.
1004 This variable is used only when `sendmail-coding-system' is nil.
1006 This variable is set/changed by the command `set-language-environment'.
1007 User should not set this variable manually,
1008 instead use `sendmail-coding-system' to get a constant encoding
1009 of outgoing mails regardless of the current language environment.
1010 See also the function `select-message-coding-system'.")
1012 (defun mail-insert-from-field ()
1013 "Insert the \"From:\" field of a mail header.
1014 The style of the field is determined by the variable `mail-from-style'.
1015 This function does not perform RFC2047 encoding."
1016 (let* ((login user-mail-address
)
1017 (fullname (user-full-name))
1018 (quote-fullname nil
))
1019 (if (string-match "[^\0-\177]" fullname
)
1020 (setq quote-fullname t
))
1021 (cond ((null mail-from-style
)
1022 (insert "From: " login
"\n"))
1023 ;; This is deprecated.
1024 ((eq mail-from-style
'system-default
)
1026 ((or (eq mail-from-style
'angles
)
1027 (and (not (eq mail-from-style
'parens
))
1028 ;; Use angles if no quoting is needed, or if
1029 ;; parens would need quoting too.
1030 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname
))
1031 (let ((tmp (concat fullname nil
)))
1032 (while (string-match "([^()]*)" tmp
)
1033 (aset tmp
(match-beginning 0) ?-
)
1034 (aset tmp
(1- (match-end 0)) ?-
))
1035 (string-match "[\\()]" tmp
)))))
1036 (insert "From: " fullname
)
1037 (let ((fullname-start (+ (point-min) 6))
1038 (fullname-end (point-marker)))
1039 (goto-char fullname-start
)
1040 ;; Look for a character that cannot appear unquoted
1041 ;; according to RFC 822.
1042 (if (or (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
1046 ;; Quote fullname, escaping specials.
1047 (goto-char fullname-start
)
1049 (while (re-search-forward "[\"\\]"
1051 (replace-match "\\\\\\&" t
))
1053 (insert " <" login
">\n"))
1054 ;; 'parens or default
1056 (insert "From: " login
" (")
1057 (let ((fullname-start (point)))
1063 (let ((fullname-end (point-marker)))
1064 (goto-char fullname-start
)
1065 ;; RFC 822 says \ and nonmatching parentheses
1066 ;; must be escaped in comments.
1067 ;; Escape every instance of ()\ ...
1068 (while (re-search-forward "[()\\]" fullname-end
1)
1069 (replace-match "\\\\\\&" t
))
1070 ;; ... then undo escaping of matching parentheses,
1071 ;; including matching nested parentheses.
1072 (goto-char fullname-start
)
1073 (while (re-search-forward
1074 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
1076 (replace-match "\\1(\\3)" t
)
1077 (goto-char fullname-start
))))
1080 (defun mail-combine-fields (field)
1081 "Offer to combine all FIELD fields in buffer into one FIELD field.
1082 If this finds multiple FIELD fields, it asks the user whether
1083 to combine them into one, and does so if the user says y."
1084 (let ((search-pattern (format "^%s[ \t]*:" field
))
1089 (old-max (point-max)))
1092 (goto-char (point-min))
1093 (narrow-to-region (point-min) (mail-header-end))
1094 ;; Find the first FIELD field and record where it ends.
1095 (when (re-search-forward search-pattern nil t
)
1097 (re-search-forward "^[^ \t]" nil t
)
1099 (setq first-to-end
(point-marker))
1100 (set-marker-insertion-type first-to-end t
)
1101 ;; Find each following FIELD field
1102 ;; and combine it with the first FIELD field.
1103 (while (re-search-forward search-pattern nil t
)
1104 ;; For the second FIELD field, ask user to
1105 ;; approve combining them.
1106 ;; But if the user refuse to combine them, signal error.
1109 ;; This is just so the screen doesn't change.
1110 (narrow-to-region (point-min) old-max
)
1111 (goto-char old-point
)
1112 (setq query-asked t
)
1113 (if (y-or-n-p (format "Message contains multiple %s fields. Combine? " field
))
1114 (setq query-answer t
))))
1116 (let ((this-to-start (line-beginning-position))
1120 (re-search-forward "^[^ \t]" nil t
)
1122 (setq this-to-end
(point))
1123 ;; Get the text of this FIELD field.
1124 (setq this-to
(buffer-substring this-to-start this-to-end
))
1126 (delete-region this-to-start this-to-end
)
1128 ;; Put a comma after the first FIELD field.
1129 (goto-char first-to-end
)
1132 ;; Copy this one after it.
1133 (goto-char first-to-end
)
1136 ;; Replace the FIELD: with spaces.
1137 (looking-at search-pattern
)
1138 ;; Try to preserve alignment of contents of the field
1139 (let ((prefix-length (length (match-string 0))))
1141 (dotimes (i (1- prefix-length
))
1143 (set-marker first-to-end nil
))))))
1145 (defun mail-encode-header (beg end
)
1146 "Encode the mail header between BEG and END according to RFC2047.
1147 Return non-nil if and only if some part of the header is encoded."
1149 (narrow-to-region beg end
)
1150 (let* ((selected (select-message-coding-system))
1151 (mm-coding-system-priorities
1152 (if (and selected
(coding-system-get selected
:mime-charset
))
1153 (cons selected mm-coding-system-priorities
)
1154 mm-coding-system-priorities
))
1155 (tick (buffer-chars-modified-tick))
1156 ;; Many mailers, including Gnus, passes a message of which
1157 ;; the header is already encoded, so this is necessary to
1158 ;; prevent it from being encoded again.
1159 (rfc2047-encode-encoded-words nil
))
1160 (rfc2047-encode-message-header)
1161 (= tick
(buffer-chars-modified-tick)))))
1163 ;; Normally you will not need to modify these options unless you are
1164 ;; using some non-genuine substitute for sendmail which does not
1165 ;; implement each and every option that the original supports.
1166 ;; E.g., ssmtp does not support "-odb", so, if your site uses it,
1167 ;; you will need to modify `sendmail-error-reporting-non-interactive'
1168 ;; in your site-init.el.
1169 (defvar sendmail-error-reporting-interactive
1170 ;; These mean "report errors to terminal" and "deliver interactively"
1172 (defvar sendmail-error-reporting-non-interactive
1173 ;; These mean "report errors by mail" and "deliver in background".
1176 (defun sendmail-send-it ()
1177 "Send the current mail buffer using the Sendmail package.
1178 This is a suitable value for `send-mail-function'. It sends using the
1179 external program defined by `sendmail-program'."
1180 (require 'mail-utils
)
1181 (let ((errbuf (if mail-interactive
1182 (generate-new-buffer " sendmail errors")
1185 (tembuf (generate-new-buffer " sendmail temp"))
1186 (multibyte enable-multibyte-characters
)
1187 (case-fold-search nil
)
1188 (selected-coding (select-message-coding-system))
1192 (mailbuf (current-buffer))
1193 ;; Examine these variables now, so that
1194 ;; local binding in the mail buffer will take effect.
1196 (and mail-specify-envelope-from
1197 (or (mail-envelope-from) user-mail-address
))))
1199 (with-current-buffer tembuf
1202 (set-buffer-multibyte nil
))
1203 (insert-buffer-substring mailbuf
)
1204 (set-buffer-file-coding-system selected-coding
)
1205 (goto-char (point-max))
1206 ;; require one newline at the end.
1207 (or (= (preceding-char) ?
\n)
1209 ;; Change header-delimiter to be what sendmail expects.
1210 (goto-char (mail-header-end))
1211 (delete-region (point) (progn (end-of-line) (point)))
1212 (setq delimline
(point-marker))
1213 (sendmail-sync-aliases)
1215 (expand-mail-aliases (point-min) delimline
))
1216 (goto-char (point-min))
1217 ;; Ignore any blank lines in the header
1218 (while (and (re-search-forward "\n\n\n*" delimline t
)
1219 (< (point) delimline
))
1220 (replace-match "\n"))
1221 (goto-char (point-min))
1222 ;; Look for Resent- headers. They require sending
1223 ;; the message specially.
1224 (let ((case-fold-search t
))
1225 (goto-char (point-min))
1226 (while (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" delimline t
)
1227 ;; Put a list of such addresses in resend-to-addresses.
1228 (setq resend-to-addresses
1230 (narrow-to-region (point)
1233 (while (looking-at "^[ \t]")
1236 (append (mail-parse-comma-list)
1237 resend-to-addresses
)))
1238 ;; Delete Resent-BCC ourselves
1239 (if (save-excursion (beginning-of-line)
1240 (looking-at "resent-bcc"))
1241 (delete-region (line-beginning-position)
1242 (line-beginning-position 2))))
1243 ;; Apparently this causes a duplicate Sender.
1244 ;; ;; If the From is different than current user, insert Sender.
1245 ;; (goto-char (point-min))
1246 ;; (and (re-search-forward "^From:" delimline t)
1248 ;; (require 'mail-utils)
1249 ;; (not (string-equal
1250 ;; (mail-strip-quoted-names
1251 ;; (save-restriction
1252 ;; (narrow-to-region (point-min) delimline)
1253 ;; (mail-fetch-field "From")))
1254 ;; (user-login-name))))
1257 ;; (insert "Sender: " (user-login-name) "\n")))
1258 ;; Don't send out a blank subject line
1259 (goto-char (point-min))
1260 (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t
)
1262 ;; This one matches a Subject just before the header delimiter.
1263 (if (and (re-search-forward "^Subject:\\([ \t]*\n\\)+" delimline t
)
1264 (= (match-end 0) delimline
))
1265 (replace-match "")))
1266 ;; Put the "From:" field in unless for some odd reason
1267 ;; they put one in themselves.
1268 (goto-char (point-min))
1269 (if (not (re-search-forward "^From:" delimline t
))
1270 (mail-insert-from-field))
1271 ;; Possibly add a MIME header for the current coding system
1272 (let (charset where-content-type
)
1273 (goto-char (point-min))
1274 (setq where-content-type
1275 (re-search-forward "^Content-type:" delimline t
))
1276 (goto-char (point-min))
1277 (and (eq mail-send-nonascii
'mime
)
1278 (not (re-search-forward "^MIME-version:" delimline t
))
1279 (progn (skip-chars-forward "\0-\177")
1280 (/= (point) (point-max)))
1283 (coding-system-get selected-coding
:mime-charset
))
1285 (goto-char delimline
)
1286 (insert "MIME-version: 1.0\n"
1287 "Content-type: text/plain; charset="
1288 (symbol-name charset
)
1289 "\nContent-Transfer-Encoding: 8bit\n")
1290 ;; The character set we will actually use
1291 ;; should override any specified in the message itself.
1292 (when where-content-type
1293 (goto-char where-content-type
)
1294 (delete-region (point-at-bol)
1295 (progn (forward-line 1) (point)))))))
1296 ;; Insert an extra newline if we need it to work around
1297 ;; Sun's bug that swallows newlines.
1298 (goto-char (1+ delimline
))
1299 (if (eval mail-mailer-swallows-blank-line
)
1301 ;; Find and handle any FCC fields.
1302 (goto-char (point-min))
1303 (if (re-search-forward "^FCC:" delimline t
)
1305 (setq fcc-was-found t
)
1306 (mail-do-fcc delimline
)))
1307 (if mail-interactive
1308 (with-current-buffer errbuf
1310 ;; Encode the header according to RFC2047.
1311 (mail-encode-header (point-min) delimline
)
1312 (goto-char (point-min))
1313 (if (let ((case-fold-search t
))
1314 (or resend-to-addresses
1315 (re-search-forward "^To:\\|^cc:\\|^bcc:"
1317 (let* ((default-directory "/")
1318 (coding-system-for-write selected-coding
)
1320 (append (list (point-min) (point-max)
1322 nil errbuf nil
"-oi")
1324 (list "-f" envelope-from
))
1325 ;; ;; Don't say "from root" if running under su.
1326 ;; (and (equal (user-real-login-name) "root")
1327 ;; (list "-f" (user-login-name)))
1328 (and mail-alias-file
1329 (list (concat "-oA" mail-alias-file
)))
1330 (if mail-interactive
1331 sendmail-error-reporting-interactive
1332 sendmail-error-reporting-non-interactive
)
1333 ;; Get the addresses from the message
1334 ;; unless this is a resend.
1335 ;; We must not do that for a resend
1336 ;; because we would find the original addresses.
1337 ;; For a resend, include the specific addresses.
1338 (or resend-to-addresses
1342 (list "-N" (mapconcat 'symbol-name
1346 (exit-value (apply 'call-process-region args
)))
1347 (cond ((or (null exit-value
) (eq 0 exit-value
)))
1348 ((numberp exit-value
)
1350 (error "Sending...failed with exit value %d" exit-value
))
1351 ((stringp exit-value
)
1353 (error "Sending...terminated by signal: %s" exit-value
))
1356 (error "SENDMAIL-SEND-IT -- fall through: %S" exit-value
))))
1358 (error "No recipients")))
1359 (if mail-interactive
1360 (with-current-buffer errbuf
1361 (goto-char (point-min))
1362 (while (re-search-forward "\n\n* *" nil t
)
1363 (replace-match "; "))
1364 (unless (zerop (buffer-size))
1366 (error "Sending...failed to %s"
1367 (buffer-substring (point-min) (point-max)))))))
1368 (kill-buffer tembuf
)
1369 (when (buffer-live-p errbuf
)
1371 (switch-to-buffer-other-window errbuf
)
1372 (kill-buffer errbuf
))))))
1374 (autoload 'rmail-output-to-rmail-buffer
"rmailout")
1376 (defun mail-do-fcc (header-end)
1377 "Find and act on any FCC: headers in the current message before HEADER-END.
1378 If a buffer is visiting the FCC file, append to it before
1379 offering to save it, if it was modified initially. If this is an
1380 Rmail buffer, update Rmail as needed. If there is no buffer,
1381 just append to the file, in Babyl format if necessary."
1382 (unless (markerp header-end
)
1383 (error "Value of `header-end' must be a marker"))
1385 (mailbuf (current-buffer))
1386 (time (current-time)))
1388 (goto-char (point-min))
1389 (let ((case-fold-search t
))
1390 (while (re-search-forward "^FCC:[ \t]*" header-end t
)
1391 (push (buffer-substring (point)
1394 (skip-chars-backward " \t")
1397 (delete-region (match-beginning 0)
1398 (progn (forward-line 1) (point)))))
1400 ;; This initial newline is not written out if we create a new
1401 ;; file (see below).
1402 (insert "\nFrom " (user-login-name) " " (current-time-string time
) "\n")
1403 ;; Insert the time zone before the year.
1406 (require 'mail-utils
)
1407 (insert (mail-rfc822-time-zone time
) " ")
1408 (goto-char (point-max))
1409 (insert-buffer-substring mailbuf
)
1410 ;; Make sure messages are separated.
1411 (goto-char (point-max))
1414 ;; ``Quote'' "^From " as ">From "
1415 ;; (note that this isn't really quoting, as there is no requirement
1416 ;; that "^[>]+From " be quoted in the same transparent way.)
1417 (let ((case-fold-search nil
))
1418 (while (search-forward "\nFrom " nil t
)
1421 (dolist (fcc fcc-list
)
1422 (let* ((buffer (find-buffer-visiting fcc
))
1423 (curbuf (current-buffer))
1426 (beg (point-min)) ; the initial blank line
1428 ;; After the ^From line.
1429 (beg2 (save-excursion (goto-char (point-min))
1430 (forward-line 2) (point))))
1432 ;; File is present in a buffer => append to that buffer.
1433 (with-current-buffer buffer
1434 (setq buffer-matches-file
1435 (and (not (buffer-modified-p))
1436 (verify-visited-file-modtime buffer
)))
1437 (let ((msg (bound-and-true-p rmail-current-message
))
1438 (buffer-read-only nil
))
1439 ;; If MSG is non-nil, buffer is in Rmail mode.
1441 (let ((buff (generate-new-buffer " *mail-do-fcc")))
1444 (with-current-buffer buff
1445 (insert-buffer-substring curbuf
(1+ beg
) end
))
1446 (rmail-output-to-rmail-buffer buff msg
))
1447 (kill-buffer buff
)))
1448 ;; Output file not in Rmail mode => just insert
1452 (goto-char (point-max))
1453 (insert-buffer-substring curbuf beg end
)))
1454 ;; Offer to save the buffer if it was modified
1455 ;; before we started.
1456 (unless buffer-matches-file
1457 (if (y-or-n-p (format "Save file %s? " fcc
))
1459 (setq dont-write-the-file t
)))))
1460 ;; Append to the file directly, unless we've already taken
1462 (unless dont-write-the-file
1463 (if (and (file-exists-p fcc
)
1464 (mail-file-babyl-p fcc
))
1465 ;; If the file is a Babyl file, convert the message to
1466 ;; Babyl format. Even though Rmail no longer uses
1467 ;; Babyl, this code can remain for the time being, on
1468 ;; the off-chance one FCCs to a Babyl file that has
1469 ;; not yet been converted to mbox.
1470 (let ((coding-system-for-write
1471 (or rmail-file-coding-system
'emacs-mule
)))
1473 (insert "\C-l\n0, unseen,,\n*** EOOH ***\nDate: "
1474 (mail-rfc822-date) "\n")
1475 (insert-buffer-substring curbuf beg2 end
)
1477 (write-region (point-min) (point-max) fcc t
)))
1478 ;; Ensure there is a blank line between messages, but
1479 ;; not at the very start of the file.
1480 (write-region (if (file-exists-p fcc
)
1483 (point-max) fcc t
)))
1484 (and buffer
(not dont-write-the-file
)
1485 (with-current-buffer buffer
1486 (set-visited-file-modtime)))))))))
1488 (defun mail-sent-via ()
1489 "Make a Sent-via header line from each To or CC header line."
1490 (declare (obsolete "nobody can remember what it is for." "24.1"))
1493 ;; put a marker at the end of the header
1494 (let ((end (copy-marker (mail-header-end)))
1495 (case-fold-search t
))
1496 (goto-char (point-min))
1497 ;; search for the To: lines and make Sent-via: lines from them
1498 ;; search for the next To: line
1499 (while (re-search-forward "^\\(to\\|cc\\):" end t
)
1500 ;; Grab this line plus all its continuations, sans the `to:'.
1502 (buffer-substring (point)
1504 (if (re-search-forward "^[^ \t\n]" end t
)
1508 ;; Insert a copy, with altered header field name.
1509 (insert-before-markers "Sent-via:" to-line
))))))
1512 "Move point to end of To field, creating it if necessary."
1515 (mail-position-on-field "To"))
1517 (defun mail-subject ()
1518 "Move point to end of Subject field, creating it if necessary."
1521 (mail-position-on-field "Subject"))
1524 "Move point to end of CC field, creating it if necessary."
1527 (or (mail-position-on-field "cc" t
)
1528 (progn (mail-position-on-field "to")
1529 (insert "\nCC: "))))
1532 "Move point to end of BCC field, creating it if necessary."
1535 (or (mail-position-on-field "bcc" t
)
1536 (progn (mail-position-on-field "to")
1537 (insert "\nBCC: "))))
1539 (defun mail-fcc (folder)
1540 "Add a new FCC field, with file name completion."
1541 (interactive "FFolder carbon copy: ")
1543 (or (mail-position-on-field "fcc" t
) ;Put new field after exiting FCC.
1544 (mail-position-on-field "to"))
1545 (insert "\nFCC: " folder
))
1547 (defun mail-reply-to ()
1548 "Move point to end of Reply-To field, creating it if necessary."
1551 (mail-position-on-field "Reply-To"))
1553 (defun mail-mail-reply-to ()
1554 "Move point to end of Mail-Reply-To field, creating it if necessary."
1557 (or (mail-position-on-field "mail-reply-to" t
)
1558 (progn (mail-position-on-field "to")
1559 (insert "\nMail-Reply-To: "))))
1561 (defun mail-mail-followup-to ()
1562 "Move point to end of Mail-Followup-To field, creating it if necessary."
1565 (or (mail-position-on-field "mail-followup-to" t
)
1566 (progn (mail-position-on-field "to")
1567 (insert "\nMail-Followup-To: "))))
1569 (defun mail-position-on-field (field &optional soft
)
1570 "Move to the end of the contents of header field FIELD.
1571 If there is no such header, insert one, unless SOFT is non-nil.
1572 If there are multiple FIELD fields, this goes to the first.
1573 Returns non-nil if FIELD was originally present."
1575 (case-fold-search t
))
1576 (setq end
(mail-header-end))
1577 (goto-char (point-min))
1578 (if (re-search-forward (concat "^" (regexp-quote field
) ":") end t
)
1580 (re-search-forward "^[^ \t]" nil
'move
)
1582 (skip-chars-backward "\n")
1585 (progn (goto-char end
)
1586 (insert field
": \n")
1587 (skip-chars-backward "\n")))
1591 "Move point to beginning of text field."
1594 (goto-char (mail-text-start)))
1596 (defun mail-signature (&optional atpoint
)
1597 "Sign letter with signature.
1598 If the variable `mail-signature' is a string, inserts it.
1599 If it is t or nil, inserts the contents of the file `mail-signature-file'.
1600 Otherwise, evals `mail-signature'.
1601 Prefix argument ATPOINT means insert at point rather than the end."
1603 ;; Test for an unreadable file here, before we delete trailing
1604 ;; whitespace, so that we don't modify the buffer needlessly.
1605 (if (and (memq mail-signature
'(t nil
))
1606 (not (file-readable-p mail-signature-file
)))
1607 (if (called-interactively-p 'interactive
)
1608 (message "The signature file `%s' could not be read"
1609 mail-signature-file
))
1612 (goto-char (point-max))
1613 ;; Delete trailing whitespace and blank lines.
1614 (skip-chars-backward " \t\n")
1616 (delete-region (point) (point-max)))
1617 (cond ((stringp mail-signature
)
1618 (insert mail-signature
))
1619 ((memq mail-signature
'(t nil
))
1620 (insert "\n\n-- \n")
1621 (insert-file-contents (expand-file-name mail-signature-file
)))
1623 ;; FIXME add condition-case error handling?
1624 (eval mail-signature
))))))
1626 (defun mail-fill-yanked-message (&optional justifyp
)
1627 "Fill the paragraphs of a message yanked into this one.
1628 Numeric argument means justify as well."
1631 (goto-char (mail-text-start))
1632 (fill-individual-paragraphs (point)
1635 mail-citation-prefix-regexp
)))
1637 (defun mail-indent-citation ()
1638 "Modify text just inserted from a message to be cited.
1639 The inserted text should be the region.
1640 When this function returns, the region is again around the modified text.
1642 Normally, indent each nonblank line `mail-indentation-spaces' spaces.
1643 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line."
1644 (mail-yank-clear-headers (region-beginning) (region-end))
1645 (if (null mail-yank-prefix
)
1646 (indent-rigidly (region-beginning) (region-end)
1647 mail-indentation-spaces
)
1649 (let ((end (set-marker (make-marker) (region-end))))
1650 (goto-char (region-beginning))
1651 (while (< (point) end
)
1652 (insert mail-yank-prefix
)
1653 (forward-line 1))))))
1655 (defun mail-yank-original (arg)
1656 "Insert the message being replied to, if any (in Rmail).
1657 Puts point after the text and mark before.
1658 Normally, indents each nonblank line ARG spaces (default 3).
1659 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
1661 Just \\[universal-argument] as argument means don't indent, insert no prefix,
1662 and don't delete any header fields."
1664 (if mail-reply-action
1665 (let ((start (point))
1666 (original mail-reply-action
)
1668 (and (consp original
) (eq (car original
) 'insert-buffer
)
1669 (setq original
(nth 1 original
)))
1670 (if (consp original
)
1672 ;; Call yank function, and set the mark if it doesn't.
1673 (apply (car original
) (cdr original
))
1674 (if (eq omark
(mark t
))
1675 (push-mark (point))))
1676 ;; If the original message is in another window in the same
1677 ;; frame, delete that window to save space.
1678 (delete-windows-on original t
)
1680 ;; We really want this to set mark.
1681 (insert-buffer original
)
1682 ;; If they yank the original text, the encoding of the
1683 ;; original message is a better default than
1684 ;; the default buffer-file-coding-system.
1685 (and (coding-system-equal
1686 (default-value 'buffer-file-coding-system
)
1687 buffer-file-coding-system
)
1688 (setq buffer-file-coding-system
1689 (coding-system-change-text-conversion
1690 buffer-file-coding-system
1692 (with-current-buffer original
1693 buffer-file-coding-system
))))))
1694 (set-text-properties (point) (mark t
) nil
))
1698 (let ((mail-indentation-spaces (if arg
(prefix-numeric-value arg
)
1699 mail-indentation-spaces
))
1700 ;; Avoid error in Transient Mark mode
1701 ;; on account of mark's being inactive.
1702 (mark-even-if-inactive t
))
1703 (cond (mail-citation-hook
1704 ;; Bind mail-citation-header to the inserted
1705 ;; message's header.
1706 (let ((mail-citation-header
1707 (buffer-substring-no-properties
1711 (narrow-to-region start
(point-max))
1715 (run-hooks 'mail-citation-hook
)))
1717 (run-hooks 'mail-yank-hooks
))
1719 (mail-indent-citation)))))
1720 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
1721 ;; It is cleaner to avoid activation, even though the command
1722 ;; loop would deactivate the mark because we inserted text.
1723 (goto-char (prog1 (mark t
)
1724 (set-marker (mark-marker) (point) (current-buffer))))
1725 (if (not (eolp)) (insert ?
\n)))))
1727 (defun mail-yank-clear-headers (start end
)
1730 (setq temp start start end end temp
)))
1731 (if mail-yank-ignored-headers
1734 (if (search-forward "\n\n" end t
)
1736 (narrow-to-region start
(point))
1738 (while (let ((case-fold-search t
))
1739 (re-search-forward mail-yank-ignored-headers nil t
))
1741 (delete-region (point)
1742 (progn (re-search-forward "\n[^ \t]")
1746 (defun mail-yank-region (arg)
1747 "Insert the selected region from the message being replied to.
1748 Puts point after the text and mark before.
1749 Normally, indents each nonblank line ARG spaces (default 3).
1750 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
1752 Just \\[universal-argument] as argument means don't indent, insert no prefix,
1753 and don't delete any header fields."
1755 (and (consp mail-reply-action
)
1756 (memq (car mail-reply-action
)
1757 '(rmail-yank-current-message insert-buffer
))
1758 (with-current-buffer (nth 1 mail-reply-action
)
1760 (error "No mark set: %S" (current-buffer))))
1761 (let ((buffer (nth 1 mail-reply-action
))
1763 ;; Avoid error in Transient Mark mode
1764 ;; on account of mark's being inactive.
1765 (mark-even-if-inactive t
))
1766 ;; Insert the citation text.
1767 (insert (with-current-buffer buffer
1768 (buffer-substring-no-properties (point) (mark))))
1770 ;; Indent or otherwise annotate the citation text.
1773 (let ((mail-indentation-spaces (if arg
(prefix-numeric-value arg
)
1774 mail-indentation-spaces
)))
1775 (if mail-citation-hook
1776 ;; Bind mail-citation-header to the original message's header.
1777 (let ((mail-citation-header
1778 (with-current-buffer buffer
1779 (buffer-substring-no-properties
1782 (goto-char (point-min))
1785 (run-hooks 'mail-citation-hook
))
1787 (run-hooks 'mail-yank-hooks
)
1788 (mail-indent-citation))))))))
1790 (defun mail-split-line ()
1791 "Split current line, moving portion beyond point vertically down.
1792 If the current line has `mail-yank-prefix', insert it on the new line."
1794 (split-line mail-yank-prefix
))
1797 (defun mail-insert-file (&optional file
)
1798 "Insert a file at the end of the buffer, with separator lines around it."
1799 (interactive "fAttach file: ")
1801 (goto-char (point-max))
1802 (or (bolp) (newline))
1804 (let ((start (point))
1806 (insert (format "===File %s===" file
))
1807 (insert-char ?
= (max 0 (- 60 (current-column))))
1809 (setq middle
(point))
1810 (insert "============================================================\n")
1813 (insert-file-contents file
)
1814 (or (bolp) (newline))
1815 (goto-char start
))))
1817 (define-obsolete-function-alias 'mail-attach-file
'mail-insert-file
"24.1")
1819 (declare-function mml-attach-file
"mml"
1820 (file &optional type description disposition
))
1821 (declare-function mm-default-file-encoding
"mm-encode" (file))
1823 (defun mail-add-attachment (file)
1824 "Add FILE as a MIME attachment to the end of the mail message being composed."
1825 (interactive "fAttach file: ")
1826 (mml-attach-file file
1827 (or (mm-default-file-encoding file
)
1828 "application/octet-stream") nil
)
1829 (setq mail-encode-mml t
))
1832 ;; Put these commands last, to reduce chance of lossage from quitting
1833 ;; in middle of loading the file.
1836 (defun mail (&optional noerase to subject in-reply-to cc replybuffer
1837 actions return-action
)
1838 "Edit a message to be sent. Prefix arg means resume editing (don't erase).
1839 When this function returns, the buffer `*mail*' is selected.
1840 The value is t if the message was newly initialized; otherwise, nil.
1842 Optionally, the signature file `mail-signature-file' can be inserted at the
1843 end; see the variable `mail-signature'.
1846 While editing message, type \\[mail-send-and-exit] to send the message and exit.
1848 Various special commands starting with C-c are available in sendmail mode
1849 to move to message header fields:
1852 If `mail-self-blind' is non-nil, a BCC to yourself is inserted
1853 when the message is initialized.
1855 If `mail-default-reply-to' is non-nil, it should be an address (a string);
1856 a Reply-to: field with that address is inserted.
1858 If `mail-archive-file-name' is non-nil, an FCC field with that file name
1861 The normal hook `mail-setup-hook' is run after the message is
1862 initialized. It can add more default fields to the message.
1864 The first argument, NOERASE, determines what to do when there is
1865 an existing modified `*mail*' buffer. If NOERASE is nil, the
1866 existing mail buffer is used, and the user is prompted whether to
1867 keep the old contents or to erase them. If NOERASE has the value
1868 `new', a new mail buffer will be created instead of using the old
1869 one. Any other non-nil value means to always select the old
1870 buffer without erasing the contents.
1872 The second through fifth arguments,
1873 TO, SUBJECT, IN-REPLY-TO and CC, specify if non-nil
1874 the initial contents of those header fields.
1875 These arguments should not have final newlines.
1876 The sixth argument REPLYBUFFER is a buffer which contains an
1877 original message being replied to, or else an action
1878 of the form (FUNCTION . ARGS) which says how to insert the original.
1879 Or it can be nil, if not replying to anything.
1880 The seventh argument ACTIONS is a list of actions to take
1881 if/when the message is sent. Each action looks like (FUNCTION . ARGS);
1882 when the message is sent, we apply FUNCTION to ARGS.
1883 This is how Rmail arranges to mark messages `answered'."
1885 (if (eq noerase
'new
)
1886 (pop-to-buffer-same-window (generate-new-buffer "*mail*"))
1888 (not (get-buffer "*mail*"))
1890 (pop-to-buffer-same-window "*mail*"))
1892 ;; Avoid danger that the auto-save file can't be written.
1893 (let ((dir (expand-file-name
1894 (file-name-as-directory mail-default-directory
))))
1895 (if (file-exists-p dir
)
1896 (setq default-directory dir
)))
1897 ;; Only call auto-save-mode if necessary, to avoid changing auto-save file.
1898 (if (or (and auto-save-default
(not buffer-auto-save-file-name
))
1899 (and (not auto-save-default
) buffer-auto-save-file-name
))
1900 (auto-save-mode auto-save-default
))
1902 ;; Disconnect the buffer from its visited file
1903 ;; (in case the user has actually visited a file *mail*).
1904 ;; (set-visited-file-name nil)
1906 (and (not (and noerase
1907 (not (eq noerase
'new
))))
1908 (if buffer-file-name
1909 (if (buffer-modified-p)
1910 (when (y-or-n-p "Buffer has unsaved changes; reinitialize it and discard them? ")
1911 (if (y-or-n-p "Disconnect buffer from visited file? ")
1912 (set-visited-file-name nil
))
1914 (when (y-or-n-p "Reinitialize buffer, and disconnect it from the visited file? ")
1915 (set-visited-file-name nil
)
1917 ;; A non-file-visiting buffer.
1918 (if (buffer-modified-p)
1919 (y-or-n-p "Unsent message being composed; erase it? ")
1921 (let ((inhibit-read-only t
))
1923 (mail-setup to subject in-reply-to cc replybuffer actions
1925 (setq initialized t
)))
1926 (if (and buffer-auto-save-file-name
1927 (file-exists-p buffer-auto-save-file-name
))
1928 (message "Auto save file for draft message exists; consider M-x mail-recover"))
1931 (declare-function dired-view-file
"dired" ())
1932 (declare-function dired-get-filename
"dired" (&optional localp no-error-if-not-filep
))
1934 (defun mail-recover-1 ()
1935 "Pop up a list of auto-saved draft messages so you can recover one of them."
1937 (let ((file-name (make-auto-save-file-name))
1938 (ls-lisp-support-shell-wildcards t
)
1939 non-random-len wildcard
)
1940 ;; Remove the random part from the auto-save-file-name, and
1941 ;; create a wildcard which matches possible candidates.
1942 ;; Note: this knows that make-auto-save-file-name appends
1943 ;; "#<RANDOM-STUFF>#" to the buffer name, where RANDOM-STUFF
1944 ;; is the result of (make-temp-name "").
1945 (setq non-random-len
1946 (- (length file-name
) (length (make-temp-name "")) 1))
1947 (setq wildcard
(concat (substring file-name
0 non-random-len
) "*"))
1948 (if (null (file-expand-wildcards wildcard
))
1949 (message "There are no auto-saved drafts to recover")
1950 ;; Bind dired-trivial-filenames to t because all auto-save file
1951 ;; names are normally ``trivial'', so Dired will set point after
1952 ;; all the files, at buffer bottom. We want it on the first
1954 ;; Require dired so that dired-trivial-filenames does not get
1955 ;; unbound on exit from the let.
1957 (let ((dired-trivial-filenames t
))
1958 (dired-other-window wildcard
(concat dired-listing-switches
" -t")))
1959 (rename-buffer "*Auto-saved Drafts*" t
)
1961 (goto-char (point-min))
1962 (or (looking-at " Move to the draft file you want to recover,")
1963 (let ((inhibit-read-only t
))
1964 ;; Each line starts with a space so that Font Lock mode
1965 ;; won't highlight the first character.
1967 Move to the draft file you want to recover, then type C-c C-c
1968 to recover text of message whose composition was interrupted.
1969 To browse text of a draft, type v on the draft file's line.
1971 You can also delete some of these files;
1972 type d on a line to mark that file for deletion.
1974 List of possible auto-save files for recovery:
1978 (let ((map (make-sparse-keymap)))
1979 (set-keymap-parent map
(current-local-map))
1981 (define-key (current-local-map) "v"
1984 (let ((coding-system-for-read 'utf-8-emacs-unix
))
1985 (dired-view-file))))
1986 (define-key (current-local-map) "\C-c\C-c"
1989 (let ((fname (dired-get-filename))
1990 ;; Auto-saved files are written in the internal
1991 ;; representation, so they should be read accordingly.
1992 (coding-system-for-read 'utf-8-emacs-unix
))
1993 (switch-to-buffer-other-window "*mail*")
1994 (let ((buffer-read-only nil
))
1996 (insert-file-contents fname nil
)
1997 ;; insert-file-contents will set buffer-file-coding-system
1998 ;; to utf-8-emacs, which is probably not what they want to
1999 ;; use for sending the message. But we don't know what
2000 ;; was its value before the buffer was killed or Emacs
2001 ;; crashed. We therefore reset buffer-file-coding-system
2002 ;; to the default value, so that either the default does
2003 ;; TRT, or the user will get prompted for the right
2004 ;; encoding when they send the message.
2005 (setq buffer-file-coding-system
2006 (default-value 'buffer-file-coding-system
)))))))))
2008 (declare-function dired-move-to-filename
"dired" (&optional raise-error eol
))
2009 (declare-function dired-get-filename
"dired" (&optional localp no-error-if-not-filep
))
2010 (declare-function dired-view-file
"dired" ())
2012 (defun mail-recover ()
2013 "Recover interrupted mail composition from auto-save files.
2015 If the mail buffer has a current valid auto-save file,
2016 the command recovers that file. Otherwise, it displays a
2017 buffer showing the existing auto-saved draft messages;
2018 you can move to one of them and type C-c C-c to recover that one."
2020 ;; In case they invoke us from some random buffer...
2021 (switch-to-buffer "*mail*")
2022 ;; If *mail* didn't exist, set its directory, so that auto-saved
2023 ;; drafts will be found.
2024 (let ((dir (expand-file-name
2025 (file-name-as-directory mail-default-directory
))))
2026 (if (file-exists-p dir
)
2027 (setq default-directory dir
)))
2028 (or (eq major-mode
'mail-mode
)
2030 (let ((file-name buffer-auto-save-file-name
))
2031 (cond ((and file-name
(file-exists-p file-name
))
2033 ;; This used to invoke `ls' via call-process, but
2034 ;; dired-noselect is more portable to systems where
2035 ;; `ls' is not a standard program (it will use
2036 ;; ls-lisp instead).
2037 (dired-noselect file-name
2038 (concat dired-listing-switches
" -t"))))
2039 (save-selected-window
2040 (switch-to-buffer-other-window dispbuf
)
2041 (goto-char (point-min))
2043 (dired-move-to-filename)
2044 (setq dispbuf
(rename-buffer "*Directory*" t
)))
2045 (if (not (yes-or-no-p
2046 (format "Recover mail draft from auto save file %s? "
2048 (error "mail-recover canceled")
2049 (let ((buffer-read-only nil
)
2050 (buffer-coding buffer-file-coding-system
)
2051 ;; Auto-save files are written in internal
2052 ;; representation of non-ASCII characters.
2053 (coding-system-for-read 'utf-8-emacs-unix
))
2055 (insert-file-contents file-name nil
)
2056 (setq buffer-file-coding-system buffer-coding
)))))
2057 (t (mail-recover-1)))))
2060 (defun mail-other-window (&optional noerase to subject in-reply-to cc replybuffer sendactions
)
2061 "Like `mail' command, but display mail buffer in another window."
2063 (switch-to-buffer-other-window "*mail*")
2064 (mail noerase to subject in-reply-to cc replybuffer sendactions
))
2067 (defun mail-other-frame (&optional noerase to subject in-reply-to cc replybuffer sendactions
)
2068 "Like `mail' command, but display mail buffer in another frame."
2070 (switch-to-buffer-other-frame "*mail*")
2071 (mail noerase to subject in-reply-to cc replybuffer sendactions
))
2073 ;; Do not add anything but external entries on this page.
2078 ;; byte-compile-dynamic: t
2082 ;;; sendmail.el ends here