annotate lisp/modes/sendmail.el @ 0:376386a54a3c r19-14

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