Mercurial > emacs
annotate lisp/mail/sendmail.el @ 8630:6d932654b63b
entered into RCS
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 26 Aug 1994 00:40:24 +0000 |
parents | ddd8e250a65d |
children | 7fcda87193a3 |
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 |
5731
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc. |
846
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 | |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1843
diff
changeset
|
24 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1843
diff
changeset
|
25 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1843
diff
changeset
|
26 ;; This mode provides mail-sending facilities from within Emacs. It is |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1843
diff
changeset
|
27 ;; documented in the Emacs user's manual. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1843
diff
changeset
|
28 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
29 ;;; Code: |
455 | 30 |
31 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
32 (defvar mail-self-blind nil "\ |
455 | 33 Non-nil means insert BCC to self in messages to be sent. |
34 This is done when the message is initialized, | |
35 so you can remove or alter the BCC field to override the default.") | |
36 | |
37 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
38 (defvar mail-interactive nil "\ |
455 | 39 Non-nil means when sending a message wait for and display errors. |
40 nil means let mailer mail back a message to report errors.") | |
41 | |
42 ;;;###autoload | |
1664
5345766220da
* sendmail.el (mail-self-blind, mail-interactive,
Jim Blandy <jimb@redhat.com>
parents:
1539
diff
changeset
|
43 (defvar mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:" "\ |
455 | 44 Delete these headers from old message when it's inserted in a reply.") |
45 | |
46 ;; Useful to set in site-init.el | |
47 ;;;###autoload | |
3232
27d2747abab2
(send-mail-function): Use defvar. not defconst.
Richard M. Stallman <rms@gnu.org>
parents:
2920
diff
changeset
|
48 (defvar send-mail-function 'sendmail-send-it "\ |
455 | 49 Function to call to send the current buffer as mail. |
1539 | 50 The headers are be delimited by a line which is `mail-header-separator'.") |
455 | 51 |
52 ;;;###autoload | |
53 (defvar mail-header-separator "--text follows this line--" "\ | |
54 *Line used to separate headers from text in messages being composed.") | |
55 | |
56 ;;;###autoload | |
57 (defvar mail-archive-file-name nil "\ | |
58 *Name of file to write all outgoing messages in, or nil for none. | |
59 Do not use an rmail file here! Instead, use its inbox file.") | |
60 | |
5261
50406a868f05
(mail-default-reply-to): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
5210
diff
changeset
|
61 ;;;###autoload |
455 | 62 (defvar mail-default-reply-to nil |
63 "*Address to insert as default Reply-to field of outgoing messages.") | |
64 | |
8488
ddd8e250a65d
(mail-alias-file): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
8416
diff
changeset
|
65 ;;;###autoload |
455 | 66 (defvar mail-alias-file nil |
67 "*If non-nil, the name of a file to use instead of `/usr/lib/aliases'. | |
68 This file defines aliases to be expanded by the mailer; this is a different | |
69 feature from that of defining aliases in `.mailrc' to be expanded in Emacs. | |
70 This variable has no effect unless your system uses sendmail as its mailer.") | |
71 | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
72 (defvar mail-aliases t |
1468
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
73 "Alist of mail address aliases, |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
74 or t meaning should be initialized from `~/.mailrc'. |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
75 The alias definitions in `~/.mailrc' have this form: |
01e760e7de34
(mail-aliases): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1431
diff
changeset
|
76 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
|
77 |
455 | 78 (defvar mail-yank-prefix nil |
79 "*Prefix insert on lines of yanked message being replied to. | |
80 nil means use indentation.") | |
3424
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
81 (defvar mail-indentation-spaces 3 |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
82 "*Number of spaces to insert at the beginning of each cited line. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
83 Used by `mail-yank-original' via `mail-yank-cite'.") |
4418
fdbbde0d4f24
(mail-yank-hooks): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4342
diff
changeset
|
84 (defvar mail-yank-hooks nil |
3816
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
85 "Obsolete hook for modifying a citation just inserted in the mail buffer. |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
86 Each hook function can find the citation between (point) and (mark t). |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
87 And each hook function should leave point and mark around the citation |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
88 text as modified. |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
89 |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
90 This is a normal hook, misnamed for historical reasons. |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
91 It is semi-obsolete and mail agents should no longer use it.") |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
92 |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
93 (defvar mail-citation-hook nil |
3424
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
94 "*Hook for modifying a citation just inserted in the mail buffer. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
95 Each hook function can find the citation between (point) and (mark t). |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
96 And each hook function should leave point and mark around the citation |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
97 text as modified. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
98 |
3816
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
99 If this hook is entirely empty (nil), a default action is taken |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
100 instead of no action.") |
455 | 101 |
102 (defvar mail-abbrevs-loaded nil) | |
103 (defvar mail-mode-map nil) | |
104 | |
1431
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
105 (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
|
106 "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
|
107 nil) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
108 |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
109 (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
|
110 "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
|
111 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
|
112 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
|
113 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
|
114 nil) |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
115 |
999 | 116 ;;;###autoload |
1025 | 117 (defvar mail-signature nil |
118 "*Text inserted at end of mail buffer when a message is initialized. | |
119 If t, it means to insert the contents of the file `~/.signature'.") | |
455 | 120 |
121 (defvar mail-reply-buffer nil) | |
122 (defvar mail-send-actions nil | |
123 "A list of actions to be performed upon successful sending of a message.") | |
124 | |
125 (defvar mail-default-headers nil | |
126 "*A string containing header lines, to be inserted in outgoing messages. | |
127 It is inserted before you edit the message, | |
128 so you can edit or delete these lines.") | |
129 | |
5667
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
130 ;; Note: could use /usr/ucb/mail instead of sendmail; |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
131 ;; options -t, and -v if not interactive. |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
132 (defvar mail-mailer-swallows-blank-line |
5731
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
133 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)" system-configuration) |
8253
e390776e5846
(mail-mailer-swallows-blank-line): Verify sendmail.cf
Richard M. Stallman <rms@gnu.org>
parents:
8216
diff
changeset
|
134 (file-readable-p "/etc/sendmail.cf") |
5731
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
135 (let ((buffer (get-buffer-create " *temp*"))) |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
136 (unwind-protect |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
137 (save-excursion |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
138 (set-buffer buffer) |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
139 (insert-file-contents "/etc/sendmail.cf") |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
140 (goto-char (point-min)) |
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
141 (let ((case-fold-search nil)) |
5977
8c5cc76de654
(mail-mailer-swallows-blank-line): Fix regexp typo.
Richard M. Stallman <rms@gnu.org>
parents:
5847
diff
changeset
|
142 (re-search-forward "^OR\\>" nil t))) |
5731
d53870d31221
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5667
diff
changeset
|
143 (kill-buffer buffer)))) |
7399
473e0321d65a
(mail-mailer-swallows-blank-line): Put space and tab into brackets.
Richard M. Stallman <rms@gnu.org>
parents:
6443
diff
changeset
|
144 '(looking-at "[ \t]\\|[-a-zA-Z]+:")) |
5667
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
145 "Set this non-nil if the system's mailer runs the header and body together. |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
146 \(This problem exists on Sunos 4 when sendmail is run in remote mode.) |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
147 The value should be an expression to test whether the problem will |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
148 actually occur.") |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
149 |
455 | 150 (defvar mail-mode-syntax-table nil |
151 "Syntax table used while in mail mode.") | |
152 | |
153 (if (null mail-mode-syntax-table) | |
154 (progn | |
155 (setq mail-mode-syntax-table (copy-syntax-table text-mode-syntax-table)) | |
156 (modify-syntax-entry ?% ". " mail-mode-syntax-table))) | |
157 | |
7917
7967c371644f
(mail-send-hook): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
7858
diff
changeset
|
158 (defvar mail-send-hook nil |
7967c371644f
(mail-send-hook): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
7858
diff
changeset
|
159 "Normal hook run before sending mail, in Mail mode.") |
7967c371644f
(mail-send-hook): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
7858
diff
changeset
|
160 |
455 | 161 (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
|
162 (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
|
163 (progn |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
164 (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
|
165 (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
|
166 (build-mail-aliases)))) |
455 | 167 (setq mail-send-actions actions) |
168 (setq mail-reply-buffer replybuffer) | |
169 (goto-char (point-min)) | |
170 (insert "To: ") | |
171 (save-excursion | |
172 (if to | |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
173 ;; 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
|
174 ;; 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
|
175 ;; 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
|
176 (let ((fill-prefix "\t") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
177 (address-start (point))) |
455 | 178 (insert to "\n") |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
179 (fill-region-as-paragraph address-start (point-max))) |
455 | 180 (newline)) |
181 (if cc | |
1843
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
182 (let ((fill-prefix "\t") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
183 (address-start (progn (insert "CC: ") (point)))) |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
184 (insert cc "\n") |
2d5caf3fd862
(mail-setup): Use fill-region-as-paragraph
Richard M. Stallman <rms@gnu.org>
parents:
1835
diff
changeset
|
185 (fill-region-as-paragraph address-start (point-max)))) |
455 | 186 (if in-reply-to |
187 (insert "In-reply-to: " in-reply-to "\n")) | |
188 (insert "Subject: " (or subject "") "\n") | |
189 (if mail-default-headers | |
190 (insert mail-default-headers)) | |
191 (if mail-default-reply-to | |
192 (insert "Reply-to: " mail-default-reply-to "\n")) | |
193 (if mail-self-blind | |
194 (insert "BCC: " (user-login-name) "\n")) | |
195 (if mail-archive-file-name | |
196 (insert "FCC: " mail-archive-file-name "\n")) | |
1024
ceb4469d3cd7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
999
diff
changeset
|
197 (insert mail-header-separator "\n") |
2852
e80e6e533533
(mail-setup): Leave point before signature, not after.
Richard M. Stallman <rms@gnu.org>
parents:
2701
diff
changeset
|
198 ;; Insert the signature. But remember the beginning of the message. |
e80e6e533533
(mail-setup): Leave point before signature, not after.
Richard M. Stallman <rms@gnu.org>
parents:
2701
diff
changeset
|
199 (if to (setq to (point))) |
1025 | 200 (cond ((eq mail-signature t) |
201 (if (file-exists-p "~/.signature") | |
8216
1f1387385ac6
(mail-setup): Insert -- line before .signature file.
Richard M. Stallman <rms@gnu.org>
parents:
8145
diff
changeset
|
202 (progn |
1f1387385ac6
(mail-setup): Insert -- line before .signature file.
Richard M. Stallman <rms@gnu.org>
parents:
8145
diff
changeset
|
203 (insert "\n\n-- \n") |
1f1387385ac6
(mail-setup): Insert -- line before .signature file.
Richard M. Stallman <rms@gnu.org>
parents:
8145
diff
changeset
|
204 (insert-file-contents "~/.signature")))) |
1025 | 205 (mail-signature |
206 (insert mail-signature))) | |
455 | 207 (goto-char (point-max)) |
208 (or (bolp) (newline))) | |
2852
e80e6e533533
(mail-setup): Leave point before signature, not after.
Richard M. Stallman <rms@gnu.org>
parents:
2701
diff
changeset
|
209 (if to (goto-char to)) |
455 | 210 (or to subject in-reply-to |
211 (set-buffer-modified-p nil)) | |
212 (run-hooks 'mail-setup-hook)) | |
213 | |
214 ;;;###autoload | |
215 (defun mail-mode () | |
216 "Major mode for editing mail to be sent. | |
217 Like Text Mode but with these additional commands: | |
218 C-c C-s mail-send (send the message) C-c C-c mail-send-and-exit | |
219 C-c C-f move to a header field (and create it if there isn't): | |
220 C-c C-f C-t move to To: C-c C-f C-s move to Subj: | |
221 C-c C-f C-b move to BCC: C-c C-f C-c move to CC: | |
6443 | 222 C-c C-f C-f move to FCC: |
455 | 223 C-c C-t move to message text. |
224 C-c C-y mail-yank-original (insert current message, in Rmail). | |
225 C-c C-q mail-fill-yanked-message (fill what was yanked). | |
226 C-c C-v mail-sent-via (add a sent-via field for each To or CC)." | |
227 (interactive) | |
228 (kill-all-local-variables) | |
229 (make-local-variable 'mail-reply-buffer) | |
230 (setq mail-reply-buffer nil) | |
231 (make-local-variable 'mail-send-actions) | |
232 (set-syntax-table mail-mode-syntax-table) | |
233 (use-local-map mail-mode-map) | |
234 (setq local-abbrev-table text-mode-abbrev-table) | |
235 (setq major-mode 'mail-mode) | |
236 (setq mode-name "Mail") | |
237 (setq buffer-offer-save t) | |
238 (make-local-variable 'paragraph-separate) | |
239 (make-local-variable 'paragraph-start) | |
240 (setq paragraph-start (concat "^" mail-header-separator | |
241 "$\\|^[ \t]*[-_][-_][-_]+$\\|" | |
242 paragraph-start)) | |
243 (setq paragraph-separate (concat "^" mail-header-separator | |
244 "$\\|^[ \t]*[-_][-_][-_]+$\\|" | |
245 paragraph-separate)) | |
246 (run-hooks 'text-mode-hook 'mail-mode-hook)) | |
3859
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
247 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
248 ;;; Set up keymap. |
455 | 249 |
250 (if mail-mode-map | |
251 nil | |
252 (setq mail-mode-map (nconc (make-sparse-keymap) text-mode-map)) | |
253 (define-key mail-mode-map "\C-c?" 'describe-mode) | |
254 (define-key mail-mode-map "\C-c\C-f\C-t" 'mail-to) | |
255 (define-key mail-mode-map "\C-c\C-f\C-b" 'mail-bcc) | |
573 | 256 (define-key mail-mode-map "\C-c\C-f\C-f" 'mail-fcc) |
455 | 257 (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc) |
258 (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject) | |
259 (define-key mail-mode-map "\C-c\C-t" 'mail-text) | |
260 (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original) | |
261 (define-key mail-mode-map "\C-c\C-q" 'mail-fill-yanked-message) | |
262 (define-key mail-mode-map "\C-c\C-w" 'mail-signature) | |
263 (define-key mail-mode-map "\C-c\C-v" 'mail-sent-via) | |
264 (define-key mail-mode-map "\C-c\C-c" 'mail-send-and-exit) | |
265 (define-key mail-mode-map "\C-c\C-s" 'mail-send)) | |
3859
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
266 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
267 (define-key mail-mode-map [menu-bar mail] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
268 (cons "Mail" (make-sparse-keymap "Mail"))) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
269 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
270 (define-key mail-mode-map [menu-bar mail fill] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
271 '("Fill Citation" . mail-fill-yanked-message)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
272 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
273 (define-key mail-mode-map [menu-bar mail yank] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
274 '("Cite Original" . mail-yank-original)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
275 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
276 (define-key mail-mode-map [menu-bar mail signature] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
277 '("Insert Signature" . mail-signature)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
278 |
4074
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
279 (define-key mail-mode-map [menu-bar mail cancel] |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
280 '("Cancel" . mail-dont-send)) |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
281 |
3859
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
282 (define-key mail-mode-map [menu-bar mail send-stay] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
283 '("Send, Keep Editing" . mail-send)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
284 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
285 (define-key mail-mode-map [menu-bar mail send] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
286 '("Send Message" . mail-send-and-exit)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
287 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
288 (define-key mail-mode-map [menu-bar headers] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
289 (cons "Headers" (make-sparse-keymap "Headers"))) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
290 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
291 (define-key mail-mode-map [menu-bar headers sent-via] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
292 '("Sent Via" . mail-sent-via)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
293 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
294 (define-key mail-mode-map [menu-bar headers text] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
295 '("Text" . mail-text)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
296 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
297 (define-key mail-mode-map [menu-bar headers bcc] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
298 '("Bcc" . mail-bcc)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
299 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
300 (define-key mail-mode-map [menu-bar headers fcc] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
301 '("Fcc" . mail-fcc)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
302 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
303 (define-key mail-mode-map [menu-bar headers cc] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
304 '("Cc" . mail-cc)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
305 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
306 (define-key mail-mode-map [menu-bar headers subject] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
307 '("Subject" . mail-subject)) |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
308 |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
309 (define-key mail-mode-map [menu-bar headers to] |
7e2410ba8e41
(mail-mode-map): Add local menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
3816
diff
changeset
|
310 '("To" . mail-to)) |
455 | 311 |
312 (defun mail-send-and-exit (arg) | |
1539 | 313 "Send message like `mail-send', then, if no errors, exit from mail buffer. |
455 | 314 Prefix arg means don't delete this window." |
315 (interactive "P") | |
316 (mail-send) | |
4074
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
317 (mail-bury arg)) |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
318 |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
319 (defun mail-dont-send (arg) |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
320 "Don't send the message you have been editing. |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
321 Prefix arg means don't delete this window." |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
322 (interactive "P") |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
323 (mail-bury arg)) |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
324 |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
325 (defun mail-bury (arg) |
daf4ba204fe5
(mail-bury): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4021
diff
changeset
|
326 "Bury this mail buffer." |
1269
d123cad4373c
(mail-send-and-exit): Do other-buffer before bury-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1075
diff
changeset
|
327 (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
|
328 (bury-buffer (current-buffer)) |
4194
053660379077
(mail-bury): Check that frame-parameters is defined.
Richard M. Stallman <rms@gnu.org>
parents:
4107
diff
changeset
|
329 (if (and (fboundp 'frame-parameters) |
053660379077
(mail-bury): Check that frame-parameters is defined.
Richard M. Stallman <rms@gnu.org>
parents:
4107
diff
changeset
|
330 (cdr (assq 'dedicated (frame-parameters))) |
4107
7b855e27223f
(mail-bury): If selected frame is dedicated,
Richard M. Stallman <rms@gnu.org>
parents:
4074
diff
changeset
|
331 (not (null (delq (selected-frame) (visible-frame-list))))) |
7b855e27223f
(mail-bury): If selected frame is dedicated,
Richard M. Stallman <rms@gnu.org>
parents:
4074
diff
changeset
|
332 (delete-frame (selected-frame)) |
7833
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
333 (let (rmail-flag summary-buffer) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
334 (and (not arg) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
335 (not (one-window-p)) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
336 (save-excursion |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
337 (set-buffer (window-buffer (next-window (selected-window) 'not))) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
338 (setq rmail-flag (eq major-mode 'rmail-mode)) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
339 (setq summary-buffer |
7963
b66df6f80740
(mail-bury): Test that rmail-summary-buffer is boundp.
Richard M. Stallman <rms@gnu.org>
parents:
7917
diff
changeset
|
340 (and (boundp 'rmail-summary-buffer) |
b66df6f80740
(mail-bury): Test that rmail-summary-buffer is boundp.
Richard M. Stallman <rms@gnu.org>
parents:
7917
diff
changeset
|
341 rmail-summary-buffer |
7833
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
342 (buffer-name rmail-summary-buffer) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
343 (not (get-buffer-window rmail-summary-buffer)) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
344 rmail-summary-buffer)))) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
345 (if rmail-flag |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
346 ;; If the Rmail buffer has a summary, show that. |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
347 (if summary-buffer (switch-to-buffer summary-buffer) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
348 (delete-window)) |
6cc0db90bcc3
(mail-bury): If showing rmail buffer that has summary, show the summary too.
Richard M. Stallman <rms@gnu.org>
parents:
7642
diff
changeset
|
349 (switch-to-buffer newbuf)))))) |
455 | 350 |
351 (defun mail-send () | |
352 "Send the message in the current buffer. | |
353 If `mail-interactive' is non-nil, wait for success indication | |
354 or error messages, and inform user. | |
355 Otherwise any failure is reported in a message back to | |
356 the user from the mailer." | |
357 (interactive) | |
3949
d95172e91f4e
(mail-send): Don't test buffer-modified-p if buffer is visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
3859
diff
changeset
|
358 (if (if buffer-file-name |
d95172e91f4e
(mail-send): Don't test buffer-modified-p if buffer is visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
3859
diff
changeset
|
359 (y-or-n-p "Send buffer contents as mail message? ") |
d95172e91f4e
(mail-send): Don't test buffer-modified-p if buffer is visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
3859
diff
changeset
|
360 (or (buffer-modified-p) |
d95172e91f4e
(mail-send): Don't test buffer-modified-p if buffer is visiting a file.
Richard M. Stallman <rms@gnu.org>
parents:
3859
diff
changeset
|
361 (y-or-n-p "Message already sent; resend? "))) |
455 | 362 (progn |
7917
7967c371644f
(mail-send-hook): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
7858
diff
changeset
|
363 (run-hooks 'mail-send-hook) |
455 | 364 (message "Sending...") |
365 (funcall send-mail-function) | |
366 ;; Now perform actions on successful sending. | |
367 (while mail-send-actions | |
368 (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
|
369 (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
|
370 (cdr (car mail-send-actions))) |
455 | 371 (error)) |
372 (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
|
373 (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
|
374 ;; 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
|
375 (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
|
376 (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
|
377 (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
|
378 (delete-auto-save-file-if-necessary t)))))) |
455 | 379 |
380 (defun sendmail-send-it () | |
381 (let ((errbuf (if mail-interactive | |
382 (generate-new-buffer " sendmail errors") | |
383 0)) | |
384 (tembuf (generate-new-buffer " sendmail temp")) | |
385 (case-fold-search nil) | |
8416
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
386 resend-to-addresses |
455 | 387 delimline |
388 (mailbuf (current-buffer))) | |
389 (unwind-protect | |
390 (save-excursion | |
391 (set-buffer tembuf) | |
392 (erase-buffer) | |
393 (insert-buffer-substring mailbuf) | |
394 (goto-char (point-max)) | |
395 ;; require one newline at the end. | |
396 (or (= (preceding-char) ?\n) | |
397 (insert ?\n)) | |
398 ;; Change header-delimiter to be what sendmail expects. | |
399 (goto-char (point-min)) | |
400 (re-search-forward | |
401 (concat "^" (regexp-quote mail-header-separator) "\n")) | |
402 (replace-match "\n") | |
403 (backward-char 1) | |
404 (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
|
405 (if mail-aliases |
240d5fe38595
(mail-setup): Call build-mail-aliases, not mail-abbrev-setup.
Richard M. Stallman <rms@gnu.org>
parents:
1269
diff
changeset
|
406 (expand-mail-aliases (point-min) delimline)) |
455 | 407 (goto-char (point-min)) |
408 ;; ignore any blank lines in the header | |
409 (while (and (re-search-forward "\n\n\n*" delimline t) | |
410 (< (point) delimline)) | |
411 (replace-match "\n")) | |
412 (let ((case-fold-search t)) | |
413 (goto-char (point-min)) | |
414 ;; Find and handle any FCC fields. | |
415 (goto-char (point-min)) | |
416 (if (re-search-forward "^FCC:" delimline t) | |
417 (mail-do-fcc delimline)) | |
8416
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
418 (goto-char (point-min)) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
419 (require 'mail-utils) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
420 (while (re-search-forward "^Resent-to:" delimline t) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
421 (setq resend-to-addresses |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
422 (save-restriction |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
423 (narrow-to-region (point) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
424 (save-excursion |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
425 (end-of-line) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
426 (point))) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
427 (append (mail-parse-comma-list) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
428 resend-to-addresses)))) |
4910
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
429 ;;; Apparently this causes a duplicate Sender. |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
430 ;;; ;; If the From is different than current user, insert Sender. |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
431 ;;; (goto-char (point-min)) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
432 ;;; (and (re-search-forward "^From:" delimline t) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
433 ;;; (progn |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
434 ;;; (require 'mail-utils) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
435 ;;; (not (string-equal |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
436 ;;; (mail-strip-quoted-names |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
437 ;;; (save-restriction |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
438 ;;; (narrow-to-region (point-min) delimline) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
439 ;;; (mail-fetch-field "From"))) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
440 ;;; (user-login-name)))) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
441 ;;; (progn |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
442 ;;; (forward-line 1) |
435032be7b12
(sendmail-send-it): Don't insert Sender.
Richard M. Stallman <rms@gnu.org>
parents:
4418
diff
changeset
|
443 ;;; (insert "Sender: " (user-login-name) "\n"))) |
455 | 444 ;; "S:" is an abbreviation for "Subject:". |
445 (goto-char (point-min)) | |
446 (if (re-search-forward "^S:" delimline t) | |
447 (replace-match "Subject:")) | |
448 ;; Don't send out a blank subject line | |
449 (goto-char (point-min)) | |
450 (if (re-search-forward "^Subject:[ \t]*\n" delimline t) | |
451 (replace-match "")) | |
5667
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
452 ;; Insert an extra newline if we need it to work around |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
453 ;; Sun's bug that swallows newlines. |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
454 (goto-char (1+ delimline)) |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
455 (if (eval mail-mailer-swallows-blank-line) |
03c03462bca3
(mail-mailer-swallows-blank-line): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5261
diff
changeset
|
456 (newline)) |
455 | 457 (if mail-interactive |
458 (save-excursion | |
459 (set-buffer errbuf) | |
460 (erase-buffer)))) | |
461 (apply 'call-process-region | |
462 (append (list (point-min) (point-max) | |
463 (if (boundp 'sendmail-program) | |
464 sendmail-program | |
465 "/usr/lib/sendmail") | |
8416
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
466 nil errbuf nil "-oi") |
455 | 467 ;; Always specify who from, |
468 ;; since some systems have broken sendmails. | |
469 (list "-f" (user-login-name)) | |
470 ;;; ;; Don't say "from root" if running under su. | |
471 ;;; (and (equal (user-real-login-name) "root") | |
472 ;;; (list "-f" (user-login-name))) | |
473 (and mail-alias-file | |
474 (list (concat "-oA" mail-alias-file))) | |
475 ;; These mean "report errors by mail" | |
476 ;; and "deliver in background". | |
8416
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
477 (if (null mail-interactive) '("-oem" "-odb")) |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
478 ;; Get the addresses from the message |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
479 ;; unless this is a resend. |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
480 ;; We must not do that for a resend |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
481 ;; because we would find the original addresses. |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
482 ;; For a resend, include the specific addresses. |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
483 (or resend-to-addresses |
31a71761eeae
(sendmail-send-it): Handle resent-to specially.
Richard M. Stallman <rms@gnu.org>
parents:
8253
diff
changeset
|
484 '("-t")))) |
455 | 485 (if mail-interactive |
486 (save-excursion | |
487 (set-buffer errbuf) | |
488 (goto-char (point-min)) | |
489 (while (re-search-forward "\n\n* *" nil t) | |
490 (replace-match "; ")) | |
491 (if (not (zerop (buffer-size))) | |
492 (error "Sending...failed to %s" | |
493 (buffer-substring (point-min) (point-max))))))) | |
494 (kill-buffer tembuf) | |
495 (if (bufferp errbuf) | |
496 (kill-buffer errbuf))))) | |
497 | |
498 (defun mail-do-fcc (header-end) | |
499 (let (fcc-list | |
500 (rmailbuf (current-buffer)) | |
2920
c47652dc3400
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2858
diff
changeset
|
501 (time (current-time)) |
455 | 502 (tembuf (generate-new-buffer " rmail output")) |
503 (case-fold-search t)) | |
504 (save-excursion | |
505 (goto-char (point-min)) | |
506 (while (re-search-forward "^FCC:[ \t]*" header-end t) | |
507 (setq fcc-list (cons (buffer-substring (point) | |
508 (progn | |
509 (end-of-line) | |
510 (skip-chars-backward " \t") | |
511 (point))) | |
512 fcc-list)) | |
513 (delete-region (match-beginning 0) | |
514 (progn (forward-line 1) (point)))) | |
515 (set-buffer tembuf) | |
516 (erase-buffer) | |
3340
908134e8308a
(mail-do-fcc): Put back the newline at the start
Richard M. Stallman <rms@gnu.org>
parents:
3232
diff
changeset
|
517 ;; This initial newline is written out if the fcc file already exists. |
908134e8308a
(mail-do-fcc): Put back the newline at the start
Richard M. Stallman <rms@gnu.org>
parents:
3232
diff
changeset
|
518 (insert "\nFrom " (user-login-name) " " |
2920
c47652dc3400
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2858
diff
changeset
|
519 (current-time-string time) "\n") |
1075 | 520 ;; Insert the time zone before the year. |
521 (forward-char -1) | |
522 (forward-word -1) | |
4021
5a8ed60f39f2
(mail-do-fcc): Use RFC 822 style date in Resent-Date: line.
Richard M. Stallman <rms@gnu.org>
parents:
3949
diff
changeset
|
523 (require 'mail-utils) |
5a8ed60f39f2
(mail-do-fcc): Use RFC 822 style date in Resent-Date: line.
Richard M. Stallman <rms@gnu.org>
parents:
3949
diff
changeset
|
524 (insert (mail-rfc822-time-zone time) " ") |
1075 | 525 (goto-char (point-max)) |
455 | 526 (insert-buffer-substring rmailbuf) |
527 ;; Make sure messages are separated. | |
528 (goto-char (point-max)) | |
529 (insert ?\n) | |
530 (goto-char 2) | |
531 ;; ``Quote'' "^From " as ">From " | |
532 ;; (note that this isn't really quoting, as there is no requirement | |
533 ;; that "^[>]+From " be quoted in the same transparent way.) | |
534 (let ((case-fold-search nil)) | |
535 (while (search-forward "\nFrom " nil t) | |
536 (forward-char -5) | |
537 (insert ?>))) | |
538 (while fcc-list | |
539 (let ((buffer (get-file-buffer (car fcc-list)))) | |
540 (if buffer | |
541 ;; File is present in a buffer => append to that buffer. | |
542 (let ((curbuf (current-buffer)) | |
3468
f3052346f005
(mail-do-fcc): Omit first 2 lines when appending to an RMAIL buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3424
diff
changeset
|
543 (beg (point-min)) (end (point-max)) |
f3052346f005
(mail-do-fcc): Omit first 2 lines when appending to an RMAIL buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3424
diff
changeset
|
544 (beg2 (save-excursion (goto-char (point-min)) |
f3052346f005
(mail-do-fcc): Omit first 2 lines when appending to an RMAIL buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3424
diff
changeset
|
545 (forward-line 2) (point)))) |
455 | 546 (save-excursion |
547 (set-buffer buffer) | |
548 ;; Keep the end of the accessible portion at the same place | |
549 ;; unless it is the end of the buffer. | |
550 (let ((max (if (/= (1+ (buffer-size)) (point-max)) | |
551 (point-max)))) | |
552 (unwind-protect | |
3513
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
553 ;; Code below lifted from rmailout.el |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
554 ;; function rmail-output-to-rmail-file: |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
555 (let ((buffer-read-only nil) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
556 (msg (and (boundp 'rmail-current-message) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
557 rmail-current-message))) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
558 ;; If MSG is non-nil, buffer is in RMAIL mode. |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
559 (if msg |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
560 (progn |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
561 (rmail-maybe-set-message-counters) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
562 (widen) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
563 (narrow-to-region (point-max) (point-max)) |
455 | 564 (insert "\C-l\n0, unseen,,\n*** EOOH ***\n" |
565 "From: " (user-login-name) "\n" | |
4021
5a8ed60f39f2
(mail-do-fcc): Use RFC 822 style date in Resent-Date: line.
Richard M. Stallman <rms@gnu.org>
parents:
3949
diff
changeset
|
566 "Date: " (mail-rfc822-date) "\n") |
3468
f3052346f005
(mail-do-fcc): Omit first 2 lines when appending to an RMAIL buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3424
diff
changeset
|
567 (insert-buffer-substring curbuf beg2 end) |
746
1b0748ff6f65
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
705
diff
changeset
|
568 (insert "\n\C-_") |
3513
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
569 (goto-char (point-min)) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
570 (widen) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
571 (search-backward "\n\^_") |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
572 (narrow-to-region (point) (point-max)) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
573 (rmail-count-new-messages t) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
574 (rmail-show-message msg) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
575 (setq max nil)) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
576 ;; Output file not in rmail mode |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
577 ;; => just insert at the end. |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
578 (narrow-to-region (point-min) (1+ (buffer-size))) |
8154b7ce787e
(mail-do-fcc): Replace the code for appending to buffer.
Richard M. Stallman <rms@gnu.org>
parents:
3468
diff
changeset
|
579 (goto-char (point-max)) |
455 | 580 (insert-buffer-substring curbuf beg end))) |
581 (if max (narrow-to-region (point-min) max)))))) | |
582 ;; Else append to the file directly. | |
583 (write-region | |
6136
74f4a8947d57
(mail-do-fcc): Don't write a newline before the text.
Richard M. Stallman <rms@gnu.org>
parents:
5977
diff
changeset
|
584 (1+ (point-min)) (point-max) (car fcc-list) t))) |
455 | 585 (setq fcc-list (cdr fcc-list)))) |
586 (kill-buffer tembuf))) | |
587 | |
588 (defun mail-sent-via () | |
589 "Make a Sent-via header line from each To or CC header line." | |
590 (interactive) | |
591 (save-excursion | |
592 (goto-char (point-min)) | |
593 ;; find the header-separator | |
594 (search-forward (concat "\n" mail-header-separator "\n")) | |
595 (forward-line -1) | |
596 ;; put a marker at the end of the header | |
597 (let ((end (point-marker)) | |
598 (case-fold-search t) | |
599 to-line) | |
600 (goto-char (point-min)) | |
601 ;; search for the To: lines and make Sent-via: lines from them | |
602 ;; search for the next To: line | |
603 (while (re-search-forward "^\\(to\\|cc\\):" end t) | |
604 ;; Grab this line plus all its continuations, sans the `to:'. | |
605 (let ((to-line | |
606 (buffer-substring (point) | |
607 (progn | |
608 (if (re-search-forward "^[^ \t\n]" end t) | |
609 (backward-char 1) | |
610 (goto-char end)) | |
611 (point))))) | |
612 ;; Insert a copy, with altered header field name. | |
613 (insert-before-markers "Sent-via:" to-line)))))) | |
614 | |
615 (defun mail-to () | |
616 "Move point to end of To-field." | |
617 (interactive) | |
618 (expand-abbrev) | |
619 (mail-position-on-field "To")) | |
620 | |
621 (defun mail-subject () | |
622 "Move point to end of Subject-field." | |
623 (interactive) | |
624 (expand-abbrev) | |
625 (mail-position-on-field "Subject")) | |
626 | |
627 (defun mail-cc () | |
628 "Move point to end of CC-field. Create a CC field if none." | |
629 (interactive) | |
630 (expand-abbrev) | |
631 (or (mail-position-on-field "cc" t) | |
632 (progn (mail-position-on-field "to") | |
633 (insert "\nCC: ")))) | |
634 | |
635 (defun mail-bcc () | |
636 "Move point to end of BCC-field. Create a BCC field if none." | |
637 (interactive) | |
638 (expand-abbrev) | |
639 (or (mail-position-on-field "bcc" t) | |
640 (progn (mail-position-on-field "to") | |
641 (insert "\nBCC: ")))) | |
642 | |
5210
4db0922992a3
(mail-fcc): Take argument and use interactive spec to prompt, rather than
Roland McGrath <roland@gnu.org>
parents:
5097
diff
changeset
|
643 (defun mail-fcc (folder) |
573 | 644 "Add a new FCC field, with file name completion." |
5210
4db0922992a3
(mail-fcc): Take argument and use interactive spec to prompt, rather than
Roland McGrath <roland@gnu.org>
parents:
5097
diff
changeset
|
645 (interactive "FFolder carbon copy: ") |
573 | 646 (expand-abbrev) |
647 (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC. | |
648 (mail-position-on-field "to")) | |
5210
4db0922992a3
(mail-fcc): Take argument and use interactive spec to prompt, rather than
Roland McGrath <roland@gnu.org>
parents:
5097
diff
changeset
|
649 (insert "\nFCC: " folder)) |
573 | 650 |
455 | 651 (defun mail-position-on-field (field &optional soft) |
652 (let (end | |
653 (case-fold-search t)) | |
654 (goto-char (point-min)) | |
604 | 655 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n")) |
455 | 656 (setq end (match-beginning 0)) |
657 (goto-char (point-min)) | |
658 (if (re-search-forward (concat "^" (regexp-quote field) ":") end t) | |
659 (progn | |
660 (re-search-forward "^[^ \t]" nil 'move) | |
661 (beginning-of-line) | |
662 (skip-chars-backward "\n") | |
663 t) | |
664 (or soft | |
665 (progn (goto-char end) | |
604 | 666 (insert field ": \n") |
667 (skip-chars-backward "\n"))) | |
455 | 668 nil))) |
669 | |
670 (defun mail-text () | |
671 "Move point to beginning of text field." | |
672 (interactive) | |
673 (goto-char (point-min)) | |
674 (search-forward (concat "\n" mail-header-separator "\n"))) | |
675 | |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
676 (defun mail-signature (atpoint) |
5847
8a2e912b29a5
(mail-signature): Insert a `-- ' line.
Richard M. Stallman <rms@gnu.org>
parents:
5839
diff
changeset
|
677 "Sign letter with contents of the file `~/.signature'. |
5839 | 678 Prefix arg means put contents at point." |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
679 (interactive "P") |
455 | 680 (save-excursion |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
681 (or atpoint |
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
682 (goto-char (point-max))) |
455 | 683 (skip-chars-backward " \t\n") |
684 (end-of-line) | |
679
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
685 (or atpoint |
046f1a6867e7
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
686 (delete-region (point) (point-max))) |
5847
8a2e912b29a5
(mail-signature): Insert a `-- ' line.
Richard M. Stallman <rms@gnu.org>
parents:
5839
diff
changeset
|
687 (insert "\n\n-- \n") |
1025 | 688 (insert-file-contents (expand-file-name "~/.signature")))) |
455 | 689 |
690 (defun mail-fill-yanked-message (&optional justifyp) | |
691 "Fill the paragraphs of a message yanked into this one. | |
692 Numeric argument means justify as well." | |
693 (interactive "P") | |
694 (save-excursion | |
695 (goto-char (point-min)) | |
696 (search-forward (concat "\n" mail-header-separator "\n") nil t) | |
697 (fill-individual-paragraphs (point) | |
698 (point-max) | |
699 justifyp | |
700 t))) | |
701 | |
3424
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
702 (defun mail-indent-citation () |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
703 "Modify text just inserted from a message to be cited. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
704 The inserted text should be the region. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
705 When this function returns, the region is again around the modified text. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
706 |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
707 Normally, indent each nonblank line `mail-indentation-spaces' spaces. |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
708 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line." |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
709 (let ((start (point))) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
710 (mail-yank-clear-headers start (mark t)) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
711 (if (null mail-yank-prefix) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
712 (indent-rigidly start (mark t) mail-indentation-spaces) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
713 (save-excursion |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
714 (goto-char start) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
715 (while (< (point) (mark t)) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
716 (insert mail-yank-prefix) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
717 (forward-line 1)))))) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
718 |
455 | 719 (defun mail-yank-original (arg) |
720 "Insert the message being replied to, if any (in rmail). | |
721 Puts point before the text and mark after. | |
722 Normally, indents each nonblank line ARG spaces (default 3). | |
723 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line. | |
724 | |
725 Just \\[universal-argument] as argument means don't indent, insert no prefix, | |
726 and don't delete any header fields." | |
727 (interactive "P") | |
728 (if mail-reply-buffer | |
729 (let ((start (point))) | |
5097
a0a5b39e3d22
(mail-yank-original): Delete windows on selected frame only.
Richard M. Stallman <rms@gnu.org>
parents:
4910
diff
changeset
|
730 ;; If the original message is in another window in the same frame, |
a0a5b39e3d22
(mail-yank-original): Delete windows on selected frame only.
Richard M. Stallman <rms@gnu.org>
parents:
4910
diff
changeset
|
731 ;; delete that window to save screen space. |
a0a5b39e3d22
(mail-yank-original): Delete windows on selected frame only.
Richard M. Stallman <rms@gnu.org>
parents:
4910
diff
changeset
|
732 ;; t means don't alter other frames. |
a0a5b39e3d22
(mail-yank-original): Delete windows on selected frame only.
Richard M. Stallman <rms@gnu.org>
parents:
4910
diff
changeset
|
733 (delete-windows-on mail-reply-buffer t) |
455 | 734 (insert-buffer mail-reply-buffer) |
735 (if (consp arg) | |
736 nil | |
3424
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
737 (goto-char start) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
738 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg) |
7ccd5b60891d
(mail-signature): Do not insert a line with `--'.
Richard M. Stallman <rms@gnu.org>
parents:
3340
diff
changeset
|
739 mail-indentation-spaces))) |
3816
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
740 (if mail-citation-hook |
231b935db22c
(mail-citation-hook): New hook var.
Richard M. Stallman <rms@gnu.org>
parents:
3513
diff
changeset
|
741 (run-hooks 'mail-citation-hook) |
4418
fdbbde0d4f24
(mail-yank-hooks): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4342
diff
changeset
|
742 (if mail-yank-hooks |
fdbbde0d4f24
(mail-yank-hooks): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4342
diff
changeset
|
743 (run-hooks 'mail-yank-hooks) |
fdbbde0d4f24
(mail-yank-hooks): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4342
diff
changeset
|
744 (mail-indent-citation))))) |
2858
ef942eda3523
(mail-yank-original): In Transient Mark mode,
Richard M. Stallman <rms@gnu.org>
parents:
2852
diff
changeset
|
745 ;; This is like exchange-point-and-mark, but doesn't activate the mark. |
ef942eda3523
(mail-yank-original): In Transient Mark mode,
Richard M. Stallman <rms@gnu.org>
parents:
2852
diff
changeset
|
746 ;; It is cleaner to avoid activation, even though the command |
ef942eda3523
(mail-yank-original): In Transient Mark mode,
Richard M. Stallman <rms@gnu.org>
parents:
2852
diff
changeset
|
747 ;; loop would deactivate the mark because we inserted text. |
ef942eda3523
(mail-yank-original): In Transient Mark mode,
Richard M. Stallman <rms@gnu.org>
parents:
2852
diff
changeset
|
748 (goto-char (prog1 (mark t) |
ef942eda3523
(mail-yank-original): In Transient Mark mode,
Richard M. Stallman <rms@gnu.org>
parents:
2852
diff
changeset
|
749 (set-marker (mark-marker) (point) (current-buffer)))) |
455 | 750 (if (not (eolp)) (insert ?\n))))) |
751 | |
752 (defun mail-yank-clear-headers (start end) | |
753 (save-excursion | |
754 (goto-char start) | |
755 (if (search-forward "\n\n" end t) | |
756 (save-restriction | |
757 (narrow-to-region start (point)) | |
758 (goto-char start) | |
759 (while (let ((case-fold-search t)) | |
760 (re-search-forward mail-yank-ignored-headers nil t)) | |
761 (beginning-of-line) | |
762 (delete-region (point) | |
763 (progn (re-search-forward "\n[^ \t]") | |
764 (forward-char -1) | |
765 (point)))))))) | |
766 | |
767 ;; Put these last, to reduce chance of lossage from quitting in middle of loading the file. | |
768 | |
769 ;;;###autoload | |
770 (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
|
771 "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
|
772 When this function returns, the buffer `*mail*' is selected. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
773 The value is t if the message was newly initialized; otherwise, nil. |
455 | 774 |
1025 | 775 By default, the signature file `~/.signature' is inserted at the end; |
776 see the variable `mail-signature'. | |
455 | 777 |
778 \\<mail-mode-map> | |
779 While editing message, type \\[mail-send-and-exit] to send the message and exit. | |
780 | |
781 Various special commands starting with C-c are available in sendmail mode | |
782 to move to message header fields: | |
783 \\{mail-mode-map} | |
784 | |
785 If `mail-self-blind' is non-nil, a BCC to yourself is inserted | |
786 when the message is initialized. | |
787 | |
788 If `mail-default-reply-to' is non-nil, it should be an address (a string); | |
789 a Reply-to: field with that address is inserted. | |
790 | |
791 If `mail-archive-file-name' is non-nil, an FCC field with that file name | |
792 is inserted. | |
793 | |
794 If `mail-setup-hook' is bound, its value is called with no arguments | |
795 after the message is initialized. It can add more default fields. | |
796 | |
797 When calling from a program, the second through fifth arguments | |
798 TO, SUBJECT, IN-REPLY-TO and CC specify if non-nil | |
799 the initial contents of those header fields. | |
800 These arguments should not have final newlines. | |
801 The sixth argument REPLYBUFFER is a buffer whose contents | |
802 should be yanked if the user types C-c C-y. | |
803 The seventh argument ACTIONS is a list of actions to take | |
804 if/when the message is sent. Each action looks like (FUNCTION . ARGS); | |
805 when the message is sent, we apply FUNCTION to ARGS. | |
806 This is how Rmail arranges to mark messages `answered'." | |
807 (interactive "P") | |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
808 ;;; 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
|
809 ;;; 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
|
810 ;;; if you want to have multiple mail buffers. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
811 ;;; And then you can control which messages to save. --rms. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
812 ;;; (let ((index 1) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
813 ;;; buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
814 ;;; ;; 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
|
815 ;;; (if noerase |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
816 ;;; (progn |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
817 ;;; (while (and (setq buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
818 ;;; (get-buffer (if (= 1 index) "*mail*" |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
819 ;;; (format "*mail*<%d>" index)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
820 ;;; (not (buffer-modified-p buffer))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
821 ;;; (setq index (1+ index))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
822 ;;; (if buffer (switch-to-buffer buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
823 ;;; ;; If none exists, start a new message. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
824 ;;; ;; This will never re-use an existing unmodified mail buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
825 ;;; ;; (since index is not 1 anymore). Perhaps it should. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
826 ;;; (setq noerase nil)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
827 ;;; ;; 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
|
828 ;;; (if (not noerase) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
829 ;;; (progn |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
830 ;;; ;; Look for existing unmodified mail buffer. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
831 ;;; (while (and (setq buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
832 ;;; (get-buffer (if (= 1 index) "*mail*" |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
833 ;;; (format "*mail*<%d>" index)))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
834 ;;; (buffer-modified-p buffer)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
835 ;;; (setq index (1+ index))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
836 ;;; ;; If none, make a new one. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
837 ;;; (or buffer |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
838 ;;; (setq buffer (generate-new-buffer "*mail*"))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
839 ;;; ;; Go there and initialize it. |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
840 ;;; (switch-to-buffer buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
841 ;;; (erase-buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
842 ;;; (setq default-directory (expand-file-name "~/")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
843 ;;; (auto-save-mode auto-save-default) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
844 ;;; (mail-mode) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
845 ;;; (mail-setup to subject in-reply-to cc replybuffer actions) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
846 ;;; (if (and buffer-auto-save-file-name |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
847 ;;; (file-exists-p buffer-auto-save-file-name)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
848 ;;; (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
|
849 ;;; t)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
850 (switch-to-buffer "*mail*") |
7858
41f30d92485e
(mail): If homedir is nonexistent, don't use as default.
Richard M. Stallman <rms@gnu.org>
parents:
7833
diff
changeset
|
851 (if (file-exists-p (expand-file-name "~/")) |
41f30d92485e
(mail): If homedir is nonexistent, don't use as default.
Richard M. Stallman <rms@gnu.org>
parents:
7833
diff
changeset
|
852 (setq default-directory (expand-file-name "~/"))) |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
853 (auto-save-mode auto-save-default) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
854 (mail-mode) |
8144 | 855 ;; Disconnect the buffer from its visited file |
856 ;; (in case the user has actually visited a file *mail*). | |
8145
d94fc60e4195
Comment out losing call to set-visited-file-name; this shouldn't hurt
Michael I. Bushnell <mib@gnu.org>
parents:
8144
diff
changeset
|
857 ; (set-visited-file-name nil) |
898
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
858 (let (initialized) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
859 (and (not noerase) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
860 (or (not (buffer-modified-p)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
861 (y-or-n-p "Unsent message being composed; erase it? ")) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
862 (progn (erase-buffer) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
863 (mail-setup to subject in-reply-to cc replybuffer actions) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
864 (setq initialized t))) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
865 (if (and buffer-auto-save-file-name |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
866 (file-exists-p buffer-auto-save-file-name)) |
d3e136526f22
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
867 (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
|
868 initialized)) |
455 | 869 |
870 (defun mail-recover () | |
871 "Reread contents of current buffer from its last auto-save file." | |
872 (interactive) | |
873 (let ((file-name (make-auto-save-file-name))) | |
874 (cond ((save-window-excursion | |
875 (if (not (eq system-type 'vax-vms)) | |
876 (with-output-to-temp-buffer "*Directory*" | |
877 (buffer-disable-undo standard-output) | |
878 (call-process "ls" nil standard-output nil "-l" file-name))) | |
879 (yes-or-no-p (format "Recover auto save file %s? " file-name))) | |
880 (let ((buffer-read-only nil)) | |
881 (erase-buffer) | |
882 (insert-file-contents file-name nil))) | |
8144 | 883 (t (error "mail-recover cancelled"))))) |
455 | 884 |
885 ;;;###autoload | |
886 (defun mail-other-window (&optional noerase to subject in-reply-to cc replybuffer sendactions) | |
887 "Like `mail' command, but display mail buffer in another window." | |
888 (interactive "P") | |
889 (let ((pop-up-windows t)) | |
890 (pop-to-buffer "*mail*")) | |
891 (mail noerase to subject in-reply-to cc replybuffer sendactions)) | |
892 | |
893 ;;;###autoload | |
779 | 894 (defun mail-other-frame (&optional noerase to subject in-reply-to cc replybuffer sendactions) |
895 "Like `mail' command, but display mail buffer in another frame." | |
455 | 896 (interactive "P") |
779 | 897 (let ((pop-up-frames t)) |
455 | 898 (pop-to-buffer "*mail*")) |
899 (mail noerase to subject in-reply-to cc replybuffer sendactions)) | |
900 | |
4342
1088a9aa4fd0
Do the global key bindings only via loaddefs.el,
Richard M. Stallman <rms@gnu.org>
parents:
4194
diff
changeset
|
901 ;;; Do not execute these when sendmail.el is loaded, |
1088a9aa4fd0
Do the global key bindings only via loaddefs.el,
Richard M. Stallman <rms@gnu.org>
parents:
4194
diff
changeset
|
902 ;;; only in loaddefs.el. |
1088a9aa4fd0
Do the global key bindings only via loaddefs.el,
Richard M. Stallman <rms@gnu.org>
parents:
4194
diff
changeset
|
903 ;;;###autoload (define-key ctl-x-map "m" 'mail) |
1088a9aa4fd0
Do the global key bindings only via loaddefs.el,
Richard M. Stallman <rms@gnu.org>
parents:
4194
diff
changeset
|
904 ;;;###autoload (define-key ctl-x-4-map "m" 'mail-other-window) |
1088a9aa4fd0
Do the global key bindings only via loaddefs.el,
Richard M. Stallman <rms@gnu.org>
parents:
4194
diff
changeset
|
905 ;;;###autoload (define-key ctl-x-5-map "m" 'mail-other-frame) |
455 | 906 |
907 ;;; Do not add anything but external entries on this page. | |
584 | 908 |
909 (provide 'sendmail) | |
910 | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
604
diff
changeset
|
911 ;;; sendmail.el ends here |