Mercurial > emacs
annotate lisp/mail/sendmail.el @ 1857:9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
(Fset_text_properties, Fremove_text_properties): Likewise.
(Fnext_single_property_change, Fprevious_single_property_change):
(Fnext_property_change, Fprevious_property_change): Likewise.
(Ferase_text_properties): #if 0.
(Fget_text_property): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 13 Feb 1993 21:56:10 +0000 |
parents | 2d5caf3fd862 |
children | 9e7ec92a4fdf |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
604
diff
changeset
|
1 ;;; sendmail.el --- mail sending commands for Emacs. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
604
diff
changeset
|
2 |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
825
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc. |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
825
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
7 |
455 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
455 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
24 ;;; Code: |
455 | 25 |
26 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
27 (defvar mail-self-blind nil "\ |
455 | 28 Non-nil means insert BCC to self in messages to be sent. |
29 This is done when the message is initialized, | |
30 so you can remove or alter the BCC field to override the default.") | |
31 | |
32 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
33 (defvar mail-interactive nil "\ |
455 | 34 Non-nil means when sending a message wait for and display errors. |
35 nil means let mailer mail back a message to report errors.") | |
36 | |
37 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
38 (defvar mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:" "\ |
455 | 39 Delete these headers from old message when it's inserted in a reply.") |
40 | |
41 ;; Useful to set in site-init.el | |
42 ;;;###autoload | |
43 (defconst send-mail-function 'sendmail-send-it "\ | |
44 Function to call to send the current buffer as mail. | |
1539 | 45 The headers are be delimited by a line which is `mail-header-separator'.") |
455 | 46 |
47 ;;;###autoload | |
48 (defvar mail-header-separator "--text follows this line--" "\ | |
49 *Line used to separate headers from text in messages being composed.") | |
50 | |
51 ;;;###autoload | |
52 (defvar mail-archive-file-name nil "\ | |
53 *Name of file to write all outgoing messages in, or nil for none. | |
54 Do not use an rmail file here! Instead, use its inbox file.") | |
55 | |
56 (defvar mail-default-reply-to nil | |
57 "*Address to insert as default Reply-to field of outgoing messages.") | |
58 | |
59 (defvar mail-alias-file nil | |
60 "*If non-nil, the name of a file to use instead of `/usr/lib/aliases'. | |
61 This file defines aliases to be expanded by the mailer; this is a different | |
62 feature from that of defining aliases in `.mailrc' to be expanded in Emacs. | |
63 This variable has no effect unless your system uses sendmail as its mailer.") | |
64 | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
65 (defvar mail-aliases t |
1468
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
66 "Alist of mail address aliases, |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
67 or t meaning should be initialized from `~/.mailrc'. |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
68 The alias definitions in `~/.mailrc' have this form: |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
69 alias ALIAS MEANING") |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
70 |
455 | 71 (defvar mail-yank-prefix nil |
72 "*Prefix insert on lines of yanked message being replied to. | |
73 nil means use indentation.") | |
74 | |
75 (defvar mail-abbrevs-loaded nil) | |
76 (defvar mail-mode-map nil) | |
77 | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
78 (autoload 'build-mail-aliases "mailalias" |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
79 "Read mail aliases from `~/.mailrc' and set `mail-aliases'." |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
80 nil) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
81 |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
82 (autoload 'expand-mail-aliases "mailalias" |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
83 "Expand all mail aliases in suitable header fields found between BEG and END. |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
84 Suitable header fields are `To', `Cc' and `Bcc' and their `Resent-' variants. |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
85 Optional second arg EXCLUDE may be a regular expression defining text to be |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
86 removed from alias expansions." |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
87 nil) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
88 |
999 | 89 ;;;###autoload |
1025 | 90 (defvar mail-signature nil |
91 "*Text inserted at end of mail buffer when a message is initialized. | |
92 If t, it means to insert the contents of the file `~/.signature'.") | |
455 | 93 |
94 (defvar mail-reply-buffer nil) | |
95 (defvar mail-send-actions nil | |
96 "A list of actions to be performed upon successful sending of a message.") | |
97 | |
98 (defvar mail-default-headers nil | |
99 "*A string containing header lines, to be inserted in outgoing messages. | |
100 It is inserted before you edit the message, | |
101 so you can edit or delete these lines.") | |
102 | |
103 (defvar mail-mode-syntax-table nil | |
104 "Syntax table used while in mail mode.") | |
105 | |
106 (if (null mail-mode-syntax-table) | |
107 (progn | |
108 (setq mail-mode-syntax-table (copy-syntax-table text-mode-syntax-table)) | |
109 (modify-syntax-entry ?% ". " mail-mode-syntax-table))) | |
110 | |
111 (defun mail-setup (to subject in-reply-to cc replybuffer actions) | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
112 (if (eq mail-aliases t) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
113 (progn |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
114 (setq mail-aliases nil) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
115 (if (file-exists-p "~/.mailrc") |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
116 (build-mail-aliases)))) |
455 | 117 (setq mail-send-actions actions) |
118 (setq mail-reply-buffer replybuffer) | |
119 (goto-char (point-min)) | |
120 (insert "To: ") | |
121 (save-excursion | |
122 (if to | |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
123 ;; Here removed code to extract names from within <...> |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
124 ;; on the assumption that mail-strip-quoted-names |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
125 ;; has been called and has done so. |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
126 (let ((fill-prefix "\t") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
127 (address-start (point))) |
455 | 128 (insert to "\n") |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
129 (fill-region-as-paragraph address-start (point-max))) |
455 | 130 (newline)) |
131 (if cc | |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
132 (let ((fill-prefix "\t") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
133 (address-start (progn (insert "CC: ") (point)))) |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
134 (insert cc "\n") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
135 (fill-region-as-paragraph address-start (point-max)))) |
455 | 136 (if in-reply-to |
137 (insert "In-reply-to: " in-reply-to "\n")) | |
138 (insert "Subject: " (or subject "") "\n") | |
139 (if mail-default-headers | |
140 (insert mail-default-headers)) | |
141 (if mail-default-reply-to | |
142 (insert "Reply-to: " mail-default-reply-to "\n")) | |
143 (if mail-self-blind | |
144 (insert "BCC: " (user-login-name) "\n")) | |
145 (if mail-archive-file-name | |
146 (insert "FCC: " mail-archive-file-name "\n")) | |
1024
ceb4469d3cd7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
999
diff
changeset
|
147 (insert mail-header-separator "\n") |
1025 | 148 ;; Insert the signature. |
149 (cond ((eq mail-signature t) | |
150 (if (file-exists-p "~/.signature") | |
151 (progn | |
152 (insert "--\n") | |
153 (insert-file-contents "~/.signature")))) | |
154 (mail-signature | |
155 (insert mail-signature))) | |
455 | 156 (goto-char (point-max)) |
157 (or (bolp) (newline))) | |
158 (if to (goto-char (point-max))) | |
159 (or to subject in-reply-to | |
160 (set-buffer-modified-p nil)) | |
161 (run-hooks 'mail-setup-hook)) | |
162 | |
163 ;;;###autoload | |
164 (defun mail-mode () | |
165 "Major mode for editing mail to be sent. | |
166 Like Text Mode but with these additional commands: | |
167 C-c C-s mail-send (send the message) C-c C-c mail-send-and-exit | |
168 C-c C-f move to a header field (and create it if there isn't): | |
169 C-c C-f C-t move to To: C-c C-f C-s move to Subj: | |
170 C-c C-f C-b move to BCC: C-c C-f C-c move to CC: | |
171 C-c C-t move to message text. | |
172 C-c C-y mail-yank-original (insert current message, in Rmail). | |
173 C-c C-q mail-fill-yanked-message (fill what was yanked). | |
174 C-c C-v mail-sent-via (add a sent-via field for each To or CC)." | |
175 (interactive) | |
176 (kill-all-local-variables) | |
177 (make-local-variable 'mail-reply-buffer) | |
178 (setq mail-reply-buffer nil) | |
179 (make-local-variable 'mail-send-actions) | |
180 (set-syntax-table mail-mode-syntax-table) | |
181 (use-local-map mail-mode-map) | |
182 (setq local-abbrev-table text-mode-abbrev-table) | |
183 (setq major-mode 'mail-mode) | |
184 (setq mode-name "Mail") | |
185 (setq buffer-offer-save t) | |
186 (make-local-variable 'paragraph-separate) | |
187 (make-local-variable 'paragraph-start) | |
188 (setq paragraph-start (concat "^" mail-header-separator | |
189 "$\\|^[ \t]*[-_][-_][-_]+$\\|" | |
190 paragraph-start)) | |
191 (setq paragraph-separate (concat "^" mail-header-separator | |
192 "$\\|^[ \t]*[-_][-_][-_]+$\\|" | |
193 paragraph-separate)) | |
194 (run-hooks 'text-mode-hook 'mail-mode-hook)) | |
195 | |
196 (if mail-mode-map | |
197 nil | |
198 (setq mail-mode-map (nconc (make-sparse-keymap) text-mode-map)) | |
199 (define-key mail-mode-map "\C-c?" 'describe-mode) | |
200 (define-key mail-mode-map "\C-c\C-f\C-t" 'mail-to) | |
201 (define-key mail-mode-map "\C-c\C-f\C-b" 'mail-bcc) | |
573 | 202 (define-key mail-mode-map "\C-c\C-f\C-f" 'mail-fcc) |
455 | 203 (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc) |
204 (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject) | |
205 (define-key mail-mode-map "\C-c\C-t" 'mail-text) | |
206 (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original) | |
207 (define-key mail-mode-map "\C-c\C-q" 'mail-fill-yanked-message) | |
208 (define-key mail-mode-map "\C-c\C-w" 'mail-signature) | |
209 (define-key mail-mode-map "\C-c\C-v" 'mail-sent-via) | |
210 (define-key mail-mode-map "\C-c\C-c" 'mail-send-and-exit) | |
211 (define-key mail-mode-map "\C-c\C-s" 'mail-send)) | |
212 | |
213 (defun mail-send-and-exit (arg) | |
1539 | 214 "Send message like `mail-send', then, if no errors, exit from mail buffer. |
455 | 215 Prefix arg means don't delete this window." |
216 (interactive "P") | |
217 (mail-send) | |
1269
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
218 (let ((newbuf (other-buffer (current-buffer)))) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
219 (bury-buffer (current-buffer)) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
220 (if (and (not arg) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
221 (not (one-window-p)) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
222 (save-excursion |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
223 (set-buffer (window-buffer (next-window (selected-window) 'not))) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
224 (eq major-mode 'rmail-mode))) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
225 (delete-window) |
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
226 (switch-to-buffer newbuf)))) |
455 | 227 |
228 (defun mail-send () | |
229 "Send the message in the current buffer. | |
230 If `mail-interactive' is non-nil, wait for success indication | |
231 or error messages, and inform user. | |
232 Otherwise any failure is reported in a message back to | |
233 the user from the mailer." | |
234 (interactive) | |
235 (if (or (buffer-modified-p) | |
236 (y-or-n-p "Message already sent; resend? ")) | |
237 (progn | |
238 (message "Sending...") | |
239 (run-hooks 'mail-send-hook) | |
240 (funcall send-mail-function) | |
241 ;; Now perform actions on successful sending. | |
242 (while mail-send-actions | |
243 (condition-case nil | |
1741
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
244 (apply (car (car mail-send-actions)) |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
245 (cdr (car mail-send-actions))) |
455 | 246 (error)) |
247 (setq mail-send-actions (cdr mail-send-actions))) | |
1741
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
248 (message "Sending...done") |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
249 ;; If buffer has no file, mark it as unmodified and delete autosave. |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
250 (if (not buffer-file-name) |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
251 (progn |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
252 (set-buffer-modified-p nil) |
bc25cbeb27c0
(mail-send): Don't clear modified or delete autosave if visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
1705
diff
changeset
|
253 (delete-auto-save-file-if-necessary t)))))) |
455 | 254 |
255 (defun sendmail-send-it () | |
256 (let ((errbuf (if mail-interactive | |
257 (generate-new-buffer " sendmail errors") | |
258 0)) | |
259 (tembuf (generate-new-buffer " sendmail temp")) | |
260 (case-fold-search nil) | |
261 delimline | |
262 (mailbuf (current-buffer))) | |
263 (unwind-protect | |
264 (save-excursion | |
265 (set-buffer tembuf) | |
266 (erase-buffer) | |
267 (insert-buffer-substring mailbuf) | |
268 (goto-char (point-max)) | |
269 ;; require one newline at the end. | |
270 (or (= (preceding-char) ?\n) | |
271 (insert ?\n)) | |
272 ;; Change header-delimiter to be what sendmail expects. | |
273 (goto-char (point-min)) | |
274 (re-search-forward | |
275 (concat "^" (regexp-quote mail-header-separator) "\n")) | |
276 (replace-match "\n") | |
277 (backward-char 1) | |
278 (setq delimline (point-marker)) | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
279 (if mail-aliases |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
280 (expand-mail-aliases (point-min) delimline)) |
455 | 281 (goto-char (point-min)) |
282 ;; ignore any blank lines in the header | |
283 (while (and (re-search-forward "\n\n\n*" delimline t) | |
284 (< (point) delimline)) | |
285 (replace-match "\n")) | |
286 (let ((case-fold-search t)) | |
287 (goto-char (point-min)) | |
288 (if (re-search-forward "^Sender:" delimline t) | |
289 (error "Sender may not be specified.")) | |
290 ;; Find and handle any FCC fields. | |
291 (goto-char (point-min)) | |
292 (if (re-search-forward "^FCC:" delimline t) | |
293 (mail-do-fcc delimline)) | |
294 ;; If the From is different than current user, insert Sender. | |
295 (goto-char (point-min)) | |
296 (and (re-search-forward "^From:" delimline t) | |
297 (progn | |
298 (require 'mail-utils) | |
299 (not (string-equal | |
300 (mail-strip-quoted-names | |
301 (save-restriction | |
302 (narrow-to-region (point-min) delimline) | |
303 (mail-fetch-field "From"))) | |
304 (user-login-name)))) | |
305 (progn | |
306 (forward-line 1) | |
307 (insert "Sender: " (user-login-name) "\n"))) | |
308 ;; "S:" is an abbreviation for "Subject:". | |
309 (goto-char (point-min)) | |
310 (if (re-search-forward "^S:" delimline t) | |
311 (replace-match "Subject:")) | |
312 ;; Don't send out a blank subject line | |
313 (goto-char (point-min)) | |
314 (if (re-search-forward "^Subject:[ \t]*\n" delimline t) | |
315 (replace-match "")) | |
316 (if mail-interactive | |
317 (save-excursion | |
318 (set-buffer errbuf) | |
319 (erase-buffer)))) | |
320 (apply 'call-process-region | |
321 (append (list (point-min) (point-max) | |
322 (if (boundp 'sendmail-program) | |
323 sendmail-program | |
324 "/usr/lib/sendmail") | |
325 nil errbuf nil | |
326 "-oi" "-t") | |
327 ;; Always specify who from, | |
328 ;; since some systems have broken sendmails. | |
329 (list "-f" (user-login-name)) | |
330 ;;; ;; Don't say "from root" if running under su. | |
331 ;;; (and (equal (user-real-login-name) "root") | |
332 ;;; (list "-f" (user-login-name))) | |
333 (and mail-alias-file | |
334 (list (concat "-oA" mail-alias-file))) | |
335 ;; These mean "report errors by mail" | |
336 ;; and "deliver in background". | |
337 (if (null mail-interactive) '("-oem" "-odb")))) | |
338 (if mail-interactive | |
339 (save-excursion | |
340 (set-buffer errbuf) | |
341 (goto-char (point-min)) | |
342 (while (re-search-forward "\n\n* *" nil t) | |
343 (replace-match "; ")) | |
344 (if (not (zerop (buffer-size))) | |
345 (error "Sending...failed to %s" | |
346 (buffer-substring (point-min) (point-max))))))) | |
347 (kill-buffer tembuf) | |
348 (if (bufferp errbuf) | |
349 (kill-buffer errbuf))))) | |
350 | |
351 (defun mail-do-fcc (header-end) | |
352 (let (fcc-list | |
353 (rmailbuf (current-buffer)) | |
1075 | 354 timezone |
455 | 355 (tembuf (generate-new-buffer " rmail output")) |
356 (case-fold-search t)) | |
357 (save-excursion | |
358 (goto-char (point-min)) | |
359 (while (re-search-forward "^FCC:[ \t]*" header-end t) | |
360 (setq fcc-list (cons (buffer-substring (point) | |
361 (progn | |
362 (end-of-line) | |
363 (skip-chars-backward " \t") | |
364 (point))) | |
365 fcc-list)) | |
366 (delete-region (match-beginning 0) | |
367 (progn (forward-line 1) (point)))) | |
368 (set-buffer tembuf) | |
369 (erase-buffer) | |
1075 | 370 (call-process "date" nil t nil) |
371 (goto-char (point-min)) | |
372 (re-search-forward | |
1835
0aa8e261f174
(mail-do-fcc): Allow dash in timezone name.
Richard M. Stallman <rms@gnu.org>
parents:
1741
diff
changeset
|
373 "[0-9] \\([A-Za-z][-A-Za-z ]*[A-Za-z]\\)[0-9 ]*$") |
1075 | 374 (setq timezone (buffer-substring (match-beginning 1) (match-end 1))) |
375 (erase-buffer) | |
455 | 376 (insert "\nFrom " (user-login-name) " " |
377 (current-time-string) "\n") | |
1075 | 378 ;; Insert the time zone before the year. |
379 (forward-char -1) | |
380 (forward-word -1) | |
381 (insert timezone " ") | |
382 (goto-char (point-max)) | |
455 | 383 (insert-buffer-substring rmailbuf) |
384 ;; Make sure messages are separated. | |
385 (goto-char (point-max)) | |
386 (insert ?\n) | |
387 (goto-char 2) | |
388 ;; ``Quote'' "^From " as ">From " | |
389 ;; (note that this isn't really quoting, as there is no requirement | |
390 ;; that "^[>]+From " be quoted in the same transparent way.) | |
391 (let ((case-fold-search nil)) | |
392 (while (search-forward "\nFrom " nil t) | |
393 (forward-char -5) | |
394 (insert ?>))) | |
395 (while fcc-list | |
396 (let ((buffer (get-file-buffer (car fcc-list)))) | |
397 (if buffer | |
398 ;; File is present in a buffer => append to that buffer. | |
399 (let ((curbuf (current-buffer)) | |
400 (beg (point-min)) (end (point-max))) | |
401 (save-excursion | |
402 (set-buffer buffer) | |
403 ;; Keep the end of the accessible portion at the same place | |
404 ;; unless it is the end of the buffer. | |
405 (let ((max (if (/= (1+ (buffer-size)) (point-max)) | |
406 (point-max)))) | |
407 (unwind-protect | |
408 (progn | |
409 (narrow-to-region (point-min) (1+ (buffer-size))) | |
410 (goto-char (point-max)) | |
411 (if (eq major-mode 'rmail-mode) | |
412 ;; Append as a message to an RMAIL file | |
413 (let ((buffer-read-only nil)) | |
414 ;; This forces RMAIL's message counters to be | |
415 ;; recomputed when the next RMAIL operation is | |
416 ;; done on the buffer. | |
417 ;; See rmail-maybe-set-message-counters. | |
418 (setq rmail-total-messages nil) | |
419 (insert "\C-l\n0, unseen,,\n*** EOOH ***\n" | |
420 "From: " (user-login-name) "\n" | |
421 "Date: " (current-time-string) "\n") | |
422 (insert-buffer-substring curbuf beg end) | |
746
1b0748ff6f65
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
705
diff
changeset
|
423 (insert "\n\C-_") |
1b0748ff6f65
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
705
diff
changeset
|
424 (rmail-set-message-counters)) |
455 | 425 (insert-buffer-substring curbuf beg end))) |
426 (if max (narrow-to-region (point-min) max)))))) | |
427 ;; Else append to the file directly. | |
428 (write-region | |
429 ;; Include a blank line before if file already exists. | |
430 (if (file-exists-p (car fcc-list)) (point-min) (1+ (point-min))) | |
431 (point-max) (car fcc-list) t))) | |
432 (setq fcc-list (cdr fcc-list)))) | |
433 (kill-buffer tembuf))) | |
434 | |
435 (defun mail-sent-via () | |
436 "Make a Sent-via header line from each To or CC header line." | |
437 (interactive) | |
438 (save-excursion | |
439 (goto-char (point-min)) | |
440 ;; find the header-separator | |
441 (search-forward (concat "\n" mail-header-separator "\n")) | |
442 (forward-line -1) | |
443 ;; put a marker at the end of the header | |
444 (let ((end (point-marker)) | |
445 (case-fold-search t) | |
446 to-line) | |
447 (goto-char (point-min)) | |
448 ;; search for the To: lines and make Sent-via: lines from them | |
449 ;; search for the next To: line | |
450 (while (re-search-forward "^\\(to\\|cc\\):" end t) | |
451 ;; Grab this line plus all its continuations, sans the `to:'. | |
452 (let ((to-line | |
453 (buffer-substring (point) | |
454 (progn | |
455 (if (re-search-forward "^[^ \t\n]" end t) | |
456 (backward-char 1) | |
457 (goto-char end)) | |
458 (point))))) | |
459 ;; Insert a copy, with altered header field name. | |
460 (insert-before-markers "Sent-via:" to-line)))))) | |
461 | |
462 (defun mail-to () | |
463 "Move point to end of To-field." | |
464 (interactive) | |
465 (expand-abbrev) | |
466 (mail-position-on-field "To")) | |
467 | |
468 (defun mail-subject () | |
469 "Move point to end of Subject-field." | |
470 (interactive) | |
471 (expand-abbrev) | |
472 (mail-position-on-field "Subject")) | |
473 | |
474 (defun mail-cc () | |
475 "Move point to end of CC-field. Create a CC field if none." | |
476 (interactive) | |
477 (expand-abbrev) | |
478 (or (mail-position-on-field "cc" t) | |
479 (progn (mail-position-on-field "to") | |
480 (insert "\nCC: ")))) | |
481 | |
482 (defun mail-bcc () | |
483 "Move point to end of BCC-field. Create a BCC field if none." | |
484 (interactive) | |
485 (expand-abbrev) | |
486 (or (mail-position-on-field "bcc" t) | |
487 (progn (mail-position-on-field "to") | |
488 (insert "\nBCC: ")))) | |
489 | |
573 | 490 (defun mail-fcc () |
491 "Add a new FCC field, with file name completion." | |
492 (interactive) | |
493 (expand-abbrev) | |
494 (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC. | |
495 (mail-position-on-field "to")) | |
496 (insert "\nFCC: " (read-file-name "Folder carbon copy: "))) | |
497 | |
455 | 498 (defun mail-position-on-field (field &optional soft) |
499 (let (end | |
500 (case-fold-search t)) | |
501 (goto-char (point-min)) | |
604 | 502 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n")) |
455 | 503 (setq end (match-beginning 0)) |
504 (goto-char (point-min)) | |
505 (if (re-search-forward (concat "^" (regexp-quote field) ":") end t) | |
506 (progn | |
507 (re-search-forward "^[^ \t]" nil 'move) | |
508 (beginning-of-line) | |
509 (skip-chars-backward "\n") | |
510 t) | |
511 (or soft | |
512 (progn (goto-char end) | |
604 | 513 (insert field ": \n") |
514 (skip-chars-backward "\n"))) | |
455 | 515 nil))) |
516 | |
517 (defun mail-text () | |
518 "Move point to beginning of text field." | |
519 (interactive) | |
520 (goto-char (point-min)) | |
521 (search-forward (concat "\n" mail-header-separator "\n"))) | |
522 | |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
523 (defun mail-signature (atpoint) |
1539 | 524 "Sign letter with contents of `mail-signature-file'." |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
525 (interactive "P") |
455 | 526 (save-excursion |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
527 (or atpoint |
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
528 (goto-char (point-max))) |
455 | 529 (skip-chars-backward " \t\n") |
530 (end-of-line) | |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
531 (or atpoint |
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
532 (delete-region (point) (point-max))) |
455 | 533 (insert "\n\n--\n") |
1025 | 534 (insert-file-contents (expand-file-name "~/.signature")))) |
455 | 535 |
536 (defun mail-fill-yanked-message (&optional justifyp) | |
537 "Fill the paragraphs of a message yanked into this one. | |
538 Numeric argument means justify as well." | |
539 (interactive "P") | |
540 (save-excursion | |
541 (goto-char (point-min)) | |
542 (search-forward (concat "\n" mail-header-separator "\n") nil t) | |
543 (fill-individual-paragraphs (point) | |
544 (point-max) | |
545 justifyp | |
546 t))) | |
547 | |
548 (defun mail-yank-original (arg) | |
549 "Insert the message being replied to, if any (in rmail). | |
550 Puts point before the text and mark after. | |
551 Normally, indents each nonblank line ARG spaces (default 3). | |
552 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line. | |
553 | |
554 Just \\[universal-argument] as argument means don't indent, insert no prefix, | |
555 and don't delete any header fields." | |
556 (interactive "P") | |
557 (if mail-reply-buffer | |
558 (let ((start (point))) | |
559 (delete-windows-on mail-reply-buffer) | |
560 (insert-buffer mail-reply-buffer) | |
561 (if (consp arg) | |
562 nil | |
563 (mail-yank-clear-headers start (mark)) | |
564 (if (null mail-yank-prefix) | |
565 (indent-rigidly start (mark) | |
566 (if arg (prefix-numeric-value arg) 3)) | |
567 (save-excursion | |
568 (goto-char start) | |
569 (while (< (point) (mark)) | |
570 (insert mail-yank-prefix) | |
571 (forward-line 1))))) | |
572 (exchange-point-and-mark) | |
573 (if (not (eolp)) (insert ?\n))))) | |
574 | |
575 (defun mail-yank-clear-headers (start end) | |
576 (save-excursion | |
577 (goto-char start) | |
578 (if (search-forward "\n\n" end t) | |
579 (save-restriction | |
580 (narrow-to-region start (point)) | |
581 (goto-char start) | |
582 (while (let ((case-fold-search t)) | |
583 (re-search-forward mail-yank-ignored-headers nil t)) | |
584 (beginning-of-line) | |
585 (delete-region (point) | |
586 (progn (re-search-forward "\n[^ \t]") | |
587 (forward-char -1) | |
588 (point)))))))) | |
589 | |
590 ;; Put these last, to reduce chance of lossage from quitting in middle of loading the file. | |
591 | |
592 ;;;###autoload | |
593 (defun mail (&optional noerase to subject in-reply-to cc replybuffer actions) | |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
594 "Edit a message to be sent. Prefix arg means resume editing (don't erase). |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
595 When this function returns, the buffer `*mail*' is selected. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
596 The value is t if the message was newly initialized; otherwise, nil. |
455 | 597 |
1025 | 598 By default, the signature file `~/.signature' is inserted at the end; |
599 see the variable `mail-signature'. | |
455 | 600 |
601 \\<mail-mode-map> | |
602 While editing message, type \\[mail-send-and-exit] to send the message and exit. | |
603 | |
604 Various special commands starting with C-c are available in sendmail mode | |
605 to move to message header fields: | |
606 \\{mail-mode-map} | |
607 | |
608 If `mail-self-blind' is non-nil, a BCC to yourself is inserted | |
609 when the message is initialized. | |
610 | |
611 If `mail-default-reply-to' is non-nil, it should be an address (a string); | |
612 a Reply-to: field with that address is inserted. | |
613 | |
614 If `mail-archive-file-name' is non-nil, an FCC field with that file name | |
615 is inserted. | |
616 | |
617 If `mail-setup-hook' is bound, its value is called with no arguments | |
618 after the message is initialized. It can add more default fields. | |
619 | |
620 When calling from a program, the second through fifth arguments | |
621 TO, SUBJECT, IN-REPLY-TO and CC specify if non-nil | |
622 the initial contents of those header fields. | |
623 These arguments should not have final newlines. | |
624 The sixth argument REPLYBUFFER is a buffer whose contents | |
625 should be yanked if the user types C-c C-y. | |
626 The seventh argument ACTIONS is a list of actions to take | |
627 if/when the message is sent. Each action looks like (FUNCTION . ARGS); | |
628 when the message is sent, we apply FUNCTION to ARGS. | |
629 This is how Rmail arranges to mark messages `answered'." | |
630 (interactive "P") | |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
631 ;;; This is commented out because I found it was confusing in practice. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
632 ;;; It is easy enough to rename *mail* by hand with rename-buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
633 ;;; if you want to have multiple mail buffers. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
634 ;;; And then you can control which messages to save. --rms. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
635 ;;; (let ((index 1) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
636 ;;; buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
637 ;;; ;; If requested, look for a mail buffer that is modified and go to it. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
638 ;;; (if noerase |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
639 ;;; (progn |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
640 ;;; (while (and (setq buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
641 ;;; (get-buffer (if (= 1 index) "*mail*" |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
642 ;;; (format "*mail*<%d>" index)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
643 ;;; (not (buffer-modified-p buffer))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
644 ;;; (setq index (1+ index))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
645 ;;; (if buffer (switch-to-buffer buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
646 ;;; ;; If none exists, start a new message. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
647 ;;; ;; This will never re-use an existing unmodified mail buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
648 ;;; ;; (since index is not 1 anymore). Perhaps it should. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
649 ;;; (setq noerase nil)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
650 ;;; ;; Unless we found a modified message and are happy, start a new message. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
651 ;;; (if (not noerase) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
652 ;;; (progn |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
653 ;;; ;; Look for existing unmodified mail buffer. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
654 ;;; (while (and (setq buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
655 ;;; (get-buffer (if (= 1 index) "*mail*" |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
656 ;;; (format "*mail*<%d>" index)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
657 ;;; (buffer-modified-p buffer)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
658 ;;; (setq index (1+ index))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
659 ;;; ;; If none, make a new one. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
660 ;;; (or buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
661 ;;; (setq buffer (generate-new-buffer "*mail*"))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
662 ;;; ;; Go there and initialize it. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
663 ;;; (switch-to-buffer buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
664 ;;; (erase-buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
665 ;;; (setq default-directory (expand-file-name "~/")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
666 ;;; (auto-save-mode auto-save-default) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
667 ;;; (mail-mode) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
668 ;;; (mail-setup to subject in-reply-to cc replybuffer actions) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
669 ;;; (if (and buffer-auto-save-file-name |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
670 ;;; (file-exists-p buffer-auto-save-file-name)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
671 ;;; (message "Auto save file for draft message exists; consider M-x mail-recover")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
672 ;;; t)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
673 (switch-to-buffer "*mail*") |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
674 (setq default-directory (expand-file-name "~/")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
675 (auto-save-mode auto-save-default) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
676 (mail-mode) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
677 (let (initialized) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
678 (and (not noerase) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
679 (or (not (buffer-modified-p)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
680 (y-or-n-p "Unsent message being composed; erase it? ")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
681 (progn (erase-buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
682 (mail-setup to subject in-reply-to cc replybuffer actions) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
683 (setq initialized t))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
684 (if (and buffer-auto-save-file-name |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
685 (file-exists-p buffer-auto-save-file-name)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
686 (message "Auto save file for draft message exists; consider M-x mail-recover")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
687 initialized)) |
455 | 688 |
689 (defun mail-recover () | |
690 "Reread contents of current buffer from its last auto-save file." | |
691 (interactive) | |
692 (let ((file-name (make-auto-save-file-name))) | |
693 (cond ((save-window-excursion | |
694 (if (not (eq system-type 'vax-vms)) | |
695 (with-output-to-temp-buffer "*Directory*" | |
696 (buffer-disable-undo standard-output) | |
697 (call-process "ls" nil standard-output nil "-l" file-name))) | |
698 (yes-or-no-p (format "Recover auto save file %s? " file-name))) | |
699 (let ((buffer-read-only nil)) | |
700 (erase-buffer) | |
701 (insert-file-contents file-name nil))) | |
702 (t (error "mail-recover cancelled."))))) | |
703 | |
704 ;;;###autoload | |
705 (defun mail-other-window (&optional noerase to subject in-reply-to cc replybuffer sendactions) | |
706 "Like `mail' command, but display mail buffer in another window." | |
707 (interactive "P") | |
708 (let ((pop-up-windows t)) | |
709 (pop-to-buffer "*mail*")) | |
710 (mail noerase to subject in-reply-to cc replybuffer sendactions)) | |
711 | |
712 ;;;###autoload | |
779 | 713 (defun mail-other-frame (&optional noerase to subject in-reply-to cc replybuffer sendactions) |
714 "Like `mail' command, but display mail buffer in another frame." | |
455 | 715 (interactive "P") |
779 | 716 (let ((pop-up-frames t)) |
455 | 717 (pop-to-buffer "*mail*")) |
718 (mail noerase to subject in-reply-to cc replybuffer sendactions)) | |
719 | |
720 | |
721 ;;;###autoload | |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
722 (define-key ctl-x-map "m" 'mail) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
723 |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
724 ;;;###autoload |
455 | 725 (define-key ctl-x-4-map "m" 'mail-other-window) |
726 | |
727 ;;;###autoload | |
779 | 728 (define-key ctl-x-5-map "m" 'mail-other-frame) |
455 | 729 |
730 | |
731 ;;; Do not add anything but external entries on this page. | |
584 | 732 |
733 (provide 'sendmail) | |
734 | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
604
diff
changeset
|
735 ;;; sendmail.el ends here |