38412
|
1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
|
658
|
2
|
64754
|
3 ;; Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998,
|
68648
|
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
846
|
5
|
807
|
6 ;; Maintainer: FSF
|
814
|
7 ;; Keywords: mail
|
807
|
8
|
270
|
9 ;; This file is part of GNU Emacs.
|
|
10
|
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
12 ;; it under the terms of the GNU General Public License as published by
|
807
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
270
|
14 ;; any later version.
|
|
15
|
|
16 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;; GNU General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
14169
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
64085
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
24 ;; Boston, MA 02110-1301, USA.
|
270
|
25
|
38412
|
26 ;;; Commentary:
|
|
27
|
807
|
28 ;;; Code:
|
270
|
29
|
|
30 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
|
|
31 ;; New features include attribute and keyword support, message
|
|
32 ;; selection by dispatch table, summary by attributes and keywords,
|
|
33 ;; expunging by dispatch table, sticky options for file commands.
|
|
34
|
2076
|
35 ;; Extended by Bob Weiner of Motorola
|
|
36 ;; New features include: rmail and rmail-summary buffers remain
|
|
37 ;; synchronized and key bindings basically operate the same way in both
|
|
38 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
|
|
39 ;; variable, and a bury rmail buffer (wipe) command.
|
|
40 ;;
|
|
41
|
270
|
42 (require 'mail-utils)
|
39298
|
43 (eval-when-compile (require 'mule-util)) ; for detect-coding-with-priority
|
2076
|
44
|
65210
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
45 (defvar deleted-head)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
46 (defvar font-lock-fontified)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
47 (defvar mail-abbrev-syntax-table)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
48 (defvar mail-abbrevs)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
49 (defvar messages-head)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
50 (defvar rmail-use-spam-filter)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
51 (defvar rsf-beep)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
52 (defvar rsf-sleep-after-message)
|
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
53 (defvar total-messages)
|
69676
|
54 (defvar tool-bar-map)
|
65210
65cc9b3bbebd
(deleted-head, font-lock-fontified, mail-abbrev-syntax-table, mail-abbrevs,
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
55
|
2076
|
56 ; These variables now declared in paths.el.
|
270
|
57 ;(defvar rmail-spool-directory "/usr/spool/mail/"
|
|
58 ; "This is the name of the directory used by the system mailer for\n\
|
16431
|
59 ;delivering new mail. Its name should end with a slash.")
|
270
|
60 ;(defvar rmail-file-name
|
|
61 ; (expand-file-name "~/RMAIL")
|
|
62 ; "")
|
|
63
|
17630
|
64 (defgroup rmail nil
|
|
65 "Mail reader for Emacs."
|
|
66 :group 'mail)
|
|
67
|
|
68 (defgroup rmail-retrieve nil
|
|
69 "Rmail retrieval options."
|
|
70 :prefix "rmail-"
|
|
71 :group 'rmail)
|
|
72
|
|
73 (defgroup rmail-files nil
|
|
74 "Rmail files."
|
|
75 :prefix "rmail-"
|
|
76 :group 'rmail)
|
|
77
|
|
78 (defgroup rmail-headers nil
|
|
79 "Rmail header options."
|
|
80 :prefix "rmail-"
|
|
81 :group 'rmail)
|
|
82
|
|
83 (defgroup rmail-reply nil
|
|
84 "Rmail reply options."
|
|
85 :prefix "rmail-"
|
|
86 :group 'rmail)
|
|
87
|
|
88 (defgroup rmail-summary nil
|
|
89 "Rmail summary options."
|
|
90 :prefix "rmail-"
|
|
91 :prefix "rmail-summary-"
|
|
92 :group 'rmail)
|
|
93
|
|
94 (defgroup rmail-output nil
|
|
95 "Output message to a file."
|
|
96 :prefix "rmail-output-"
|
|
97 :prefix "rmail-"
|
|
98 :group 'rmail)
|
|
99
|
37587
|
100 (defgroup rmail-edit nil
|
|
101 "Rmail editing."
|
|
102 :prefix "rmail-edit-"
|
|
103 :group 'rmail)
|
|
104
|
59561
|
105 (defgroup rmail-obsolete nil
|
|
106 "Rmail obsolete customization variables."
|
|
107 :group 'rmail)
|
17630
|
108
|
21435
|
109 (defcustom rmail-movemail-program nil
|
60692
|
110 "If non-nil, the file name of the `movemail' program."
|
21435
|
111 :group 'rmail-retrieve
|
23266
|
112 :type '(choice (const nil) string))
|
8234
|
113
|
17630
|
114 (defcustom rmail-pop-password nil
|
60692
|
115 "*Password to use when reading mail from POP server.
|
|
116 Please use `rmail-remote-password' instead."
|
59561
|
117 :type '(choice (string :tag "Password")
|
|
118 (const :tag "Not Required" nil))
|
|
119 :group 'rmail-obsolete)
|
|
120
|
|
121 (defcustom rmail-pop-password-required nil
|
64754
|
122 "*Non-nil if a password is required when reading mail from a POP server.
|
60692
|
123 Please use rmail-remote-password-required instead."
|
59561
|
124 :type 'boolean
|
|
125 :group 'rmail-obsolete)
|
|
126
|
|
127 (defcustom rmail-remote-password nil
|
60692
|
128 "*Password to use when reading mail from a remote server.
|
|
129 This setting is ignored for mailboxes whose URL already contains a password."
|
17630
|
130 :type '(choice (string :tag "Password")
|
|
131 (const :tag "Not Required" nil))
|
59561
|
132 :set-after '(rmail-pop-password)
|
|
133 :set #'(lambda (symbol value)
|
59996
|
134 (set-default symbol
|
59561
|
135 (if (and (not value)
|
|
136 (boundp 'rmail-pop-password)
|
|
137 rmail-pop-password)
|
|
138 rmail-pop-password
|
|
139 value))
|
|
140 (setq rmail-pop-password nil))
|
|
141 :group 'rmail-retrieve
|
59996
|
142 :version "22.1")
|
59561
|
143
|
|
144 (defcustom rmail-remote-password-required nil
|
|
145 "*Non-nil if a password is required when reading mail from a remote server."
|
17630
|
146 :type 'boolean
|
59561
|
147 :set-after '(rmail-pop-password-required)
|
|
148 :set #'(lambda (symbol value)
|
59996
|
149 (set-default symbol
|
59561
|
150 (if (and (not value)
|
|
151 (boundp 'rmail-pop-password-required)
|
|
152 rmail-pop-password-required)
|
|
153 rmail-pop-password-required
|
|
154 value))
|
|
155 (setq rmail-pop-password-required nil))
|
|
156 :group 'rmail-retrieve
|
59996
|
157 :version "22.1")
|
15085
|
158
|
21395
|
159 (defcustom rmail-movemail-flags nil
|
21398
|
160 "*List of flags to pass to movemail.
|
|
161 Most commonly used to specify `-g' to enable GSS-API authentication
|
|
162 or `-k' to enable Kerberos authentication."
|
21512
|
163 :type '(repeat string)
|
21669
|
164 :group 'rmail-retrieve
|
|
165 :version "20.3")
|
21395
|
166
|
59561
|
167 (defvar rmail-remote-password-error "invalid usercode or password\\|
|
|
168 unknown user name or bad password\\|Authentication failed\\|MU_ERR_AUTH_FAILURE"
|
|
169 "Regular expression matching incorrect-password POP or IMAP server error
|
|
170 messages.
|
18989
|
171 If you get an incorrect-password error that this expression does not match,
|
|
172 please report it with \\[report-emacs-bug].")
|
|
173
|
59561
|
174 (defvar rmail-encoded-remote-password nil)
|
22912
|
175
|
17630
|
176 (defcustom rmail-preserve-inbox nil
|
60692
|
177 "*Non-nil means leave incoming mail in the user's inbox--don't delete it."
|
17630
|
178 :type 'boolean
|
|
179 :group 'rmail-retrieve)
|
16908
|
180
|
59561
|
181 (defcustom rmail-movemail-search-path nil
|
|
182 "*List of directories to search for movemail (in addition to `exec-path')."
|
|
183 :group 'rmail-retrieve
|
|
184 :type '(repeat (directory)))
|
|
185
|
|
186 (defun rmail-probe (prog)
|
60692
|
187 "Determine what flavor of movemail PROG is.
|
|
188 We do this by executing it with `--version' and analyzing its output."
|
59561
|
189 (with-temp-buffer
|
|
190 (let ((tbuf (current-buffer)))
|
|
191 (buffer-disable-undo tbuf)
|
|
192 (call-process prog nil tbuf nil "--version")
|
|
193 (if (not (buffer-modified-p tbuf))
|
|
194 ;; Should not happen...
|
|
195 nil
|
|
196 (goto-char (point-min))
|
|
197 (cond
|
|
198 ((looking-at ".*movemail: invalid option")
|
|
199 'emacs) ;; Possibly...
|
|
200 ((looking-at "movemail (GNU Mailutils .*)")
|
|
201 'mailutils)
|
|
202 (t
|
|
203 ;; FIXME:
|
|
204 'emacs))))))
|
|
205
|
|
206 (defun rmail-autodetect ()
|
60692
|
207 "Determine and return the file name of the `movemail' program.
|
|
208 If `rmail-movemail-program' is non-nil, use it.
|
|
209 Otherwise, look for `movemail' in the directories in
|
|
210 `rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
|
59561
|
211 (if rmail-movemail-program
|
|
212 (rmail-probe rmail-movemail-program)
|
|
213 (catch 'scan
|
|
214 (dolist (dir (append rmail-movemail-search-path exec-path
|
|
215 (list exec-directory)))
|
|
216 (when (and dir (file-accessible-directory-p dir))
|
|
217 (let ((progname (expand-file-name "movemail" dir)))
|
|
218 (when (and (not (file-directory-p progname))
|
|
219 (file-executable-p progname))
|
|
220 (let ((x (rmail-probe progname)))
|
|
221 (when x
|
|
222 (setq rmail-movemail-program progname)
|
|
223 (throw 'scan x))))))))))
|
|
224
|
|
225 (defvar rmail-movemail-variant-in-use nil
|
|
226 "The movemail variant currently in use. Known variants are:
|
|
227
|
|
228 `emacs' Means any implementation, compatible with the native Emacs one.
|
|
229 This is the default;
|
|
230 `mailutils' Means GNU mailutils implementation, capable of handling full
|
|
231 mail URLs as the source mailbox;")
|
|
232
|
|
233 ;;;###autoload
|
|
234 (defun rmail-movemail-variant-p (&rest variants)
|
|
235 "Return t if the current movemail variant is any of VARIANTS.
|
|
236 Currently known variants are 'emacs and 'mailutils."
|
|
237 (when (not rmail-movemail-variant-in-use)
|
|
238 ;; Autodetect
|
|
239 (setq rmail-movemail-variant-in-use (rmail-autodetect)))
|
|
240 (not (null (member rmail-movemail-variant-in-use variants))))
|
|
241
|
270
|
242 ;;;###autoload
|
17630
|
243 (defcustom rmail-dont-reply-to-names nil "\
|
44025
5766d225ccf3
(rmail-dont-reply-to-names): Modify the documentation to make it email
Paul Reilly <pmr@pajato.com>
diff
changeset
|
244 *A regexp specifying addresses to prune from a reply message.
|
5766d225ccf3
(rmail-dont-reply-to-names): Modify the documentation to make it email
Paul Reilly <pmr@pajato.com>
diff
changeset
|
245 A value of nil means exclude your own email address as an address
|
22840
|
246 plus whatever is specified by `rmail-default-dont-reply-to-names'."
|
17630
|
247 :type '(choice regexp (const :tag "Your Name" nil))
|
|
248 :group 'rmail-reply)
|
270
|
249
|
|
250 ;;;###autoload
|
53967
|
251 (defvar rmail-default-dont-reply-to-names "\\`info-" "\
|
|
252 A regular expression specifying part of the default value of the
|
|
253 variable `rmail-dont-reply-to-names', for when the user does not set
|
270
|
254 `rmail-dont-reply-to-names' explicitly. (The other part of the default
|
44025
5766d225ccf3
(rmail-dont-reply-to-names): Modify the documentation to make it email
Paul Reilly <pmr@pajato.com>
diff
changeset
|
255 value is the user's email address and name.)
|
3931
|
256 It is useful to set this variable in the site customization file.")
|
270
|
257
|
|
258 ;;;###autoload
|
35675
|
259 (defcustom rmail-ignored-headers
|
61598
|
260 (concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
|
35675
|
261 "\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
|
|
262 "\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
|
|
263 "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
|
51003
|
264 "\\|^nntp-posting-host:\\|^path:\\|^x-char.*:\\|^x-face:\\|^face:"
|
64831
40c02e6cdccd
(rmail-ignored-headers): Don't hide mime-version: and content-type: headers.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
265 "\\|^x-mailer:\\|^delivered-to:\\|^lines:"
|
35675
|
266 "\\|^content-transfer-encoding:\\|^x-coding-system:"
|
|
267 "\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
|
|
268 "\\|^precedence:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
|
|
269 "\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
|
64972
|
270 "\\|^content-length:\\|^nntp-posting-date:\\|^user-agent"
|
|
271 "\\|^importance:\\|^envelope-to:\\|^delivery-date\\|^openpgp:"
|
69386
|
272 "\\|^mbox-line:\\|^cancel-lock:\\|^DomainKey-Signature:"
|
64972
|
273 "\\|^resent-face:\\|^resent-x.*:\\|^resent-organization:\\|^resent-openpgp:"
|
|
274
|
|
275 "\\|^x-.*:")
|
24562
|
276 "*Regexp to match header fields that Rmail should normally hide.
|
64972
|
277 \(See also `rmail-nonignored-headers', which overrides this regexp.)
|
|
278 This variable is used for reformatting the message header,
|
|
279 which normally happens once for each message,
|
|
280 when you view the message for the first time in Rmail.
|
|
281 To make a change in this variable take effect
|
|
282 for a message that you have already viewed,
|
|
283 go to that message and type \\[rmail-toggle-header] twice."
|
|
284 :type 'regexp
|
|
285 :group 'rmail-headers)
|
|
286
|
|
287 (defcustom rmail-nonignored-headers "^x-spam-status:"
|
|
288 "*Regexp to match X header fields that Rmail should show.
|
|
289 This regexp overrides `rmail-ignored-headers'; if both this regexp
|
|
290 and that one match a certain header field, Rmail shows the field.
|
|
291
|
24562
|
292 This variable is used for reformatting the message header,
|
|
293 which normally happens once for each message,
|
|
294 when you view the message for the first time in Rmail.
|
|
295 To make a change in this variable take effect
|
|
296 for a message that you have already viewed,
|
|
297 go to that message and type \\[rmail-toggle-header] twice."
|
17630
|
298 :type 'regexp
|
|
299 :group 'rmail-headers)
|
270
|
300
|
|
301 ;;;###autoload
|
17630
|
302 (defcustom rmail-displayed-headers nil
|
11452
|
303 "*Regexp to match Header fields that Rmail should display.
|
|
304 If nil, display all header fields except those matched by
|
17630
|
305 `rmail-ignored-headers'."
|
|
306 :type '(choice regexp (const :tag "All"))
|
|
307 :group 'rmail-headers)
|
11452
|
308
|
|
309 ;;;###autoload
|
36568
|
310 (defcustom rmail-retry-ignored-headers "^x-authentication-warning:" "\
|
17630
|
311 *Headers that should be stripped when retrying a failed message."
|
|
312 :type '(choice regexp (const nil :tag "None"))
|
|
313 :group 'rmail-headers)
|
9010
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
314
|
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
315 ;;;###autoload
|
17630
|
316 (defcustom rmail-highlighted-headers "^From:\\|^Subject:" "\
|
8383
|
317 *Regexp to match Header fields that Rmail should normally highlight.
|
8384
|
318 A value of nil means don't highlight.
|
17630
|
319 See also `rmail-highlight-face'."
|
|
320 :type 'regexp
|
|
321 :group 'rmail-headers)
|
7051
|
322
|
69386
|
323 (defface rmail-highlight
|
|
324 '((t :default highlight))
|
|
325 "Face to use for highlighting the most important header fields."
|
|
326 :group 'rmail-headers
|
|
327 :version "22.1")
|
|
328
|
7051
|
329 ;;;###autoload
|
69386
|
330 (defcustom rmail-highlight-face 'rmail-highlight "\
|
17630
|
331 *Face used by Rmail for highlighting headers."
|
|
332 :type '(choice (const :tag "Default" nil)
|
|
333 face)
|
|
334 :group 'rmail-headers)
|
8383
|
335
|
|
336 ;;;###autoload
|
17630
|
337 (defcustom rmail-delete-after-output nil "\
|
|
338 *Non-nil means automatically delete a message that is copied to a file."
|
|
339 :type 'boolean
|
|
340 :group 'rmail-files)
|
270
|
341
|
|
342 ;;;###autoload
|
17630
|
343 (defcustom rmail-primary-inbox-list nil "\
|
2423
|
344 *List of files which are inboxes for user's primary mail file `~/RMAIL'.
|
50864
5f3b64308e0c
(rmail-primary-inbox-list): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
345 nil means the default, which is (\"/usr/spool/mail/$USER\")
|
2423
|
346 \(the name varies depending on the operating system,
|
17630
|
347 and the value of the environment variable MAIL overrides it)."
|
17821
|
348 ;; Don't use backquote here, because we don't want to need it
|
|
349 ;; at load time.
|
|
350 :type (list 'choice '(const :tag "Default" nil)
|
23185
|
351 (list 'repeat ':value (list (or (getenv "MAIL")
|
|
352 (concat "/var/spool/mail/"
|
|
353 (getenv "USER"))))
|
17821
|
354 'file))
|
17630
|
355 :group 'rmail-retrieve
|
|
356 :group 'rmail-files)
|
270
|
357
|
4108
|
358 ;;;###autoload
|
17630
|
359 (defcustom rmail-mail-new-frame nil
|
55114
|
360 "*Non-nil means Rmail makes a new frame for composing outgoing mail.
|
|
361 This is handy if you want to preserve the window configuration of
|
|
362 the frame where you have the RMAIL buffer displayed."
|
17630
|
363 :type 'boolean
|
|
364 :group 'rmail-reply)
|
4108
|
365
|
4844
|
366 ;;;###autoload
|
17630
|
367 (defcustom rmail-secondary-file-directory "~/"
|
|
368 "*Directory for additional secondary Rmail files."
|
|
369 :type 'directory
|
|
370 :group 'rmail-files)
|
6408
|
371 ;;;###autoload
|
17630
|
372 (defcustom rmail-secondary-file-regexp "\\.xmail$"
|
|
373 "*Regexp for which files are secondary Rmail files."
|
|
374 :type 'regexp
|
|
375 :group 'rmail-files)
|
6408
|
376
|
13477
|
377 ;;;###autoload
|
33792
|
378 (defcustom rmail-confirm-expunge 'y-or-n-p
|
28290
|
379 "*Whether and how to ask for confirmation before expunging deleted messages."
|
|
380 :type '(choice (const :tag "No confirmation" nil)
|
|
381 (const :tag "Confirm with y-or-n-p" y-or-n-p)
|
|
382 (const :tag "Confirm with yes-or-no-p" yes-or-no-p))
|
|
383 :version "21.1"
|
|
384 :group 'rmail-files)
|
|
385
|
|
386 ;;;###autoload
|
13477
|
387 (defvar rmail-mode-hook nil
|
|
388 "List of functions to call when Rmail is invoked.")
|
|
389
|
|
390 ;;;###autoload
|
|
391 (defvar rmail-get-new-mail-hook nil
|
|
392 "List of functions to call when Rmail has retrieved new mail.")
|
|
393
|
|
394 ;;;###autoload
|
28910
|
395 (defcustom rmail-show-message-hook nil
|
|
396 "List of functions to call when Rmail displays a message."
|
|
397 :type 'hook
|
45360
|
398 :options '(goto-address)
|
28910
|
399 :group 'rmail)
|
13477
|
400
|
|
401 ;;;###autoload
|
27944
|
402 (defvar rmail-quit-hook nil
|
|
403 "List of functions to call when quitting out of Rmail.")
|
|
404
|
|
405 ;;;###autoload
|
13477
|
406 (defvar rmail-delete-message-hook nil
|
|
407 "List of functions to call when Rmail deletes a message.
|
|
408 When the hooks are called, the message has been marked deleted but is
|
|
409 still the current message in the Rmail buffer.")
|
|
410
|
2076
|
411 ;; These may be altered by site-init.el to match the format of mmdf files
|
|
412 ;; delimiting used on a given host (delim1 and delim2 from the config
|
|
413 ;; files).
|
270
|
414
|
18091
|
415 (defvar rmail-mmdf-delim1 "^\001\001\001\001\n"
|
49082
|
416 "Regexp marking the start of an mmdf message.")
|
18091
|
417 (defvar rmail-mmdf-delim2 "^\001\001\001\001\n"
|
49082
|
418 "Regexp marking the end of an mmdf message.")
|
270
|
419
|
21435
|
420 (defcustom rmail-message-filter nil
|
15832
|
421 "If non-nil, a filter function for new messages in RMAIL.
|
|
422 Called with region narrowed to the message, including headers,
|
21435
|
423 before obeying `rmail-ignored-headers'."
|
|
424 :group 'rmail-headers
|
|
425 :type 'function)
|
270
|
426
|
29160
|
427 (defcustom rmail-automatic-folder-directives nil
|
|
428 "List of directives specifying where to put a message.
|
|
429 Each element of the list is of the form:
|
|
430
|
|
431 (FOLDERNAME FIELD REGEXP [ FIELD REGEXP ] ... )
|
|
432
|
|
433 Where FOLDERNAME is the name of a BABYL format folder to put the
|
|
434 message. If any of the field regexp's are nil, then it is ignored.
|
|
435
|
|
436 If FOLDERNAME is \"/dev/null\", it is deleted.
|
|
437 If FOLDERNAME is nil then it is deleted, and skipped.
|
|
438
|
|
439 FIELD is the plain text name of a field in the message, such as
|
|
440 \"subject\" or \"from\". A FIELD of \"to\" will automatically include
|
|
441 all text from the \"cc\" field as well.
|
|
442
|
|
443 REGEXP is an expression to match in the preceeding specified FIELD.
|
|
444 FIELD/REGEXP pairs continue in the list.
|
|
445
|
|
446 examples:
|
|
447 (\"/dev/null\" \"from\" \"@spam.com\") ; delete all mail from spam.com
|
33918
|
448 (\"RMS\" \"from\" \"rms@\") ; save all mail from RMS."
|
|
449 :group 'rmail
|
|
450 :version "21.1"
|
|
451 :type '(repeat (sexp :tag "Directive")))
|
45144
|
452
|
2076
|
453 (defvar rmail-reply-prefix "Re: "
|
|
454 "String to prepend to Subject line when replying to a message.")
|
|
455
|
17065
|
456 ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
|
69568
|
457 ;; This pattern should catch all the common variants.
|
|
458 ;; rms: I deleted the change to delete tags in square brackets
|
|
459 ;; because they mess up RT tags.
|
|
460 (defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
|
15832
|
461 "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
|
10640
|
462
|
21435
|
463 (defcustom rmail-display-summary nil
|
|
464 "*If non-nil, Rmail always displays the summary buffer."
|
|
465 :group 'rmail-summary
|
|
466 :type 'boolean)
|
|
467
|
|
468 (defvar rmail-inbox-list nil)
|
|
469 (put 'rmail-inbox-list 'permanent-local t)
|
8384
|
470
|
270
|
471 (defvar rmail-keywords nil)
|
21435
|
472 (put 'rmail-keywords 'permanent-local t)
|
270
|
473
|
19509
|
474 (defvar rmail-buffer nil
|
|
475 "The RMAIL buffer related to the current buffer.
|
|
476 In an RMAIL buffer, this holds the RMAIL buffer itself.
|
|
477 In a summary buffer, this holds the RMAIL buffer it is a summary for.")
|
|
478 (put 'rmail-buffer 'permanent-local t)
|
|
479
|
270
|
480 ;; Message counters and markers. Deleted flags.
|
|
481
|
|
482 (defvar rmail-current-message nil)
|
21435
|
483 (put 'rmail-current-message 'permanent-local t)
|
|
484
|
270
|
485 (defvar rmail-total-messages nil)
|
21435
|
486 (put 'rmail-total-messages 'permanent-local t)
|
|
487
|
270
|
488 (defvar rmail-message-vector nil)
|
21435
|
489 (put 'rmail-message-vector 'permanent-local t)
|
|
490
|
270
|
491 (defvar rmail-deleted-vector nil)
|
21435
|
492 (put 'rmail-deleted-vector 'permanent-local t)
|
|
493
|
17620
|
494 (defvar rmail-msgref-vector nil
|
|
495 "In an Rmail buffer, a vector whose Nth element is a list (N).
|
|
496 When expunging renumbers messages, these lists are modified
|
|
497 by substituting the new message number into the existing list.")
|
21435
|
498 (put 'rmail-msgref-vector 'permanent-local t)
|
270
|
499
|
7061
|
500 (defvar rmail-overlay-list nil)
|
21435
|
501 (put 'rmail-overlay-list 'permanent-local t)
|
9380
|
502
|
270
|
503 ;; These are used by autoloaded rmail-summary.
|
|
504
|
|
505 (defvar rmail-summary-buffer nil)
|
19509
|
506 (put 'rmail-summary-buffer 'permanent-local t)
|
270
|
507 (defvar rmail-summary-vector nil)
|
19509
|
508 (put 'rmail-summary-vector 'permanent-local t)
|
270
|
509
|
21435
|
510 (defvar rmail-view-buffer nil
|
|
511 "Buffer which holds RMAIL message for MIME displaying.")
|
|
512 (put 'rmail-view-buffer 'permanent-local t)
|
|
513
|
270
|
514 ;; `Sticky' default variables.
|
|
515
|
|
516 ;; Last individual label specified to a or k.
|
|
517 (defvar rmail-last-label nil)
|
21435
|
518 (put 'rmail-last-label 'permanent-local t)
|
|
519
|
2076
|
520 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
|
270
|
521 (defvar rmail-last-multi-labels nil)
|
21435
|
522
|
2076
|
523 (defvar rmail-last-regexp nil)
|
21435
|
524 (put 'rmail-last-regexp 'permanent-local t)
|
|
525
|
17630
|
526 (defcustom rmail-default-file "~/xmail"
|
|
527 "*Default file name for \\[rmail-output]."
|
|
528 :type 'file
|
|
529 :group 'rmail-files)
|
|
530 (defcustom rmail-default-rmail-file "~/XMAIL"
|
|
531 "*Default file name for \\[rmail-output-to-rmail-file]."
|
|
532 :type 'file
|
|
533 :group 'rmail-files)
|
22201
|
534 (defcustom rmail-default-body-file "~/mailout"
|
|
535 "*Default file name for \\[rmail-output-body-to-file]."
|
|
536 :type 'file
|
|
537 :group 'rmail-files
|
|
538 :version "20.3")
|
617
|
539
|
21435
|
540 ;; Mule and MIME related variables.
|
|
541
|
|
542 ;;;###autoload
|
|
543 (defvar rmail-file-coding-system nil
|
|
544 "Coding system used in RMAIL file.
|
|
545
|
|
546 This is set to nil by default.")
|
|
547
|
|
548 ;;;###autoload
|
|
549 (defcustom rmail-enable-mime nil
|
|
550 "*If non-nil, RMAIL uses MIME feature.
|
|
551 If the value is t, RMAIL automatically shows MIME decoded message.
|
|
552 If the value is neither t nor nil, RMAIL does not show MIME decoded message
|
68255
|
553 until a user explicitly requires it.
|
|
554
|
|
555 Even if the value is non-nil, you can't use MIME feature
|
|
556 if the feature specified by `rmail-mime-feature' is not available
|
|
557 in your session."
|
21435
|
558 :type '(choice (const :tag "on" t)
|
|
559 (const :tag "off" nil)
|
22591
|
560 (other :tag "when asked" ask))
|
21435
|
561 :group 'rmail)
|
|
562
|
41511
|
563 (defvar rmail-enable-mime-composing nil
|
|
564 "*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
|
|
565
|
21435
|
566 ;;;###autoload
|
|
567 (defvar rmail-show-mime-function nil
|
37611
|
568 "Function to show MIME decoded message of RMAIL file.
|
|
569 This function is called when `rmail-enable-mime' is non-nil.
|
|
570 It is called with no argument.")
|
|
571
|
|
572 ;;;###autoload
|
|
573 (defvar rmail-insert-mime-forwarded-message-function nil
|
|
574 "Function to insert a message in MIME format so it can be forwarded.
|
45144
|
575 This function is called if `rmail-enable-mime' or
|
41511
|
576 `rmail-enable-mime-composing' is non-nil.
|
37611
|
577 It is called with one argument FORWARD-BUFFER, which is a
|
|
578 buffer containing the message to forward. The current buffer
|
|
579 is the outgoing mail buffer.")
|
|
580
|
|
581 ;;;###autoload
|
37956
|
582 (defvar rmail-insert-mime-resent-message-function nil
|
|
583 "Function to insert a message in MIME format so it can be resent.
|
|
584 This function is called if `rmail-enable-mime' is non-nil.
|
|
585 It is called with one argument FORWARD-BUFFER, which is a
|
|
586 buffer containing the message to forward. The current buffer
|
|
587 is the outgoing mail buffer.")
|
|
588
|
|
589 ;;;###autoload
|
37611
|
590 (defvar rmail-search-mime-message-function nil
|
|
591 "Function to check if a regexp matches a MIME message.
|
|
592 This function is called if `rmail-enable-mime' is non-nil.
|
|
593 It is called with two arguments MSG and REGEXP, where
|
|
594 MSG is the message number, REGEXP is the regular expression.")
|
|
595
|
|
596 ;;;###autoload
|
|
597 (defvar rmail-search-mime-header-function nil
|
|
598 "Function to check if a regexp matches a header of MIME message.
|
|
599 This function is called if `rmail-enable-mime' is non-nil.
|
46924
|
600 It is called with three arguments MSG, REGEXP, and LIMIT, where
|
37611
|
601 MSG is the message number,
|
|
602 REGEXP is the regular expression,
|
|
603 LIMIT is the position specifying the end of header.")
|
21435
|
604
|
|
605 ;;;###autoload
|
|
606 (defvar rmail-mime-feature 'rmail-mime
|
22133
|
607 "Feature to require to load MIME support in Rmail.
|
|
608 When starting Rmail, if `rmail-enable-mime' is non-nil,
|
68255
|
609 this feature is required with `require'.
|
|
610
|
|
611 The default value is `rmail-mime'. This feature is provided by
|
|
612 the rmail-mime package available at <http://www.m17n.org/rmail-mime/>.")
|
24209
|
613
|
|
614 ;;;###autoload
|
|
615 (defvar rmail-decode-mime-charset t
|
|
616 "*Non-nil means a message is decoded by MIME's charset specification.
|
|
617 If this variable is nil, or the message has not MIME specification,
|
|
618 the message is decoded as normal way.
|
|
619
|
|
620 If the variable `rmail-enable-mime' is non-nil, this variables is
|
|
621 ignored, and all the decoding work is done by a feature specified by
|
|
622 the variable `rmail-mime-feature'.")
|
|
623
|
|
624 ;;;###autoload
|
|
625 (defvar rmail-mime-charset-pattern
|
69907
|
626 (concat "^content-type:[ ]*text/plain;"
|
70771
|
627 "\\(?:[ \t\n]*\\(?:format\\|delsp\\)=\"?[-a-z0-9]+\"?;\\)*"
|
69907
|
628 "[ \t\n]*charset=\"?\\([^ \t\n\";]+\\)\"?")
|
24209
|
629 "Regexp to match MIME-charset specification in a header of message.
|
|
630 The first parenthesized expression should match the MIME-charset name.")
|
|
631
|
21435
|
632
|
621
|
633 ;;; Regexp matching the delimiter of messages in UNIX mail format
|
|
634 ;;; (UNIX From lines), minus the initial ^. Note that if you change
|
|
635 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
|
|
636 ;;; that knows the exact ordering of the \\( \\) subexpressions.
|
617
|
637 (defvar rmail-unix-mail-delimiter
|
1112
|
638 (let ((time-zone-regexp
|
12727
|
639 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
|
1112
|
640 "\\|[-+]?[0-9][0-9][0-9][0-9]"
|
|
641 "\\|"
|
|
642 "\\) *")))
|
|
643 (concat
|
|
644 "From "
|
|
645
|
15534
|
646 ;; Many things can happen to an RFC 822 mailbox before it is put into
|
|
647 ;; a `From' line. The leading phrase can be stripped, e.g.
|
|
648 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
|
|
649 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
|
|
650 ;; can be removed, e.g.
|
|
651 ;; From: joe@y.z (Joe K
|
|
652 ;; User)
|
|
653 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
|
|
654 ;; From: Joe User
|
|
655 ;; <joe@y.z>
|
|
656 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
|
15820
|
657 ;; The mailbox can be removed or be replaced by white space, e.g.
|
|
658 ;; From: "Joe User"{space}{tab}
|
|
659 ;; <joe@y.z>
|
|
660 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
|
|
661 ;; where {space} and {tab} represent the Ascii space and tab characters.
|
15534
|
662 ;; We want to match the results of any of these manglings.
|
|
663 ;; The following regexp rejects names whose first characters are
|
|
664 ;; obviously bogus, but after that anything goes.
|
15820
|
665 "\\([^\0-\b\n-\r\^?].*\\)? "
|
1112
|
666
|
|
667 ;; The time the message was sent.
|
15534
|
668 "\\([^\0-\r \^?]+\\) +" ; day of the week
|
|
669 "\\([^\0-\r \^?]+\\) +" ; month
|
|
670 "\\([0-3]?[0-9]\\) +" ; day of month
|
|
671 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
|
1112
|
672
|
|
673 ;; Perhaps a time zone, specified by an abbreviation, or by a
|
|
674 ;; numeric offset.
|
|
675 time-zone-regexp
|
|
676
|
|
677 ;; The year.
|
15534
|
678 " \\([0-9][0-9]+\\) *"
|
1112
|
679
|
|
680 ;; On some systems the time zone can appear after the year, too.
|
|
681 time-zone-regexp
|
|
682
|
7037
|
683 ;; Old uucp cruft.
|
|
684 "\\(remote from .*\\)?"
|
1112
|
685
|
|
686 "\n"))
|
|
687 nil)
|
|
688
|
21435
|
689 (defvar rmail-font-lock-keywords
|
49064
|
690 ;; These are all matched case-insensitively.
|
21435
|
691 (eval-when-compile
|
|
692 (let* ((cite-chars "[>|}]")
|
49064
|
693 (cite-prefix "a-z")
|
21435
|
694 (cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
|
49064
|
695 (list '("^\\(From\\|Sender\\|Resent-From\\):"
|
|
696 . font-lock-function-name-face)
|
21435
|
697 '("^Reply-To:.*$" . font-lock-function-name-face)
|
|
698 '("^Subject:" . font-lock-comment-face)
|
61598
|
699 '("^X-Spam-Status:" . font-lock-keyword-face)
|
21435
|
700 '("^\\(To\\|Apparently-To\\|Cc\\|Newsgroups\\):"
|
|
701 . font-lock-keyword-face)
|
|
702 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
|
|
703 `(,cite-chars
|
|
704 (,(concat "\\=[ \t]*"
|
61814
|
705 "\\(\\(\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
|
|
706 "\\(" cite-chars "[ \t]*\\)\\)+\\)"
|
21435
|
707 "\\(.*\\)")
|
|
708 (beginning-of-line) (end-of-line)
|
61814
|
709 (1 font-lock-comment-delimiter-face nil t)
|
|
710 (5 font-lock-comment-face nil t)))
|
49064
|
711 '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
|
21435
|
712 . font-lock-string-face))))
|
|
713 "Additional expressions to highlight in Rmail mode.")
|
|
714
|
2076
|
715 ;; Perform BODY in the summary buffer
|
|
716 ;; in such a way that its cursor is properly updated in its own window.
|
|
717 (defmacro rmail-select-summary (&rest body)
|
26455
|
718 `(let ((total rmail-total-messages))
|
|
719 (if (rmail-summary-displayed)
|
|
720 (let ((window (selected-window)))
|
|
721 (save-excursion
|
|
722 (unwind-protect
|
|
723 (progn
|
|
724 (pop-to-buffer rmail-summary-buffer)
|
|
725 ;; rmail-total-messages is a buffer-local var
|
|
726 ;; in the rmail buffer.
|
|
727 ;; This way we make it available for the body
|
|
728 ;; even tho the rmail buffer is not current.
|
|
729 (let ((rmail-total-messages total))
|
|
730 ,@body))
|
|
731 (select-window window))))
|
|
732 (save-excursion
|
|
733 (set-buffer rmail-summary-buffer)
|
|
734 (let ((rmail-total-messages total))
|
|
735 ,@body)))
|
|
736 (rmail-maybe-display-summary)))
|
270
|
737
|
|
738 ;;;; *** Rmail Mode ***
|
|
739
|
37787
|
740 ;; This variable is dynamically bound. The defvar is here to placate
|
|
741 ;; the byte compiler.
|
|
742
|
20943
|
743 (defvar rmail-enable-multibyte nil)
|
|
744
|
37787
|
745
|
|
746 (defun rmail-require-mime-maybe ()
|
|
747 "Require `rmail-mime-feature' if that is non-nil.
|
|
748 Signal an error and set `rmail-mime-feature' to nil if the feature
|
|
749 isn't provided."
|
|
750 (when rmail-enable-mime
|
|
751 (condition-case err
|
|
752 (require rmail-mime-feature)
|
|
753 (error
|
68255
|
754 (display-warning
|
|
755 :warning
|
|
756 (format "Although MIME support is requested
|
|
757 by setting `rmail-enable-mime' to non-nil, the required feature
|
|
758 `%s' (the value of `rmail-mime-feature')
|
|
759 is not available in the current session.
|
|
760 So, the MIME support is turned off for the moment."
|
|
761 rmail-mime-feature))
|
37787
|
762 (setq rmail-enable-mime nil)))))
|
|
763
|
|
764
|
270
|
765 ;;;###autoload
|
|
766 (defun rmail (&optional file-name-arg)
|
|
767 "Read and edit incoming mail.
|
4838
|
768 Moves messages into file named by `rmail-file-name' (a babyl format file)
|
270
|
769 and edits that file in RMAIL Mode.
|
|
770 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
|
|
771
|
5274
|
772 May be called with file name as argument; then performs rmail editing on
|
|
773 that file, but does not copy any new mail into the file.
|
|
774 Interactively, if you supply a prefix argument, then you
|
8384
|
775 have a chance to specify a file name with the minibuffer.
|
|
776
|
|
777 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
|
270
|
778 (interactive (if current-prefix-arg
|
13818
|
779 (list (read-file-name "Run rmail on RMAIL file: "))))
|
37787
|
780 (rmail-require-mime-maybe)
|
270
|
781 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
|
43087
|
782 ;; Use find-buffer-visiting, not get-file-buffer, for those users
|
|
783 ;; who have find-file-visit-truename set to t.
|
|
784 (existed (find-buffer-visiting file-name))
|
39298
|
785 ;; This binding is necessary because we must decide if we
|
20947
|
786 ;; need code conversion while the buffer is unibyte
|
|
787 ;; (i.e. enable-multibyte-characters is nil).
|
22724
|
788 (rmail-enable-multibyte
|
45144
|
789 (if existed
|
22724
|
790 (with-current-buffer existed enable-multibyte-characters)
|
|
791 (default-value 'enable-multibyte-characters)))
|
20943
|
792 ;; Since the file may contain messages of different encodings
|
|
793 ;; at the tail (non-BYBYL part), we can't decode them at once
|
|
794 ;; on reading. So, at first, we read the file without text
|
|
795 ;; code conversion, then decode the messages one by one by
|
|
796 ;; rmail-decode-babyl-format or
|
|
797 ;; rmail-convert-to-babyl-format.
|
|
798 (coding-system-for-read (and rmail-enable-multibyte 'raw-text))
|
20053
|
799 run-mail-hook msg-shown)
|
270
|
800 ;; Like find-file, but in the case where a buffer existed
|
|
801 ;; and the file was reverted, recompute the message-data.
|
21705
|
802 ;; We used to bind enable-local-variables to nil here,
|
|
803 ;; but that should not be needed now that rmail-mode
|
|
804 ;; sets it locally to nil.
|
|
805 ;; (Binding a variable locally with let is not safe if it has
|
|
806 ;; buffer-local bindings.)
|
270
|
807 (if (and existed (not (verify-visited-file-modtime existed)))
|
|
808 (progn
|
21705
|
809 (find-file file-name)
|
2076
|
810 (if (and (verify-visited-file-modtime existed)
|
|
811 (eq major-mode 'rmail-mode))
|
270
|
812 (progn (rmail-forget-messages)
|
|
813 (rmail-set-message-counters))))
|
45144
|
814 (switch-to-buffer
|
22474
|
815 (let ((enable-local-variables nil))
|
|
816 (find-file-noselect file-name))))
|
2076
|
817 (if (eq major-mode 'rmail-edit-mode)
|
20681
|
818 (error "Exit Rmail Edit mode before getting new mail"))
|
270
|
819 (if (and existed (> (buffer-size) 0))
|
|
820 ;; Buffer not new and not empty; ensure in proper mode, but that's all.
|
|
821 (or (eq major-mode 'rmail-mode)
|
16431
|
822 (progn (rmail-mode-2)
|
|
823 (setq run-mail-hook t)))
|
|
824 (setq run-mail-hook t)
|
270
|
825 (rmail-mode-2)
|
|
826 ;; Convert all or part to Babyl file if possible.
|
|
827 (rmail-convert-file)
|
22374
|
828 (goto-char (point-max)))
|
22498
|
829 ;; As we have read a file by raw-text, the buffer is set to
|
|
830 ;; unibyte. We must make it multibyte if necessary.
|
|
831 (if (and rmail-enable-multibyte
|
|
832 (not enable-multibyte-characters))
|
|
833 (set-buffer-multibyte t))
|
22435
|
834 ;; If necessary, scan to find all the messages.
|
|
835 (rmail-maybe-set-message-counters)
|
20662
|
836 (unwind-protect
|
22374
|
837 (unless (and (not file-name-arg)
|
|
838 (rmail-get-new-mail))
|
|
839 (rmail-show-message (rmail-first-unseen-message)))
|
20662
|
840 (progn
|
|
841 (if rmail-display-summary (rmail-summary))
|
|
842 (rmail-construct-io-menu)
|
|
843 (if run-mail-hook
|
|
844 (run-hooks 'rmail-mode-hook))))))
|
270
|
845
|
|
846 ;; Given the value of MAILPATH, return a list of inbox file names.
|
|
847 ;; This is turned off because it is not clear that the user wants
|
|
848 ;; all these inboxes to feed into the primary rmail file.
|
|
849 ; (defun rmail-convert-mailpath (string)
|
|
850 ; (let (idx list)
|
|
851 ; (while (setq idx (string-match "[%:]" string))
|
|
852 ; (let ((this (substring string 0 idx)))
|
|
853 ; (setq string (substring string (1+ idx)))
|
|
854 ; (setq list (cons (if (string-match "%" this)
|
|
855 ; (substring this 0 (string-match "%" this))
|
|
856 ; this)
|
|
857 ; list))))
|
|
858 ; list))
|
|
859
|
|
860 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
|
|
861 ; will not cause emacs 18.55 problems.
|
|
862
|
22045
|
863 ;; This calls rmail-decode-babyl-format if the file is already Babyl.
|
|
864
|
270
|
865 (defun rmail-convert-file ()
|
|
866 (let (convert)
|
|
867 (widen)
|
|
868 (goto-char (point-min))
|
|
869 ;; If file doesn't start like a Babyl file,
|
|
870 ;; convert it to one, by adding a header and converting each message.
|
|
871 (cond ((looking-at "BABYL OPTIONS:"))
|
|
872 ((looking-at "Version: 5\n")
|
|
873 ;; Losing babyl file made by old version of Rmail.
|
|
874 ;; Just fix the babyl file header; don't make a new one,
|
|
875 ;; so we don't lose the Labels: file attribute, etc.
|
|
876 (let ((buffer-read-only nil))
|
|
877 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
|
4764
|
878 ((equal (point-min) (point-max))
|
|
879 ;; Empty RMAIL file. Just insert the header.
|
|
880 (rmail-insert-rmail-file-header))
|
270
|
881 (t
|
4764
|
882 ;; Non-empty file in non-RMAIL format. Add header and convert.
|
270
|
883 (setq convert t)
|
|
884 (rmail-insert-rmail-file-header)))
|
|
885 ;; If file was not a Babyl file or if there are
|
|
886 ;; Unix format messages added at the end,
|
|
887 ;; convert file as necessary.
|
|
888 (if (or convert
|
4673
|
889 (save-excursion
|
|
890 (goto-char (point-max))
|
12839
|
891 (search-backward "\n\^_")
|
|
892 (forward-char 2)
|
4673
|
893 (looking-at "\n*From ")))
|
270
|
894 (let ((buffer-read-only nil))
|
|
895 (message "Converting to Babyl format...")
|
4673
|
896 ;; If file needs conversion, convert it all,
|
|
897 ;; except for the BABYL header.
|
|
898 ;; (rmail-convert-to-babyl-format would delete the header.)
|
|
899 (goto-char (point-min))
|
|
900 (search-forward "\n\^_" nil t)
|
4698
|
901 (narrow-to-region (point) (point-max))
|
270
|
902 (rmail-convert-to-babyl-format)
|
20943
|
903 (message "Converting to Babyl format...done"))
|
|
904 (if (and (not rmail-enable-mime)
|
|
905 rmail-enable-multibyte)
|
|
906 ;; We still have to decode BABYL part.
|
|
907 (rmail-decode-babyl-format)))))
|
270
|
908
|
|
909 (defun rmail-insert-rmail-file-header ()
|
|
910 (let ((buffer-read-only nil))
|
22045
|
911 ;; -*-rmail-*- is here so that visiting the file normally
|
|
912 ;; recognizes it as an Rmail file.
|
270
|
913 (insert "BABYL OPTIONS: -*- rmail -*-
|
|
914 Version: 5
|
|
915 Labels:
|
|
916 Note: This is the header of an rmail file.
|
|
917 Note: If you are seeing it in rmail,
|
|
918 Note: it means the file has no messages in it.\n\^_")))
|
|
919
|
46129
|
920 ;; Decode Babyl formatted part at the head of current buffer by
|
20943
|
921 ;; rmail-file-coding-system, or if it is nil, do auto conversion.
|
17093
|
922
|
|
923 (defun rmail-decode-babyl-format ()
|
|
924 (let ((modifiedp (buffer-modified-p))
|
|
925 (buffer-read-only nil)
|
22045
|
926 (coding-system rmail-file-coding-system)
|
20943
|
927 from to)
|
17093
|
928 (goto-char (point-min))
|
22045
|
929 (search-forward "\n\^_" nil t) ; Skip BABYL header.
|
20943
|
930 (setq from (point))
|
|
931 (goto-char (point-max))
|
|
932 (search-backward "\n\^_" from 'mv)
|
|
933 (setq to (point))
|
22045
|
934 (unless (and coding-system
|
|
935 (coding-system-p coding-system))
|
39298
|
936 (setq coding-system
|
|
937 ;; Emacs 21.1 and later writes RMAIL files in emacs-mule, but
|
|
938 ;; earlier versions did that with the current buffer's encoding.
|
|
939 ;; So we want to favor detection of emacs-mule (whose normal
|
|
940 ;; priority is quite low), but still allow detection of other
|
|
941 ;; encodings if emacs-mule won't fit. The call to
|
|
942 ;; detect-coding-with-priority below achieves that.
|
|
943 (car (detect-coding-with-priority
|
|
944 from to
|
|
945 '((coding-category-emacs-mule . emacs-mule))))))
|
23293
|
946 (unless (memq coding-system
|
|
947 '(undecided undecided-unix))
|
24584
|
948 (set-buffer-modified-p t) ; avoid locking when decoding
|
42659
9522b2780ef1
(rmail-decode-babyl-format): Disable undo around the decode-coding-region call.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
949 (let ((buffer-undo-list t))
|
9522b2780ef1
(rmail-decode-babyl-format): Disable undo around the decode-coding-region call.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
950 (decode-coding-region from to coding-system))
|
24584
|
951 (setq coding-system last-coding-system-used))
|
22045
|
952 (set-buffer-modified-p modifiedp)
|
|
953 (setq buffer-file-coding-system nil)
|
|
954 (setq save-buffer-coding-system
|
|
955 (or coding-system 'undecided))))
|
17093
|
956
|
21435
|
957 (defvar rmail-mode-map nil)
|
270
|
958 (if rmail-mode-map
|
|
959 nil
|
|
960 (setq rmail-mode-map (make-keymap))
|
|
961 (suppress-keymap rmail-mode-map)
|
2076
|
962 (define-key rmail-mode-map "a" 'rmail-add-label)
|
|
963 (define-key rmail-mode-map "b" 'rmail-bury)
|
|
964 (define-key rmail-mode-map "c" 'rmail-continue)
|
|
965 (define-key rmail-mode-map "d" 'rmail-delete-forward)
|
|
966 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward)
|
|
967 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
|
|
968 (define-key rmail-mode-map "f" 'rmail-forward)
|
|
969 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
|
|
970 (define-key rmail-mode-map "h" 'rmail-summary)
|
|
971 (define-key rmail-mode-map "i" 'rmail-input)
|
|
972 (define-key rmail-mode-map "j" 'rmail-show-message)
|
|
973 (define-key rmail-mode-map "k" 'rmail-kill-label)
|
|
974 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
|
270
|
975 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
|
|
976 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
|
|
977 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
|
|
978 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
|
2076
|
979 (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
|
|
980 (define-key rmail-mode-map "m" 'rmail-mail)
|
|
981 (define-key rmail-mode-map "\em" 'rmail-retry-failure)
|
|
982 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
|
|
983 (define-key rmail-mode-map "\en" 'rmail-next-message)
|
|
984 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
|
|
985 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
|
|
986 (define-key rmail-mode-map "\C-o" 'rmail-output)
|
|
987 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
|
|
988 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
|
|
989 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
|
|
990 (define-key rmail-mode-map "q" 'rmail-quit)
|
|
991 (define-key rmail-mode-map "r" 'rmail-reply)
|
1464
|
992 ;; I find I can't live without the default M-r command -- rms.
|
2076
|
993 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
|
|
994 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
|
|
995 (define-key rmail-mode-map "\es" 'rmail-search)
|
|
996 (define-key rmail-mode-map "t" 'rmail-toggle-header)
|
|
997 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
|
17306
|
998 (define-key rmail-mode-map "w" 'rmail-output-body-to-file)
|
2076
|
999 (define-key rmail-mode-map "x" 'rmail-expunge)
|
|
1000 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
|
64928
|
1001 (define-key rmail-mode-map "/" 'rmail-end-of-message)
|
2076
|
1002 (define-key rmail-mode-map "<" 'rmail-first-message)
|
|
1003 (define-key rmail-mode-map ">" 'rmail-last-message)
|
|
1004 (define-key rmail-mode-map " " 'scroll-up)
|
|
1005 (define-key rmail-mode-map "\177" 'scroll-down)
|
|
1006 (define-key rmail-mode-map "?" 'describe-mode)
|
3877
|
1007 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
|
|
1008 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
|
|
1009 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
|
|
1010 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
|
|
1011 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
|
|
1012 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
|
37592
|
1013 (define-key rmail-mode-map "\C-c\C-s\C-k" 'rmail-sort-by-labels)
|
10662
|
1014 (define-key rmail-mode-map "\C-c\C-n" 'rmail-next-same-subject)
|
|
1015 (define-key rmail-mode-map "\C-c\C-p" 'rmail-previous-same-subject)
|
2076
|
1016 )
|
3863
|
1017
|
|
1018 (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
|
270
|
1019
|
3863
|
1020 (define-key rmail-mode-map [menu-bar classify]
|
|
1021 (cons "Classify" (make-sparse-keymap "Classify")))
|
|
1022
|
6483
|
1023 (define-key rmail-mode-map [menu-bar classify input-menu]
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1024 nil)
|
6483
|
1025
|
|
1026 (define-key rmail-mode-map [menu-bar classify output-menu]
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1027 nil)
|
6483
|
1028
|
17306
|
1029 (define-key rmail-mode-map [menu-bar classify output-body]
|
|
1030 '("Output body to file..." . rmail-output-body-to-file))
|
|
1031
|
3863
|
1032 (define-key rmail-mode-map [menu-bar classify output-inbox]
|
8423
|
1033 '("Output (inbox)..." . rmail-output))
|
3863
|
1034
|
|
1035 (define-key rmail-mode-map [menu-bar classify output]
|
8423
|
1036 '("Output (Rmail)..." . rmail-output-to-rmail-file))
|
3863
|
1037
|
|
1038 (define-key rmail-mode-map [menu-bar classify kill-label]
|
8423
|
1039 '("Kill Label..." . rmail-kill-label))
|
3863
|
1040
|
|
1041 (define-key rmail-mode-map [menu-bar classify add-label]
|
8423
|
1042 '("Add Label..." . rmail-add-label))
|
3863
|
1043
|
|
1044 (define-key rmail-mode-map [menu-bar summary]
|
|
1045 (cons "Summary" (make-sparse-keymap "Summary")))
|
|
1046
|
12447
|
1047 (define-key rmail-mode-map [menu-bar summary senders]
|
|
1048 '("By Senders..." . rmail-summary-by-senders))
|
|
1049
|
3863
|
1050 (define-key rmail-mode-map [menu-bar summary labels]
|
8423
|
1051 '("By Labels..." . rmail-summary-by-labels))
|
3863
|
1052
|
|
1053 (define-key rmail-mode-map [menu-bar summary recipients]
|
8423
|
1054 '("By Recipients..." . rmail-summary-by-recipients))
|
3863
|
1055
|
|
1056 (define-key rmail-mode-map [menu-bar summary topic]
|
8423
|
1057 '("By Topic..." . rmail-summary-by-topic))
|
3863
|
1058
|
|
1059 (define-key rmail-mode-map [menu-bar summary regexp]
|
8423
|
1060 '("By Regexp..." . rmail-summary-by-regexp))
|
3863
|
1061
|
|
1062 (define-key rmail-mode-map [menu-bar summary all]
|
|
1063 '("All" . rmail-summary))
|
|
1064
|
|
1065 (define-key rmail-mode-map [menu-bar mail]
|
|
1066 (cons "Mail" (make-sparse-keymap "Mail")))
|
|
1067
|
8420
|
1068 (define-key rmail-mode-map [menu-bar mail rmail-get-new-mail]
|
8219
|
1069 '("Get New Mail" . rmail-get-new-mail))
|
|
1070
|
|
1071 (define-key rmail-mode-map [menu-bar mail lambda]
|
8230
|
1072 '("----"))
|
8219
|
1073
|
|
1074 (define-key rmail-mode-map [menu-bar mail continue]
|
3863
|
1075 '("Continue" . rmail-continue))
|
|
1076
|
8393
|
1077 (define-key rmail-mode-map [menu-bar mail resend]
|
8423
|
1078 '("Re-send..." . rmail-resend))
|
8393
|
1079
|
3863
|
1080 (define-key rmail-mode-map [menu-bar mail forward]
|
|
1081 '("Forward" . rmail-forward))
|
|
1082
|
|
1083 (define-key rmail-mode-map [menu-bar mail retry]
|
|
1084 '("Retry" . rmail-retry-failure))
|
|
1085
|
|
1086 (define-key rmail-mode-map [menu-bar mail reply]
|
|
1087 '("Reply" . rmail-reply))
|
|
1088
|
|
1089 (define-key rmail-mode-map [menu-bar mail mail]
|
|
1090 '("Mail" . rmail-mail))
|
|
1091
|
|
1092 (define-key rmail-mode-map [menu-bar delete]
|
|
1093 (cons "Delete" (make-sparse-keymap "Delete")))
|
|
1094
|
|
1095 (define-key rmail-mode-map [menu-bar delete expunge/save]
|
|
1096 '("Expunge/Save" . rmail-expunge-and-save))
|
|
1097
|
|
1098 (define-key rmail-mode-map [menu-bar delete expunge]
|
|
1099 '("Expunge" . rmail-expunge))
|
|
1100
|
|
1101 (define-key rmail-mode-map [menu-bar delete undelete]
|
|
1102 '("Undelete" . rmail-undelete-previous-message))
|
|
1103
|
|
1104 (define-key rmail-mode-map [menu-bar delete delete]
|
|
1105 '("Delete" . rmail-delete-forward))
|
|
1106
|
|
1107 (define-key rmail-mode-map [menu-bar move]
|
|
1108 (cons "Move" (make-sparse-keymap "Move")))
|
|
1109
|
|
1110 (define-key rmail-mode-map [menu-bar move search-back]
|
10187
|
1111 '("Search Back..." . rmail-search-backwards))
|
3863
|
1112
|
|
1113 (define-key rmail-mode-map [menu-bar move search]
|
8423
|
1114 '("Search..." . rmail-search))
|
3863
|
1115
|
|
1116 (define-key rmail-mode-map [menu-bar move previous]
|
|
1117 '("Previous Nondeleted" . rmail-previous-undeleted-message))
|
|
1118
|
|
1119 (define-key rmail-mode-map [menu-bar move next]
|
|
1120 '("Next Nondeleted" . rmail-next-undeleted-message))
|
|
1121
|
|
1122 (define-key rmail-mode-map [menu-bar move last]
|
|
1123 '("Last" . rmail-last-message))
|
|
1124
|
|
1125 (define-key rmail-mode-map [menu-bar move first]
|
|
1126 '("First" . rmail-first-message))
|
|
1127
|
|
1128 (define-key rmail-mode-map [menu-bar move previous]
|
|
1129 '("Previous" . rmail-previous-message))
|
|
1130
|
|
1131 (define-key rmail-mode-map [menu-bar move next]
|
|
1132 '("Next" . rmail-next-message))
|
69676
|
1133
|
|
1134 ;; Rmail toolbar
|
|
1135 (defvar rmail-tool-bar-map
|
|
1136 (if (display-graphic-p)
|
|
1137 (let ((map (make-sparse-keymap)))
|
|
1138 (tool-bar-local-item-from-menu 'rmail-get-new-mail "mail/inbox"
|
|
1139 map rmail-mode-map)
|
|
1140 (tool-bar-local-item-from-menu 'rmail-next-undeleted-message "right-arrow"
|
|
1141 map rmail-mode-map)
|
|
1142 (tool-bar-local-item-from-menu 'rmail-previous-undeleted-message "left-arrow"
|
|
1143 map rmail-mode-map)
|
|
1144 (tool-bar-local-item-from-menu 'rmail-search "search"
|
|
1145 map rmail-mode-map)
|
|
1146 (tool-bar-local-item-from-menu 'rmail-input "open"
|
|
1147 map rmail-mode-map)
|
|
1148 (tool-bar-local-item-from-menu 'rmail-mail "mail/compose"
|
|
1149 map rmail-mode-map)
|
|
1150 (tool-bar-local-item-from-menu 'rmail-reply "mail/reply-all"
|
|
1151 map rmail-mode-map)
|
|
1152 (tool-bar-local-item-from-menu 'rmail-forward "mail/forward"
|
|
1153 map rmail-mode-map)
|
|
1154 (tool-bar-local-item-from-menu 'rmail-delete-forward "close"
|
|
1155 map rmail-mode-map)
|
|
1156 (tool-bar-local-item-from-menu 'rmail-output "mail/move"
|
|
1157 map rmail-mode-map)
|
|
1158 (tool-bar-local-item-from-menu 'rmail-output-body-to-file "mail/save"
|
|
1159 map rmail-mode-map)
|
|
1160 (tool-bar-local-item-from-menu 'rmail-expunge "delete"
|
|
1161 map rmail-mode-map)
|
|
1162 map)))
|
|
1163
|
|
1164
|
3863
|
1165
|
270
|
1166 ;; Rmail mode is suitable only for specially formatted data.
|
|
1167 (put 'rmail-mode 'mode-class 'special)
|
|
1168
|
8963
|
1169 (defun rmail-mode-kill-summary ()
|
|
1170 (if rmail-summary-buffer (kill-buffer rmail-summary-buffer)))
|
|
1171
|
1382
|
1172 ;;;###autoload
|
270
|
1173 (defun rmail-mode ()
|
|
1174 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
|
|
1175 All normal editing commands are turned off.
|
|
1176 Instead, these commands are available:
|
|
1177
|
64928
|
1178 \\[rmail-beginning-of-message] Move point to front of this message.
|
|
1179 \\[rmail-end-of-message] Move point to bottom of this message.
|
270
|
1180 \\[scroll-up] Scroll to next screen of this message.
|
|
1181 \\[scroll-down] Scroll to previous screen of this message.
|
|
1182 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
|
|
1183 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
|
|
1184 \\[rmail-next-message] Move to Next message whether deleted or not.
|
|
1185 \\[rmail-previous-message] Move to Previous message whether deleted or not.
|
|
1186 \\[rmail-first-message] Move to the first message in Rmail file.
|
|
1187 \\[rmail-last-message] Move to the last message in Rmail file.
|
|
1188 \\[rmail-show-message] Jump to message specified by numeric position in file.
|
|
1189 \\[rmail-search] Search for string and show message it is found in.
|
|
1190 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
|
|
1191 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
|
|
1192 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
|
|
1193 till a deleted message is found.
|
2076
|
1194 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
|
270
|
1195 \\[rmail-expunge] Expunge deleted messages.
|
|
1196 \\[rmail-expunge-and-save] Expunge and save the file.
|
|
1197 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
|
|
1198 \\[save-buffer] Save without expunging.
|
2423
|
1199 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
|
270
|
1200 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
|
|
1201 \\[rmail-continue] Continue composing outgoing message started before.
|
2076
|
1202 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
|
|
1203 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
|
270
|
1204 \\[rmail-forward] Forward this message to another user.
|
|
1205 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
|
|
1206 \\[rmail-output] Output this message to a Unix-format mail file (append it).
|
21405
|
1207 \\[rmail-output-body-to-file] Save message body to a file. Default filename comes from Subject line.
|
270
|
1208 \\[rmail-input] Input Rmail file. Run Rmail on that file.
|
|
1209 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
|
|
1210 \\[rmail-kill-label] Kill label. Remove a label from current message.
|
|
1211 \\[rmail-next-labeled-message] Move to Next message with specified label
|
|
1212 (label defaults to last one specified).
|
|
1213 Standard labels: filed, unseen, answered, forwarded, deleted.
|
2076
|
1214 Any other label is present only if you add it with \\[rmail-add-label].
|
270
|
1215 \\[rmail-previous-labeled-message] Move to Previous message with specified label
|
|
1216 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
|
2076
|
1217 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
|
|
1218 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
|
|
1219 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
|
|
1220 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
|
|
1221 \\[rmail-toggle-header] Toggle display of complete header."
|
270
|
1222 (interactive)
|
37787
|
1223 (let ((finding-rmail-file (not (eq major-mode 'rmail-mode))))
|
|
1224 (rmail-mode-2)
|
|
1225 (when (and finding-rmail-file
|
|
1226 (null coding-system-for-read)
|
|
1227 default-enable-multibyte-characters)
|
|
1228 (let ((rmail-enable-multibyte t))
|
|
1229 (rmail-require-mime-maybe)
|
|
1230 (rmail-convert-file)
|
|
1231 (goto-char (point-max))
|
|
1232 (set-buffer-multibyte t)))
|
|
1233 (rmail-set-message-counters)
|
|
1234 (rmail-show-message rmail-total-messages)
|
|
1235 (when finding-rmail-file
|
|
1236 (when rmail-display-summary
|
|
1237 (rmail-summary))
|
|
1238 (rmail-construct-io-menu))
|
62762
|
1239 (run-mode-hooks 'rmail-mode-hook)))
|
270
|
1240
|
|
1241 (defun rmail-mode-2 ()
|
|
1242 (kill-all-local-variables)
|
|
1243 (rmail-mode-1)
|
21435
|
1244 (rmail-perm-variables)
|
16431
|
1245 (rmail-variables))
|
270
|
1246
|
|
1247 (defun rmail-mode-1 ()
|
|
1248 (setq major-mode 'rmail-mode)
|
|
1249 (setq mode-name "RMAIL")
|
|
1250 (setq buffer-read-only t)
|
5330
|
1251 ;; No need to auto save RMAIL files in normal circumstances
|
|
1252 ;; because they contain no info except attribute changes
|
|
1253 ;; and deletion of messages.
|
|
1254 ;; The one exception is when messages are copied into an Rmail mode buffer.
|
|
1255 ;; rmail-output-to-rmail-file enables auto save when you do that.
|
270
|
1256 (setq buffer-auto-save-file-name nil)
|
19536
|
1257 (setq mode-line-modified "--")
|
270
|
1258 (use-local-map rmail-mode-map)
|
|
1259 (set-syntax-table text-mode-syntax-table)
|
|
1260 (setq local-abbrev-table text-mode-abbrev-table))
|
|
1261
|
21435
|
1262 ;; Set up the permanent locals associated with an Rmail file.
|
|
1263 (defun rmail-perm-variables ()
|
270
|
1264 (make-local-variable 'rmail-last-label)
|
2076
|
1265 (make-local-variable 'rmail-last-regexp)
|
270
|
1266 (make-local-variable 'rmail-deleted-vector)
|
17093
|
1267 (make-local-variable 'rmail-buffer)
|
|
1268 (setq rmail-buffer (current-buffer))
|
|
1269 (make-local-variable 'rmail-view-buffer)
|
|
1270 (setq rmail-view-buffer rmail-buffer)
|
270
|
1271 (make-local-variable 'rmail-summary-buffer)
|
|
1272 (make-local-variable 'rmail-summary-vector)
|
|
1273 (make-local-variable 'rmail-current-message)
|
|
1274 (make-local-variable 'rmail-total-messages)
|
7061
|
1275 (make-local-variable 'rmail-overlay-list)
|
|
1276 (setq rmail-overlay-list nil)
|
270
|
1277 (make-local-variable 'rmail-message-vector)
|
17620
|
1278 (make-local-variable 'rmail-msgref-vector)
|
270
|
1279 (make-local-variable 'rmail-inbox-list)
|
|
1280 (setq rmail-inbox-list (rmail-parse-file-inboxes))
|
3540
|
1281 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
|
|
1282 (and (null rmail-inbox-list)
|
4010
|
1283 (or (equal buffer-file-name (expand-file-name rmail-file-name))
|
5192
|
1284 (equal buffer-file-truename
|
|
1285 (abbreviate-file-name (file-truename rmail-file-name))))
|
3540
|
1286 (setq rmail-inbox-list
|
|
1287 (or rmail-primary-inbox-list
|
|
1288 (list (or (getenv "MAIL")
|
|
1289 (concat rmail-spool-directory
|
5913
3d155c2636bf
(rmail-variables, rmail-insert-inbox-text): Change user-original-login-name to
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1290 (user-login-name)))))))
|
270
|
1291 (make-local-variable 'rmail-keywords)
|
69676
|
1292 (set (make-local-variable 'tool-bar-map) rmail-tool-bar-map)
|
270
|
1293 ;; this gets generated as needed
|
7563
|
1294 (setq rmail-keywords nil))
|
270
|
1295
|
21435
|
1296 ;; Set up the non-permanent locals associated with Rmail mode.
|
|
1297 (defun rmail-variables ()
|
22045
|
1298 (make-local-variable 'save-buffer-coding-system)
|
|
1299 ;; If we don't already have a value for save-buffer-coding-system,
|
|
1300 ;; get it from buffer-file-coding-system, and clear that
|
|
1301 ;; because it should be determined in rmail-show-message.
|
|
1302 (unless save-buffer-coding-system
|
|
1303 (setq save-buffer-coding-system (or buffer-file-coding-system 'undecided))
|
|
1304 (setq buffer-file-coding-system nil))
|
21435
|
1305 ;; Don't let a local variables list in a message cause confusion.
|
22474
|
1306 (make-local-variable 'local-enable-local-variables)
|
|
1307 (setq local-enable-local-variables nil)
|
21435
|
1308 (make-local-variable 'revert-buffer-function)
|
|
1309 (setq revert-buffer-function 'rmail-revert)
|
|
1310 (make-local-variable 'font-lock-defaults)
|
|
1311 (setq font-lock-defaults
|
22045
|
1312 '(rmail-font-lock-keywords
|
49064
|
1313 t t nil nil
|
22045
|
1314 (font-lock-maximum-size . nil)
|
|
1315 (font-lock-fontify-buffer-function . rmail-fontify-buffer-function)
|
|
1316 (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function)
|
|
1317 (font-lock-inhibit-thing-lock . (lazy-lock-mode fast-lock-mode))))
|
21435
|
1318 (make-local-variable 'require-final-newline)
|
|
1319 (setq require-final-newline nil)
|
|
1320 (make-local-variable 'version-control)
|
|
1321 (setq version-control 'never)
|
|
1322 (make-local-variable 'kill-buffer-hook)
|
|
1323 (add-hook 'kill-buffer-hook 'rmail-mode-kill-summary)
|
|
1324 (make-local-variable 'file-precious-flag)
|
55152
|
1325 (setq file-precious-flag t)
|
|
1326 (make-local-variable 'desktop-save-buffer)
|
|
1327 (setq desktop-save-buffer t))
|
21435
|
1328
|
270
|
1329 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
|
|
1330 (defun rmail-revert (arg noconfirm)
|
37956
|
1331 (set-buffer rmail-buffer)
|
22724
|
1332 (let* ((revert-buffer-function (default-value 'revert-buffer-function))
|
|
1333 (rmail-enable-multibyte enable-multibyte-characters)
|
|
1334 ;; See similar code in `rmail'.
|
|
1335 (coding-system-for-read (and rmail-enable-multibyte 'raw-text)))
|
270
|
1336 ;; Call our caller again, but this time it does the default thing.
|
|
1337 (if (revert-buffer arg noconfirm)
|
|
1338 ;; If the user said "yes", and we changed something,
|
|
1339 ;; reparse the messages.
|
20681
|
1340 (progn
|
37956
|
1341 (set-buffer rmail-buffer)
|
|
1342 (rmail-mode-2)
|
22724
|
1343 ;; Convert all or part to Babyl file if possible.
|
270
|
1344 (rmail-convert-file)
|
22724
|
1345 ;; We have read the file as raw-text, so the buffer is set to
|
|
1346 ;; unibyte. Make it multibyte if necessary.
|
|
1347 (if (and rmail-enable-multibyte
|
|
1348 (not enable-multibyte-characters))
|
|
1349 (set-buffer-multibyte t))
|
270
|
1350 (goto-char (point-max))
|
22724
|
1351 (rmail-set-message-counters)
|
|
1352 (rmail-show-message rmail-total-messages)
|
|
1353 (run-hooks 'rmail-mode-hook)))))
|
270
|
1354
|
|
1355 ;; Return a list of files from this buffer's Mail: option.
|
|
1356 ;; Does not assume that messages have been parsed.
|
|
1357 ;; Just returns nil if buffer does not look like Babyl format.
|
|
1358 (defun rmail-parse-file-inboxes ()
|
|
1359 (save-excursion
|
|
1360 (save-restriction
|
|
1361 (widen)
|
|
1362 (goto-char 1)
|
|
1363 (cond ((looking-at "BABYL OPTIONS:")
|
|
1364 (search-forward "\n\^_" nil 'move)
|
|
1365 (narrow-to-region 1 (point))
|
|
1366 (goto-char 1)
|
|
1367 (if (search-forward "\nMail:" nil t)
|
|
1368 (progn
|
|
1369 (narrow-to-region (point) (progn (end-of-line) (point)))
|
|
1370 (goto-char (point-min))
|
|
1371 (mail-parse-comma-list))))))))
|
|
1372
|
|
1373 (defun rmail-expunge-and-save ()
|
|
1374 "Expunge and save RMAIL file."
|
|
1375 (interactive)
|
|
1376 (rmail-expunge)
|
37611
|
1377 (set-buffer rmail-buffer)
|
5860
|
1378 (save-buffer)
|
|
1379 (if (rmail-summary-exists)
|
|
1380 (rmail-select-summary (set-buffer-modified-p nil))))
|
270
|
1381
|
|
1382 (defun rmail-quit ()
|
24110
|
1383 "Quit out of RMAIL.
|
|
1384 Hook `rmail-quit-hook' is run after expunging."
|
270
|
1385 (interactive)
|
|
1386 (rmail-expunge-and-save)
|
24110
|
1387 (when (boundp 'rmail-quit-hook)
|
|
1388 (run-hooks 'rmail-quit-hook))
|
270
|
1389 ;; Don't switch to the summary buffer even if it was recently visible.
|
21100
|
1390 (when rmail-summary-buffer
|
|
1391 (replace-buffer-in-windows rmail-summary-buffer)
|
|
1392 (bury-buffer rmail-summary-buffer))
|
37611
|
1393 (if rmail-enable-mime
|
|
1394 (let ((obuf rmail-buffer)
|
|
1395 (ovbuf rmail-view-buffer))
|
|
1396 (set-buffer rmail-view-buffer)
|
|
1397 (quit-window)
|
|
1398 (replace-buffer-in-windows ovbuf)
|
|
1399 (replace-buffer-in-windows obuf)
|
|
1400 (bury-buffer obuf))
|
|
1401 (let ((obuf (current-buffer)))
|
|
1402 (quit-window)
|
|
1403 (replace-buffer-in-windows obuf))))
|
270
|
1404
|
10970
|
1405 (defun rmail-bury ()
|
|
1406 "Bury current Rmail buffer and its summary buffer."
|
|
1407 (interactive)
|
|
1408 ;; This let var was called rmail-buffer, but that interfered
|
|
1409 ;; with the buffer-local var used in summary buffers.
|
|
1410 (let ((buffer-to-bury (current-buffer)))
|
|
1411 (if (rmail-summary-exists)
|
|
1412 (let (window)
|
|
1413 (while (setq window (get-buffer-window rmail-summary-buffer))
|
21100
|
1414 (quit-window nil window))
|
10970
|
1415 (bury-buffer rmail-summary-buffer)))
|
21100
|
1416 (quit-window)))
|
10970
|
1417
|
|
1418 (defun rmail-duplicate-message ()
|
|
1419 "Create a duplicated copy of the current message.
|
|
1420 The duplicate copy goes into the Rmail file just after the
|
|
1421 original copy."
|
|
1422 (interactive)
|
|
1423 (widen)
|
|
1424 (let ((buffer-read-only nil)
|
|
1425 (number rmail-current-message)
|
|
1426 (string (buffer-substring (rmail-msgbeg rmail-current-message)
|
|
1427 (rmail-msgend rmail-current-message))))
|
|
1428 (goto-char (rmail-msgend rmail-current-message))
|
|
1429 (insert string)
|
|
1430 (rmail-forget-messages)
|
|
1431 (rmail-show-message number)
|
|
1432 (message "Message duplicated")))
|
|
1433
|
270
|
1434 ;;;###autoload
|
|
1435 (defun rmail-input (filename)
|
2076
|
1436 "Run Rmail on file FILENAME."
|
270
|
1437 (interactive "FRun rmail on RMAIL file: ")
|
|
1438 (rmail filename))
|
|
1439
|
16241
|
1440
|
|
1441 ;; This used to scan subdirectories recursively, but someone pointed out
|
|
1442 ;; that if the user wants that, person can put all the files in one dir.
|
|
1443 ;; And the recursive scan was slow. So I took it out.
|
|
1444 ;; rms, Sep 1996.
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1445 (defun rmail-find-all-files (start)
|
16241
|
1446 "Return list of file in dir START that match `rmail-secondary-file-regexp'."
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1447 (if (file-accessible-directory-p start)
|
9449
|
1448 ;; Don't sort here.
|
16241
|
1449 (let* ((case-fold-search t)
|
|
1450 (files (directory-files start t rmail-secondary-file-regexp)))
|
9449
|
1451 ;; Sort here instead of in directory-files
|
|
1452 ;; because this list is usually much shorter.
|
16241
|
1453 (sort files 'string<))))
|
7321
|
1454
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1455 (defun rmail-list-to-menu (menu-name l action &optional full-name)
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1456 (let ((menu (make-sparse-keymap menu-name)))
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1457 (mapcar
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1458 (function (lambda (item)
|
10971
|
1459 (let (command)
|
|
1460 (if (consp item)
|
|
1461 (progn
|
|
1462 (setq command
|
45144
|
1463 (rmail-list-to-menu (car item) (cdr item)
|
|
1464 action
|
10971
|
1465 (if full-name
|
|
1466 (concat full-name "/"
|
|
1467 (car item))
|
|
1468 (car item))))
|
|
1469 (setq name (car item)))
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1470 (progn
|
10971
|
1471 (setq name item)
|
45144
|
1472 (setq command
|
10971
|
1473 (list 'lambda () '(interactive)
|
|
1474 (list action
|
45144
|
1475 (expand-file-name
|
10971
|
1476 (if full-name
|
|
1477 (concat full-name "/" item)
|
|
1478 item)
|
|
1479 rmail-secondary-file-directory))))))
|
|
1480 (define-key menu (vector (intern name))
|
|
1481 (cons name command)))))
|
9449
|
1482 (reverse l))
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1483 menu))
|
45144
|
1484
|
9449
|
1485 ;; This command is always "disabled" when it appears in a menu.
|
|
1486 (put 'rmail-disable-menu 'menu-enable ''nil)
|
|
1487
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1488 (defun rmail-construct-io-menu ()
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1489 (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
|
9449
|
1490 (if files
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1491 (progn
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1492 (define-key rmail-mode-map [menu-bar classify input-menu]
|
45144
|
1493 (cons "Input Rmail File"
|
|
1494 (rmail-list-to-menu "Input Rmail File"
|
9449
|
1495 files
|
8909
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1496 'rmail-input)))
|
d9c10eb46ce9
Build proper keymap for the "Input (menu)" and "Output (menu)" submenus:
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1497 (define-key rmail-mode-map [menu-bar classify output-menu]
|
45144
|
1498 (cons "Output Rmail File"
|
|
1499 (rmail-list-to-menu "Output Rmail File"
|
9449
|
1500 files
|
|
1501 'rmail-output-to-rmail-file))))
|
|
1502
|
|
1503 (define-key rmail-mode-map [menu-bar classify input-menu]
|
|
1504 '("Input Rmail File" . rmail-disable-menu))
|
|
1505 (define-key rmail-mode-map [menu-bar classify output-menu]
|
|
1506 '("Output Rmail File" . rmail-disable-menu)))))
|
6408
|
1507
|
270
|
1508
|
|
1509 ;;;; *** Rmail input ***
|
|
1510
|
|
1511 ;; RLK feature not added in this version:
|
|
1512 ;; argument specifies inbox file or files in various ways.
|
|
1513
|
|
1514 (defun rmail-get-new-mail (&optional file-name)
|
|
1515 "Move any new mail from this RMAIL file's inbox files.
|
|
1516 The inbox files can be specified with the file's Mail: option. The
|
|
1517 variable `rmail-primary-inbox-list' specifies the inboxes for your
|
2423
|
1518 primary RMAIL file if it has no Mail: option. By default, this is
|
|
1519 your /usr/spool/mail/$USER.
|
270
|
1520
|
|
1521 You can also specify the file to get new mail from. In this case, the
|
|
1522 file of new mail is not changed or deleted. Noninteractively, you can
|
|
1523 pass the inbox file name as an argument. Interactively, a prefix
|
8701
|
1524 argument causes us to read a file name and use that file as the inbox.
|
|
1525
|
16908
|
1526 If the variable `rmail-preserve-inbox' is non-nil, new mail will
|
|
1527 always be left in inbox files rather than deleted.
|
|
1528
|
10103
|
1529 This function runs `rmail-get-new-mail-hook' before saving the updated file.
|
|
1530 It returns t if it got any new messages."
|
270
|
1531 (interactive
|
|
1532 (list (if current-prefix-arg
|
|
1533 (read-file-name "Get new mail from file: "))))
|
15549
|
1534 (run-hooks 'rmail-before-get-new-mail-hook)
|
11533
|
1535 ;; If the disk file has been changed from under us,
|
|
1536 ;; revert to it before we get new mail.
|
270
|
1537 (or (verify-visited-file-modtime (current-buffer))
|
11533
|
1538 (find-file (buffer-file-name)))
|
37611
|
1539 (set-buffer rmail-buffer)
|
270
|
1540 (rmail-maybe-set-message-counters)
|
|
1541 (widen)
|
|
1542 ;; Get rid of all undo records for this buffer.
|
|
1543 (or (eq buffer-undo-list t)
|
|
1544 (setq buffer-undo-list nil))
|
16241
|
1545 (let ((all-files (if file-name (list file-name)
|
20053
|
1546 rmail-inbox-list))
|
20943
|
1547 (rmail-enable-multibyte (default-value 'enable-multibyte-characters))
|
20053
|
1548 found)
|
16241
|
1549 (unwind-protect
|
20053
|
1550 (progn
|
16928
|
1551 (while all-files
|
|
1552 (let ((opoint (point))
|
|
1553 (new-messages 0)
|
53598
|
1554 (rsf-number-of-spam 0)
|
16928
|
1555 (delete-files ())
|
|
1556 ;; If buffer has not changed yet, and has not been saved yet,
|
|
1557 ;; don't replace the old backup file now.
|
|
1558 (make-backup-files (and make-backup-files (buffer-modified-p)))
|
|
1559 (buffer-read-only nil)
|
|
1560 ;; Don't make undo records for what we do in getting mail.
|
|
1561 (buffer-undo-list t)
|
|
1562 success
|
|
1563 ;; Files to insert this time around.
|
|
1564 files
|
|
1565 ;; Last names of those files.
|
|
1566 file-last-names)
|
|
1567 ;; Pull files off all-files onto files
|
|
1568 ;; as long as there is no name conflict.
|
|
1569 ;; A conflict happens when two inbox file names
|
|
1570 ;; have the same last component.
|
|
1571 (while (and all-files
|
|
1572 (not (member (file-name-nondirectory (car all-files))
|
|
1573 file-last-names)))
|
|
1574 (setq files (cons (car all-files) files)
|
|
1575 file-last-names
|
|
1576 (cons (file-name-nondirectory (car all-files)) files))
|
|
1577 (setq all-files (cdr all-files)))
|
|
1578 ;; Put them back in their original order.
|
|
1579 (setq files (nreverse files))
|
16241
|
1580
|
16928
|
1581 (goto-char (point-max))
|
|
1582 (skip-chars-backward " \t\n") ; just in case of brain damage
|
|
1583 (delete-region (point) (point-max)) ; caused by require-final-newline
|
|
1584 (save-excursion
|
|
1585 (save-restriction
|
|
1586 (narrow-to-region (point) (point))
|
|
1587 ;; Read in the contents of the inbox files,
|
|
1588 ;; renaming them as necessary,
|
|
1589 ;; and adding to the list of files to delete eventually.
|
|
1590 (if file-name
|
|
1591 (rmail-insert-inbox-text files nil)
|
|
1592 (setq delete-files (rmail-insert-inbox-text files t)))
|
|
1593 ;; Scan the new text and convert each message to babyl format.
|
|
1594 (goto-char (point-min))
|
|
1595 (unwind-protect
|
|
1596 (save-excursion
|
|
1597 (setq new-messages (rmail-convert-to-babyl-format)
|
|
1598 success t))
|
23530
|
1599 ;; Try to delete the garbage just inserted.
|
|
1600 (or success (delete-region (point-min) (point-max)))
|
16928
|
1601 ;; If we could not convert the file's inboxes,
|
|
1602 ;; rename the files we tried to read
|
|
1603 ;; so we won't over and over again.
|
|
1604 (if (and (not file-name) (not success))
|
|
1605 (let ((delfiles delete-files)
|
|
1606 (count 0))
|
|
1607 (while delfiles
|
|
1608 (while (file-exists-p (format "RMAILOSE.%d" count))
|
|
1609 (setq count (1+ count)))
|
|
1610 (rename-file (car delfiles)
|
|
1611 (format "RMAILOSE.%d" count))
|
|
1612 (setq delfiles (cdr delfiles))))))
|
|
1613 (or (zerop new-messages)
|
|
1614 (let (success)
|
|
1615 (widen)
|
|
1616 (search-backward "\n\^_" nil t)
|
|
1617 (narrow-to-region (point) (point-max))
|
|
1618 (goto-char (1+ (point-min)))
|
|
1619 (rmail-count-new-messages)
|
|
1620 (run-hooks 'rmail-get-new-mail-hook)
|
|
1621 (save-buffer)))
|
|
1622 ;; Delete the old files, now that babyl file is saved.
|
|
1623 (while delete-files
|
|
1624 (condition-case ()
|
|
1625 ;; First, try deleting.
|
|
1626 (condition-case ()
|
|
1627 (delete-file (car delete-files))
|
|
1628 (file-error
|
|
1629 ;; If we can't delete it, truncate it.
|
|
1630 (write-region (point) (point) (car delete-files))))
|
|
1631 (file-error nil))
|
|
1632 (setq delete-files (cdr delete-files)))))
|
|
1633 (if (= new-messages 0)
|
|
1634 (progn (goto-char opoint)
|
|
1635 (if (or file-name rmail-inbox-list)
|
|
1636 (message "(No new mail has arrived)")))
|
53598
|
1637 ;; check new messages to see if any of them is spam:
|
54049
|
1638 (if (and (featurep 'rmail-spam-filter)
|
|
1639 rmail-use-spam-filter)
|
53598
|
1640 (let*
|
|
1641 ((old-messages (- rmail-total-messages new-messages))
|
|
1642 (rsf-scanned-message-number (1+ old-messages))
|
|
1643 ;; save deletion flags of old messages: vector starts
|
|
1644 ;; at zero (is one longer that no of messages),
|
|
1645 ;; therefore take 1+ old-messages
|
|
1646 (save-deleted
|
|
1647 (substring rmail-deleted-vector 0 (1+
|
|
1648 old-messages))))
|
|
1649 ;; set all messages to undeleted
|
|
1650 (setq rmail-deleted-vector
|
|
1651 (make-string (1+ rmail-total-messages) ?\ ))
|
|
1652 (while (<= rsf-scanned-message-number
|
|
1653 rmail-total-messages)
|
|
1654 (progn
|
|
1655 (if (not (rmail-spam-filter rsf-scanned-message-number))
|
|
1656 (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam)))
|
|
1657 )
|
|
1658 (setq rsf-scanned-message-number (1+ rsf-scanned-message-number))
|
|
1659 ))
|
|
1660 (if (> rsf-number-of-spam 0)
|
|
1661 (progn
|
|
1662 (when (rmail-expunge-confirmed)
|
|
1663 (rmail-only-expunge t))
|
|
1664 ))
|
|
1665 (setq rmail-deleted-vector
|
|
1666 (concat
|
|
1667 save-deleted
|
|
1668 (make-string (- rmail-total-messages old-messages)
|
|
1669 ?\ )))
|
|
1670 ))
|
|
1671 (if (rmail-summary-exists)
|
16928
|
1672 (rmail-select-summary
|
|
1673 (rmail-update-summary)))
|
53598
|
1674 (message "%d new message%s read%s"
|
|
1675 new-messages (if (= 1 new-messages) "" "s")
|
|
1676 ;; print out a message on number of spam messages found:
|
54049
|
1677 (if (and (featurep 'rmail-spam-filter)
|
|
1678 rmail-use-spam-filter
|
|
1679 (> rsf-number-of-spam 0))
|
53598
|
1680 (if (= 1 new-messages)
|
53860
|
1681 ", and found to be a spam message"
|
53598
|
1682 (if (> rsf-number-of-spam 1)
|
|
1683 (format ", %d of which found to be spam messages"
|
|
1684 rsf-number-of-spam)
|
53860
|
1685 ", one of which found to be a spam message"))
|
53598
|
1686 ""))
|
54049
|
1687 (if (and (featurep 'rmail-spam-filter)
|
|
1688 rmail-use-spam-filter
|
|
1689 (> rsf-number-of-spam 0))
|
58184
|
1690 (progn (if rsf-beep (beep t))
|
|
1691 (sleep-for rsf-sleep-after-message)))
|
53598
|
1692
|
16928
|
1693 ;; Move to the first new message
|
|
1694 ;; unless we have other unseen messages before it.
|
|
1695 (rmail-show-message (rmail-first-unseen-message))
|
|
1696 (run-hooks 'rmail-after-get-new-mail-hook)
|
|
1697 (setq found t))))
|
|
1698 found)
|
16241
|
1699 ;; Don't leave the buffer screwed up if we get a disk-full error.
|
20053
|
1700 (or found (rmail-show-message)))))
|
270
|
1701
|
59561
|
1702 (defun rmail-parse-url (file)
|
|
1703 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
|
|
1704 WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
|
|
1705 actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
|
|
1706 a remote mailbox, PASSWORD is the password if it should be
|
|
1707 supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
|
|
1708 is non-nil if the user has supplied the password interactively.
|
|
1709 "
|
61223
|
1710 (cond
|
|
1711 ((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
|
59996
|
1712 (let (got-password supplied-password
|
59561
|
1713 (proto (match-string 1 file))
|
|
1714 (user (match-string 3 file))
|
|
1715 (pass (match-string 5 file))
|
|
1716 (host (substring file (or (match-end 2)
|
|
1717 (+ 3 (match-end 1))))))
|
64754
|
1718
|
59561
|
1719 (if (not pass)
|
|
1720 (when rmail-remote-password-required
|
|
1721 (setq got-password (not (rmail-have-password)))
|
|
1722 (setq supplied-password (rmail-get-remote-password
|
|
1723 (string-equal proto "imap")))))
|
59996
|
1724
|
59561
|
1725 (if (rmail-movemail-variant-p 'emacs)
|
|
1726 (if (string-equal proto "pop")
|
|
1727 (list (concat "po:" user ":" host)
|
|
1728 t
|
|
1729 (or pass supplied-password)
|
|
1730 got-password)
|
|
1731 (error "Emacs movemail does not support %s protocol" proto))
|
|
1732 (list file
|
|
1733 (or (string-equal proto "pop") (string-equal proto "imap"))
|
|
1734 supplied-password
|
61223
|
1735 got-password))))
|
64754
|
1736
|
61223
|
1737 ((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file)
|
|
1738 (let (got-password supplied-password
|
|
1739 (proto "pop")
|
|
1740 (user (match-string 1 file))
|
|
1741 (host (match-string 3 file)))
|
64754
|
1742
|
61223
|
1743 (when rmail-remote-password-required
|
|
1744 (setq got-password (not (rmail-have-password)))
|
|
1745 (setq supplied-password (rmail-get-remote-password nil)))
|
|
1746
|
|
1747 (list file "pop" supplied-password got-password)))
|
64754
|
1748
|
61223
|
1749 (t
|
|
1750 (list file nil nil nil))))
|
59561
|
1751
|
270
|
1752 (defun rmail-insert-inbox-text (files renamep)
|
16241
|
1753 ;; Detect a locked file now, so that we avoid moving mail
|
|
1754 ;; out of the real inbox file. (That could scare people.)
|
|
1755 (or (memq (file-locked-p buffer-file-name) '(nil t))
|
|
1756 (error "RMAIL file %s is locked"
|
|
1757 (file-name-nondirectory buffer-file-name)))
|
22838
|
1758 (let (file tofile delete-files movemail popmail got-password password)
|
270
|
1759 (while files
|
59561
|
1760 ;; Handle remote mailbox names specially; don't expand as filenames
|
24220
|
1761 ;; in case the userid contains a directory separator.
|
|
1762 (setq file (car files))
|
59561
|
1763 (let ((url-data (rmail-parse-url file)))
|
|
1764 (setq file (nth 0 url-data))
|
|
1765 (setq popmail (nth 1 url-data))
|
|
1766 (setq password (nth 2 url-data))
|
|
1767 (setq got-password (nth 3 url-data)))
|
|
1768
|
24220
|
1769 (if popmail
|
|
1770 (setq renamep t)
|
|
1771 (setq file (file-truename
|
36830
|
1772 (substitute-in-file-name (expand-file-name file)))))
|
24220
|
1773 (setq tofile (expand-file-name
|
12650
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1774 ;; Generate name to move to from inbox name,
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1775 ;; in case of multiple inboxes that need moving.
|
59561
|
1776 (concat ".newmail-"
|
59996
|
1777 (file-name-nondirectory
|
59561
|
1778 (if (memq system-type '(windows-nt cygwin))
|
|
1779 ;; cannot have "po:" in file name
|
|
1780 (substring file 3)
|
|
1781 file)))
|
12650
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1782 ;; Use the directory of this rmail file
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1783 ;; because it's a nuisance to use the homedir
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1784 ;; if that is on a full disk and this rmail
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1785 ;; file isn't.
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1786 (file-name-directory
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1787 (expand-file-name buffer-file-name))))
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1788 ;; Always use movemail to rename the file,
|
6f4785fee5cc
(rmail-insert-inbox-text): Always use movemail when renaming a file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1789 ;; since there can be mailboxes in various directories.
|
61223
|
1790 (if (not popmail)
|
270
|
1791 (progn
|
|
1792 ;; On some systems, /usr/spool/mail/foo is a directory
|
|
1793 ;; and the actual inbox is /usr/spool/mail/foo/foo.
|
|
1794 (if (file-directory-p file)
|
5913
3d155c2636bf
(rmail-variables, rmail-insert-inbox-text): Change user-original-login-name to
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1795 (setq file (expand-file-name (user-login-name)
|
270
|
1796 file)))))
|
11452
|
1797 (cond (popmail
|
59561
|
1798 (message "Getting mail from the remote server ..."))
|
11452
|
1799 ((and (file-exists-p tofile)
|
|
1800 (/= 0 (nth 7 (file-attributes tofile))))
|
|
1801 (message "Getting mail from %s..." tofile))
|
|
1802 ((and (file-exists-p file)
|
|
1803 (/= 0 (nth 7 (file-attributes file))))
|
|
1804 (message "Getting mail from %s..." file)))
|
270
|
1805 ;; Set TOFILE if have not already done so, and
|
|
1806 ;; rename or copy the file FILE to TOFILE if and as appropriate.
|
|
1807 (cond ((not renamep)
|
|
1808 (setq tofile file))
|
2076
|
1809 ((or (file-exists-p tofile) (and (not popmail)
|
|
1810 (not (file-exists-p file))))
|
270
|
1811 nil)
|
|
1812 (t
|
59561
|
1813 (with-temp-buffer
|
|
1814 (let ((errors (current-buffer)))
|
|
1815 (buffer-disable-undo errors)
|
|
1816 (let ((args
|
|
1817 (append
|
|
1818 (list (or rmail-movemail-program
|
|
1819 (expand-file-name "movemail"
|
|
1820 exec-directory))
|
|
1821 nil errors nil)
|
|
1822 (if rmail-preserve-inbox
|
|
1823 (list "-p")
|
|
1824 nil)
|
|
1825 (if (rmail-movemail-variant-p 'mailutils)
|
|
1826 (append (list "--emacs") rmail-movemail-flags)
|
|
1827 rmail-movemail-flags)
|
|
1828 (list file tofile)
|
|
1829 (if password (list password) nil))))
|
|
1830 (apply 'call-process args))
|
|
1831 (if (not (buffer-modified-p errors))
|
|
1832 ;; No output => movemail won
|
|
1833 nil
|
|
1834 (set-buffer errors)
|
|
1835 (subst-char-in-region (point-min) (point-max)
|
|
1836 ?\n ?\ )
|
|
1837 (goto-char (point-max))
|
|
1838 (skip-chars-backward " \t")
|
|
1839 (delete-region (point) (point-max))
|
|
1840 (goto-char (point-min))
|
|
1841 (if (looking-at "movemail: ")
|
|
1842 (delete-region (point-min) (match-end 0)))
|
|
1843 (beep t)
|
|
1844 ;; If we just read the password, most likely it is
|
|
1845 ;; wrong. Otherwise, see if there is a specific
|
|
1846 ;; reason to think that the problem is a wrong passwd.
|
|
1847 (if (or got-password
|
|
1848 (re-search-forward rmail-remote-password-error
|
|
1849 nil t))
|
|
1850 (rmail-set-remote-password nil))
|
|
1851
|
|
1852 ;; If using Mailutils, remove initial error code
|
|
1853 ;; abbreviation
|
|
1854 (when (rmail-movemail-variant-p 'mailutils)
|
|
1855 (goto-char (point-min))
|
|
1856 (when (looking-at "[A-Z][A-Z0-9_]*:")
|
|
1857 (delete-region (point-min) (match-end 0))))
|
59996
|
1858
|
59561
|
1859 (message "movemail: %s"
|
|
1860 (buffer-substring (point-min)
|
|
1861 (point-max)))
|
59996
|
1862
|
59561
|
1863 (sit-for 3)
|
|
1864 nil)))))
|
59996
|
1865
|
270
|
1866 ;; At this point, TOFILE contains the name to read:
|
|
1867 ;; Either the alternate name (if we renamed)
|
|
1868 ;; or the actual inbox (if not renaming).
|
|
1869 (if (file-exists-p tofile)
|
17093
|
1870 (let ((coding-system-for-read 'no-conversion)
|
|
1871 size)
|
270
|
1872 (goto-char (point-max))
|
17093
|
1873 (setq size (nth 1 (insert-file-contents tofile)))
|
270
|
1874 (goto-char (point-max))
|
|
1875 (or (= (preceding-char) ?\n)
|
|
1876 (zerop size)
|
|
1877 (insert ?\n))
|
16908
|
1878 (if (not (and rmail-preserve-inbox (string= file tofile)))
|
|
1879 (setq delete-files (cons tofile delete-files)))))
|
270
|
1880 (message "")
|
|
1881 (setq files (cdr files)))
|
|
1882 delete-files))
|
|
1883
|
24209
|
1884 ;; Decode the region specified by FROM and TO by CODING.
|
|
1885 ;; If CODING is nil or an invalid coding system, decode by `undecided'.
|
|
1886 (defun rmail-decode-region (from to coding)
|
|
1887 (if (or (not coding) (not (coding-system-p coding)))
|
|
1888 (setq coding 'undecided))
|
55114
|
1889 ;; Use -dos decoding, to remove ^M characters left from base64 or
|
|
1890 ;; rogue qp-encoded text.
|
|
1891 (decode-coding-region from to
|
|
1892 (coding-system-change-eol-conversion coding 1))
|
|
1893 ;; Don't reveal the fact we used -dos decoding, as users generally
|
|
1894 ;; will not expect the RMAIL buffer to use DOS EOL format.
|
|
1895 (setq buffer-file-coding-system
|
|
1896 (setq last-coding-system-used
|
|
1897 (coding-system-change-eol-conversion coding 0))))
|
24209
|
1898
|
270
|
1899 ;; the rmail-break-forwarded-messages feature is not implemented
|
|
1900 (defun rmail-convert-to-babyl-format ()
|
|
1901 (let ((count 0) start
|
402
|
1902 (case-fold-search nil)
|
|
1903 (invalid-input-resync
|
|
1904 (function (lambda ()
|
|
1905 (message "Invalid Babyl format in inbox!")
|
16241
|
1906 (sit-for 3)
|
402
|
1907 ;; Try to get back in sync with a real message.
|
|
1908 (if (re-search-forward
|
18091
|
1909 (concat rmail-mmdf-delim1 "\\|^From") nil t)
|
402
|
1910 (beginning-of-line)
|
|
1911 (goto-char (point-max)))))))
|
270
|
1912 (goto-char (point-min))
|
|
1913 (save-restriction
|
|
1914 (while (not (eobp))
|
17093
|
1915 (setq start (point))
|
270
|
1916 (cond ((looking-at "BABYL OPTIONS:");Babyl header
|
402
|
1917 (if (search-forward "\n\^_" nil t)
|
|
1918 ;; If we find the proper terminator, delete through there.
|
|
1919 (delete-region (point-min) (point))
|
|
1920 (funcall invalid-input-resync)
|
405
|
1921 (delete-region (point-min) (point))))
|
270
|
1922 ;; Babyl format message
|
|
1923 ((looking-at "\^L")
|
|
1924 (or (search-forward "\n\^_" nil t)
|
402
|
1925 (funcall invalid-input-resync))
|
270
|
1926 (setq count (1+ count))
|
|
1927 ;; Make sure there is no extra white space after the ^_
|
|
1928 ;; at the end of the message.
|
|
1929 ;; Narrowing will make sure that whatever follows the junk
|
|
1930 ;; will be treated properly.
|
|
1931 (delete-region (point)
|
|
1932 (save-excursion
|
|
1933 (skip-chars-forward " \t\n")
|
|
1934 (point)))
|
52358
|
1935 (save-excursion
|
|
1936 (let* ((header-end
|
|
1937 (progn
|
|
1938 (save-excursion
|
|
1939 (goto-char start)
|
|
1940 (forward-line 1)
|
|
1941 (if (looking-at "0")
|
|
1942 (forward-line 1)
|
|
1943 (forward-line 2))
|
|
1944 (save-restriction
|
|
1945 (narrow-to-region (point) (point-max))
|
|
1946 (rfc822-goto-eoh)
|
|
1947 (point)))))
|
|
1948 (case-fold-search t)
|
|
1949 (quoted-printable-header-field-end
|
|
1950 (save-excursion
|
|
1951 (goto-char start)
|
|
1952 (re-search-forward
|
|
1953 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
|
|
1954 header-end t)))
|
|
1955 (base64-header-field-end
|
|
1956 (save-excursion
|
|
1957 (goto-char start)
|
|
1958 (re-search-forward
|
|
1959 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
|
|
1960 header-end t))))
|
|
1961 (if quoted-printable-header-field-end
|
|
1962 (save-excursion
|
53570
8e83b9e560f0
(rmail-convert-to-babyl-format): Use mail-unquote-printable-region.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1963 (unless
|
54262
|
1964 (mail-unquote-printable-region header-end (point) nil t t)
|
53570
8e83b9e560f0
(rmail-convert-to-babyl-format): Use mail-unquote-printable-region.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1965 (message "Malformed MIME quoted-printable message"))
|
52358
|
1966 ;; Change "quoted-printable" to "8bit",
|
|
1967 ;; to reflect the decoding we just did.
|
|
1968 (goto-char quoted-printable-header-field-end)
|
|
1969 (delete-region (point) (search-backward ":"))
|
|
1970 (insert ": 8bit")))
|
|
1971 (if base64-header-field-end
|
53445
|
1972 (save-excursion
|
|
1973 (when
|
|
1974 (condition-case nil
|
|
1975 (progn
|
|
1976 (base64-decode-region (1+ header-end)
|
|
1977 (- (point) 2))
|
|
1978 t)
|
|
1979 (error nil))
|
|
1980 ;; Change "base64" to "8bit", to reflect the
|
|
1981 ;; decoding we just did.
|
|
1982 (goto-char base64-header-field-end)
|
|
1983 (delete-region (point) (search-backward ":"))
|
|
1984 (insert ": 8bit"))))
|
52358
|
1985 (setq last-coding-system-used nil)
|
|
1986 (or rmail-enable-mime
|
|
1987 (not rmail-enable-multibyte)
|
|
1988 (let ((mime-charset
|
|
1989 (if (and rmail-decode-mime-charset
|
|
1990 (save-excursion
|
|
1991 (goto-char start)
|
|
1992 (search-forward "\n\n" nil t)
|
|
1993 (let ((case-fold-search t))
|
|
1994 (re-search-backward
|
|
1995 rmail-mime-charset-pattern
|
|
1996 start t))))
|
70771
|
1997 (intern (downcase (match-string 1))))))
|
52358
|
1998 (rmail-decode-region start (point) mime-charset)))))
|
22045
|
1999 ;; Add an X-Coding-System: header if we don't have one.
|
|
2000 (save-excursion
|
|
2001 (goto-char start)
|
|
2002 (forward-line 1)
|
|
2003 (if (looking-at "0")
|
|
2004 (forward-line 1)
|
|
2005 (forward-line 2))
|
|
2006 (or (save-restriction
|
|
2007 (narrow-to-region (point) (point-max))
|
|
2008 (rfc822-goto-eoh)
|
|
2009 (goto-char (point-min))
|
|
2010 (re-search-forward "^X-Coding-System:" nil t))
|
|
2011 (insert "X-Coding-System: "
|
|
2012 (symbol-name last-coding-system-used)
|
|
2013 "\n")))
|
52864
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2014 (narrow-to-region (point) (point-max))
|
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2015 (and (= 0 (% count 10))
|
52866
|
2016 (message "Converting to Babyl format...%d" count)))
|
270
|
2017 ;;*** MMDF format
|
|
2018 ((let ((case-fold-search t))
|
18091
|
2019 (looking-at rmail-mmdf-delim1))
|
270
|
2020 (let ((case-fold-search t))
|
|
2021 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
|
18091
|
2022 (re-search-forward rmail-mmdf-delim2 nil t)
|
270
|
2023 (replace-match "\^_"))
|
|
2024 (save-excursion
|
|
2025 (save-restriction
|
|
2026 (narrow-to-region start (1- (point)))
|
|
2027 (goto-char (point-min))
|
|
2028 (while (search-forward "\n\^_" nil t); single char "\^_"
|
|
2029 (replace-match "\n^_")))); 2 chars: "^" and "_"
|
22045
|
2030 (setq last-coding-system-used nil)
|
17093
|
2031 (or rmail-enable-mime
|
20943
|
2032 (not rmail-enable-multibyte)
|
17839
|
2033 (decode-coding-region start (point) 'undecided))
|
22045
|
2034 (save-excursion
|
|
2035 (goto-char start)
|
|
2036 (forward-line 3)
|
|
2037 (insert "X-Coding-System: "
|
|
2038 (symbol-name last-coding-system-used)
|
|
2039 "\n"))
|
270
|
2040 (narrow-to-region (point) (point-max))
|
52864
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2041 (setq count (1+ count))
|
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2042 (and (= 0 (% count 10))
|
52866
|
2043 (message "Converting to Babyl format...%d" count)))
|
270
|
2044 ;;*** Mail format
|
|
2045 ((looking-at "^From ")
|
|
2046 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
|
|
2047 (rmail-nuke-pinhead-header)
|
2076
|
2048 ;; If this message has a Content-Length field,
|
|
2049 ;; skip to the end of the contents.
|
|
2050 (let* ((header-end (save-excursion
|
|
2051 (and (re-search-forward "\n\n" nil t)
|
5466
|
2052 (1- (point)))))
|
2076
|
2053 (case-fold-search t)
|
20273
|
2054 (quoted-printable-header-field-end
|
|
2055 (save-excursion
|
|
2056 (re-search-forward
|
20274
|
2057 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
|
20273
|
2058 header-end t)))
|
52358
|
2059 (base64-header-field-end
|
|
2060 (save-excursion
|
|
2061 (re-search-forward
|
|
2062 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
|
|
2063 header-end t)))
|
2076
|
2064 (size
|
|
2065 ;; Get the numeric value from the Content-Length field.
|
|
2066 (save-excursion
|
|
2067 ;; Back up to end of prev line,
|
|
2068 ;; in case the Content-Length field comes first.
|
|
2069 (forward-char -1)
|
|
2070 (and (search-forward "\ncontent-length: "
|
|
2071 header-end t)
|
|
2072 (let ((beg (point))
|
|
2073 (eol (progn (end-of-line) (point))))
|
62402
|
2074 (string-to-number (buffer-substring beg eol)))))))
|
6389
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2075 (and size
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2076 (if (and (natnump size)
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2077 (<= (+ header-end size) (point-max))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2078 ;; Make sure this would put us at a position
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2079 ;; that we could continue from.
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2080 (save-excursion
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2081 (goto-char (+ header-end size))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2082 (skip-chars-forward "\n")
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2083 (or (eobp)
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2084 (and (looking-at "BABYL OPTIONS:")
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2085 (search-forward "\n\^_" nil t))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2086 (and (looking-at "\^L")
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2087 (search-forward "\n\^_" nil t))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2088 (let ((case-fold-search t))
|
18091
|
2089 (looking-at rmail-mmdf-delim1))
|
6389
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2090 (looking-at "From "))))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2091 (goto-char (+ header-end size))
|
9b45e828c2a7
(rmail-convert-to-babyl-format): Check Content-Length field for consistency.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2092 (message "Ignoring invalid Content-Length field")
|
20273
|
2093 (sit-for 1 0 t)))
|
48584
|
2094 (if (let ((case-fold-search nil))
|
|
2095 (re-search-forward
|
|
2096 (concat "^[\^_]?\\("
|
|
2097 rmail-unix-mail-delimiter
|
|
2098 "\\|"
|
|
2099 rmail-mmdf-delim1 "\\|"
|
|
2100 "^BABYL OPTIONS:\\|"
|
|
2101 "\^L\n[01],\\)") nil t))
|
20273
|
2102 (goto-char (match-beginning 1))
|
|
2103 (goto-char (point-max)))
|
|
2104 (setq count (1+ count))
|
|
2105 (if quoted-printable-header-field-end
|
|
2106 (save-excursion
|
53570
8e83b9e560f0
(rmail-convert-to-babyl-format): Use mail-unquote-printable-region.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2107 (unless
|
54262
|
2108 (mail-unquote-printable-region header-end (point) nil t t)
|
53570
8e83b9e560f0
(rmail-convert-to-babyl-format): Use mail-unquote-printable-region.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2109 (message "Malformed MIME quoted-printable message"))
|
20273
|
2110 ;; Change "quoted-printable" to "8bit",
|
|
2111 ;; to reflect the decoding we just did.
|
|
2112 (goto-char quoted-printable-header-field-end)
|
20274
|
2113 (delete-region (point) (search-backward ":"))
|
52358
|
2114 (insert ": 8bit")))
|
|
2115 (if base64-header-field-end
|
53445
|
2116 (save-excursion
|
|
2117 (when
|
|
2118 (condition-case nil
|
|
2119 (progn
|
53666
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2120 (base64-decode-region
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2121 (1+ header-end)
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2122 (save-excursion
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2123 ;; Prevent base64-decode-region
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2124 ;; from removing newline characters.
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2125 (skip-chars-backward "\n\t ")
|
0a56d6bd40da
(rmail-convert-to-babyl-format): Avoid deleting trailing white space
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
2126 (point)))
|
53445
|
2127 t)
|
|
2128 (error nil))
|
|
2129 ;; Change "base64" to "8bit", to reflect the
|
|
2130 ;; decoding we just did.
|
|
2131 (goto-char base64-header-field-end)
|
|
2132 (delete-region (point) (search-backward ":"))
|
|
2133 (insert ": 8bit")))))
|
2076
|
2134
|
270
|
2135 (save-excursion
|
|
2136 (save-restriction
|
|
2137 (narrow-to-region start (point))
|
|
2138 (goto-char (point-min))
|
|
2139 (while (search-forward "\n\^_" nil t); single char
|
|
2140 (replace-match "\n^_")))); 2 chars: "^" and "_"
|
54262
|
2141 ;; This is for malformed messages that don't end in newline.
|
|
2142 ;; There shouldn't be any, but some users say occasionally
|
|
2143 ;; there are some.
|
|
2144 (or (bolp) (newline))
|
270
|
2145 (insert ?\^_)
|
22045
|
2146 (setq last-coding-system-used nil)
|
17093
|
2147 (or rmail-enable-mime
|
20943
|
2148 (not rmail-enable-multibyte)
|
24209
|
2149 (let ((mime-charset
|
|
2150 (if (and rmail-decode-mime-charset
|
|
2151 (save-excursion
|
|
2152 (goto-char start)
|
|
2153 (search-forward "\n\n" nil t)
|
|
2154 (let ((case-fold-search t))
|
|
2155 (re-search-backward
|
|
2156 rmail-mime-charset-pattern
|
|
2157 start t))))
|
70771
|
2158 (intern (downcase (match-string 1))))))
|
24209
|
2159 (rmail-decode-region start (point) mime-charset)))
|
22045
|
2160 (save-excursion
|
|
2161 (goto-char start)
|
|
2162 (forward-line 3)
|
|
2163 (insert "X-Coding-System: "
|
|
2164 (symbol-name last-coding-system-used)
|
|
2165 "\n"))
|
52864
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2166 (narrow-to-region (point) (point-max))
|
6cb616f8963b
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2167 (and (= 0 (% count 10))
|
52866
|
2168 (message "Converting to Babyl format...%d" count)))
|
270
|
2169 ;;
|
2700
|
2170 ;; This kludge is because some versions of sendmail.el
|
|
2171 ;; insert an extra newline at the beginning that shouldn't
|
|
2172 ;; be there. sendmail.el has been fixed, but old versions
|
|
2173 ;; may still be in use. -- rms, 7 May 1993.
|
|
2174 ((eolp) (delete-char 1))
|
405
|
2175 (t (error "Cannot convert to babyl format")))))
|
270
|
2176 count))
|
|
2177
|
|
2178 ;; Delete the "From ..." line, creating various other headers with
|
|
2179 ;; information from it if they don't already exist. Now puts the
|
4838
|
2180 ;; original line into a mail-from: header line for debugging and for
|
|
2181 ;; use by the rmail-output function.
|
270
|
2182 (defun rmail-nuke-pinhead-header ()
|
|
2183 (save-excursion
|
|
2184 (save-restriction
|
|
2185 (let ((start (point))
|
|
2186 (end (progn
|
|
2187 (condition-case ()
|
|
2188 (search-forward "\n\n")
|
|
2189 (error
|
|
2190 (goto-char (point-max))
|
|
2191 (insert "\n\n")))
|
|
2192 (point)))
|
|
2193 has-from has-date)
|
|
2194 (narrow-to-region start end)
|
|
2195 (let ((case-fold-search t))
|
|
2196 (goto-char start)
|
|
2197 (setq has-from (search-forward "\nFrom:" nil t))
|
|
2198 (goto-char start)
|
|
2199 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
|
|
2200 (goto-char start))
|
|
2201 (let ((case-fold-search nil))
|
617
|
2202 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
|
270
|
2203 (replace-match
|
|
2204 (concat
|
|
2205 "Mail-from: \\&"
|
|
2206 ;; Keep and reformat the date if we don't
|
|
2207 ;; have a Date: field.
|
|
2208 (if has-date
|
|
2209 ""
|
1112
|
2210 (concat
|
15534
|
2211 "Date: \\2, \\4 \\3 \\9 \\5 "
|
45144
|
2212
|
1112
|
2213 ;; The timezone could be matched by group 7 or group 10.
|
|
2214 ;; If neither of them matched, assume EST, since only
|
|
2215 ;; Easterners would be so sloppy.
|
|
2216 ;; It's a shame the substitution can't use "\\10".
|
|
2217 (cond
|
|
2218 ((/= (match-beginning 7) (match-end 7)) "\\7")
|
|
2219 ((/= (match-beginning 10) (match-end 10))
|
|
2220 (buffer-substring (match-beginning 10)
|
|
2221 (match-end 10)))
|
|
2222 (t "EST"))
|
|
2223 "\n"))
|
270
|
2224 ;; Keep and reformat the sender if we don't
|
|
2225 ;; have a From: field.
|
|
2226 (if has-from
|
|
2227 ""
|
4340
505fb5222dea
(rmail-nuke-pinhead-header): Tell replace-match not to alter the case.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2228 "From: \\1\n"))
|
505fb5222dea
(rmail-nuke-pinhead-header): Tell replace-match not to alter the case.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2229 t)))))))
|
270
|
2230
|
|
2231 ;;;; *** Rmail Message Formatting and Header Manipulation ***
|
|
2232
|
|
2233 (defun rmail-reformat-message (beg end)
|
|
2234 (goto-char beg)
|
|
2235 (forward-line 1)
|
|
2236 (if (/= (following-char) ?0)
|
38412
|
2237 (error "Bad format in RMAIL file"))
|
38228
|
2238 (let ((inhibit-read-only t)
|
270
|
2239 (delta (- (buffer-size) end)))
|
|
2240 (delete-char 1)
|
|
2241 (insert ?1)
|
|
2242 (forward-line 1)
|
4340
505fb5222dea
(rmail-nuke-pinhead-header): Tell replace-match not to alter the case.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2243 (let ((case-fold-search t))
|
4838
|
2244 (while (looking-at "Summary-line:\\|Mail-From:")
|
|
2245 (forward-line 1)))
|
270
|
2246 (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
|
|
2247 (delete-region (point)
|
|
2248 (progn (forward-line 1) (point))))
|
|
2249 (let ((str (buffer-substring (point)
|
|
2250 (save-excursion (search-forward "\n\n" end 'move)
|
|
2251 (point)))))
|
|
2252 (insert str "*** EOOH ***\n")
|
|
2253 (narrow-to-region (point) (- (buffer-size) delta)))
|
|
2254 (goto-char (point-min))
|
9062
|
2255 (if rmail-message-filter (funcall rmail-message-filter))
|
11452
|
2256 (if (or rmail-displayed-headers rmail-ignored-headers)
|
|
2257 (rmail-clear-headers))))
|
270
|
2258
|
9010
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2259 (defun rmail-clear-headers (&optional ignored-headers)
|
11452
|
2260 "Delete all header fields that Rmail should not show.
|
|
2261 If the optional argument IGNORED-HEADERS is non-nil,
|
|
2262 delete all header fields whose names match that regexp.
|
|
2263 Otherwise, if `rmail-displayed-headers' is non-nil,
|
|
2264 delete all header fields *except* those whose names match that regexp.
|
64972
|
2265 Otherwise, delete all header fields whose names match `rmail-ignored-headers'
|
|
2266 unless they also match `rmail-nonignored-headers'."
|
21195
|
2267 (when (search-forward "\n\n" nil t)
|
|
2268 (forward-char -1)
|
|
2269 (let ((case-fold-search t)
|
|
2270 (buffer-read-only nil))
|
|
2271 (if (and rmail-displayed-headers (null ignored-headers))
|
21293
|
2272 (save-restriction
|
|
2273 (narrow-to-region (point-min) (point))
|
|
2274 (let (lim next)
|
|
2275 (goto-char (point-min))
|
|
2276 (while (and (not (eobp))
|
|
2277 (save-excursion
|
|
2278 (if (re-search-forward "\n[^ \t]" nil t)
|
|
2279 (setq lim (match-beginning 0)
|
|
2280 next (1+ lim))
|
|
2281 (setq lim nil next (point-max)))))
|
|
2282 (if (save-excursion
|
|
2283 (re-search-forward rmail-displayed-headers lim t))
|
|
2284 (goto-char next)
|
|
2285 (delete-region (point) next))))
|
|
2286 (goto-char (point-min)))
|
21195
|
2287 (or ignored-headers (setq ignored-headers rmail-ignored-headers))
|
|
2288 (save-restriction
|
|
2289 (narrow-to-region (point-min) (point))
|
64972
|
2290 (goto-char (point-min))
|
30112
|
2291 (while (and ignored-headers
|
64972
|
2292 (re-search-forward ignored-headers nil t))
|
21195
|
2293 (beginning-of-line)
|
64972
|
2294 (if (looking-at rmail-nonignored-headers)
|
|
2295 (forward-line 1)
|
|
2296 (delete-region (point)
|
|
2297 (save-excursion
|
|
2298 (if (re-search-forward "\n[^ \t]" nil t)
|
|
2299 (1- (point))
|
|
2300 (point-max)))))))))))
|
270
|
2301
|
16772
|
2302 (defun rmail-msg-is-pruned ()
|
270
|
2303 (rmail-maybe-set-message-counters)
|
16772
|
2304 (save-restriction
|
22263
|
2305 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
|
16772
|
2306 (save-excursion
|
22263
|
2307 (goto-char (point-min))
|
|
2308 (forward-line 1)
|
16772
|
2309 (= (following-char) ?1))))
|
|
2310
|
38191
|
2311 (defun rmail-msg-restore-non-pruned-header ()
|
38228
|
2312 (let ((old-point (point))
|
|
2313 new-point
|
|
2314 new-start
|
|
2315 (inhibit-read-only t))
|
|
2316 (save-excursion
|
|
2317 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
|
38191
|
2318 (goto-char (point-min))
|
|
2319 (forward-line 1)
|
|
2320 ;; Change 1 to 0.
|
|
2321 (delete-char 1)
|
|
2322 (insert ?0)
|
|
2323 ;; Insert new EOOH line at the proper place.
|
|
2324 (forward-line 1)
|
|
2325 (let ((case-fold-search t))
|
|
2326 (while (looking-at "Summary-Line:\\|Mail-From:")
|
|
2327 (forward-line 1)))
|
|
2328 (insert "*** EOOH ***\n")
|
|
2329 (setq new-start (point))
|
|
2330 ;; Delete the old reformatted header.
|
|
2331 (forward-char -1)
|
|
2332 (search-forward "\n*** EOOH ***\n")
|
|
2333 (forward-line -1)
|
|
2334 (let ((start (point)))
|
|
2335 (search-forward "\n\n")
|
38228
|
2336 (if (and (<= start old-point)
|
|
2337 (<= old-point (point)))
|
|
2338 (setq new-point new-start))
|
38191
|
2339 (delete-region start (point)))
|
|
2340 ;; Narrow to after the new EOOH line.
|
38228
|
2341 (narrow-to-region new-start (point-max)))
|
|
2342 (if new-point
|
|
2343 (goto-char new-point))))
|
38191
|
2344
|
|
2345 (defun rmail-msg-prune-header ()
|
38228
|
2346 (let ((new-point
|
|
2347 (= (point) (point-min))))
|
|
2348 (save-excursion
|
|
2349 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
|
|
2350 (rmail-reformat-message (point-min) (point-max)))
|
|
2351 (if new-point
|
|
2352 (goto-char (point-min)))))
|
38191
|
2353
|
16772
|
2354 (defun rmail-toggle-header (&optional arg)
|
|
2355 "Show original message header if pruned header currently shown, or vice versa.
|
|
2356 With argument ARG, show the message header pruned if ARG is greater than zero;
|
|
2357 otherwise, show it in full."
|
|
2358 (interactive "P")
|
38191
|
2359 (let* ((pruned (with-current-buffer rmail-buffer
|
|
2360 (rmail-msg-is-pruned)))
|
22351
|
2361 (prune (if arg
|
|
2362 (> (prefix-numeric-value arg) 0)
|
|
2363 (not pruned))))
|
|
2364 (if (eq pruned prune)
|
|
2365 t
|
38191
|
2366 (set-buffer rmail-buffer)
|
22351
|
2367 (rmail-maybe-set-message-counters)
|
38191
|
2368 (if rmail-enable-mime
|
|
2369 (let ((buffer-read-only nil))
|
|
2370 (if pruned
|
|
2371 (rmail-msg-restore-non-pruned-header)
|
|
2372 (rmail-msg-prune-header))
|
|
2373 (funcall rmail-show-mime-function))
|
|
2374 (let* ((buffer-read-only nil)
|
|
2375 (window (get-buffer-window (current-buffer)))
|
|
2376 (at-point-min (= (point) (point-min)))
|
|
2377 (all-headers-visible (= (window-start window) (point-min)))
|
|
2378 (on-header
|
|
2379 (save-excursion
|
|
2380 (and (not (search-backward "\n\n" nil t))
|
|
2381 (progn
|
|
2382 (end-of-line)
|
|
2383 (re-search-backward "^[-A-Za-z0-9]+:" nil t))
|
|
2384 (match-string 0))))
|
|
2385 (old-screen-line
|
|
2386 (rmail-count-screen-lines (window-start window) (point))))
|
22435
|
2387 (if pruned
|
38191
|
2388 (rmail-msg-restore-non-pruned-header)
|
|
2389 (rmail-msg-prune-header))
|
|
2390 (cond (at-point-min
|
|
2391 (goto-char (point-min)))
|
|
2392 (on-header
|
|
2393 (goto-char (point-min))
|
|
2394 (search-forward "\n\n")
|
|
2395 (or (re-search-backward
|
|
2396 (concat "^" (regexp-quote on-header)) nil t)
|
|
2397 (goto-char (point-min))))
|
|
2398 (t
|
|
2399 (save-selected-window
|
|
2400 (select-window window)
|
|
2401 (recenter old-screen-line)
|
|
2402 (if (and all-headers-visible
|
|
2403 (not (= (window-start) (point-min))))
|
43124
|
2404 (recenter (- (window-height) 2))))))))
|
22351
|
2405 (rmail-highlight-headers))))
|
|
2406
|
38228
|
2407 (defun rmail-narrow-to-non-pruned-header ()
|
|
2408 "Narrow to the whole (original) header of the current message."
|
|
2409 (let (start end)
|
|
2410 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
|
|
2411 (goto-char (point-min))
|
|
2412 (forward-line 1)
|
|
2413 (if (= (following-char) ?1)
|
|
2414 (progn
|
|
2415 (forward-line 1)
|
|
2416 (setq start (point))
|
|
2417 (search-forward "*** EOOH ***\n")
|
|
2418 (setq end (match-beginning 0)))
|
|
2419 (forward-line 2)
|
|
2420 (setq start (point))
|
|
2421 (search-forward "\n\n")
|
|
2422 (setq end (1- (point))))
|
|
2423 (narrow-to-region start end)
|
|
2424 (goto-char start)))
|
|
2425
|
22351
|
2426 ;; Lifted from repos-count-screen-lines.
|
|
2427 ;; Return number of screen lines between START and END.
|
|
2428 (defun rmail-count-screen-lines (start end)
|
22330
|
2429 (save-excursion
|
22351
|
2430 (save-restriction
|
|
2431 (narrow-to-region start end)
|
|
2432 (goto-char (point-min))
|
|
2433 (vertical-motion (- (point-max) (point-min))))))
|
270
|
2434
|
|
2435 ;;;; *** Rmail Attributes and Keywords ***
|
|
2436
|
|
2437 ;; Make a string describing current message's attributes and keywords
|
|
2438 ;; and set it up as the name of a minor mode
|
|
2439 ;; so it will appear in the mode line.
|
|
2440 (defun rmail-display-labels ()
|
|
2441 (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
|
|
2442 (save-excursion
|
|
2443 (unwind-protect
|
|
2444 (progn
|
|
2445 (widen)
|
|
2446 (goto-char (rmail-msgbeg rmail-current-message))
|
|
2447 (forward-line 1)
|
|
2448 (if (looking-at "[01],")
|
|
2449 (progn
|
|
2450 (narrow-to-region (point) (progn (end-of-line) (point)))
|
|
2451 ;; Truly valid BABYL format requires a space before each
|
|
2452 ;; attribute or keyword name. Put them in if missing.
|
|
2453 (let (buffer-read-only)
|
|
2454 (goto-char (point-min))
|
|
2455 (while (search-forward "," nil t)
|
|
2456 (or (looking-at "[ ,]") (eobp)
|
|
2457 (insert " "))))
|
|
2458 (goto-char (point-max))
|
|
2459 (if (search-backward ",," nil 'move)
|
|
2460 (progn
|
|
2461 (if (> (point) (1+ (point-min)))
|
|
2462 (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
|
|
2463 (if (> (- (point-max) (point)) 2)
|
|
2464 (setq blurb
|
|
2465 (concat blurb
|
|
2466 ";"
|
|
2467 (buffer-substring (+ (point) 3)
|
|
2468 (1- (point-max)))))))))))
|
|
2469 ;; Note: we don't use save-restriction because that does not work right
|
|
2470 ;; if changes are made outside the saved restriction
|
|
2471 ;; before that restriction is restored.
|
|
2472 (narrow-to-region beg end)
|
|
2473 (set-marker beg nil)
|
|
2474 (set-marker end nil)))
|
|
2475 (while (string-match " +," blurb)
|
|
2476 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
|
|
2477 (substring blurb (match-end 0)))))
|
|
2478 (while (string-match ", +" blurb)
|
|
2479 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
|
|
2480 (substring blurb (match-end 0)))))
|
|
2481 (setq mode-line-process
|
11452
|
2482 (format " %d/%d%s"
|
37611
|
2483 rmail-current-message rmail-total-messages blurb))
|
|
2484 ;; If rmail-enable-mime is non-nil, we may have to update
|
|
2485 ;; `mode-line-process' of rmail-view-buffer too.
|
|
2486 (if (and rmail-enable-mime
|
|
2487 (not (eq (current-buffer) rmail-view-buffer))
|
|
2488 (buffer-live-p rmail-view-buffer))
|
|
2489 (let ((mlp mode-line-process))
|
|
2490 (with-current-buffer rmail-view-buffer
|
|
2491 (setq mode-line-process mlp))))))
|
270
|
2492
|
|
2493 ;; Turn an attribute of a message on or off according to STATE.
|
|
2494 ;; ATTR is the name of the attribute, as a string.
|
|
2495 ;; MSGNUM is message number to change; nil means current message.
|
|
2496 (defun rmail-set-attribute (attr state &optional msgnum)
|
37611
|
2497 (set-buffer rmail-buffer)
|
270
|
2498 (let ((omax (point-max-marker))
|
|
2499 (omin (point-min-marker))
|
|
2500 (buffer-read-only nil))
|
|
2501 (or msgnum (setq msgnum rmail-current-message))
|
5047
|
2502 (if (> msgnum 0)
|
|
2503 (unwind-protect
|
|
2504 (save-excursion
|
|
2505 (widen)
|
|
2506 (goto-char (+ 3 (rmail-msgbeg msgnum)))
|
|
2507 (let ((curstate
|
|
2508 (not
|
|
2509 (null (search-backward (concat ", " attr ",")
|
|
2510 (prog1 (point) (end-of-line)) t)))))
|
|
2511 (or (eq curstate (not (not state)))
|
|
2512 (if curstate
|
|
2513 (delete-region (point) (1- (match-end 0)))
|
|
2514 (beginning-of-line)
|
|
2515 (forward-char 2)
|
|
2516 (insert " " attr ","))))
|
|
2517 (if (string= attr "deleted")
|
|
2518 (rmail-set-message-deleted-p msgnum state)))
|
|
2519 ;; Note: we don't use save-restriction because that does not work right
|
|
2520 ;; if changes are made outside the saved restriction
|
|
2521 ;; before that restriction is restored.
|
|
2522 (narrow-to-region omin omax)
|
|
2523 (set-marker omin nil)
|
|
2524 (set-marker omax nil)
|
|
2525 (if (= msgnum rmail-current-message)
|
|
2526 (rmail-display-labels))))))
|
270
|
2527
|
|
2528 ;; Return t if the attributes/keywords line of msg number MSG
|
|
2529 ;; contains a match for the regexp LABELS.
|
|
2530 (defun rmail-message-labels-p (msg labels)
|
|
2531 (save-excursion
|
|
2532 (save-restriction
|
|
2533 (widen)
|
|
2534 (goto-char (rmail-msgbeg msg))
|
|
2535 (forward-char 3)
|
|
2536 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
|
|
2537
|
|
2538 ;;;; *** Rmail Message Selection And Support ***
|
|
2539
|
|
2540 (defun rmail-msgend (n)
|
|
2541 (marker-position (aref rmail-message-vector (1+ n))))
|
|
2542
|
|
2543 (defun rmail-msgbeg (n)
|
|
2544 (marker-position (aref rmail-message-vector n)))
|
|
2545
|
|
2546 (defun rmail-widen-to-current-msgbeg (function)
|
|
2547 "Call FUNCTION with point at start of internal data of current message.
|
|
2548 Assumes that bounds were previously narrowed to display the message in Rmail.
|
|
2549 The bounds are widened enough to move point where desired, then narrowed
|
|
2550 again afterward.
|
|
2551
|
|
2552 FUNCTION may not change the visible text of the message, but it may
|
|
2553 change the invisible header text."
|
|
2554 (save-excursion
|
29301
|
2555 (unwind-protect
|
|
2556 (progn
|
|
2557 (narrow-to-region (rmail-msgbeg rmail-current-message)
|
|
2558 (point-max))
|
|
2559 (goto-char (point-min))
|
|
2560 (funcall function))
|
270
|
2561 ;; Note: we don't use save-restriction because that does not work right
|
|
2562 ;; if changes are made outside the saved restriction
|
|
2563 ;; before that restriction is restored.
|
29301
|
2564 (narrow-to-region (rmail-msgbeg rmail-current-message)
|
|
2565 (rmail-msgend rmail-current-message)))))
|
270
|
2566
|
|
2567 (defun rmail-forget-messages ()
|
|
2568 (unwind-protect
|
|
2569 (if (vectorp rmail-message-vector)
|
|
2570 (let* ((i 0)
|
|
2571 (v rmail-message-vector)
|
|
2572 (n (length v)))
|
|
2573 (while (< i n)
|
|
2574 (move-marker (aref v i) nil)
|
|
2575 (setq i (1+ i)))))
|
|
2576 (setq rmail-message-vector nil)
|
17620
|
2577 (setq rmail-msgref-vector nil)
|
270
|
2578 (setq rmail-deleted-vector nil)))
|
|
2579
|
|
2580 (defun rmail-maybe-set-message-counters ()
|
|
2581 (if (not (and rmail-deleted-vector
|
|
2582 rmail-message-vector
|
|
2583 rmail-current-message
|
|
2584 rmail-total-messages))
|
|
2585 (rmail-set-message-counters)))
|
|
2586
|
|
2587 (defun rmail-count-new-messages (&optional nomsg)
|
|
2588 (let* ((case-fold-search nil)
|
|
2589 (total-messages 0)
|
|
2590 (messages-head nil)
|
|
2591 (deleted-head nil))
|
|
2592 (or nomsg (message "Counting new messages..."))
|
|
2593 (goto-char (point-max))
|
|
2594 ;; Put at the end of messages-head
|
|
2595 ;; the entry for message N+1, which marks
|
|
2596 ;; the end of message N. (N = number of messages).
|
|
2597 (search-backward "\n\^_")
|
|
2598 (forward-char 1)
|
|
2599 (setq messages-head (list (point-marker)))
|
|
2600 (rmail-set-message-counters-counter (point-min))
|
|
2601 (setq rmail-current-message (1+ rmail-total-messages))
|
|
2602 (setq rmail-total-messages
|
|
2603 (+ rmail-total-messages total-messages))
|
|
2604 (setq rmail-message-vector
|
|
2605 (vconcat rmail-message-vector (cdr messages-head)))
|
|
2606 (aset rmail-message-vector
|
|
2607 rmail-current-message (car messages-head))
|
|
2608 (setq rmail-deleted-vector
|
|
2609 (concat rmail-deleted-vector deleted-head))
|
|
2610 (setq rmail-summary-vector
|
|
2611 (vconcat rmail-summary-vector (make-vector total-messages nil)))
|
17620
|
2612 (setq rmail-msgref-vector
|
|
2613 (vconcat rmail-msgref-vector (make-vector total-messages nil)))
|
|
2614 ;; Fill in the new elements of rmail-msgref-vector.
|
17640
|
2615 (let ((i (1+ (- rmail-total-messages total-messages))))
|
17620
|
2616 (while (<= i rmail-total-messages)
|
|
2617 (aset rmail-msgref-vector i (list i))
|
|
2618 (setq i (1+ i))))
|
270
|
2619 (goto-char (point-min))
|
|
2620 (or nomsg (message "Counting new messages...done (%d)" total-messages))))
|
|
2621
|
|
2622 (defun rmail-set-message-counters ()
|
|
2623 (rmail-forget-messages)
|
|
2624 (save-excursion
|
|
2625 (save-restriction
|
|
2626 (widen)
|
|
2627 (let* ((point-save (point))
|
|
2628 (total-messages 0)
|
|
2629 (messages-after-point)
|
|
2630 (case-fold-search nil)
|
|
2631 (messages-head nil)
|
|
2632 (deleted-head nil))
|
|
2633 (message "Counting messages...")
|
|
2634 (goto-char (point-max))
|
|
2635 ;; Put at the end of messages-head
|
|
2636 ;; the entry for message N+1, which marks
|
|
2637 ;; the end of message N. (N = number of messages).
|
5586
|
2638 (search-backward "\n\^_" nil t)
|
|
2639 (if (/= (point) (point-max)) (forward-char 1))
|
270
|
2640 (setq messages-head (list (point-marker)))
|
|
2641 (rmail-set-message-counters-counter (min (point) point-save))
|
|
2642 (setq messages-after-point total-messages)
|
|
2643 (rmail-set-message-counters-counter)
|
|
2644 (setq rmail-total-messages total-messages)
|
|
2645 (setq rmail-current-message
|
|
2646 (min total-messages
|
|
2647 (max 1 (- total-messages messages-after-point))))
|
|
2648 (setq rmail-message-vector
|
|
2649 (apply 'vector (cons (point-min-marker) messages-head))
|
34055
|
2650 rmail-deleted-vector (concat "0" deleted-head)
|
17620
|
2651 rmail-summary-vector (make-vector rmail-total-messages nil)
|
|
2652 rmail-msgref-vector (make-vector (1+ rmail-total-messages) nil))
|
|
2653 (let ((i 0))
|
|
2654 (while (<= i rmail-total-messages)
|
|
2655 (aset rmail-msgref-vector i (list i))
|
|
2656 (setq i (1+ i))))
|
270
|
2657 (message "Counting messages...done")))))
|
45144
|
2658
|
270
|
2659 (defun rmail-set-message-counters-counter (&optional stop)
|
23750
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2660 (let ((start (point))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2661 next)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2662 (while (search-backward "\n\^_\^L" stop t)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2663 ;; Detect messages that have been added with DOS line endings and
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2664 ;; convert the line endings for such messages.
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2665 (setq next (point))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2666 (if (looking-at "\n\^_\^L\r\n")
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2667 (let ((buffer-read-only nil)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2668 (buffer-undo t))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2669 (message "Counting messages...(converting line endings)")
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2670 (save-excursion
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2671 (goto-char start)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2672 (while (search-backward "\r\n" next t)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2673 (delete-char 1)))))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2674 (setq start next)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2675 (forward-char 1)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2676 (setq messages-head (cons (point-marker) messages-head))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2677 (save-excursion
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2678 (setq deleted-head
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2679 (cons (if (search-backward ", deleted,"
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2680 (prog1 (point)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2681 (forward-line 2))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2682 t)
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2683 ?D ?\ )
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2684 deleted-head)))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2685 (if (zerop (% (setq total-messages (1+ total-messages)) 20))
|
15450ece2f24
(rmail-set-message-counters-counter): Detect messages that have been
Andrew Innes <andrewi@gnu.org>
diff
changeset
|
2686 (message "Counting messages...%d" total-messages)))))
|
270
|
2687
|
|
2688 (defun rmail-beginning-of-message ()
|
|
2689 "Show current message starting from the beginning."
|
|
2690 (interactive)
|
64928
|
2691 (let ((rmail-show-message-hook
|
|
2692 (list (function (lambda ()
|
|
2693 (goto-char (point-min)))))))
|
|
2694 (rmail-show-message rmail-current-message)))
|
|
2695
|
|
2696 (defun rmail-end-of-message ()
|
|
2697 "Show bottom of current message."
|
|
2698 (interactive)
|
|
2699 (let ((rmail-show-message-hook
|
|
2700 (list (function (lambda ()
|
|
2701 (goto-char (point-max))
|
|
2702 (recenter (1- (window-height))))))))
|
|
2703 (rmail-show-message rmail-current-message)))
|
270
|
2704
|
60692
|
2705 (defun rmail-unknown-mail-followup-to ()
|
|
2706 "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
|
|
2707 Ask the user whether to add that list name to `mail-mailing-lists'."
|
|
2708 (save-restriction
|
|
2709 (rmail-narrow-to-non-pruned-header)
|
|
2710 (let ((mail-followup-to (mail-fetch-field "mail-followup-to" nil t)))
|
|
2711 (when mail-followup-to
|
|
2712 (let ((addresses
|
64754
|
2713 (split-string
|
60692
|
2714 (mail-strip-quoted-names mail-followup-to)
|
|
2715 ",[[:space:]]+" t)))
|
|
2716 (dolist (addr addresses)
|
|
2717 (when (and (not (member addr mail-mailing-lists))
|
|
2718 (not
|
|
2719 ;; taken from rmailsum.el
|
|
2720 (string-match
|
|
2721 (or rmail-user-mail-address-regexp
|
|
2722 (concat "^\\("
|
|
2723 (regexp-quote (user-login-name))
|
|
2724 "\\($\\|@\\)\\|"
|
|
2725 (regexp-quote
|
|
2726 (or user-mail-address
|
|
2727 (concat (user-login-name) "@"
|
|
2728 (or mail-host-address
|
|
2729 (system-name)))))
|
|
2730 "\\>\\)"))
|
|
2731 addr))
|
|
2732 (y-or-n-p
|
|
2733 (format "Add `%s' to `mail-mailing-lists'? "
|
|
2734 addr)))
|
|
2735 (customize-save-variable 'mail-mailing-lists
|
|
2736 (cons addr mail-mailing-lists)))))))))
|
|
2737
|
9431
|
2738 (defun rmail-show-message (&optional n no-summary)
|
2076
|
2739 "Show message number N (prefix argument), counting from start of file.
|
|
2740 If summary buffer is currently displayed, update current message there also."
|
270
|
2741 (interactive "p")
|
17093
|
2742 (or (eq major-mode 'rmail-mode)
|
|
2743 (switch-to-buffer rmail-buffer))
|
270
|
2744 (rmail-maybe-set-message-counters)
|
|
2745 (widen)
|
|
2746 (if (zerop rmail-total-messages)
|
|
2747 (progn (narrow-to-region (point-min) (1- (point-max)))
|
|
2748 (goto-char (point-min))
|
|
2749 (setq mode-line-process nil))
|
22045
|
2750 (let (blurb coding-system)
|
270
|
2751 (if (not n)
|
|
2752 (setq n rmail-current-message)
|
|
2753 (cond ((<= n 0)
|
|
2754 (setq n 1
|
|
2755 rmail-current-message 1
|
|
2756 blurb "No previous message"))
|
|
2757 ((> n rmail-total-messages)
|
|
2758 (setq n rmail-total-messages
|
|
2759 rmail-current-message rmail-total-messages
|
|
2760 blurb "No following message"))
|
|
2761 (t
|
|
2762 (setq rmail-current-message n))))
|
16241
|
2763 (let ((beg (rmail-msgbeg n)))
|
270
|
2764 (goto-char beg)
|
|
2765 (forward-line 1)
|
22045
|
2766 (save-excursion
|
|
2767 (let ((end (rmail-msgend n)))
|
|
2768 (save-restriction
|
|
2769 (if (prog1 (= (following-char) ?0)
|
|
2770 (forward-line 2)
|
24323
|
2771 ;; If there's a Summary-line in the (otherwise empty)
|
|
2772 ;; header, we didn't yet get past the EOOH line.
|
|
2773 (if (looking-at "^\\*\\*\\* EOOH \\*\\*\\*\n")
|
|
2774 (forward-line 1))
|
22045
|
2775 (narrow-to-region (point) end))
|
|
2776 (rfc822-goto-eoh)
|
|
2777 (search-forward "\n*** EOOH ***\n" end t))
|
|
2778 (narrow-to-region beg (point))
|
|
2779 (goto-char (point-min))
|
|
2780 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
|
|
2781 (let ((coding-system (intern (match-string 1))))
|
45218
|
2782 (condition-case nil
|
|
2783 (progn
|
|
2784 (check-coding-system coding-system)
|
|
2785 (setq buffer-file-coding-system coding-system))
|
49082
|
2786 (error
|
45218
|
2787 (setq buffer-file-coding-system nil))))
|
22045
|
2788 (setq buffer-file-coding-system nil)))))
|
16241
|
2789 ;; Clear the "unseen" attribute when we show a message.
|
|
2790 (rmail-set-attribute "unseen" nil)
|
|
2791 (let ((end (rmail-msgend n)))
|
22045
|
2792 ;; Reformat the header, or else find the reformatted header.
|
16241
|
2793 (if (= (following-char) ?0)
|
270
|
2794 (rmail-reformat-message beg end)
|
16241
|
2795 (search-forward "\n*** EOOH ***\n" end t)
|
|
2796 (narrow-to-region (point) end)))
|
270
|
2797 (goto-char (point-min))
|
38352
|
2798 (walk-windows
|
|
2799 (function (lambda (window)
|
|
2800 (if (eq (window-buffer window) (current-buffer))
|
|
2801 (set-window-point window (point)))))
|
|
2802 nil t)
|
270
|
2803 (rmail-display-labels)
|
17093
|
2804 (if (eq rmail-enable-mime t)
|
|
2805 (funcall rmail-show-mime-function)
|
60692
|
2806 (setq rmail-view-buffer rmail-buffer))
|
|
2807 (when mail-mailing-lists
|
|
2808 (rmail-unknown-mail-followup-to))
|
7084
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2809 (rmail-highlight-headers)
|
7696
ebcefadd2e1b
(rmail-show-message): If transient-mark-mode, deactivate the mark.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2810 (if transient-mark-mode (deactivate-mark))
|
270
|
2811 (run-hooks 'rmail-show-message-hook)
|
2076
|
2812 ;; If there is a summary buffer, try to move to this message
|
|
2813 ;; in that buffer. But don't complain if this message
|
|
2814 ;; is not mentioned in the summary.
|
9431
|
2815 ;; Don't do this at all if we were called on behalf
|
|
2816 ;; of cursor motion in the summary buffer.
|
|
2817 (and (rmail-summary-exists) (not no-summary)
|
|
2818 (let ((curr-msg rmail-current-message))
|
|
2819 (rmail-select-summary
|
|
2820 (rmail-summary-goto-msg curr-msg t t))))
|
37611
|
2821 (with-current-buffer rmail-buffer
|
|
2822 (rmail-auto-file))
|
270
|
2823 (if blurb
|
|
2824 (message blurb))))))
|
|
2825
|
35471
|
2826 (defun rmail-redecode-body (coding)
|
|
2827 "Decode the body of the current message using coding system CODING.
|
|
2828 This is useful with mail messages that have malformed or missing
|
|
2829 charset= headers.
|
|
2830
|
|
2831 This function assumes that the current message is already decoded
|
|
2832 and displayed in the RMAIL buffer, but the coding system used to
|
|
2833 decode it was incorrect. It then encodes the message back to its
|
35548
|
2834 original form, and decodes it again, using the coding system CODING.
|
35471
|
2835
|
|
2836 Note that if Emacs erroneously auto-detected one of the iso-2022
|
|
2837 encodings in the message, this function might fail because the escape
|
|
2838 sequences that switch between character sets and also single-shift and
|
|
2839 locking-shift codes are impossible to recover. This function is meant
|
|
2840 to be used to fix messages encoded with 8-bit encodings, such as
|
|
2841 iso-8859, koi8-r, etc."
|
|
2842 (interactive "zCoding system for re-decoding this message: ")
|
|
2843 (when (not rmail-enable-mime)
|
|
2844 (or (eq major-mode 'rmail-mode)
|
|
2845 (switch-to-buffer rmail-buffer))
|
|
2846 (save-excursion
|
43066
|
2847 (let ((pruned (rmail-msg-is-pruned)))
|
|
2848 (unwind-protect
|
|
2849 (let ((msgbeg (rmail-msgbeg rmail-current-message))
|
|
2850 (msgend (rmail-msgend rmail-current-message))
|
|
2851 x-coding-header)
|
|
2852 ;; We need the message headers pruned (we later restore
|
|
2853 ;; the pruned stat to what it was, see the end of
|
|
2854 ;; unwind-protect form).
|
|
2855 (or pruned
|
|
2856 (rmail-toggle-header 1))
|
|
2857 (narrow-to-region msgbeg msgend)
|
|
2858 (goto-char (point-min))
|
|
2859 (when (search-forward "\n*** EOOH ***\n" (point-max) t)
|
|
2860 (narrow-to-region msgbeg (point)))
|
|
2861 (goto-char (point-min))
|
|
2862 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
|
|
2863 (let ((old-coding (intern (match-string 1)))
|
|
2864 (buffer-read-only nil))
|
|
2865 (check-coding-system old-coding)
|
|
2866 ;; Make sure the new coding system uses the same EOL
|
|
2867 ;; conversion, to prevent ^M characters from popping
|
|
2868 ;; up all over the place.
|
|
2869 (setq coding
|
|
2870 (coding-system-change-eol-conversion
|
|
2871 coding
|
|
2872 (coding-system-eol-type old-coding)))
|
|
2873 (setq x-coding-header (point-marker))
|
|
2874 (narrow-to-region msgbeg msgend)
|
|
2875 (encode-coding-region (point) msgend old-coding)
|
|
2876 (decode-coding-region (point) msgend coding)
|
|
2877 (setq last-coding-system-used coding)
|
|
2878 ;; Rewrite the coding-system header according
|
|
2879 ;; to what we did.
|
|
2880 (goto-char x-coding-header)
|
|
2881 (delete-region (point)
|
|
2882 (save-excursion
|
|
2883 (beginning-of-line)
|
|
2884 (point)))
|
|
2885 (insert "X-Coding-System: "
|
|
2886 (symbol-name last-coding-system-used))
|
|
2887 (set-marker x-coding-header nil)
|
|
2888 (rmail-show-message))
|
|
2889 (error "No X-Coding-System header found")))
|
|
2890 (or pruned
|
|
2891 (rmail-toggle-header 0)))))))
|
35471
|
2892
|
7084
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2893 ;; Find all occurrences of certain fields, and highlight them.
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2894 (defun rmail-highlight-headers ()
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2895 ;; Do this only if the system supports faces.
|
8094
|
2896 (if (and (fboundp 'internal-find-face)
|
|
2897 rmail-highlighted-headers)
|
7084
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2898 (save-excursion
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2899 (search-forward "\n\n" nil 'move)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2900 (save-restriction
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2901 (narrow-to-region (point-min) (point))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2902 (let ((case-fold-search t)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2903 (inhibit-read-only t)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2904 ;; Highlight with boldface if that is available.
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2905 ;; Otherwise use the `highlight' face.
|
8383
|
2906 (face (or rmail-highlight-face
|
|
2907 (if (face-differs-from-default-p 'bold)
|
|
2908 'bold 'highlight)))
|
7084
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2909 ;; List of overlays to reuse.
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2910 (overlays rmail-overlay-list))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2911 (goto-char (point-min))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2912 (while (re-search-forward rmail-highlighted-headers nil t)
|
7955
a03d7bdee306
(rmail-highlight-headers): Don't skip newlines, just tab and space.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2913 (skip-chars-forward " \t")
|
7084
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2914 (let ((beg (point))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2915 overlay)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2916 (while (progn (forward-line 1)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2917 (looking-at "[ \t]")))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2918 ;; Back up over newline, then trailing spaces or tabs
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2919 (forward-char -1)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2920 (while (member (preceding-char) '(? ?\t))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2921 (forward-char -1))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2922 (if overlays
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2923 ;; Reuse an overlay we already have.
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2924 (progn
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2925 (setq overlay (car overlays)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2926 overlays (cdr overlays))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2927 (overlay-put overlay 'face face)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2928 (move-overlay overlay beg (point)))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2929 ;; Make a new overlay and add it to
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2930 ;; rmail-overlay-list.
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2931 (setq overlay (make-overlay beg (point)))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2932 (overlay-put overlay 'face face)
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2933 (setq rmail-overlay-list
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2934 (cons overlay rmail-overlay-list))))))))))
|
5ceea5b326b6
(rmail-highlight-headers): Extracted as a new function. Fix overlay position.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2935
|
29160
|
2936 (defun rmail-auto-file ()
|
|
2937 "Automatically move a message into a sub-folder based on criteria.
|
|
2938 Called when a new message is displayed."
|
|
2939 (if (or (rmail-message-labels-p rmail-current-message "filed")
|
|
2940 (not (string= (buffer-file-name)
|
|
2941 (expand-file-name rmail-file-name))))
|
|
2942 ;; Do nothing if it's already been filed.
|
|
2943 nil
|
|
2944 ;; Find out some basics (common fields)
|
|
2945 (let ((from (mail-fetch-field "from"))
|
|
2946 (subj (mail-fetch-field "subject"))
|
|
2947 (to (concat (mail-fetch-field "to") "," (mail-fetch-field "cc")))
|
|
2948 (d rmail-automatic-folder-directives)
|
|
2949 (directive-loop nil)
|
|
2950 (folder nil))
|
|
2951 (while d
|
|
2952 (setq folder (car (car d))
|
|
2953 directive-loop (cdr (car d)))
|
|
2954 (while (and (car directive-loop)
|
|
2955 (let ((f (cond
|
|
2956 ((string= (car directive-loop) "from") from)
|
|
2957 ((string= (car directive-loop) "to") to)
|
|
2958 ((string= (car directive-loop) "subject") subj)
|
|
2959 (t (mail-fetch-field (car directive-loop))))))
|
|
2960 (and f (string-match (car (cdr directive-loop)) f))))
|
|
2961 (setq directive-loop (cdr (cdr directive-loop))))
|
|
2962 ;; If there are no directives left, then it was a complete match.
|
|
2963 (if (null directive-loop)
|
|
2964 (if (null folder)
|
|
2965 (rmail-delete-forward)
|
|
2966 (if (string= "/dev/null" folder)
|
|
2967 (rmail-delete-message)
|
|
2968 (rmail-output-to-rmail-file folder 1 t)
|
|
2969 (setq d nil))))
|
|
2970 (setq d (cdr d))))))
|
|
2971
|
270
|
2972 (defun rmail-next-message (n)
|
|
2973 "Show following message whether deleted or not.
|
|
2974 With prefix arg N, moves forward N messages, or backward if N is negative."
|
|
2975 (interactive "p")
|
37611
|
2976 (set-buffer rmail-buffer)
|
270
|
2977 (rmail-maybe-set-message-counters)
|
|
2978 (rmail-show-message (+ rmail-current-message n)))
|
|
2979
|
|
2980 (defun rmail-previous-message (n)
|
|
2981 "Show previous message whether deleted or not.
|
|
2982 With prefix arg N, moves backward N messages, or forward if N is negative."
|
|
2983 (interactive "p")
|
45144
|
2984 (rmail-next-message (- n)))
|
270
|
2985
|
|
2986 (defun rmail-next-undeleted-message (n)
|
|
2987 "Show following non-deleted message.
|
|
2988 With prefix arg N, moves forward N non-deleted messages,
|
4838
|
2989 or backward if N is negative.
|
|
2990
|
|
2991 Returns t if a new message is being shown, nil otherwise."
|
270
|
2992 (interactive "p")
|
37611
|
2993 (set-buffer rmail-buffer)
|
270
|
2994 (rmail-maybe-set-message-counters)
|
|
2995 (let ((lastwin rmail-current-message)
|
|
2996 (current rmail-current-message))
|
|
2997 (while (and (> n 0) (< current rmail-total-messages))
|
|
2998 (setq current (1+ current))
|
|
2999 (if (not (rmail-message-deleted-p current))
|
|
3000 (setq lastwin current n (1- n))))
|
|
3001 (while (and (< n 0) (> current 1))
|
|
3002 (setq current (1- current))
|
|
3003 (if (not (rmail-message-deleted-p current))
|
|
3004 (setq lastwin current n (1+ n))))
|
|
3005 (if (/= lastwin rmail-current-message)
|
4838
|
3006 (progn (rmail-show-message lastwin)
|
|
3007 t)
|
|
3008 (if (< n 0)
|
|
3009 (message "No previous nondeleted message"))
|
|
3010 (if (> n 0)
|
|
3011 (message "No following nondeleted message"))
|
|
3012 nil)))
|
270
|
3013
|
|
3014 (defun rmail-previous-undeleted-message (n)
|
|
3015 "Show previous non-deleted message.
|
|
3016 With prefix argument N, moves backward N non-deleted messages,
|
|
3017 or forward if N is negative."
|
|
3018 (interactive "p")
|
|
3019 (rmail-next-undeleted-message (- n)))
|
|
3020
|
|
3021 (defun rmail-first-message ()
|
|
3022 "Show first message in file."
|
|
3023 (interactive)
|
|
3024 (rmail-maybe-set-message-counters)
|
|
3025 (rmail-show-message 1))
|
|
3026
|
|
3027 (defun rmail-last-message ()
|
|
3028 "Show last message in file."
|
|
3029 (interactive)
|
|
3030 (rmail-maybe-set-message-counters)
|
|
3031 (rmail-show-message rmail-total-messages))
|
|
3032
|
|
3033 (defun rmail-what-message ()
|
|
3034 (let ((where (point))
|
|
3035 (low 1)
|
|
3036 (high rmail-total-messages)
|
|
3037 (mid (/ rmail-total-messages 2)))
|
|
3038 (while (> (- high low) 1)
|
|
3039 (if (>= where (rmail-msgbeg mid))
|
|
3040 (setq low mid)
|
|
3041 (setq high mid))
|
|
3042 (setq mid (+ low (/ (- high low) 2))))
|
|
3043 (if (>= where (rmail-msgbeg high)) high low)))
|
|
3044
|
2076
|
3045 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
|
|
3046 (save-restriction
|
|
3047 (goto-char (rmail-msgbeg msg))
|
21640
|
3048 (search-forward "\n*** EOOH ***\n")
|
2076
|
3049 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
|
|
3050 (or (string-match recipients (or (mail-fetch-field "To") ""))
|
|
3051 (string-match recipients (or (mail-fetch-field "From") ""))
|
|
3052 (if (not primary-only)
|
|
3053 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
|
|
3054
|
37494
|
3055 (defun rmail-message-regexp-p (n regexp)
|
|
3056 "Return t, if for message number N, regexp REGEXP matches in the header."
|
|
3057 (let ((beg (rmail-msgbeg n))
|
|
3058 (end (rmail-msgend n)))
|
|
3059 (goto-char beg)
|
|
3060 (forward-line 1)
|
|
3061 (save-excursion
|
|
3062 (save-restriction
|
|
3063 (if (prog1 (= (following-char) ?0)
|
|
3064 (forward-line 2)
|
|
3065 ;; If there's a Summary-line in the (otherwise empty)
|
|
3066 ;; header, we didn't yet get past the EOOH line.
|
37517
|
3067 (when (looking-at "^\\*\\*\\* EOOH \\*\\*\\*\n")
|
|
3068 (forward-line 1))
|
37500
|
3069 (setq beg (point))
|
37494
|
3070 (narrow-to-region (point) end))
|
45144
|
3071 (progn
|
37517
|
3072 (rfc822-goto-eoh)
|
|
3073 (setq end (point)))
|
37500
|
3074 (setq beg (point))
|
37517
|
3075 (search-forward "\n*** EOOH ***\n" end t)
|
|
3076 (setq end (1+ (match-beginning 0)))))
|
37500
|
3077 (goto-char beg)
|
37611
|
3078 (if rmail-enable-mime
|
|
3079 (funcall rmail-search-mime-header-function n regexp end)
|
|
3080 (re-search-forward regexp end t)))))
|
|
3081
|
|
3082 (defun rmail-search-message (msg regexp)
|
|
3083 "Return non-nil, if for message number MSG, regexp REGEXP matches."
|
|
3084 (goto-char (rmail-msgbeg msg))
|
|
3085 (if rmail-enable-mime
|
|
3086 (funcall rmail-search-mime-message-function msg regexp)
|
|
3087 (re-search-forward regexp (rmail-msgend msg) t)))
|
2076
|
3088
|
270
|
3089 (defvar rmail-search-last-regexp nil)
|
874
|
3090 (defun rmail-search (regexp &optional n)
|
13808
|
3091 "Show message containing next match for REGEXP (but not the current msg).
|
874
|
3092 Prefix argument gives repeat count; negative argument means search
|
|
3093 backwards (through earlier messages).
|
|
3094 Interactively, empty argument means use same regexp used last time."
|
270
|
3095 (interactive
|
|
3096 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
|
|
3097 (prompt
|
65680
|
3098 (concat (if reversep "Reverse " "") "Rmail search (regexp"))
|
270
|
3099 regexp)
|
65680
|
3100 (setq prompt
|
|
3101 (concat prompt
|
|
3102 (if rmail-search-last-regexp
|
|
3103 (concat ", default "
|
|
3104 rmail-search-last-regexp "): ")
|
|
3105 "): ")))
|
270
|
3106 (setq regexp (read-string prompt))
|
|
3107 (cond ((not (equal regexp ""))
|
|
3108 (setq rmail-search-last-regexp regexp))
|
|
3109 ((not rmail-search-last-regexp)
|
|
3110 (error "No previous Rmail search string")))
|
874
|
3111 (list rmail-search-last-regexp
|
|
3112 (prefix-numeric-value current-prefix-arg))))
|
|
3113 (or n (setq n 1))
|
270
|
3114 (message "%sRmail search for %s..."
|
937
|
3115 (if (< n 0) "Reverse " "")
|
270
|
3116 regexp)
|
37611
|
3117 (set-buffer rmail-buffer)
|
270
|
3118 (rmail-maybe-set-message-counters)
|
|
3119 (let ((omin (point-min))
|
|
3120 (omax (point-max))
|
|
3121 (opoint (point))
|
|
3122 win
|
874
|
3123 (reversep (< n 0))
|
270
|
3124 (msg rmail-current-message))
|
|
3125 (unwind-protect
|
|
3126 (progn
|
|
3127 (widen)
|
874
|
3128 (while (/= n 0)
|
|
3129 ;; Check messages one by one, advancing message number up or down
|
|
3130 ;; but searching forward through each message.
|
|
3131 (if reversep
|
|
3132 (while (and (null win) (> msg 1))
|
37611
|
3133 (setq msg (1- msg)
|
|
3134 win (rmail-search-message msg regexp)))
|
874
|
3135 (while (and (null win) (< msg rmail-total-messages))
|
37611
|
3136 (setq msg (1+ msg)
|
|
3137 win (rmail-search-message msg regexp))))
|
937
|
3138 (setq n (+ n (if reversep 1 -1)))))
|
270
|
3139 (if win
|
|
3140 (progn
|
37611
|
3141 (rmail-show-message msg)
|
|
3142 ;; Search forward (if this is a normal search) or backward
|
|
3143 ;; (if this is a reverse search) through this message to
|
|
3144 ;; position point. This search may fail because REGEXP
|
|
3145 ;; was found in the hidden portion of this message. In
|
|
3146 ;; that case, move point to the beginning of visible
|
|
3147 ;; portion.
|
270
|
3148 (if reversep
|
|
3149 (progn
|
37611
|
3150 (goto-char (point-max))
|
|
3151 (re-search-backward regexp nil 'move))
|
|
3152 (goto-char (point-min))
|
|
3153 (re-search-forward regexp nil t))
|
270
|
3154 (message "%sRmail search for %s...done"
|
|
3155 (if reversep "Reverse " "")
|
37611
|
3156 regexp))
|
270
|
3157 (goto-char opoint)
|
|
3158 (narrow-to-region omin omax)
|
|
3159 (ding)
|
|
3160 (message "Search failed: %s" regexp)))))
|
|
3161
|
874
|
3162 (defun rmail-search-backwards (regexp &optional n)
|
|
3163 "Show message containing previous match for REGEXP.
|
|
3164 Prefix argument gives repeat count; negative argument means search
|
|
3165 forward (through later messages).
|
|
3166 Interactively, empty argument means use same regexp used last time."
|
|
3167 (interactive
|
937
|
3168 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
|
874
|
3169 (prompt
|
65680
|
3170 (concat (if reversep "Reverse " "") "Rmail search (regexp"))
|
874
|
3171 regexp)
|
65680
|
3172 (setq prompt
|
|
3173 (concat prompt
|
|
3174 (if rmail-search-last-regexp
|
|
3175 (concat ", default "
|
|
3176 rmail-search-last-regexp "): ")
|
|
3177 "): ")))
|
874
|
3178 (setq regexp (read-string prompt))
|
|
3179 (cond ((not (equal regexp ""))
|
|
3180 (setq rmail-search-last-regexp regexp))
|
|
3181 ((not rmail-search-last-regexp)
|
|
3182 (error "No previous Rmail search string")))
|
|
3183 (list rmail-search-last-regexp
|
|
3184 (prefix-numeric-value current-prefix-arg))))
|
12198
|
3185 (rmail-search regexp (- (or n 1))))
|
874
|
3186
|
270
|
3187 ;; Show the first message which has the `unseen' attribute.
|
|
3188 (defun rmail-first-unseen-message ()
|
1360
|
3189 (rmail-maybe-set-message-counters)
|
270
|
3190 (let ((current 1)
|
|
3191 found)
|
|
3192 (save-restriction
|
|
3193 (widen)
|
10191
|
3194 (while (and (not found) (<= current rmail-total-messages))
|
270
|
3195 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
|
346
|
3196 (setq found current))
|
|
3197 (setq current (1+ current))))
|
1342
|
3198 ;; Let the caller show the message.
|
|
3199 ;; (if found
|
|
3200 ;; (rmail-show-message found))
|
|
3201 found))
|
10662
|
3202
|
68091
|
3203 (defun rmail-current-subject ()
|
|
3204 "Return the current subject.
|
|
3205 The subject is stripped of leading and trailing whitespace, and
|
|
3206 of typical reply prefixes such as Re:."
|
|
3207 (let ((subject (or (mail-fetch-field "Subject") "")))
|
21100
|
3208 (if (string-match "\\`[ \t]+" subject)
|
|
3209 (setq subject (substring subject (match-end 0))))
|
68091
|
3210 (if (string-match rmail-reply-regexp subject)
|
15746
|
3211 (setq subject (substring subject (match-end 0))))
|
21100
|
3212 (if (string-match "[ \t]+\\'" subject)
|
|
3213 (setq subject (substring subject 0 (match-beginning 0))))
|
68091
|
3214 subject))
|
|
3215
|
|
3216 (defun rmail-current-subject-regexp ()
|
|
3217 "Return a regular expression matching the current subject.
|
|
3218 The regular expression matches the subject header line of
|
|
3219 messages about the same subject. The subject itself is stripped
|
|
3220 of leading and trailing whitespace, of typical reply prefixes
|
|
3221 such as Re: and whitespace within the subject is replaced by a
|
|
3222 regular expression matching whitespace in general in order to
|
|
3223 take into account that subject header lines may include newlines
|
|
3224 and more whitespace. The returned regular expressions contains
|
|
3225 `rmail-reply-regexp' and ends with a newline."
|
|
3226 (let ((subject (rmail-current-subject)))
|
67469
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3227 ;; If Subject is long, mailers will break it into several lines at
|
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3228 ;; arbitrary places, so replace whitespace with a regexp that will
|
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3229 ;; match any sequence of spaces, TABs, and newlines.
|
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3230 (setq subject (regexp-quote subject))
|
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3231 (setq subject
|
b845fff9455c
(rmail-next-same-subject): Handle multiple "Re: " strings and long subject
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3232 (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t))
|
68091
|
3233 (concat "^Subject: "
|
|
3234 (if (string= "\\`" (substring rmail-reply-regexp 0 2))
|
|
3235 (substring rmail-reply-regexp 2)
|
|
3236 rmail-reply-regexp)
|
|
3237 subject "[ \t]*\n")))
|
|
3238
|
|
3239 (defun rmail-next-same-subject (n)
|
|
3240 "Go to the next mail message having the same subject header.
|
|
3241 With prefix argument N, do this N times.
|
|
3242 If N is negative, go backwards instead."
|
|
3243 (interactive "p")
|
|
3244 (let ((search-regexp (rmail-current-subject-regexp))
|
|
3245 (forward (> n 0))
|
|
3246 (i rmail-current-message)
|
|
3247 (case-fold-search t)
|
|
3248 found)
|
10662
|
3249 (save-excursion
|
|
3250 (save-restriction
|
|
3251 (widen)
|
|
3252 (while (and (/= n 0)
|
|
3253 (if forward
|
|
3254 (< i rmail-total-messages)
|
|
3255 (> i 1)))
|
|
3256 (let (done)
|
|
3257 (while (and (not done)
|
|
3258 (if forward
|
|
3259 (< i rmail-total-messages)
|
|
3260 (> i 1)))
|
|
3261 (setq i (if forward (1+ i) (1- i)))
|
|
3262 (goto-char (rmail-msgbeg i))
|
|
3263 (search-forward "\n*** EOOH ***\n")
|
|
3264 (let ((beg (point)) end)
|
|
3265 (search-forward "\n\n")
|
|
3266 (setq end (point))
|
|
3267 (goto-char beg)
|
|
3268 (setq done (re-search-forward search-regexp end t))))
|
|
3269 (if done (setq found i)))
|
|
3270 (setq n (if forward (1- n) (1+ n))))))
|
|
3271 (if found
|
|
3272 (rmail-show-message found)
|
|
3273 (error "No %s message with same subject"
|
|
3274 (if forward "following" "previous")))))
|
|
3275
|
|
3276 (defun rmail-previous-same-subject (n)
|
|
3277 "Go to the previous mail message having the same subject header.
|
|
3278 With prefix argument N, do this N times.
|
|
3279 If N is negative, go forwards instead."
|
|
3280 (interactive "p")
|
|
3281 (rmail-next-same-subject (- n)))
|
270
|
3282
|
|
3283 ;;;; *** Rmail Message Deletion Commands ***
|
|
3284
|
|
3285 (defun rmail-message-deleted-p (n)
|
|
3286 (= (aref rmail-deleted-vector n) ?D))
|
|
3287
|
|
3288 (defun rmail-set-message-deleted-p (n state)
|
|
3289 (aset rmail-deleted-vector n (if state ?D ?\ )))
|
|
3290
|
|
3291 (defun rmail-delete-message ()
|
|
3292 "Delete this message and stay on it."
|
|
3293 (interactive)
|
13477
|
3294 (rmail-set-attribute "deleted" t)
|
|
3295 (run-hooks 'rmail-delete-message-hook))
|
270
|
3296
|
|
3297 (defun rmail-undelete-previous-message ()
|
|
3298 "Back up to deleted message, select it, and undelete it."
|
|
3299 (interactive)
|
37611
|
3300 (set-buffer rmail-buffer)
|
270
|
3301 (let ((msg rmail-current-message))
|
|
3302 (while (and (> msg 0)
|
|
3303 (not (rmail-message-deleted-p msg)))
|
|
3304 (setq msg (1- msg)))
|
|
3305 (if (= msg 0)
|
|
3306 (error "No previous deleted message")
|
|
3307 (if (/= msg rmail-current-message)
|
|
3308 (rmail-show-message msg))
|
2076
|
3309 (rmail-set-attribute "deleted" nil)
|
|
3310 (if (rmail-summary-exists)
|
|
3311 (save-excursion
|
|
3312 (set-buffer rmail-summary-buffer)
|
|
3313 (rmail-summary-mark-undeleted msg)))
|
|
3314 (rmail-maybe-display-summary))))
|
270
|
3315
|
|
3316 (defun rmail-delete-forward (&optional backward)
|
|
3317 "Delete this message and move to next nondeleted one.
|
|
3318 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
|
4838
|
3319 With prefix argument, delete and move backward.
|
|
3320
|
|
3321 Returns t if a new message is displayed after the delete, or nil otherwise."
|
270
|
3322 (interactive "P")
|
|
3323 (rmail-set-attribute "deleted" t)
|
13477
|
3324 (run-hooks 'rmail-delete-message-hook)
|
2076
|
3325 (let ((del-msg rmail-current-message))
|
|
3326 (if (rmail-summary-exists)
|
9394
|
3327 (rmail-select-summary
|
|
3328 (rmail-summary-mark-deleted del-msg)))
|
4838
|
3329 (prog1 (rmail-next-undeleted-message (if backward -1 1))
|
|
3330 (rmail-maybe-display-summary))))
|
270
|
3331
|
|
3332 (defun rmail-delete-backward ()
|
|
3333 "Delete this message and move to previous nondeleted one.
|
|
3334 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
|
|
3335 (interactive)
|
|
3336 (rmail-delete-forward t))
|
|
3337
|
9153
|
3338 ;; Compute the message number a given message would have after expunging.
|
|
3339 ;; The present number of the message is OLDNUM.
|
|
3340 ;; DELETEDVEC should be rmail-deleted-vector.
|
|
3341 ;; The value is nil for a message that would be deleted.
|
|
3342 (defun rmail-msg-number-after-expunge (deletedvec oldnum)
|
|
3343 (if (or (null oldnum) (= (aref deletedvec oldnum) ?D))
|
|
3344 nil
|
|
3345 (let ((i 0)
|
|
3346 (newnum 0))
|
|
3347 (while (< i oldnum)
|
|
3348 (if (/= (aref deletedvec i) ?D)
|
|
3349 (setq newnum (1+ newnum)))
|
|
3350 (setq i (1+ i)))
|
|
3351 newnum)))
|
|
3352
|
34185
|
3353 (defun rmail-expunge-confirmed ()
|
|
3354 "Return t if deleted message should be expunged. If necessary, ask the user.
|
|
3355 See also user-option `rmail-confirm-expunge'."
|
37611
|
3356 (set-buffer rmail-buffer)
|
34185
|
3357 (or (not (stringp rmail-deleted-vector))
|
|
3358 (not (string-match "D" rmail-deleted-vector))
|
|
3359 (null rmail-confirm-expunge)
|
|
3360 (funcall rmail-confirm-expunge
|
|
3361 "Erase deleted messages from Rmail file? ")))
|
|
3362
|
53598
|
3363 (defun rmail-only-expunge (&optional dont-show)
|
270
|
3364 "Actually erase all deleted messages in the file."
|
|
3365 (interactive)
|
37611
|
3366 (set-buffer rmail-buffer)
|
270
|
3367 (message "Expunging deleted messages...")
|
|
3368 ;; Discard all undo records for this buffer.
|
|
3369 (or (eq buffer-undo-list t)
|
|
3370 (setq buffer-undo-list nil))
|
|
3371 (rmail-maybe-set-message-counters)
|
|
3372 (let* ((omax (- (buffer-size) (point-max)))
|
|
3373 (omin (- (buffer-size) (point-min)))
|
|
3374 (opoint (if (and (> rmail-current-message 0)
|
7037
|
3375 (rmail-message-deleted-p rmail-current-message))
|
|
3376 0
|
37611
|
3377 (if rmail-enable-mime
|
|
3378 (with-current-buffer rmail-view-buffer
|
|
3379 (- (point)(point-min)))
|
|
3380 (- (point) (point-min)))))
|
270
|
3381 (messages-head (cons (aref rmail-message-vector 0) nil))
|
|
3382 (messages-tail messages-head)
|
|
3383 ;; Don't make any undo records for the expunging.
|
|
3384 (buffer-undo-list t)
|
|
3385 (win))
|
|
3386 (unwind-protect
|
|
3387 (save-excursion
|
|
3388 (widen)
|
|
3389 (goto-char (point-min))
|
|
3390 (let ((counter 0)
|
|
3391 (number 1)
|
|
3392 (total rmail-total-messages)
|
|
3393 (new-message-number rmail-current-message)
|
|
3394 (new-summary nil)
|
17620
|
3395 (new-msgref (list (list 0)))
|
9153
|
3396 (rmailbuf (current-buffer))
|
270
|
3397 (buffer-read-only nil)
|
|
3398 (messages rmail-message-vector)
|
|
3399 (deleted rmail-deleted-vector)
|
|
3400 (summary rmail-summary-vector))
|
|
3401 (setq rmail-total-messages nil
|
|
3402 rmail-current-message nil
|
|
3403 rmail-message-vector nil
|
|
3404 rmail-deleted-vector nil
|
|
3405 rmail-summary-vector nil)
|
9153
|
3406
|
270
|
3407 (while (<= number total)
|
|
3408 (if (= (aref deleted number) ?D)
|
|
3409 (progn
|
|
3410 (delete-region
|
|
3411 (marker-position (aref messages number))
|
|
3412 (marker-position (aref messages (1+ number))))
|
|
3413 (move-marker (aref messages number) nil)
|
|
3414 (if (> new-message-number counter)
|
|
3415 (setq new-message-number (1- new-message-number))))
|
|
3416 (setq counter (1+ counter))
|
|
3417 (setq messages-tail
|
|
3418 (setcdr messages-tail
|
|
3419 (cons (aref messages number) nil)))
|
|
3420 (setq new-summary
|
|
3421 (cons (if (= counter number) (aref summary (1- number)))
|
17620
|
3422 new-summary))
|
|
3423 (setq new-msgref
|
|
3424 (cons (aref rmail-msgref-vector number)
|
|
3425 new-msgref))
|
|
3426 (setcar (car new-msgref) counter))
|
270
|
3427 (if (zerop (% (setq number (1+ number)) 20))
|
|
3428 (message "Expunging deleted messages...%d" number)))
|
|
3429 (setq messages-tail
|
|
3430 (setcdr messages-tail
|
|
3431 (cons (aref messages number) nil)))
|
|
3432 (setq rmail-current-message new-message-number
|
|
3433 rmail-total-messages counter
|
|
3434 rmail-message-vector (apply 'vector messages-head)
|
|
3435 rmail-deleted-vector (make-string (1+ counter) ?\ )
|
|
3436 rmail-summary-vector (vconcat (nreverse new-summary))
|
17620
|
3437 rmail-msgref-vector (apply 'vector (nreverse new-msgref))
|
270
|
3438 win t)))
|
|
3439 (message "Expunging deleted messages...done")
|
|
3440 (if (not win)
|
|
3441 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
|
53598
|
3442 (if (not dont-show)
|
|
3443 (rmail-show-message
|
64177
|
3444 (if (zerop rmail-current-message) 1 nil)))
|
|
3445 (if rmail-enable-mime
|
|
3446 (goto-char (+ (point-min) opoint))
|
|
3447 (goto-char (+ (point) opoint))))))
|
2076
|
3448
|
|
3449 (defun rmail-expunge ()
|
|
3450 "Erase deleted messages from Rmail file and summary buffer."
|
|
3451 (interactive)
|
34185
|
3452 (when (rmail-expunge-confirmed)
|
28290
|
3453 (rmail-only-expunge)
|
|
3454 (if (rmail-summary-exists)
|
34185
|
3455 (rmail-select-summary (rmail-update-summary)))))
|
270
|
3456
|
|
3457 ;;;; *** Rmail Mailing Commands ***
|
|
3458
|
16633
|
3459 (defun rmail-start-mail (&optional noerase to subject in-reply-to cc
|
|
3460 replybuffer sendactions same-window others)
|
|
3461 (let (yank-action)
|
|
3462 (if replybuffer
|
|
3463 (setq yank-action (list 'insert-buffer replybuffer)))
|
|
3464 (setq others (cons (cons "cc" cc) others))
|
|
3465 (setq others (cons (cons "in-reply-to" in-reply-to) others))
|
|
3466 (if same-window
|
|
3467 (compose-mail to subject others
|
|
3468 noerase nil
|
|
3469 yank-action sendactions)
|
55114
|
3470 (if rmail-mail-new-frame
|
16633
|
3471 (prog1
|
|
3472 (compose-mail to subject others
|
|
3473 noerase 'switch-to-buffer-other-frame
|
|
3474 yank-action sendactions)
|
|
3475 ;; This is not a standard frame parameter;
|
|
3476 ;; nothing except sendmail.el looks at it.
|
|
3477 (modify-frame-parameters (selected-frame)
|
|
3478 '((mail-dedicated-frame . t))))
|
|
3479 (compose-mail to subject others
|
|
3480 noerase 'switch-to-buffer-other-window
|
|
3481 yank-action sendactions)))))
|
4108
|
3482
|
270
|
3483 (defun rmail-mail ()
|
2076
|
3484 "Send mail in another window.
|
|
3485 While composing the message, use \\[mail-yank-original] to yank the
|
|
3486 original message into it."
|
270
|
3487 (interactive)
|
17093
|
3488 (rmail-start-mail nil nil nil nil nil rmail-view-buffer))
|
270
|
3489
|
|
3490 (defun rmail-continue ()
|
|
3491 "Continue composing outgoing message previously being composed."
|
|
3492 (interactive)
|
4108
|
3493 (rmail-start-mail t))
|
270
|
3494
|
|
3495 (defun rmail-reply (just-sender)
|
|
3496 "Reply to the current message.
|
|
3497 Normally include CC: to all other recipients of original message;
|
|
3498 prefix argument means ignore them. While composing the reply,
|
|
3499 use \\[mail-yank-original] to yank the original message into it."
|
|
3500 (interactive "P")
|
16953
|
3501 (let (from reply-to cc subject date to message-id references
|
16467
|
3502 resent-to resent-cc resent-reply-to
|
17093
|
3503 (msgnum rmail-current-message))
|
270
|
3504 (save-excursion
|
|
3505 (save-restriction
|
38305
|
3506 (if rmail-enable-mime
|
|
3507 (narrow-to-region
|
|
3508 (goto-char (point-min))
|
|
3509 (if (search-forward "\n\n" nil 'move)
|
|
3510 (1+ (match-beginning 0))
|
|
3511 (point)))
|
37611
|
3512 (widen)
|
|
3513 (goto-char (rmail-msgbeg rmail-current-message))
|
|
3514 (forward-line 1)
|
|
3515 (if (= (following-char) ?0)
|
|
3516 (narrow-to-region
|
|
3517 (progn (forward-line 2)
|
|
3518 (point))
|
|
3519 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
|
|
3520 'move)
|
|
3521 (point)))
|
|
3522 (narrow-to-region (point)
|
|
3523 (progn (search-forward "\n*** EOOH ***\n")
|
|
3524 (beginning-of-line) (point)))))
|
16467
|
3525 (setq from (mail-fetch-field "from")
|
64972
|
3526 reply-to (or (mail-fetch-field "mail-reply-to" nil t)
|
60692
|
3527 (mail-fetch-field "reply-to" nil t)
|
270
|
3528 from)
|
16467
|
3529 subject (mail-fetch-field "subject")
|
|
3530 date (mail-fetch-field "date")
|
|
3531 message-id (mail-fetch-field "message-id")
|
16953
|
3532 references (mail-fetch-field "references" nil nil t)
|
|
3533 resent-reply-to (mail-fetch-field "resent-reply-to" nil t)
|
16467
|
3534 resent-cc (and (not just-sender)
|
|
3535 (mail-fetch-field "resent-cc" nil t))
|
|
3536 resent-to (or (mail-fetch-field "resent-to" nil t) "")
|
|
3537 ;;; resent-subject (mail-fetch-field "resent-subject")
|
|
3538 ;;; resent-date (mail-fetch-field "resent-date")
|
|
3539 ;;; resent-message-id (mail-fetch-field "resent-message-id")
|
64972
|
3540 )
|
|
3541 (unless just-sender
|
|
3542 (if (mail-fetch-field "mail-followup-to" nil t)
|
|
3543 ;; If this header field is present, use it instead of the To and CC fields.
|
|
3544 (setq to (mail-fetch-field "mail-followup-to" nil t))
|
|
3545 (setq cc (or (mail-fetch-field "cc" nil t) "")
|
|
3546 to (or (mail-fetch-field "to" nil t) ""))))
|
|
3547
|
|
3548 ))
|
|
3549
|
16467
|
3550 ;; Merge the resent-to and resent-cc into the to and cc.
|
|
3551 (if (and resent-to (not (equal resent-to "")))
|
|
3552 (if (not (equal to ""))
|
|
3553 (setq to (concat to ", " resent-to))
|
|
3554 (setq to resent-to)))
|
|
3555 (if (and resent-cc (not (equal resent-cc "")))
|
|
3556 (if (not (equal cc ""))
|
|
3557 (setq cc (concat cc ", " resent-cc))
|
|
3558 (setq cc resent-cc)))
|
|
3559 ;; Add `Re: ' to subject if not there already.
|
2076
|
3560 (and (stringp subject)
|
10640
|
3561 (setq subject
|
|
3562 (concat rmail-reply-prefix
|
17065
|
3563 (if (let ((case-fold-search t))
|
|
3564 (string-match rmail-reply-regexp subject))
|
10640
|
3565 (substring subject (match-end 0))
|
|
3566 subject))))
|
18091
|
3567 (rmail-start-mail
|
|
3568 nil
|
|
3569 ;; Using mail-strip-quoted-names is undesirable with newer mailers
|
|
3570 ;; since they can handle the names unstripped.
|
|
3571 ;; I don't know whether there are other mailers that still
|
|
3572 ;; need the names to be stripped.
|
49008
|
3573 ;;; (mail-strip-quoted-names reply-to)
|
62587
bb278282ddbc
(rmail-reply): Filter the list in reply-to through rmail-dont-reply-to.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3574 ;; Remove unwanted names from reply-to, since Mail-Followup-To
|
bb278282ddbc
(rmail-reply): Filter the list in reply-to through rmail-dont-reply-to.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3575 ;; header causes all the names in it to wind up in reply-to, not
|
bb278282ddbc
(rmail-reply): Filter the list in reply-to through rmail-dont-reply-to.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3576 ;; in cc. But if what's left is an empty list, use the original.
|
bb278282ddbc
(rmail-reply): Filter the list in reply-to through rmail-dont-reply-to.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3577 (let* ((reply-to-list (rmail-dont-reply-to reply-to)))
|
bb278282ddbc
(rmail-reply): Filter the list in reply-to through rmail-dont-reply-to.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
3578 (if (string= reply-to-list "") reply-to reply-to-list))
|
18091
|
3579 subject
|
|
3580 (rmail-make-in-reply-to-field from date message-id)
|
|
3581 (if just-sender
|
|
3582 nil
|
|
3583 ;; mail-strip-quoted-names is NOT necessary for rmail-dont-reply-to
|
|
3584 ;; to do its job.
|
|
3585 (let* ((cc-list (rmail-dont-reply-to
|
|
3586 (mail-strip-quoted-names
|
|
3587 (if (null cc) to (concat to ", " cc))))))
|
|
3588 (if (string= cc-list "") nil cc-list)))
|
|
3589 rmail-view-buffer
|
|
3590 (list (list 'rmail-mark-message
|
37611
|
3591 rmail-buffer
|
|
3592 (with-current-buffer rmail-buffer
|
|
3593 (aref rmail-msgref-vector msgnum))
|
18091
|
3594 "answered"))
|
|
3595 nil
|
|
3596 (list (cons "References" (concat (mapconcat 'identity references " ")
|
|
3597 " " message-id))))))
|
17565
|
3598
|
17620
|
3599 (defun rmail-mark-message (buffer msgnum-list attribute)
|
|
3600 "Give BUFFER's message number in MSGNUM-LIST the attribute ATTRIBUTE.
|
|
3601 This is use in the send-actions for message buffers.
|
|
3602 MSGNUM-LIST is a list of the form (MSGNUM)
|
|
3603 which is an element of rmail-msgref-vector."
|
17565
|
3604 (save-excursion
|
|
3605 (set-buffer buffer)
|
17620
|
3606 (if (car msgnum-list)
|
|
3607 (rmail-set-attribute attribute t (car msgnum-list)))))
|
270
|
3608
|
|
3609 (defun rmail-make-in-reply-to-field (from date message-id)
|
|
3610 (cond ((not from)
|
|
3611 (if message-id
|
|
3612 message-id
|
|
3613 nil))
|
|
3614 (mail-use-rfc822
|
|
3615 (require 'rfc822)
|
|
3616 (let ((tem (car (rfc822-addresses from))))
|
|
3617 (if message-id
|
19315
|
3618 (if (or (not tem)
|
|
3619 (string-match
|
|
3620 (regexp-quote (if (string-match "@[^@]*\\'" tem)
|
|
3621 (substring tem 0
|
|
3622 (match-beginning 0))
|
|
3623 tem))
|
|
3624 message-id))
|
|
3625 ;; missing From, or Message-ID is sufficiently informative
|
270
|
3626 message-id
|
|
3627 (concat message-id " (" tem ")"))
|
5692
|
3628 ;; Copy TEM, discarding text properties.
|
|
3629 (setq tem (copy-sequence tem))
|
|
3630 (set-text-properties 0 (length tem) nil tem)
|
|
3631 (setq tem (copy-sequence tem))
|
|
3632 ;; Use prin1 to fake RFC822 quoting
|
|
3633 (let ((field (prin1-to-string tem)))
|
|
3634 (if date
|
|
3635 (concat field "'s message of " date)
|
|
3636 field)))))
|
20681
|
3637 ((let* ((foo "[^][\000-\037()<>@,;:\\\" ]+")
|
|
3638 (bar "[^][\000-\037()<>@,;:\\\"]+"))
|
|
3639 ;; These strings both match all non-ASCII characters.
|
270
|
3640 (or (string-match (concat "\\`[ \t]*\\(" bar
|
|
3641 "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
|
|
3642 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
|
|
3643 from)
|
|
3644 (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
|
|
3645 bar "\\))[ \t]*\\'")
|
|
3646 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
|
|
3647 from)))
|
|
3648 (let ((start (match-beginning 1))
|
|
3649 (end (match-end 1)))
|
|
3650 ;; Trim whitespace which above regexp match allows
|
|
3651 (while (and (< start end)
|
|
3652 (memq (aref from start) '(?\t ?\ )))
|
|
3653 (setq start (1+ start)))
|
|
3654 (while (and (< start end)
|
|
3655 (memq (aref from (1- end)) '(?\t ?\ )))
|
|
3656 (setq end (1- end)))
|
|
3657 (let ((field (substring from start end)))
|
|
3658 (if date (setq field (concat "message from " field " on " date)))
|
|
3659 (if message-id
|
|
3660 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
|
|
3661 (concat message-id " (" field ")")
|
|
3662 field))))
|
|
3663 (t
|
|
3664 ;; If we can't kludge it simply, do it correctly
|
|
3665 (let ((mail-use-rfc822 t))
|
|
3666 (rmail-make-in-reply-to-field from date message-id)))))
|
10970
|
3667
|
2687
|
3668 (defun rmail-forward (resend)
|
|
3669 "Forward the current message to another user.
|
|
3670 With prefix argument, \"resend\" the message instead of forwarding it;
|
|
3671 see the documentation of `rmail-resend'."
|
|
3672 (interactive "P")
|
|
3673 (if resend
|
|
3674 (call-interactively 'rmail-resend)
|
37611
|
3675 (let ((forward-buffer rmail-buffer)
|
9153
|
3676 (msgnum rmail-current-message)
|
2687
|
3677 (subject (concat "["
|
|
3678 (let ((from (or (mail-fetch-field "From")
|
|
3679 (mail-fetch-field ">From"))))
|
|
3680 (if from
|
|
3681 (concat (mail-strip-quoted-names from) ": ")
|
|
3682 ""))
|
|
3683 (or (mail-fetch-field "Subject") "")
|
|
3684 "]")))
|
16633
|
3685 (if (rmail-start-mail
|
|
3686 nil nil subject nil nil nil
|
17565
|
3687 (list (list 'rmail-mark-message
|
17620
|
3688 forward-buffer
|
37611
|
3689 (with-current-buffer rmail-buffer
|
|
3690 (aref rmail-msgref-vector msgnum))
|
17565
|
3691 "forwarded"))
|
16633
|
3692 ;; If only one window, use it for the mail buffer.
|
|
3693 ;; Otherwise, use another window for the mail buffer
|
|
3694 ;; so that the Rmail buffer remains visible
|
|
3695 ;; and sending the mail will get back to it.
|
|
3696 (and (not rmail-mail-new-frame) (one-window-p t)))
|
9153
|
3697 ;; The mail buffer is now current.
|
4263
|
3698 (save-excursion
|
4724
04714985ce20
(rmail-forward): Insert the text right after the header separator.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3699 ;; Insert after header separator--before signature if any.
|
21864
|
3700 (goto-char (mail-text-start))
|
41511
|
3701 (if (or rmail-enable-mime rmail-enable-mime-composing)
|
37611
|
3702 (funcall rmail-insert-mime-forwarded-message-function
|
|
3703 forward-buffer)
|
|
3704 (insert "------- Start of forwarded message -------\n")
|
|
3705 ;; Quote lines with `- ' if they start with `-'.
|
|
3706 (let ((beg (point)) end)
|
|
3707 (setq end (point-marker))
|
|
3708 (set-marker-insertion-type end t)
|
|
3709 (insert-buffer-substring forward-buffer)
|
|
3710 (goto-char beg)
|
|
3711 (while (re-search-forward "^-" end t)
|
|
3712 (beginning-of-line)
|
|
3713 (insert "- ")
|
|
3714 (forward-line 1))
|
|
3715 (goto-char end)
|
|
3716 (skip-chars-backward "\n")
|
|
3717 (if (< (point) end)
|
|
3718 (forward-char 1))
|
|
3719 (delete-region (point) end)
|
|
3720 (set-marker end nil))
|
|
3721 (insert "------- End of forwarded message -------\n"))
|
9153
|
3722 (push-mark))))))
|
10970
|
3723
|
270
|
3724 (defun rmail-resend (address &optional from comment mail-alias-file)
|
|
3725 "Resend current message to ADDRESSES.
|
5274
|
3726 ADDRESSES should be a single address, a string consisting of several
|
270
|
3727 addresses separated by commas, or a list of addresses.
|
|
3728
|
|
3729 Optional FROM is the address to resend the message from, and
|
19031
|
3730 defaults from the value of `user-mail-address'.
|
|
3731 Optional COMMENT is a string to insert as a comment in the resent message.
|
270
|
3732 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
|
|
3733 typically for purposes of moderating a list."
|
|
3734 (interactive "sResend to: ")
|
3484
|
3735 (require 'sendmail)
|
|
3736 (require 'mailalias)
|
37956
|
3737 (unless (or (eq rmail-view-buffer (current-buffer))
|
|
3738 (eq rmail-buffer (current-buffer)))
|
27871
|
3739 (error "Not an Rmail buffer"))
|
19031
|
3740 (if (not from) (setq from user-mail-address))
|
270
|
3741 (let ((tembuf (generate-new-buffer " sendmail temp"))
|
|
3742 (case-fold-search nil)
|
59118
a3caa12a673a
(rmail-resend): Let MAIL-ALIAS-FILE arg override mail-personal-alias-file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3743 (mail-personal-alias-file
|
a3caa12a673a
(rmail-resend): Let MAIL-ALIAS-FILE arg override mail-personal-alias-file.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3744 (or mail-alias-file mail-personal-alias-file))
|
23298
|
3745 (mailbuf rmail-buffer))
|
270
|
3746 (unwind-protect
|
23298
|
3747 (with-current-buffer tembuf
|
270
|
3748 ;;>> Copy message into temp buffer
|
37956
|
3749 (if rmail-enable-mime
|
|
3750 (funcall rmail-insert-mime-resent-message-function mailbuf)
|
|
3751 (insert-buffer-substring mailbuf))
|
270
|
3752 (goto-char (point-min))
|
14033
|
3753 ;; Delete any Sender field, since that's not specifiable.
|
5274
|
3754 ; Only delete Sender fields in the actual header.
|
|
3755 (re-search-forward "^$" nil 'move)
|
|
3756 ; Using "while" here rather than "if" because some buggy mail
|
|
3757 ; software may have inserted multiple Sender fields.
|
|
3758 (while (re-search-backward "^Sender:" nil t)
|
|
3759 (let (beg)
|
|
3760 (setq beg (point))
|
|
3761 (forward-line 1)
|
|
3762 (while (looking-at "[ \t]")
|
|
3763 (forward-line 1))
|
|
3764 (delete-region beg (point))))
|
|
3765 ; Go back to the beginning of the buffer so the Resent- fields
|
|
3766 ; are inserted there.
|
|
3767 (goto-char (point-min))
|
270
|
3768 ;;>> Insert resent-from:
|
|
3769 (insert "Resent-From: " from "\n")
|
4020
|
3770 (insert "Resent-Date: " (mail-rfc822-date) "\n")
|
270
|
3771 ;;>> Insert resent-to: and bcc if need be.
|
|
3772 (let ((before (point)))
|
4838
|
3773 (if mail-self-blind
|
|
3774 (insert "Resent-Bcc: " (user-login-name) "\n"))
|
270
|
3775 (insert "Resent-To: " (if (stringp address)
|
|
3776 address
|
|
3777 (mapconcat 'identity address ",\n\t"))
|
|
3778 "\n")
|
11452
|
3779 ;; Expand abbrevs in the recipients.
|
8545
|
3780 (save-excursion
|
11452
|
3781 (if (featurep 'mailabbrev)
|
11533
|
3782 (let ((end (point-marker))
|
|
3783 (local-abbrev-table mail-abbrevs)
|
|
3784 (old-syntax-table (syntax-table)))
|
|
3785 (if (and (not (vectorp mail-abbrevs))
|
|
3786 (file-exists-p mail-personal-alias-file))
|
|
3787 (build-mail-abbrevs))
|
44141
|
3788 (unless mail-abbrev-syntax-table
|
|
3789 (mail-abbrev-make-syntax-table))
|
11533
|
3790 (set-syntax-table mail-abbrev-syntax-table)
|
|
3791 (goto-char before)
|
|
3792 (while (and (< (point) end)
|
|
3793 (progn (forward-word 1)
|
|
3794 (<= (point) end)))
|
|
3795 (expand-abbrev))
|
|
3796 (set-syntax-table old-syntax-table))
|
11452
|
3797 (expand-mail-aliases before (point)))))
|
270
|
3798 ;;>> Set up comment, if any.
|
|
3799 (if (and (sequencep comment) (not (zerop (length comment))))
|
|
3800 (let ((before (point))
|
|
3801 after)
|
|
3802 (insert comment)
|
|
3803 (or (eolp) (insert "\n"))
|
|
3804 (setq after (point))
|
|
3805 (goto-char before)
|
|
3806 (while (< (point) after)
|
|
3807 (insert "Resent-Comment: ")
|
|
3808 (forward-line 1))))
|
|
3809 ;; Don't expand aliases in the destination fields
|
|
3810 ;; of the original message.
|
|
3811 (let (mail-aliases)
|
5470
|
3812 (funcall send-mail-function)))
|
2687
|
3813 (kill-buffer tembuf))
|
23298
|
3814 (with-current-buffer rmail-buffer
|
|
3815 (rmail-set-attribute "resent" t rmail-current-message))))
|
10970
|
3816
|
1267
|
3817 (defvar mail-unsent-separator
|
1370
c017b62c8073
(mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3818 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
|
c017b62c8073
(mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3819 "^ *---+ +Returned message +---+ *$\\|"
|
22158
|
3820 "^ *---+ *Returned mail follows *---+ *$\\|"
|
10815
|
3821 "^Start of returned message$\\|"
|
22610
|
3822 "^---+ Below this line is a copy of the message.$\\|"
|
1372
|
3823 "^ *---+ +Original message +---+ *$\\|"
|
1757
|
3824 "^ *--+ +begin message +--+ *$\\|"
|
4838
|
3825 "^ *---+ +Original message follows +---+ *$\\|"
|
20984
|
3826 "^ *---+ +Your message follows +---+ *$\\|"
|
24929
|
3827 "^|? *---+ +Message text follows: +---+ *|?$\\|"
|
30100
|
3828 "^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *$")
|
8572
|
3829 "A regexp that matches the separator before the text of a failed message.")
|
270
|
3830
|
17197
|
3831 (defvar mail-mime-unsent-header "^Content-Type: message/rfc822 *$"
|
|
3832 "A regexp that matches the header of a MIME body part with a failed message.")
|
|
3833
|
270
|
3834 (defun rmail-retry-failure ()
|
|
3835 "Edit a mail message which is based on the contents of the current message.
|
|
3836 For a message rejected by the mail system, extract the interesting headers and
|
8572
|
3837 the body of the original message.
|
17197
|
3838 If the failed message is a MIME multipart message, it is searched for a
|
|
3839 body part with a header which matches the variable `mail-mime-unsent-header'.
|
|
3840 Otherwise, the variable `mail-unsent-separator' should match the string that
|
9010
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3841 delimits the returned original message.
|
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3842 The variable `rmail-retry-ignored-headers' is a regular expression
|
9d48b6752dbf
(rmail-retry-failure): Copy the whole block of headers from the message
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3843 specifying headers which should not be copied into the new message."
|
270
|
3844 (interactive)
|
|
3845 (require 'mail-utils)
|
17821
|
3846 (let ((rmail-this-buffer (current-buffer))
|
13808
|
3847 (msgnum rmail-current-message)
|
38228
|
3848 bounce-start bounce-end bounce-indent resending
|
|
3849 ;; Fetch any content-type header in current message
|
|
3850 ;; Must search thru the whole unpruned header.
|
|
3851 (content-type
|
|
3852 (save-excursion
|
|
3853 (save-restriction
|
|
3854 (rmail-narrow-to-non-pruned-header)
|
|
3855 (mail-fetch-field "Content-Type") ))))
|
|
3856 (save-excursion
|
|
3857 (goto-char (point-min))
|
|
3858 (let ((case-fold-search t))
|
45144
|
3859 (if (and content-type
|
|
3860 (string-match
|
|
3861 ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=? ]+\\)\"?"
|
38228
|
3862 content-type))
|
|
3863 ;; Handle a MIME multipart bounce message.
|
|
3864 (let ((codestring
|
|
3865 (concat "\n--"
|
45144
|
3866 (substring content-type (match-beginning 1)
|
38228
|
3867 (match-end 1)))))
|
|
3868 (unless (re-search-forward mail-mime-unsent-header nil t)
|
|
3869 (error "Cannot find beginning of header in failed message"))
|
|
3870 (unless (search-forward "\n\n" nil t)
|
|
3871 (error "Cannot find start of Mime data in failed message"))
|
|
3872 (setq bounce-start (point))
|
|
3873 (if (search-forward codestring nil t)
|
|
3874 (setq bounce-end (match-beginning 0))
|
|
3875 (setq bounce-end (point-max))))
|
|
3876 ;; Non-MIME bounce.
|
|
3877 (or (re-search-forward mail-unsent-separator nil t)
|
|
3878 (error "Cannot parse this as a failure message"))
|
|
3879 (skip-chars-forward "\n")
|
|
3880 ;; Support a style of failure message in which the original
|
|
3881 ;; message is indented, and included within lines saying
|
|
3882 ;; `Start of returned message' and `End of returned message'.
|
|
3883 (if (looking-at " +Received:")
|
|
3884 (progn
|
|
3885 (setq bounce-start (point))
|
|
3886 (skip-chars-forward " ")
|
|
3887 (setq bounce-indent (- (current-column)))
|
|
3888 (goto-char (point-max))
|
|
3889 (re-search-backward "^End of returned message$" nil t)
|
|
3890 (setq bounce-end (point)))
|
|
3891 ;; One message contained a few random lines before
|
|
3892 ;; the old message header. The first line of the
|
|
3893 ;; message started with two hyphens. A blank line
|
|
3894 ;; followed these random lines. The same line
|
|
3895 ;; beginning with two hyphens was possibly marking
|
|
3896 ;; the end of the message.
|
|
3897 (if (looking-at "^--")
|
|
3898 (let ((boundary (buffer-substring-no-properties
|
|
3899 (point)
|
|
3900 (progn (end-of-line) (point)))))
|
|
3901 (search-forward "\n\n")
|
|
3902 (skip-chars-forward "\n")
|
|
3903 (setq bounce-start (point))
|
|
3904 (goto-char (point-max))
|
|
3905 (search-backward (concat "\n\n" boundary) bounce-start t)
|
|
3906 (setq bounce-end (point)))
|
|
3907 (setq bounce-start (point)
|
|
3908 bounce-end (point-max)))
|
|
3909 (unless (search-forward "\n\n" nil t)
|
|
3910 (error "Cannot find end of header in failed message"))))))
|
|
3911 ;; We have found the message that bounced, within the current message.
|
|
3912 ;; Now start sending new message; default header fields from original.
|
|
3913 ;; Turn off the usual actions for initializing the message body
|
|
3914 ;; because we want to get only the text from the failure message.
|
|
3915 (let (mail-signature mail-setup-hook)
|
|
3916 (if (rmail-start-mail nil nil nil nil nil rmail-this-buffer
|
|
3917 (list (list 'rmail-mark-message
|
|
3918 rmail-this-buffer
|
|
3919 (aref rmail-msgref-vector msgnum)
|
|
3920 "retried")))
|
|
3921 ;; Insert original text as initial text of new draft message.
|
|
3922 ;; Bind inhibit-read-only since the header delimiter
|
|
3923 ;; of the previous message was probably read-only.
|
|
3924 (let ((inhibit-read-only t)
|
|
3925 rmail-displayed-headers
|
|
3926 rmail-ignored-headers)
|
|
3927 (erase-buffer)
|
|
3928 (insert-buffer-substring rmail-this-buffer
|
|
3929 bounce-start bounce-end)
|
|
3930 (goto-char (point-min))
|
|
3931 (if bounce-indent
|
|
3932 (indent-rigidly (point-min) (point-max) bounce-indent))
|
|
3933 (rmail-clear-headers rmail-retry-ignored-headers)
|
|
3934 (rmail-clear-headers "^sender:\\|^return-path:\\|^received:")
|
|
3935 (mail-sendmail-delimit-header)
|
|
3936 (save-restriction
|
|
3937 (narrow-to-region (point-min) (mail-header-end))
|
|
3938 (setq resending (mail-fetch-field "resent-to"))
|
|
3939 (if mail-self-blind
|
|
3940 (if resending
|
|
3941 (insert "Resent-Bcc: " (user-login-name) "\n")
|
|
3942 (insert "BCC: " (user-login-name) "\n"))))
|
|
3943 (goto-char (point-min))
|
|
3944 (mail-position-on-field (if resending "Resent-To" "To") t))))))
|
10970
|
3945
|
2076
|
3946 (defun rmail-summary-exists ()
|
|
3947 "Non-nil iff in an RMAIL buffer and an associated summary buffer exists.
|
6408
|
3948 In fact, the non-nil value returned is the summary buffer itself."
|
2076
|
3949 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
|
|
3950 rmail-summary-buffer))
|
|
3951
|
|
3952 (defun rmail-summary-displayed ()
|
|
3953 "t iff in RMAIL buffer and an associated summary buffer is displayed."
|
|
3954 (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
|
|
3955
|
17630
|
3956 (defcustom rmail-redisplay-summary nil
|
2076
|
3957 "*Non-nil means Rmail should show the summary when it changes.
|
17630
|
3958 This has an effect only if a summary buffer exists."
|
|
3959 :type 'boolean
|
|
3960 :group 'rmail-summary)
|
2076
|
3961
|
17630
|
3962 (defcustom rmail-summary-window-size nil
|
|
3963 "*Non-nil means specify the height for an Rmail summary window."
|
20261
|
3964 :type '(choice (const :tag "Disabled" nil) integer)
|
17630
|
3965 :group 'rmail-summary)
|
6408
|
3966
|
2076
|
3967 ;; Put the summary buffer back on the screen, if user wants that.
|
|
3968 (defun rmail-maybe-display-summary ()
|
6408
|
3969 (let ((selected (selected-window))
|
|
3970 window)
|
|
3971 ;; If requested, make sure the summary is displayed.
|
|
3972 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
|
|
3973 rmail-redisplay-summary
|
8533
|
3974 (if (get-buffer-window rmail-summary-buffer 0)
|
|
3975 ;; It's already in some frame; show that one.
|
|
3976 (let ((frame (window-frame
|
|
3977 (get-buffer-window rmail-summary-buffer 0))))
|
|
3978 (make-frame-visible frame)
|
|
3979 (raise-frame frame))
|
|
3980 (display-buffer rmail-summary-buffer)))
|
6408
|
3981 ;; If requested, set the height of the summary window.
|
|
3982 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
|
|
3983 rmail-summary-window-size
|
|
3984 (setq window (get-buffer-window rmail-summary-buffer))
|
8533
|
3985 ;; Don't try to change the size if just one window in frame.
|
|
3986 (not (eq window (frame-root-window (window-frame window))))
|
45144
|
3987 (unwind-protect
|
6408
|
3988 (progn
|
|
3989 (select-window window)
|
14779
|
3990 (enlarge-window (- rmail-summary-window-size (window-height))))
|
6408
|
3991 (select-window selected)))))
|
270
|
3992
|
14374
|
3993 ;;;; *** Rmail Local Fontification ***
|
|
3994
|
|
3995 (defun rmail-fontify-buffer-function ()
|
|
3996 ;; This function's symbol is bound to font-lock-fontify-buffer-function.
|
14467
|
3997 (add-hook 'rmail-show-message-hook 'rmail-fontify-message nil t)
|
14779
|
3998 ;; If we're already showing a message, fontify it now.
|
|
3999 (if rmail-current-message (rmail-fontify-message))
|
|
4000 ;; Prevent Font Lock mode from kicking in.
|
14467
|
4001 (setq font-lock-fontified t))
|
14374
|
4002
|
|
4003 (defun rmail-unfontify-buffer-function ()
|
|
4004 ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
|
14467
|
4005 (let ((modified (buffer-modified-p))
|
|
4006 (buffer-undo-list t) (inhibit-read-only t)
|
|
4007 before-change-functions after-change-functions
|
|
4008 buffer-file-name buffer-file-truename)
|
|
4009 (save-restriction
|
|
4010 (widen)
|
|
4011 (remove-hook 'rmail-show-message-hook 'rmail-fontify-message t)
|
|
4012 (remove-text-properties (point-min) (point-max) '(rmail-fontified nil))
|
14898
|
4013 (font-lock-default-unfontify-buffer)
|
|
4014 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))
|
14374
|
4015
|
|
4016 (defun rmail-fontify-message ()
|
|
4017 ;; Fontify the current message if it is not already fontified.
|
|
4018 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil)
|
|
4019 (let ((modified (buffer-modified-p))
|
|
4020 (buffer-undo-list t) (inhibit-read-only t)
|
|
4021 before-change-functions after-change-functions
|
|
4022 buffer-file-name buffer-file-truename)
|
|
4023 (save-excursion
|
|
4024 (save-match-data
|
|
4025 (add-text-properties (point-min) (point-max) '(rmail-fontified t))
|
14898
|
4026 (font-lock-fontify-region (point-min) (point-max))
|
|
4027 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))))
|
22732
|
4028
|
20757
|
4029 ;;; Speedbar support for RMAIL files.
|
22732
|
4030 (eval-when-compile (require 'speedbar))
|
|
4031
|
|
4032 (defvar rmail-speedbar-match-folder-regexp "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"
|
47024
15430c8d0eaa
* startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
diff
changeset
|
4033 "*This regex is used to match folder names to be displayed in speedbar.
|
22732
|
4034 Enabling this will permit speedbar to display your folders for easy
|
|
4035 browsing, and moving of messages.")
|
20757
|
4036
|
|
4037 (defvar rmail-speedbar-last-user nil
|
|
4038 "The last user to be displayed in the speedbar.")
|
|
4039
|
22732
|
4040 (defvar rmail-speedbar-key-map nil
|
|
4041 "Keymap used when in rmail display mode.")
|
|
4042
|
|
4043 (defun rmail-install-speedbar-variables ()
|
|
4044 "Install those variables used by speedbar to enhance rmail."
|
|
4045 (if rmail-speedbar-key-map
|
|
4046 nil
|
|
4047 (setq rmail-speedbar-key-map (speedbar-make-specialized-keymap))
|
|
4048
|
|
4049 (define-key rmail-speedbar-key-map "e" 'speedbar-edit-line)
|
|
4050 (define-key rmail-speedbar-key-map "r" 'speedbar-edit-line)
|
|
4051 (define-key rmail-speedbar-key-map "\C-m" 'speedbar-edit-line)
|
|
4052 (define-key rmail-speedbar-key-map "M"
|
|
4053 'rmail-speedbar-move-message-to-folder-on-line)))
|
|
4054
|
20757
|
4055 (defvar rmail-speedbar-menu-items
|
22732
|
4056 '(["Read Folder" speedbar-edit-line t]
|
|
4057 ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line
|
20757
|
4058 (save-excursion (beginning-of-line)
|
|
4059 (looking-at "<M> "))])
|
|
4060 "Additional menu-items to add to speedbar frame.")
|
|
4061
|
22732
|
4062 ;; Make sure our special speedbar major mode is loaded
|
|
4063 (if (featurep 'speedbar)
|
|
4064 (rmail-install-speedbar-variables)
|
|
4065 (add-hook 'speedbar-load-hook 'rmail-install-speedbar-variables))
|
|
4066
|
20757
|
4067 (defun rmail-speedbar-buttons (buffer)
|
|
4068 "Create buttons for BUFFER containing rmail messages.
|
|
4069 Click on the address under Reply to: to reply to this person.
|
|
4070 Under Folders: Click a name to read it, or on the <M> to move the
|
|
4071 current message into that RMAIL folder."
|
|
4072 (let ((from nil))
|
|
4073 (save-excursion
|
|
4074 (set-buffer buffer)
|
|
4075 (goto-char (point-min))
|
|
4076 (if (not (re-search-forward "^Reply-To: " nil t))
|
|
4077 (if (not (re-search-forward "^From:? " nil t))
|
|
4078 (setq from t)))
|
|
4079 (if from
|
|
4080 nil
|
|
4081 (setq from (buffer-substring (point) (save-excursion
|
|
4082 (end-of-line)
|
|
4083 (point))))))
|
|
4084 (goto-char (point-min))
|
|
4085 (if (and (looking-at "Reply to:")
|
|
4086 (equal from rmail-speedbar-last-user))
|
|
4087 nil
|
|
4088 (setq rmail-speedbar-last-user from)
|
|
4089 (erase-buffer)
|
|
4090 (insert "Reply To:\n")
|
|
4091 (if (stringp from)
|
|
4092 (speedbar-insert-button from 'speedbar-directory-face 'highlight
|
|
4093 'rmail-speedbar-button 'rmail-reply))
|
|
4094 (insert "Folders:\n")
|
|
4095 (let* ((case-fold-search nil)
|
|
4096 (df (directory-files (save-excursion (set-buffer buffer)
|
|
4097 default-directory)
|
22732
|
4098 nil rmail-speedbar-match-folder-regexp)))
|
20757
|
4099 (while df
|
|
4100 (speedbar-insert-button "<M>" 'speedbar-button-face 'highlight
|
|
4101 'rmail-speedbar-move-message (car df))
|
|
4102 (speedbar-insert-button (car df) 'speedbar-file-face 'highlight
|
|
4103 'rmail-speedbar-find-file nil t)
|
|
4104 (setq df (cdr df)))))))
|
|
4105
|
|
4106 (defun rmail-speedbar-button (text token indent)
|
|
4107 "Execute an rmail command specified by TEXT.
|
|
4108 The command used is TOKEN. INDENT is not used."
|
|
4109 (speedbar-with-attached-buffer
|
|
4110 (funcall token t)))
|
|
4111
|
|
4112 (defun rmail-speedbar-find-file (text token indent)
|
|
4113 "Load in the rmail file TEXT.
|
|
4114 TOKEN and INDENT are not used."
|
|
4115 (speedbar-with-attached-buffer
|
|
4116 (message "Loading in RMAIL file %s..." text)
|
|
4117 (find-file text)))
|
|
4118
|
22732
|
4119 (defun rmail-speedbar-move-message-to-folder-on-line ()
|
20757
|
4120 "If the current line is a folder, move current message to it."
|
|
4121 (interactive)
|
|
4122 (save-excursion
|
|
4123 (beginning-of-line)
|
|
4124 (if (re-search-forward "<M> " (save-excursion (end-of-line) (point)) t)
|
|
4125 (progn
|
|
4126 (forward-char -2)
|
|
4127 (speedbar-do-function-pointer)))))
|
|
4128
|
|
4129 (defun rmail-speedbar-move-message (text token indent)
|
|
4130 "From button TEXT, copy current message to the rmail file specified by TOKEN.
|
|
4131 TEXT and INDENT are not used."
|
|
4132 (speedbar-with-attached-buffer
|
|
4133 (message "Moving message to %s" token)
|
|
4134 (rmail-output-to-rmail-file token)))
|
|
4135
|
22838
|
4136 ; Functions for setting, getting and encoding the POP password.
|
|
4137 ; The password is encoded to prevent it from being easily accessible
|
|
4138 ; to "prying eyes." Obviously, this encoding isn't "real security,"
|
|
4139 ; nor is it meant to be.
|
|
4140
|
|
4141 ;;;###autoload
|
59561
|
4142 (defun rmail-set-remote-password (password)
|
|
4143 "Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
|
22838
|
4144 (interactive "sPassword: ")
|
|
4145 (if password
|
59561
|
4146 (setq rmail-encoded-remote-password
|
22838
|
4147 (rmail-encode-string password (emacs-pid)))
|
59561
|
4148 (setq rmail-remote-password nil)
|
|
4149 (setq rmail-encoded-remote-password nil)))
|
|
4150
|
|
4151 (defun rmail-get-remote-password (imap)
|
|
4152 "Get the password for retrieving mail from a POP or IMAP server. If none
|
22838
|
4153 has been set, then prompt the user for one."
|
59561
|
4154 (when (not rmail-encoded-remote-password)
|
|
4155 (if (not rmail-remote-password)
|
|
4156 (setq rmail-remote-password
|
|
4157 (read-passwd (if imap
|
|
4158 "IMAP password: "
|
|
4159 "POP password: "))))
|
|
4160 (rmail-set-remote-password rmail-remote-password)
|
|
4161 (setq rmail-remote-password nil))
|
|
4162 (rmail-encode-string rmail-encoded-remote-password (emacs-pid)))
|
22838
|
4163
|
|
4164 (defun rmail-have-password ()
|
59561
|
4165 (or rmail-remote-password rmail-encoded-remote-password))
|
22838
|
4166
|
|
4167 (defun rmail-encode-string (string mask)
|
|
4168 "Encode STRING with integer MASK, by taking the exclusive OR of the
|
|
4169 lowest byte in the mask with the first character of string, the
|
|
4170 second-lowest-byte with the second character of the string, etc.,
|
|
4171 restarting at the lowest byte of the mask whenever it runs out.
|
|
4172 Returns the encoded string. Calling the function again with an
|
|
4173 encoded string (and the same mask) will decode the string."
|
23969
|
4174 (setq mask (abs mask)) ; doesn't work if negative
|
45144
|
4175 (let* ((string-vector (string-to-vector string)) (i 0)
|
22838
|
4176 (len (length string-vector)) (curmask mask) charmask)
|
|
4177 (while (< i len)
|
|
4178 (if (= curmask 0)
|
|
4179 (setq curmask mask))
|
|
4180 (setq charmask (% curmask 256))
|
|
4181 (setq curmask (lsh curmask -8))
|
|
4182 (aset string-vector i (logxor charmask (aref string-vector i)))
|
|
4183 (setq i (1+ i)))
|
|
4184 (concat string-vector)))
|
20757
|
4185
|
55056
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4186 ;;;; Desktop support
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4187
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4188 (defun rmail-restore-desktop-buffer (desktop-buffer-file-name
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4189 desktop-buffer-name
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4190 desktop-buffer-misc)
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4191 "Restore an rmail buffer specified in a desktop file."
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4192 (condition-case error
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4193 (progn
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4194 (rmail-input desktop-buffer-file-name)
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4195 (if (eq major-mode 'rmail-mode)
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4196 (current-buffer)
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4197 rmail-buffer))
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4198 (file-locked
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4199 (kill-buffer (current-buffer))
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4200 nil)))
|
c7ded215e268
(rmail-restore-desktop-buffer): Move from desktop.el. Add Parameters.
Lars Hansen <larsh@soem.dk>
diff
changeset
|
4201
|
64961
|
4202 (add-to-list 'desktop-buffer-mode-handlers
|
|
4203 '(rmail-mode . rmail-restore-desktop-buffer))
|
64897
|
4204
|
584
|
4205 (provide 'rmail)
|
|
4206
|
52401
|
4207 ;;; arch-tag: cff0a950-57fe-4f73-a86e-91ff75afd06c
|
658
|
4208 ;;; rmail.el ends here
|