annotate lisp/modes/sendmail.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 9f59509498e1
children 538048ae2ab8
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
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
289 ;; Courtesy of Per Abrahamsen <abraham@dina.kvl.dk> in an attempt to make
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
290 ;; Emacs and XEmacs less stupid about default mail addresses.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
291
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
292 ;; We trust the administrator if he has set `mail-host-address'.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
293 ;; We trust the user if he has already customized `user-mail-address'.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
294 (defcustom query-user-mail-address (and (not mail-host-address)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
295 (not user-mail-address))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
296 "If non-nil, prompt the user for his mail address."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
297 :group 'message
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
298 :type 'boolean)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
299
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
300 ;;;###autoload
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
301 (defun user-mail-address ()
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
302 "Query the user for his mail address, unless it is already known."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
303 (interactive)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
304 (when (and (not noninteractive) query-user-mail-address)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
305 (let ((addr (or user-mail-address
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
306 (concat (user-login-name) "@"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
307 (or mail-host-address
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
308 (system-name))))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
309 (setq user-mail-address
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
310 (read-string "Your mail address? " (cons addr 0)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
311 (setq query-user-mail-address nil)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
312 ;; TODO: Run sanity check from Gnus here.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
313 (when (y-or-n-p "Save address for future sessions? ")
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
314 (put 'user-mail-address 'saved-value
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
315 (list user-mail-address))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
316 (put 'query-user-mail-address 'saved-value '(nil))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
317 (require 'cus-edit)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
318 (custom-save-all))))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
319 (if user-mail-address
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
320 user-mail-address
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
321 (setq user-mail-address (concat (user-login-name) "@"
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
322 (or mail-host-address
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
323 (system-name))))))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
324
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun mail-setup (to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (or mail-default-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq mail-default-reply-to (getenv "REPLYTO")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;Removed. See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ; (sendmail-synch-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ; (if (eq mail-aliases t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ; (setq mail-aliases nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ; (if (file-exists-p mail-personal-alias-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ; (build-mail-aliases))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq mail-send-actions actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (mail-aliases-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq mail-reply-buffer replybuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (insert "To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; Here removed code to extract names from within <...>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;; on the assumption that mail-strip-quoted-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; has been called and has done so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (let ((fill-prefix "\t")
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 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 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (if cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (let ((fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (address-start (progn (insert "CC: ") (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (insert cc "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (fill-region-as-paragraph address-start (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if in-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (let ((fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (fill-column 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (address-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (insert "In-reply-to: " in-reply-to "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (fill-region-as-paragraph address-start (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (insert "Subject: " (or subject "") "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if mail-default-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (insert mail-default-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (if mail-default-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (insert "Reply-to: " mail-default-reply-to "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if mail-self-blind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (insert "BCC: " (user-login-name) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (if mail-archive-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (insert "FCC: " mail-archive-file-name "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (insert mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; Insert the signature. But remember the beginning of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (if to (setq to (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (cond ((eq mail-signature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (file-exists-p mail-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (insert "\n\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (insert-file-contents mail-signature-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (mail-signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (insert mail-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (or (bolp) (newline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if to (goto-char to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (or to subject in-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (run-hooks 'mail-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defun mail-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "Major mode for editing mail to be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 Like Text Mode but with these additional commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 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
393 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
394 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
395 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
396 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
397 C-c C-t mail-text (move to beginning of message text).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 C-c C-w mail-signature (insert `mail-signature-file' file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 C-c C-y mail-yank-original (insert current message, in Rmail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 C-c C-q mail-fill-yanked-message (fill what was yanked).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 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
402 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (make-local-variable 'mail-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (setq mail-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (make-local-variable 'mail-send-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (set-syntax-table mail-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (use-local-map mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (setq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (setq mode-name "Mail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq buffer-offer-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (turn-on-auto-fill) ; XEmacs - maybe filladapt should be default, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (setq paragraph-start (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 paragraph-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq paragraph-separate (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 paragraph-separate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; Set menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq mode-popup-menu mail-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (featurep 'menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; make a local copy of the menubar, so our modes don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; change the global menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (set-buffer-menubar current-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (add-submenu nil mail-menubar-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (run-hooks 'text-mode-hook 'mail-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;;; Set up keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if mail-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq mail-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (set-keymap-parents mail-mode-map (list text-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (set-keymap-name mail-mode-map 'mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (define-key mail-mode-map "\C-c?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (define-key mail-mode-map "\C-c\C-f\C-t" 'mail-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (define-key mail-mode-map "\C-c\C-f\C-b" 'mail-bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (define-key mail-mode-map "\C-c\C-f\C-f" 'mail-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (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
448 (define-key mail-mode-map "\C-c\C-t" 'mail-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (define-key mail-mode-map "\C-c\C-q" 'mail-fill-yanked-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (define-key mail-mode-map "\C-c\C-w" 'mail-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;;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
453 (define-key mail-mode-map "\C-c\C-c" 'mail-send-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (define-key mail-mode-map "\C-c\C-s" 'mail-send))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;;; mail-mode popup menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defvar mail-menubar-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 '("Mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 "Sending Mail:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ["Send and Exit" mail-send-and-exit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ["Send Mail" mail-send t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Go to Field:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ["To:" mail-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ["Subject:" mail-subject t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ["CC:" mail-cc t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ["BCC:" mail-bcc t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ["Reply-To:" mail-reply-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; ["Sent Via:" mail-sent-via t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ["Text" mail-text t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 "Miscellaneous Commands:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ["Yank Original" mail-yank-original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (not (null mail-reply-buffer))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ["Fill Yanked Message" mail-fill-yanked-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (and (search-forward (concat "\n" mail-header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (not (looking-at "[ \t\n]*\\'"))))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ["Insert Signature" mail-signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (and (stringp mail-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (file-exists-p mail-signature-file))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ["Insert File..." insert-file t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ["Insert Buffer..." insert-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ["Cancel" mail-dont-send t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Menubar menu for `mail-mode'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defvar mail-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (cons "Sendmail Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (cdr mail-menubar-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 "Menubar menu for `mail-mode'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun mail-send-and-exit (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 "Send message like `mail-send', then, if no errors, exit from mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 Prefix arg means don't delete this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (mail-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (mail-bury arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun mail-dont-send (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "Don't send the message you have been editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Prefix arg means don't delete this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (mail-bury arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (defun mail-bury (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 "Bury this mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (let ((newbuf (other-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (if (and (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (cdr (assq 'dedicated (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (not (null (delq (selected-frame) (visible-frame-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (delete-frame (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (let (rmail-flag summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (and (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (not (one-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (set-buffer (window-buffer (next-window (selected-window) 'not)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq rmail-flag (eq major-mode 'rmail-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (setq summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (and mail-bury-selects-summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (boundp 'rmail-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 rmail-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (buffer-name rmail-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (not (get-buffer-window rmail-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 rmail-summary-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if rmail-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; If the Rmail buffer has a summary, show that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if summary-buffer (switch-to-buffer summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (switch-to-buffer newbuf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (defun mail-send ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "Send the message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 If `mail-interactive' is non-nil, wait for success indication or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 messages, and inform user. Otherwise any failure is reported in a message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 back to the user from the mailer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (y-or-n-p "Send buffer contents as mail message? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (or (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (y-or-n-p "Message already sent; resend? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (expand-abbrev) ; for mail-abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (run-hooks 'mail-send-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (funcall send-mail-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; Now perform actions on successful sending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (while mail-send-actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (apply (car (car mail-send-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (cdr (car mail-send-actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq mail-send-actions (cdr mail-send-actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (message "Sending...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; If buffer has no file, mark it as unmodified and delete autosave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (cond ((or (not buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (not (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (delete-auto-save-file-if-necessary t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ((or noninteractive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (y-or-n-p (format "Save file %s? " buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (save-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defun sendmail-send-it ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (let ((errbuf (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (generate-new-buffer " sendmail errors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (tembuf (generate-new-buffer " sendmail temp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 delimline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (mailbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (insert-buffer-substring mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; Change header-delimiter to be what sendmail expects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (setq delimline (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;Removed. See `mail-abbrevs.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ; (sendmail-synch-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ; (if mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ; (expand-mail-aliases (point-min) delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;; ignore any blank lines in the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (while (and (re-search-forward "\n\n\n*" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (< (point) delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (replace-match "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (let ((case-fold-search t))
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 (while (re-search-forward "^Resent-to:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (setq resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (append (mail-parse-comma-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 resend-to-addresses))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;;; Apparently this causes a duplicate Sender.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;;; ;; If the From is different than current user, insert Sender.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;;; (and (re-search-forward "^From:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;;; (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;;; (not (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;; (mail-strip-quoted-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;; (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;; (narrow-to-region (point-min) delimline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;; (mail-fetch-field "From")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;; (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;;; (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;;; (insert "Sender: " (user-login-name) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; Don't send out a blank subject line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; Put the "From:" field in unless for some odd reason
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;; they put one in themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (not (re-search-forward "^From:" delimline t))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
645 (let* ((login (user-mail-address))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (fullname (user-full-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (cond ((eq mail-from-style 'angles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (insert "From: " fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (let ((fullname-start (+ (point-min) 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (fullname-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Look for a character that cannot appear unquoted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; according to RFC 822.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;; Quote fullname, escaping specials.
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 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (while (re-search-forward "[\"\\]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (insert "\""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (insert " <" login ">\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ((eq mail-from-style 'parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (insert "From: " login " (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (let ((fullname-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (let ((fullname-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; RFC 822 says \ and nonmatching parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; must be escaped in comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; Escape every instance of ()\ ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (while (re-search-forward "[()\\]" fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; ... then undo escaping of matching parentheses,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; including matching nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 fullname-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (replace-match "\\1(\\3)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (goto-char fullname-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (insert ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ((null mail-from-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (insert "From: " login "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; Insert an extra newline if we need it to work around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; Sun's bug that swallows newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (goto-char (1+ delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (if (eval mail-mailer-swallows-blank-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; Find and handle any FCC fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (if (re-search-forward "^FCC:" delimline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (mail-do-fcc delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (erase-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (if (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 sendmail-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 "/usr/lib/sendmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 nil errbuf nil "-oi")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; Always specify who from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; since some systems have broken sendmails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (list "-f" (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;;; ;; Don't say "from root" if running under su.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;;; (and (equal (user-real-login-name) "root")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;;; (list "-f" (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (and mail-alias-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (list (concat "-oA" mail-alias-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;; These mean "report errors by mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ;; and "deliver in background".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if (null mail-interactive) '("-oem" "-odb"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;; Get the addresses from the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; unless this is a resend.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; We must not do that for a resend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; because we would find the original addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ;; For a resend, include the specific addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (or resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 '("-t")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (if mail-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (while (re-search-forward "\n\n* *" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (replace-match "; "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (if (not (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (error "Sending...failed to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (buffer-substring (point-min) (point-max)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (kill-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (if (bufferp errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (kill-buffer errbuf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;;; FCC hackery, by jwz. This version works on BABYL and VM buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;;; To accomplish the latter, VM is loaded when this file is compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;;; Don't worry, it's only loaded at compile-time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (defun mail-do-fcc (header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (let (fcc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (send-mail-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (tembuf (generate-new-buffer " rmail output"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (or (markerp header-end) (error "header-end must be a marker"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (while (re-search-forward "^FCC:[ \t]*" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (setq fcc-list (cons (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 fcc-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (delete-region (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; insert just the headers to avoid moving the gap more than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ;; necessary (the message body could be arbitrarily huge.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (insert-buffer-substring send-mail-buffer 1 header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;; if there's no From: or Date: field, cons some.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (or (re-search-forward "^From[ \t]*:" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (insert "From: " (user-login-name) " (" (user-full-name) ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (or (re-search-forward "^Date[ \t]*:" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (mail-do-fcc-insert-date-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;; insert a magic From_ line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (insert "\nFrom " (user-login-name) " " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (insert-buffer-substring send-mail-buffer header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (goto-char (1- header-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;; ``Quote'' "^From " as ">From "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; (note that this isn't really quoting, as there is no requirement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; that "^[>]+From " be quoted in the same transparent way.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (while (search-forward "\nFrom " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (forward-char -5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (insert ?>)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (setq beg (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 end (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (while fcc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (let ((target-buffer (get-file-buffer (car fcc-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (if target-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; File is present in a buffer => append to that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (set-buffer target-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (cond ((eq major-mode 'rmail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (mail-do-fcc-rmail-internal tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ((eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (mail-do-fcc-vm-internal tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; Append to an ordinary buffer as a Unix mail message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (insert-buffer-substring tembuf beg end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; Else append to the file directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; (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
809 ;; parsed when the file is read in.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (1+ (point-min)) (point-max) (car fcc-list) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq fcc-list (cdr fcc-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (kill-buffer tembuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (defvar mail-do-fcc-cached-timezone nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (defun mail-do-fcc-insert-date-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;; Convert the ctime() format that `current-time-string' returns into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; an RFC-822-legal date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (let ((s (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (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
822 s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (insert "Date: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (substring s (match-beginning 1) (match-end 1)) ", "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (substring s (match-beginning 3) (match-end 3)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (substring s (match-beginning 2) (match-end 2)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (substring s (match-beginning 5) (match-end 5)) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (substring s (match-beginning 4) (match-end 4)) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (if mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (insert mail-do-fcc-cached-timezone "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; First, try to use the current-time-zone function, which may not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; defined, and even if it is defined, may error or return 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 (or (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (let ((zoneinfo (current-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (setq mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (if (stringp (nth 1 zoneinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (nth 1 zoneinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (or (if (nth 1 zoneinfo) (nth 3 zoneinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (nth 2 zoneinfo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (insert mail-do-fcc-cached-timezone "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 mail-do-fcc-cached-timezone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Otherwise, run date(1) and parse its output. Yuck!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (call-process "date" nil t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (forward-word -1) ; skip back over year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (delete-region (1- (point)) (1- (point-max))) ; nuke year to end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (forward-word -1) ; skip back over zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (delete-region (point-min) (point)) ; nuke beginning to zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (setq mail-do-fcc-cached-timezone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (buffer-substring (point-min) (1- (point-max)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
862 (eval-when-compile
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
863 (require 'vm-misc))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
864
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defun mail-do-fcc-rmail-internal (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (or (eq major-mode 'rmail-mode) (error "this only works in rmail-mode"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (let ((b (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (e (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; This forces RMAIL's message counters to be recomputed when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;; next RMAIL operation is done on the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ;; See rmail-maybe-set-message-counters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (setq rmail-total-messages nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (insert "\^L\n0, unseen,,\n*** EOOH ***")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (insert "\n\C-_"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (narrow-to-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (rmail-maybe-set-message-counters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (defun mail-do-fcc-vm-internal (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (or (eq major-mode 'vm-mode) (error "this only works in vm-mode"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (foreign-folder-p (not (eq vm-folder-type 'From_))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; `buffer' has already been prepared with a "From " line which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; 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
892 ;; a VM folder that isn't in From_ format, we must discard that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ;; and let VM do whatever voodoo it needs to do. (Actually we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; could do this all the time, but then all FCCed messages would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;; have "From VM ..." envelopes, which is less attractive.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (skip-chars-forward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (delete-region (point-min) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; Largely copied from #'vm-save-message in vm-save.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (vm-write-string (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (vm-leading-message-separator vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (insert-buffer-substring buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (if foreign-folder-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (vm-write-string (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (vm-trailing-message-separator vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (vm-increment vm-messages-not-on-disk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (vm-assimilate-new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (vm-update-summary-and-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ;;(defun mail-sent-via ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; "Make a Sent-via header line from each To or CC header line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; ;; find the header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; (search-forward (concat "\n" mail-header-separator "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; ;; put a marker at the end of the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; (let ((end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; to-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; ;; search for the To: lines and make Sent-via: lines from them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;; ;; search for the next To: line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;; (while (re-search-forward "^\\(to\\|cc\\):" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ;; ;; Grab this line plus all its continuations, sans the `to:'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;; (let ((to-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 ;; (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; (if (re-search-forward "^[^ \t\n]" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;; (goto-char end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; ;; Insert a copy, with altered header field name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; (insert-before-markers "Sent-via:" to-line))))))
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-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 "Move point to end of To-field."
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 (mail-position-on-field "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (defun mail-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 "Move point to end of Subject-field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (mail-position-on-field "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (defun mail-cc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 "Move point to end of CC-field. Create a CC field if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (or (mail-position-on-field "cc" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (insert "\nCC: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (defun mail-bcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 "Move point to end of BCC-field. Create a BCC field if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (or (mail-position-on-field "bcc" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (insert "\nBCC: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (defun mail-fcc (folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 "Add a new FCC field, with file name completion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (interactive "FFolder carbon copy: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (mail-position-on-field "to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (insert "\nFCC: " folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (defun mail-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 "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
987 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (or (mail-position-on-field "reply-to" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (progn (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (insert "\nReply-To: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (defun mail-position-on-field (field &optional soft)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (let (end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (setq end (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (if (re-search-forward (concat "^" (regexp-quote field) ":") end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (or soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (progn (goto-char end)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1008 ;; #### FSF has the next two clauses reversed.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1009 ;; which is correct?
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1010 (skip-chars-backward "\n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1011 (insert "\n" field ": ")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (defun mail-text ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 "Move point to beginning of message text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (search-forward (concat "\n" mail-header-separator "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (defun mail-signature (&optional atpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 "Sign letter with contents of the file `mail-signature-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 Prefix arg means put contents at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (or atpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (or atpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (delete-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (insert "\n\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (insert-file-contents (expand-file-name mail-signature-file))))
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-fill-yanked-message (&optional justifyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 "Fill the paragraphs of a message yanked into this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 Numeric argument means justify as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (search-forward (concat "\n" mail-header-separator "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (fill-individual-paragraphs (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 justifyp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (defun mail-indent-citation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 "Modify text just inserted from a message to be cited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 The inserted text should be the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 When this function returns, the region is again around the modified text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 Normally, indent each nonblank line `mail-indentation-spaces' spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 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
1054 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (mail-yank-clear-headers start (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (if (null mail-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (indent-rigidly start (mark t) mail-indentation-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (while (< (point) (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (insert mail-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (forward-line 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (defun mail-yank-original (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 "Insert the message being replied to, if any (in rmail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 Puts point before the text and mark after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 Normally, indents each nonblank line ARG spaces (default 3).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 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
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 Just \\[universal-argument] as argument means don't indent, insert no prefix,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 and don't delete any header fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (if mail-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (reader-buf mail-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (reader-window (get-buffer-window mail-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (selected-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;; If the original message is in another window in the same frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;; delete that window to save screen space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ;; t means don't alter other frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (if reader-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (delete-windows-on reader-buf t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (insert-buffer reader-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (if (consp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 mail-indentation-spaces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (cond (mail-citation-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (run-hooks 'mail-citation-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (mail-yank-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (run-hooks 'mail-yank-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (mail-indent-citation)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (exchange-point-and-mark t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (if (not (eolp)) (insert ?\n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (defun mail-yank-clear-headers (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (if mail-yank-ignored-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (if (search-forward "\n\n" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (narrow-to-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (while (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (re-search-forward mail-yank-ignored-headers nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (progn (re-search-forward "\n[^ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; 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
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (defun mail (&optional noerase to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 "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
1119 When this function returns, the buffer `*mail*' is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 The value is t if the message was newly initialized; otherwise, nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 Optionally, the signature file `mail-signature-file' can be inserted at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 end; see the variable `mail-signature'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 \\<mail-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 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
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 Various special commands starting with C-c are available in sendmail mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 to move to message header fields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 \\{mail-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 The variable `mail-signature' controls whether the signature file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 `mail-signature-file' is inserted immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 If `mail-signature' is nil, use \\[mail-signature] to insert the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 signature in `mail-signature-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 If `mail-self-blind' is non-nil, a BCC to yourself is inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 when the message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 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
1142 a Reply-to: field with that address is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 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
1145 is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 The normal hook `mail-setup-hook' is run after the message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 initialized. It can add more default fields to the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 When calling from a program, the first argument if non-nil says
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 not to erase the existing contents of the `*mail*' buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 The second through fifth arguments,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 TO, SUBJECT, IN-REPLY-TO and CC, specify if non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 the initial contents of those header fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 These arguments should not have final newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 The sixth argument REPLYBUFFER is a buffer whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 should be yanked if the user types C-c C-y.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 The seventh argument ACTIONS is a list of actions to take
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 if/when the message is sent. Each action looks like (FUNCTION . ARGS);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 when the message is sent, we apply FUNCTION to ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 This is how Rmail arranges to mark messages `answered'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (if mail-use-multiple-buffers-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;; 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
1167 (let ((index 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; 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
1170 (if noerase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (while (and (setq buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (get-buffer (if (= 1 index) "*mail*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (format "*mail*<%d>" index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (not (buffer-modified-p buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (setq index (1+ index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (if buffer (switch-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; If none exists, start a new message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 ;; This will never re-use an existing unmodified mail buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ;; (since index is not 1 anymore). Perhaps it should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (setq noerase nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ;; Unless we found a modified message and are happy, start a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;; new message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (if (not noerase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; Look for existing unmodified mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (while (and (setq buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (get-buffer (if (= 1 index) "*mail*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (format "*mail*<%d>" index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (buffer-modified-p buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq index (1+ index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; If none, make a new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (or buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (setq buffer (generate-new-buffer "*mail*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; Go there and initialize it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (switch-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 ;; put mail auto-save files in home dir instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;; scattering them around the file system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (setq default-directory (or mail-dir (expand-file-name "~/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (mail-setup to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (if (and buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (message "Auto save file for draft message exists; consider M-x mail-recover"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ;; Alternate behavior that RMS likes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (pop-to-buffer "*mail*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; Disconnect the buffer from its visited file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; (in case the user has actually visited a file *mail*).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ; (set-visited-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (let (initialized)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (and (not noerase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (or (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (y-or-n-p "Unsent message being composed; erase it? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (progn (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (mail-setup to subject in-reply-to cc replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (setq initialized t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (if (and buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (message "Auto save file for draft message exists; consider M-x mail-recover"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 initialized)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (defun mail-recover ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 "Reread contents of current buffer from its last auto-save file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (let ((file-name (let ((default-directory (expand-file-name "~/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; put mail auto-save files in home dir instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; scattering them around the file system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (make-auto-save-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (cond ((save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (if (not (eq system-type 'vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (with-output-to-temp-buffer "*Directory*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (buffer-disable-undo standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (call-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 "ls" nil standard-output nil "-l" file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (insert-file-contents file-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (t (error "mail-recover cancelled")))))
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-window (&optional noerase to subject in-reply-to cc replybuffer sendactions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 "Like `mail' command, but display mail buffer in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (pop-to-buffer "*mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (mail noerase to subject in-reply-to cc replybuffer sendactions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (defun mail-other-frame (&optional noerase to subject in-reply-to cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 replybuffer sendactions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 "Like `mail' command, but display mail buffer in another frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (pop-to-buffer "*mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (mail noerase to subject in-reply-to cc replybuffer sendactions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;;; Do not execute these when sendmail.el is loaded,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;;; only in loaddefs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 ;;;###autoload (define-key ctl-x-map "m" 'mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;;;###autoload (define-key ctl-x-4-map "m" 'mail-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ;;;###autoload (define-key ctl-x-5-map "m" 'mail-other-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;;;###autoload (add-hook 'same-window-buffer-names "*mail*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;;; Do not add anything but external entries on this page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (provide 'sendmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 ;;; sendmail.el ends here