annotate lisp/modes/sendmail.el @ 32:e04119814345 r19-15b99

Import from CVS: tag r19-15b99
author cvs
date Mon, 13 Aug 2007 08:52:56 +0200
parents d95e72db5c07
children 1a767b41a199
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; sendmail.el --- mail sending commands for Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
23 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This mode provides mail-sending facilities from within Emacs. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; documented in the Emacs user's manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar mail-from-style 'angles "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 *Specifies how \"From:\" fields look.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 If `nil', they contain just the return address like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 king@grassland.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 If `parens', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 king@grassland.com (Elvis Parsley)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 If `angles', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Elvis Parsley <king@grassland.com>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvar mail-self-blind nil "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Non-nil means insert BCC to self in messages to be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 This is done when the message is initialized,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 so you can remove or alter the BCC field to override the default.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defvar mail-interactive nil "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 Non-nil means when sending a message wait for and display errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 nil means let mailer mail back a message to report errors.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar mail-dir nil "*Default directory for saving messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; XEmacs change: moved rmail-ignored-headers here from rmail.el so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; the value of mail-yank-ignored-headers can default from it. Both of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; these end up in loaddefs.el, but "sendmail" comes before "rmail", so...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar rmail-ignored-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "^\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 '(;; RFC822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "Sender:" "References:" "Return-Path:" "Received:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "[^: \t\n]*Message-ID:" "Errors-To:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; RFC977 (NNTP)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "Path:" "Expires:" "Xref:" "Lines:" "Approved:" "Distribution:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; SYSV mail:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "Content-Length:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; MIME:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "Mime-Version:" "Content-Type:" "Content-Transfer-Encoding:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; X400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "X400-Received:" "X400-Originator:" "X400-Mts-Identifier:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "X400-Content-Type:" "Content-Identifier:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; RMAIL and /usr/ucb/mail:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Status:" "Summary-Line:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Supercite:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "X-Attribution:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Other random junk occasionally seen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Via:" "Sent-Via:" "Mail-From:" "Origin:" "Comments:" "Originator:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "NF-ID:" "NF-From:" "Posting-Version:" "Posted:" "Posted-Date:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Date-Received:" "Relay-Version:" "Article-I\\.D\\.:" "NNTP-Version:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "NNTP-Posting-Host:" "X-Mailer:" "X-Newsreader:" "News-Software:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "X-Received:" "X-References:" "X-Envelope-To:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 "X-VMS-" "Remailed-" "X-Plantation:" "X-Windows:" "X-Pgp-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "*Gubbish header fields one would rather not see.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defvar mail-yank-ignored-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (concat rmail-ignored-headers "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "^\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (mapconcat 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 '(;; RFC822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Resent-To:" "Resent-By:" "Resent-CC:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 "To:" "Subject:" "In-Reply-To:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "Delete these headers from old message when it's inserted in a reply.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; minimalist FSF version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;(defvar mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:" "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;Delete these headers from old message when it's inserted in a reply.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Useful to set in site-init.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defvar send-mail-function 'sendmail-send-it "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Function to call to send the current buffer as mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 The headers should be delimited by a line whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 match the variable `mail-header-separator'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defvar mail-header-separator (purecopy "--text follows this line--") "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 *Line used to separate headers from text in messages being composed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defvar mail-archive-file-name nil "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 *Name of file to write all outgoing messages in, or nil for none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 This can be an inbox file or an Rmail file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defvar mail-default-reply-to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "*Address to insert as default Reply-to field of outgoing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 If nil, it will be initialized from the REPLYTO environment variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 when you first send mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvar mail-alias-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "*If non-nil, the name of a file to use instead of `/usr/lib/aliases'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 This file defines aliases to be expanded by the mailer; this is a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 feature from that of defining aliases in `.mailrc' to be expanded in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 This variable has no effect unless your system uses sendmail as its mailer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;(defvar mail-personal-alias-file "~/.mailrc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ; "*If non-nil, the name of the user's personal mail alias file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;This file typically should be in same format as the `.mailrc' file used by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;the `Mail' or `mailx' program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;This file need not actually exist.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defvaralias 'mail-personal-alias-file 'mail-abbrev-mailrc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar mail-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Normal hook, run each time a new outgoing mail message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 The function `mail-setup' runs this hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ; These are removed. See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;(defvar mail-aliases t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ; "Alist of mail address aliases,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;or t meaning should be initialized from your mail aliases file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;\(The file's name is normally `~/.mailrc', but your MAILRC environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;variable can override that name.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;The alias definitions in the file have this form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ; alias ALIAS MEANING")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;(defvar mail-alias-modtime nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ; "The modification time of your mail alias file when it was last examined.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defvar mail-yank-prefix "> " ; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "*Prefix insert on lines of yanked message being replied to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 nil means use indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defvar mail-indentation-spaces 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "*Number of spaces to insert at the beginning of each cited line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Used by `mail-yank-original' via `mail-indent-citation'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defvar mail-yank-hooks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "Obsolete hook for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 Each hook function can find the citation between (point) and (mark t).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 And each hook function should leave point and mark around the citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 text as modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 This is a normal hook, misnamed for historical reasons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 It is semi-obsolete and mail agents should no longer use it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defvar mail-citation-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "*Hook for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Each hook function can find the citation between (point) and (mark t).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 And each hook function should leave point and mark around the citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 text as modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 If this hook is entirely empty (nil), a default action is taken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 instead of no action.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (defvar mail-abbrevs-loaded nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defvar mail-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ; Removed autoloads of `build-mail-aliases' and `expand-mail-aliases'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ; See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (autoload 'mail-aliases-setup "mail-abbrevs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defvar mail-signature nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "*Text inserted at end of mail buffer when a message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 If t, it means to insert the contents of the file `mail-signature-file'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defvar mail-signature-file "~/.signature"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "*File containing the text inserted at end of mail buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defvar mail-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defvar mail-send-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "A list of actions to be performed upon successful sending of a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defvar mail-default-headers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "*A string containing header lines, to be inserted in outgoing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 It is inserted before you edit the message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 so you can edit or delete these lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defvar mail-bury-selects-summary t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "*If non-nil, try to show RMAIL summary buffer after returning from mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 The functions \\[mail-send-on-exit] or \\[mail-dont-send] select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 the RMAIL summary buffer before returning, if it exists and this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 is non-nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Note: could use /usr/ucb/mail instead of sendmail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; options -t, and -v if not interactive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defvar mail-mailer-swallows-blank-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)" system-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (file-readable-p "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((buffer (get-buffer-create " *temp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (insert-file-contents "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (re-search-forward "^OR\\>" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (kill-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; According to RFC822, "The field-name must be composed of printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; ASCII characters (i.e. characters that have decimal values between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; 33 and 126, except colon)", i.e. any chars except ctl chars,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; space, or colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "Set this non-nil if the system's mailer runs the header and body together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 The value should be an expression to test whether the problem will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 actually occur.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defvar mail-use-multiple-buffers-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Non-nil means `mail' will create a new buffer if one already exists.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defvar mail-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Syntax table used while in mail mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (not mail-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq mail-mode-syntax-table (copy-syntax-table text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (modify-syntax-entry ?% ". " mail-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defvar mail-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let* ((cite-prefix "A-Za-z") (cite-suffix (concat cite-prefix "0-9_.@-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (list '("^To:" . font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 '("^B?CC:\\|^Reply-To:" . font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 '("^\\(Subject:\\)[ \t]*\\(.+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (1 font-lock-comment-face) (2 font-lock-type-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (list (concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 1 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (cons (concat "^[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "[>|}].*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 'font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\):.*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 . font-lock-string-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "Additional expressions to highlight in Mail mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (put 'mail-mode 'font-lock-defaults '(mail-font-lock-keywords t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar mail-send-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "Normal hook run before sending mail, in Mail mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ; Removed. See above and `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;(defun sendmail-synch-aliases ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ; (let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ; (or (equal mail-alias-modtime modtime)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ; (setq mail-alias-modtime modtime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ; mail-aliases t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
289 ;; Courtesy of Per Abrahamsen <abraham@dina.kvl.dk> in an attempt to make
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
290 ;; Emacs and XEmacs less stupid about default mail addresses.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
291
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
292 ;; We trust the administrator if he has set `mail-host-address'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
293 (defcustom query-user-mail-address (not mail-host-address)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
294 "If non-nil, prompt the user for his mail address."
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
295 :group 'message
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
296 :type 'boolean)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
297
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
298 (defun user-mail-address ()
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
299 "Query the user for his mail address, unless it is already known."
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
300 (interactive)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
301 (when query-user-mail-address
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
302 (setq user-mail-address
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
303 (read-string "Your mail address? " (cons user-mail-address 0)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
304 (setq query-user-mail-address nil)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
305 ;; TODO: Run sanity check from Gnus here.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
306 (when (y-or-n-p "Save address for future sessions? ")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
307 (put 'user-mail-address 'saved-value
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
308 (list user-mail-address))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
309 (put 'query-user-mail-address 'saved-value '(nil))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
310 (custom-save-all)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
311 user-mail-address)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
312
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun mail-setup (to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (or mail-default-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (setq mail-default-reply-to (getenv "REPLYTO")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;Removed. See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ; (sendmail-synch-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ; (if (eq mail-aliases t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ; (setq mail-aliases nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ; (if (file-exists-p mail-personal-alias-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ; (build-mail-aliases))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq mail-send-actions actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (mail-aliases-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq mail-reply-buffer replybuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (insert "To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; Here removed code to extract names from within <...>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; on the assumption that mail-strip-quoted-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; has been called and has done so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (let ((fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (address-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (insert to "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (fill-region-as-paragraph address-start (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (let ((fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (address-start (progn (insert "CC: ") (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (insert cc "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (fill-region-as-paragraph address-start (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if in-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (let ((fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (fill-column 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (address-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (insert "In-reply-to: " in-reply-to "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (fill-region-as-paragraph address-start (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (insert "Subject: " (or subject "") "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (if mail-default-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (insert mail-default-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if mail-default-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (insert "Reply-to: " mail-default-reply-to "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if mail-self-blind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (insert "BCC: " (user-login-name) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if mail-archive-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (insert "FCC: " mail-archive-file-name "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (insert mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; Insert the signature. But remember the beginning of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if to (setq to (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (cond ((eq mail-signature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (if (file-exists-p mail-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (insert "\n\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (insert-file-contents mail-signature-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (mail-signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (insert mail-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (or (bolp) (newline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (if to (goto-char to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (or to subject in-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (run-hooks 'mail-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun mail-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "Major mode for editing mail to be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 Like Text Mode but with these additional commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 C-c C-s mail-send (send the message) C-c C-c mail-send-and-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 C-c C-f move to a header field (and create it if there isn't):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 C-c C-f C-t move to To: C-c C-f C-s move to Subj:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 C-c C-f C-b move to BCC: C-c C-f C-c move to CC:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 C-c C-f C-f move to FCC: C-c C-f C-r move to Reply-To:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 C-c C-t mail-text (move to beginning of message text).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 C-c C-w mail-signature (insert `mail-signature-file' file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 C-c C-y mail-yank-original (insert current message, in Rmail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 C-c C-q mail-fill-yanked-message (fill what was yanked).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 C-c C-v mail-sent-via (add a sent-via field for each To or CC)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (make-local-variable 'mail-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (setq mail-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (make-local-variable 'mail-send-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (set-syntax-table mail-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (use-local-map mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq mode-name "Mail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq buffer-offer-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (turn-on-auto-fill) ; XEmacs - maybe filladapt should be default, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (setq paragraph-start (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 paragraph-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (setq paragraph-separate (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 paragraph-separate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; Set menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (setq mode-popup-menu mail-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if (featurep 'menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; make a local copy of the menubar, so our modes don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; change the global menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (set-buffer-menubar current-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (add-submenu nil mail-menubar-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (run-hooks 'text-mode-hook 'mail-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;;; Set up keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if mail-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (setq mail-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (set-keymap-parents mail-mode-map (list text-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (set-keymap-name mail-mode-map 'mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (define-key mail-mode-map "\C-c?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (define-key mail-mode-map "\C-c\C-f\C-t" 'mail-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (define-key mail-mode-map "\C-c\C-f\C-b" 'mail-bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (define-key mail-mode-map "\C-c\C-f\C-f" 'mail-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (define-key mail-mode-map "\C-c\C-f\C-r" 'mail-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (define-key mail-mode-map "\C-c\C-t" 'mail-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (define-key mail-mode-map "\C-c\C-q" 'mail-fill-yanked-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (define-key mail-mode-map "\C-c\C-w" 'mail-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;;CRAP!!(define-key mail-mode-map "\C-c\C-v" 'mail-sent-via)CRAP!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (define-key mail-mode-map "\C-c\C-c" 'mail-send-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (define-key mail-mode-map "\C-c\C-s" 'mail-send))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;; mail-mode popup menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (defvar mail-menubar-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 '("Mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Sending Mail:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ["Send and Exit" mail-send-and-exit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ["Send Mail" mail-send t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 "Go to Field:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ["To:" mail-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ["Subject:" mail-subject t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ["CC:" mail-cc t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ["BCC:" mail-bcc t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ["Reply-To:" mail-reply-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;; ["Sent Via:" mail-sent-via t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ["Text" mail-text t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Miscellaneous Commands:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ["Yank Original" mail-yank-original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (not (null mail-reply-buffer))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ["Fill Yanked Message" mail-fill-yanked-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (and (search-forward (concat "\n" mail-header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (not (looking-at "[ \t\n]*\\'"))))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ["Insert Signature" mail-signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (and (stringp mail-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (file-exists-p mail-signature-file))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ["Insert File..." insert-file t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ["Insert Buffer..." insert-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ["Cancel" mail-dont-send t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 "Menubar menu for `mail-mode'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defvar mail-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (cons "Sendmail Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (cdr mail-menubar-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Menubar menu for `mail-mode'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun mail-send-and-exit (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "Send message like `mail-send', then, if no errors, exit from mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 Prefix arg means don't delete this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (mail-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (mail-bury arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun mail-dont-send (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "Don't send the message you have been editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 Prefix arg means don't delete this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (mail-bury arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defun mail-bury (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 "Bury this mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (let ((newbuf (other-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (and (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (cdr (assq 'dedicated (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (not (null (delq (selected-frame) (visible-frame-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (delete-frame (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (let (rmail-flag summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (and (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (not (one-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (set-buffer (window-buffer (next-window (selected-window) 'not)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq rmail-flag (eq major-mode 'rmail-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (setq summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (and mail-bury-selects-summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (boundp 'rmail-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 rmail-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (buffer-name rmail-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (not (get-buffer-window rmail-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 rmail-summary-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (if rmail-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;; If the Rmail buffer has a summary, show that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (if summary-buffer (switch-to-buffer summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (switch-to-buffer newbuf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defun mail-send ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 "Send the message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 If `mail-interactive' is non-nil, wait for success indication or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 messages, and inform user. Otherwise any failure is reported in a message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 back to the user from the mailer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (y-or-n-p "Send buffer contents as mail message? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (or (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (y-or-n-p "Message already sent; resend? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (expand-abbrev) ; for mail-abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (run-hooks 'mail-send-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (funcall send-mail-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; Now perform actions on successful sending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (while mail-send-actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (apply (car (car mail-send-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (cdr (car mail-send-actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq mail-send-actions (cdr mail-send-actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (message "Sending...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; If buffer has no file, mark it as unmodified and delete autosave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (cond ((or (not buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (not (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (delete-auto-save-file-if-necessary t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ((or noninteractive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (y-or-n-p (format "Save file %s? " buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (save-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (defun sendmail-send-it ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (let ((errbuf (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (generate-new-buffer " sendmail errors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (tembuf (generate-new-buffer " sendmail temp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 delimline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (mailbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (insert-buffer-substring mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; Change header-delimiter to be what sendmail expects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (setq delimline (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;Removed. See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ; (sendmail-synch-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ; (if mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ; (expand-mail-aliases (point-min) delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; ignore any blank lines in the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (while (and (re-search-forward "\n\n\n*" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (< (point) delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (replace-match "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (while (re-search-forward "^Resent-to:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (append (mail-parse-comma-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 resend-to-addresses))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;;; Apparently this causes a duplicate Sender.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;;; ;; If the From is different than current user, insert Sender.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;;; (and (re-search-forward "^From:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;;; (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;;; (not (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;;; (mail-strip-quoted-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;;; (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;;; (narrow-to-region (point-min) delimline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;;; (mail-fetch-field "From")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;;; (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;;; (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; (insert "Sender: " (user-login-name) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; Don't send out a blank subject line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; Put the "From:" field in unless for some odd reason
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; they put one in themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (if (not (re-search-forward "^From:" delimline t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (let* ((login user-mail-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (fullname (user-full-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (cond ((eq mail-from-style 'angles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (insert "From: " fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (let ((fullname-start (+ (point-min) 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (fullname-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ;; Look for a character that cannot appear unquoted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; according to RFC 822.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;; Quote fullname, escaping specials.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (while (re-search-forward "[\"\\]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (insert "\""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (insert " <" login ">\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ((eq mail-from-style 'parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (insert "From: " login " (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((fullname-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (let ((fullname-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;; RFC 822 says \ and nonmatching parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;; must be escaped in comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;; Escape every instance of ()\ ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (while (re-search-forward "[()\\]" fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;; ... then undo escaping of matching parentheses,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;; including matching nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (replace-match "\\1(\\3)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (goto-char fullname-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (insert ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ((null mail-from-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (insert "From: " login "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;; Insert an extra newline if we need it to work around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; Sun's bug that swallows newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (goto-char (1+ delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (if (eval mail-mailer-swallows-blank-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;; Find and handle any FCC fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (if (re-search-forward "^FCC:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (mail-do-fcc delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (erase-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (if (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 sendmail-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 "/usr/lib/sendmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 nil errbuf nil "-oi")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; Always specify who from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; since some systems have broken sendmails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (list "-f" (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 ;;; ;; Don't say "from root" if running under su.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;;; (and (equal (user-real-login-name) "root")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;;; (list "-f" (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (and mail-alias-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (list (concat "-oA" mail-alias-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 ;; These mean "report errors by mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 ;; and "deliver in background".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (if (null mail-interactive) '("-oem" "-odb"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; Get the addresses from the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; unless this is a resend.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; We must not do that for a resend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;; because we would find the original addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; For a resend, include the specific addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (or resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 '("-t")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (while (re-search-forward "\n\n* *" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (replace-match "; "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (if (not (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (error "Sending...failed to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (buffer-substring (point-min) (point-max)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (kill-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (if (bufferp errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (kill-buffer errbuf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ;;; FCC hackery, by jwz. This version works on BABYL and VM buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;;; To accomplish the latter, VM is loaded when this file is compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;;; Don't worry, it's only loaded at compile-time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (defun mail-do-fcc (header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (let (fcc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (send-mail-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (tembuf (generate-new-buffer " rmail output"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (or (markerp header-end) (error "header-end must be a marker"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (while (re-search-forward "^FCC:[ \t]*" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (setq fcc-list (cons (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 fcc-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (delete-region (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; insert just the headers to avoid moving the gap more than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;; necessary (the message body could be arbitrarily huge.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (insert-buffer-substring send-mail-buffer 1 header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ;; if there's no From: or Date: field, cons some.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (or (re-search-forward "^From[ \t]*:" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (insert "From: " (user-login-name) " (" (user-full-name) ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (or (re-search-forward "^Date[ \t]*:" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (mail-do-fcc-insert-date-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; insert a magic From_ line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (insert "\nFrom " (user-login-name) " " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (insert-buffer-substring send-mail-buffer header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (goto-char (1- header-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ;; ``Quote'' "^From " as ">From "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;; (note that this isn't really quoting, as there is no requirement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;; that "^[>]+From " be quoted in the same transparent way.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (while (search-forward "\nFrom " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (forward-char -5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (insert ?>)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (setq beg (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 end (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (while fcc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (let ((target-buffer (get-file-buffer (car fcc-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (if target-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; File is present in a buffer => append to that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (set-buffer target-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (cond ((eq major-mode 'rmail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (mail-do-fcc-rmail-internal tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ((eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (mail-do-fcc-vm-internal tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; Append to an ordinary buffer as a Unix mail message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (insert-buffer-substring tembuf beg end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; Else append to the file directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; (It's OK if it is an RMAIL or VM file -- the message will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 ;; parsed when the file is read in.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (1+ (point-min)) (point-max) (car fcc-list) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (setq fcc-list (cdr fcc-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (kill-buffer tembuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (defvar mail-do-fcc-cached-timezone nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (defun mail-do-fcc-insert-date-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; Convert the ctime() format that `current-time-string' returns into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; an RFC-822-legal date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (let ((s (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (string-match "\\`\\([A-Z][a-z][a-z]\\) +\\([A-Z][a-z][a-z]\\) +\\([0-9][0-9]?\\) *\\([0-9][0-9]?:[0-9][0-9]:[0-9][0-9]\\) *[0-9]?[0-9]?\\([0-9][0-9]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (insert "Date: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (substring s (match-beginning 1) (match-end 1)) ", "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (substring s (match-beginning 3) (match-end 3)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (substring s (match-beginning 2) (match-end 2)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (substring s (match-beginning 5) (match-end 5)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (substring s (match-beginning 4) (match-end 4)) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (if mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (insert mail-do-fcc-cached-timezone "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; First, try to use the current-time-zone function, which may not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;; defined, and even if it is defined, may error or return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (or (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (let ((zoneinfo (current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (if (stringp (nth 1 zoneinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (nth 1 zoneinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (or (if (nth 1 zoneinfo) (nth 3 zoneinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (nth 2 zoneinfo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (insert mail-do-fcc-cached-timezone "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 mail-do-fcc-cached-timezone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; Otherwise, run date(1) and parse its output. Yuck!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (call-process "date" nil t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (forward-word -1) ; skip back over year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (delete-region (1- (point)) (1- (point-max))) ; nuke year to end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (forward-word -1) ; skip back over zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (delete-region (point-min) (point)) ; nuke beginning to zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (setq mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (buffer-substring (point-min) (1- (point-max)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (defun mail-do-fcc-rmail-internal (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (or (eq major-mode 'rmail-mode) (error "this only works in rmail-mode"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (let ((b (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (e (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; This forces RMAIL's message counters to be recomputed when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; next RMAIL operation is done on the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; See rmail-maybe-set-message-counters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (setq rmail-total-messages nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (insert "\^L\n0, unseen,,\n*** EOOH ***")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (insert "\n\C-_"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (narrow-to-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (rmail-maybe-set-message-counters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (eval-when-compile
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
870 (require 'vm-misc))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (defun mail-do-fcc-vm-internal (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (or (eq major-mode 'vm-mode) (error "this only works in vm-mode"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (foreign-folder-p (not (eq vm-folder-type 'From_))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; `buffer' has already been prepared with a "From " line which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; has a sensible user-id and date in it, but if we're FCCing to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; a VM folder that isn't in From_ format, we must discard that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; and let VM do whatever voodoo it needs to do. (Actually we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ;; could do this all the time, but then all FCCed messages would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ;; have "From VM ..." envelopes, which is less attractive.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (skip-chars-forward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (delete-region (point-min) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; Largely copied from #'vm-save-message in vm-save.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (vm-write-string (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (vm-leading-message-separator vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (vm-write-string (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (vm-trailing-message-separator vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (vm-increment vm-messages-not-on-disk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (vm-assimilate-new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (vm-update-summary-and-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ;;(defun mail-sent-via ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 ;; "Make a Sent-via header line from each To or CC header line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; ;; find the header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; (search-forward (concat "\n" mail-header-separator "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; ;; put a marker at the end of the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ;; (let ((end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ;; (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; to-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; ;; search for the To: lines and make Sent-via: lines from them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; ;; search for the next To: line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; (while (re-search-forward "^\\(to\\|cc\\):" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; ;; Grab this line plus all its continuations, sans the `to:'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; (let ((to-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; (if (re-search-forward "^[^ \t\n]" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; (goto-char end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; ;; Insert a copy, with altered header field name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; (insert-before-markers "Sent-via:" to-line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (defun mail-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 "Move point to end of To-field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (mail-position-on-field "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (defun mail-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 "Move point to end of Subject-field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (mail-position-on-field "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (defun mail-cc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 "Move point to end of CC-field. Create a CC field if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (or (mail-position-on-field "cc" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (insert "\nCC: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (defun mail-bcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 "Move point to end of BCC-field. Create a BCC field if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (or (mail-position-on-field "bcc" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (insert "\nBCC: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (defun mail-fcc (folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 "Add a new FCC field, with file name completion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (interactive "FFolder carbon copy: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (mail-position-on-field "to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (insert "\nFCC: " folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (defun mail-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 "Move point to end of Reply-To-field. Create a Reply-To field if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (or (mail-position-on-field "reply-to" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (insert "\nReply-To: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (defun mail-position-on-field (field &optional soft)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (let (end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (setq end (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (if (re-search-forward (concat "^" (regexp-quote field) ":") end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (or soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (progn (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; #### FSF has the next two clauses reversed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; which is correct?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (insert "\n" field ": ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (defun mail-text ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 "Move point to beginning of message text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (search-forward (concat "\n" mail-header-separator "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (defun mail-signature (&optional atpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 "Sign letter with contents of the file `mail-signature-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 Prefix arg means put contents at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (or atpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (or atpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (delete-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (insert "\n\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (insert-file-contents (expand-file-name mail-signature-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (defun mail-fill-yanked-message (&optional justifyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 "Fill the paragraphs of a message yanked into this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 Numeric argument means justify as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (search-forward (concat "\n" mail-header-separator "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (fill-individual-paragraphs (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 justifyp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (defun mail-indent-citation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 "Modify text just inserted from a message to be cited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 The inserted text should be the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 When this function returns, the region is again around the modified text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 Normally, indent each nonblank line `mail-indentation-spaces' spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (mail-yank-clear-headers start (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (if (null mail-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (indent-rigidly start (mark t) mail-indentation-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (while (< (point) (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (insert mail-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (forward-line 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (defun mail-yank-original (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 "Insert the message being replied to, if any (in rmail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 Puts point before the text and mark after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 Normally, indents each nonblank line ARG spaces (default 3).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 Just \\[universal-argument] as argument means don't indent, insert no prefix,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 and don't delete any header fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (if mail-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (reader-buf mail-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (reader-window (get-buffer-window mail-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (selected-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 ;; If the original message is in another window in the same frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;; delete that window to save screen space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;; t means don't alter other frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (if reader-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (delete-windows-on reader-buf t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (insert-buffer reader-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (if (consp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 mail-indentation-spaces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (cond (mail-citation-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (run-hooks 'mail-citation-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (mail-yank-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (run-hooks 'mail-yank-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (mail-indent-citation)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (exchange-point-and-mark t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (if (not (eolp)) (insert ?\n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (defun mail-yank-clear-headers (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (if mail-yank-ignored-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (if (search-forward "\n\n" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (narrow-to-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (while (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (re-search-forward mail-yank-ignored-headers nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (progn (re-search-forward "\n[^ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 ;; Put these last, to reduce chance of lossage from quitting in middle of loading the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (defun mail (&optional noerase to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 "Edit a message to be sent. Prefix arg means resume editing (don't erase).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 When this function returns, the buffer `*mail*' is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 The value is t if the message was newly initialized; otherwise, nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 Optionally, the signature file `mail-signature-file' can be inserted at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 end; see the variable `mail-signature'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 \\<mail-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 While editing message, type \\[mail-send-and-exit] to send the message and exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 Various special commands starting with C-c are available in sendmail mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 to move to message header fields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 \\{mail-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 The variable `mail-signature' controls whether the signature file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 `mail-signature-file' is inserted immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 If `mail-signature' is nil, use \\[mail-signature] to insert the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 signature in `mail-signature-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 If `mail-self-blind' is non-nil, a BCC to yourself is inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 when the message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 If `mail-default-reply-to' is non-nil, it should be an address (a string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 a Reply-to: field with that address is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 If `mail-archive-file-name' is non-nil, an FCC field with that file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 The normal hook `mail-setup-hook' is run after the message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 initialized. It can add more default fields to the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 When calling from a program, the first argument if non-nil says
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 not to erase the existing contents of the `*mail*' buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 The second through fifth arguments,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 TO, SUBJECT, IN-REPLY-TO and CC, specify if non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 the initial contents of those header fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 These arguments should not have final newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 The sixth argument REPLYBUFFER is a buffer whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 should be yanked if the user types C-c C-y.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 The seventh argument ACTIONS is a list of actions to take
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 if/when the message is sent. Each action looks like (FUNCTION . ARGS);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 when the message is sent, we apply FUNCTION to ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 This is how Rmail arranges to mark messages `answered'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (if mail-use-multiple-buffers-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; RMS doesn't like this behavior but it seems more logical to me. --ben
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (let ((index 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; If requested, look for a mail buffer that is modified and go to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (if noerase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (while (and (setq buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (get-buffer (if (= 1 index) "*mail*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (format "*mail*<%d>" index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (not (buffer-modified-p buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (setq index (1+ index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (if buffer (switch-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;; If none exists, start a new message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;; This will never re-use an existing unmodified mail buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; (since index is not 1 anymore). Perhaps it should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (setq noerase nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; Unless we found a modified message and are happy, start a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;; new message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (if (not noerase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; Look for existing unmodified mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (while (and (setq buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (get-buffer (if (= 1 index) "*mail*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (format "*mail*<%d>" index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (buffer-modified-p buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (setq index (1+ index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ;; If none, make a new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (or buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (setq buffer (generate-new-buffer "*mail*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;; Go there and initialize it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (switch-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; put mail auto-save files in home dir instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;; scattering them around the file system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (setq default-directory (or mail-dir (expand-file-name "~/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (mail-setup to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (if (and buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (message "Auto save file for draft message exists; consider M-x mail-recover"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; Alternate behavior that RMS likes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (pop-to-buffer "*mail*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; Disconnect the buffer from its visited file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; (in case the user has actually visited a file *mail*).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 ; (set-visited-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (let (initialized)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (and (not noerase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (or (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (y-or-n-p "Unsent message being composed; erase it? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (progn (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (mail-setup to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (setq initialized t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (if (and buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (message "Auto save file for draft message exists; consider M-x mail-recover"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 initialized)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (defun mail-recover ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 "Reread contents of current buffer from its last auto-save file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (let ((file-name (let ((default-directory (expand-file-name "~/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 ;; put mail auto-save files in home dir instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; scattering them around the file system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (make-auto-save-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (cond ((save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (if (not (eq system-type 'vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (with-output-to-temp-buffer "*Directory*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (buffer-disable-undo standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (call-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 "ls" nil standard-output nil "-l" file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (insert-file-contents file-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (t (error "mail-recover cancelled")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (defun mail-other-window (&optional noerase to subject in-reply-to cc replybuffer sendactions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 "Like `mail' command, but display mail buffer in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (pop-to-buffer "*mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (mail noerase to subject in-reply-to cc replybuffer sendactions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (defun mail-other-frame (&optional noerase to subject in-reply-to cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 replybuffer sendactions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 "Like `mail' command, but display mail buffer in another frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (pop-to-buffer "*mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (mail noerase to subject in-reply-to cc replybuffer sendactions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ;;; Do not execute these when sendmail.el is loaded,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;;; only in loaddefs.el.
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
1263 ;;; Do not autoload, this package is obsolete. -sb
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;;;###autoload (define-key ctl-x-map "m" 'mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;;;###autoload (define-key ctl-x-4-map "m" 'mail-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;;;###autoload (define-key ctl-x-5-map "m" 'mail-other-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;;;###autoload (add-hook 'same-window-buffer-names "*mail*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;;; Do not add anything but external entries on this page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (provide 'sendmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;;; sendmail.el ends here