]> code.delx.au - gnu-emacs/blob - lisp/mail/rmail.el
(rmail-retry-failure): Copy the whole block of headers from the message
[gnu-emacs] / lisp / mail / rmail.el
1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs.
2
3 ;; Copyright (C) 1985,86,87,88,93,94 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: mail
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Code:
25
26 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
27 ;; New features include attribute and keyword support, message
28 ;; selection by dispatch table, summary by attributes and keywords,
29 ;; expunging by dispatch table, sticky options for file commands.
30
31 ;; Extended by Bob Weiner of Motorola
32 ;; New features include: rmail and rmail-summary buffers remain
33 ;; synchronized and key bindings basically operate the same way in both
34 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
35 ;; variable, and a bury rmail buffer (wipe) command.
36 ;;
37
38 (require 'mail-utils)
39
40 ;; For Emacs V18 compatibility
41 (and (not (fboundp 'buffer-disable-undo))
42 (fboundp 'buffer-flush-undo)
43 (defalias 'buffer-disable-undo 'buffer-flush-undo))
44
45 ; These variables now declared in paths.el.
46 ;(defvar rmail-spool-directory "/usr/spool/mail/"
47 ; "This is the name of the directory used by the system mailer for\n\
48 ;delivering new mail. It's name should end with a slash.")
49 ;(defvar rmail-file-name
50 ; (expand-file-name "~/RMAIL")
51 ; "")
52
53 (defvar rmail-movemail-program nil
54 "If non-nil, name of program for fetching new mail.")
55
56 ;;;###autoload
57 (defvar rmail-dont-reply-to-names nil "\
58 *A regexp specifying names to prune of reply to messages.
59 A value of nil means exclude your own name only.")
60
61 ;;;###autoload
62 (defvar rmail-default-dont-reply-to-names "info-" "\
63 A regular expression specifying part of the value of the default value of
64 the variable `rmail-dont-reply-to-names', for when the user does not set
65 `rmail-dont-reply-to-names' explicitly. (The other part of the default
66 value is the user's name.)
67 It is useful to set this variable in the site customization file.")
68
69 ;;;###autoload
70 (defvar rmail-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:\\|^\\(resent-\\|\\)message-id:\\|^summary-line:" "\
71 ^received:\\|^x400-originator:\\|^x400-recipients:\\|^x400-received:\\|\
72 ^x400-mts-identifier:\\|^x400-content-type:\\|^message-id:\\|^summary-line:"
73 "*Regexp to match Header fields that Rmail should normally hide.")
74
75 ;;;###autoload
76 (defvar rmail-retry-ignored-headers nil "\
77 *Headers that should be stripped when retrying a failed message.")
78
79 ;;;###autoload
80 (defvar rmail-highlighted-headers "^From:\\|^Subject:" "\
81 *Regexp to match Header fields that Rmail should normally highlight.
82 A value of nil means don't highlight.
83 See also `rmail-highlight-face'.")
84
85 ;;;###autoload
86 (defvar rmail-highlight-face nil "\
87 *Face used by Rmail for highlighting headers.")
88
89 ;;;###autoload
90 (defvar rmail-delete-after-output nil "\
91 *Non-nil means automatically delete a message that is copied to a file.")
92
93 ;;;###autoload
94 (defvar rmail-primary-inbox-list nil "\
95 *List of files which are inboxes for user's primary mail file `~/RMAIL'.
96 `nil' means the default, which is (\"/usr/spool/mail/$USER\")
97 \(the name varies depending on the operating system,
98 and the value of the environment variable MAIL overrides it).")
99
100 ;;;###autoload
101 (defvar rmail-mail-new-frame nil
102 "*Non-nil means Rmail makes a new frame for composing outgoing mail.")
103
104 ;;;###autoload
105 (defvar rmail-secondary-file-directory "~/"
106 "*Directory for additional secondary Rmail files.")
107 ;;;###autoload
108 (defvar rmail-secondary-file-regexp "\\.xmail$"
109 "*Regexp for which files are secondary Rmail files.")
110
111 ;; These may be altered by site-init.el to match the format of mmdf files
112 ;; delimiting used on a given host (delim1 and delim2 from the config
113 ;; files).
114
115 (defvar mmdf-delim1 "^\001\001\001\001\n"
116 "Regexp marking the start of an mmdf message")
117 (defvar mmdf-delim2 "^\001\001\001\001\n"
118 "Regexp marking the end of an mmdf message")
119
120 (defvar rmail-message-filter nil
121 "If non nil, a filter function for new messages in RMAIL.
122 Called with region narrowed to the message, including headers.")
123
124 (defvar rmail-reply-prefix "Re: "
125 "String to prepend to Subject line when replying to a message.")
126
127 (defvar rmail-display-summary nil
128 "If non nil, the summary buffer is always displayed.")
129
130 (defvar rmail-mode-map nil)
131
132 (defvar rmail-inbox-list nil)
133 (defvar rmail-keywords nil)
134
135 ;; Message counters and markers. Deleted flags.
136
137 (defvar rmail-current-message nil)
138 (defvar rmail-total-messages nil)
139 (defvar rmail-message-vector nil)
140 (defvar rmail-deleted-vector nil)
141
142 (defvar rmail-overlay-list nil)
143
144 ;; These are used by autoloaded rmail-summary.
145
146 (defvar rmail-summary-buffer nil)
147 (defvar rmail-summary-vector nil)
148
149 ;; `Sticky' default variables.
150
151 ;; Last individual label specified to a or k.
152 (defvar rmail-last-label nil)
153 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
154 (defvar rmail-last-multi-labels nil)
155 (defvar rmail-last-regexp nil)
156 (defvar rmail-default-file nil
157 "*Default file name for \\[rmail-output].")
158 (defvar rmail-default-rmail-file (expand-file-name "~/XMAIL")
159 "*Default file name for \\[rmail-output-to-rmail-file].")
160
161 ;;; Regexp matching the delimiter of messages in UNIX mail format
162 ;;; (UNIX From lines), minus the initial ^. Note that if you change
163 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
164 ;;; that knows the exact ordering of the \\( \\) subexpressions.
165 (defvar rmail-unix-mail-delimiter
166 (let ((time-zone-regexp
167 (concat "\\([A-Z]?[A-Z][A-Z][A-Z]\\( DST\\)?"
168 "\\|[-+]?[0-9][0-9][0-9][0-9]"
169 "\\|"
170 "\\) *")))
171 (concat
172 "From "
173
174 ;; Username, perhaps with a quoted section that can contain spaces.
175 "\\("
176 "[^ \n]*"
177 "\\(\\|\".*\"[^ \n]*\\)"
178 "\\) ?"
179
180 ;; The time the message was sent.
181 "\\([^ \n]*\\) *" ; day of the week
182 "\\([^ ]*\\) *" ; month
183 "\\([0-9]*\\) *" ; day of month
184 "\\([0-9:]*\\) *" ; time of day
185
186 ;; Perhaps a time zone, specified by an abbreviation, or by a
187 ;; numeric offset.
188 time-zone-regexp
189
190 ;; The year.
191 " [0-9][0-9]\\([0-9]*\\) *"
192
193 ;; On some systems the time zone can appear after the year, too.
194 time-zone-regexp
195
196 ;; Old uucp cruft.
197 "\\(remote from .*\\)?"
198
199 "\n"))
200 nil)
201
202 ;; Perform BODY in the summary buffer
203 ;; in such a way that its cursor is properly updated in its own window.
204 (defmacro rmail-select-summary (&rest body)
205 (` (let ((total rmail-total-messages))
206 (if (rmail-summary-displayed)
207 (let ((window (selected-window)))
208 (save-excursion
209 (unwind-protect
210 (progn
211 (pop-to-buffer rmail-summary-buffer)
212 ;; rmail-total-messages is a buffer-local var
213 ;; in the rmail buffer.
214 ;; This way we make it available for the body
215 ;; even tho the rmail buffer is not current.
216 (let ((rmail-total-messages total))
217 (,@ body)))
218 (select-window window))))
219 (save-excursion
220 (set-buffer rmail-summary-buffer)
221 (let ((rmail-total-messages total))
222 (,@ body))))
223 (rmail-maybe-display-summary))))
224 \f
225 ;;;; *** Rmail Mode ***
226
227 ;;;###autoload
228 (defun rmail (&optional file-name-arg)
229 "Read and edit incoming mail.
230 Moves messages into file named by `rmail-file-name' (a babyl format file)
231 and edits that file in RMAIL Mode.
232 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
233
234 May be called with file name as argument; then performs rmail editing on
235 that file, but does not copy any new mail into the file.
236 Interactively, if you supply a prefix argument, then you
237 have a chance to specify a file name with the minibuffer.
238
239 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
240 (interactive (if current-prefix-arg
241 (list (read-file-name "Run rmail on RMAIL file: "
242 nil nil t))))
243 (or rmail-default-file
244 (setq rmail-default-file (expand-file-name "~/xmail")))
245 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
246 (existed (get-file-buffer file-name)))
247 ;; Like find-file, but in the case where a buffer existed
248 ;; and the file was reverted, recompute the message-data.
249 (if (and existed (not (verify-visited-file-modtime existed)))
250 (progn
251 ;; Don't be confused by apparent local-variables spec
252 ;; in the last message in the RMAIL file.
253 (let ((enable-local-variables nil))
254 (find-file file-name))
255 (if (and (verify-visited-file-modtime existed)
256 (eq major-mode 'rmail-mode))
257 (progn (rmail-forget-messages)
258 (rmail-set-message-counters))))
259 (let ((enable-local-variables nil))
260 (find-file file-name)))
261 (if (eq major-mode 'rmail-edit-mode)
262 (error "Exit Rmail Edit mode before getting new mail."))
263 (if (and existed (> (buffer-size) 0))
264 ;; Buffer not new and not empty; ensure in proper mode, but that's all.
265 (or (eq major-mode 'rmail-mode)
266 (rmail-mode-2))
267 (rmail-mode-2)
268 ;; Convert all or part to Babyl file if possible.
269 (rmail-convert-file)
270 (goto-char (point-max))
271 (if (null rmail-inbox-list)
272 (progn
273 (rmail-set-message-counters)
274 (rmail-show-message))))
275 (let ((existing-unseen (rmail-first-unseen-message)))
276 (or file-name-arg
277 (rmail-get-new-mail))
278 ;; Show the first unseen message, which might be from a previous session
279 ;; or might have been just read in by rmail-get-new-mail. Must
280 ;; determine already unseen messages first, as rmail-get-new-mail
281 ;; positions on the first new message, thus marking it as seen.
282 (rmail-show-message existing-unseen))
283 (if rmail-display-summary (rmail-summary))
284 (rmail-construct-io-menu)))
285
286 ;; Given the value of MAILPATH, return a list of inbox file names.
287 ;; This is turned off because it is not clear that the user wants
288 ;; all these inboxes to feed into the primary rmail file.
289 ; (defun rmail-convert-mailpath (string)
290 ; (let (idx list)
291 ; (while (setq idx (string-match "[%:]" string))
292 ; (let ((this (substring string 0 idx)))
293 ; (setq string (substring string (1+ idx)))
294 ; (setq list (cons (if (string-match "%" this)
295 ; (substring this 0 (string-match "%" this))
296 ; this)
297 ; list))))
298 ; list))
299
300 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
301 ; will not cause emacs 18.55 problems.
302
303 (defun rmail-convert-file ()
304 (let (convert)
305 (widen)
306 (goto-char (point-min))
307 ;; If file doesn't start like a Babyl file,
308 ;; convert it to one, by adding a header and converting each message.
309 (cond ((looking-at "BABYL OPTIONS:"))
310 ((looking-at "Version: 5\n")
311 ;; Losing babyl file made by old version of Rmail.
312 ;; Just fix the babyl file header; don't make a new one,
313 ;; so we don't lose the Labels: file attribute, etc.
314 (let ((buffer-read-only nil))
315 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
316 ((equal (point-min) (point-max))
317 ;; Empty RMAIL file. Just insert the header.
318 (rmail-insert-rmail-file-header))
319 (t
320 ;; Non-empty file in non-RMAIL format. Add header and convert.
321 (setq convert t)
322 (rmail-insert-rmail-file-header)))
323 ;; If file was not a Babyl file or if there are
324 ;; Unix format messages added at the end,
325 ;; convert file as necessary.
326 (if (or convert
327 (save-excursion
328 (goto-char (point-max))
329 (search-backward "\^_")
330 (forward-char 1)
331 (looking-at "\n*From ")))
332 (let ((buffer-read-only nil))
333 (message "Converting to Babyl format...")
334 ;; If file needs conversion, convert it all,
335 ;; except for the BABYL header.
336 ;; (rmail-convert-to-babyl-format would delete the header.)
337 (goto-char (point-min))
338 (search-forward "\n\^_" nil t)
339 (narrow-to-region (point) (point-max))
340 (rmail-convert-to-babyl-format)
341 (message "Converting to Babyl format...done")))))
342
343 ;;; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
344 ;;; will not cause emacs 18.55 problems.
345
346 (defun rmail-insert-rmail-file-header ()
347 (let ((buffer-read-only nil))
348 (insert "BABYL OPTIONS: -*- rmail -*-
349 Version: 5
350 Labels:
351 Note: This is the header of an rmail file.
352 Note: If you are seeing it in rmail,
353 Note: it means the file has no messages in it.\n\^_")))
354
355 (if rmail-mode-map
356 nil
357 (setq rmail-mode-map (make-keymap))
358 (suppress-keymap rmail-mode-map)
359 (define-key rmail-mode-map "a" 'rmail-add-label)
360 (define-key rmail-mode-map "b" 'rmail-bury)
361 (define-key rmail-mode-map "c" 'rmail-continue)
362 (define-key rmail-mode-map "d" 'rmail-delete-forward)
363 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward)
364 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
365 (define-key rmail-mode-map "f" 'rmail-forward)
366 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
367 (define-key rmail-mode-map "h" 'rmail-summary)
368 (define-key rmail-mode-map "i" 'rmail-input)
369 (define-key rmail-mode-map "j" 'rmail-show-message)
370 (define-key rmail-mode-map "k" 'rmail-kill-label)
371 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
372 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
373 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
374 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
375 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
376 (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
377 (define-key rmail-mode-map "m" 'rmail-mail)
378 (define-key rmail-mode-map "\em" 'rmail-retry-failure)
379 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
380 (define-key rmail-mode-map "\en" 'rmail-next-message)
381 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
382 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
383 (define-key rmail-mode-map "\C-o" 'rmail-output)
384 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
385 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
386 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
387 (define-key rmail-mode-map "q" 'rmail-quit)
388 (define-key rmail-mode-map "r" 'rmail-reply)
389 ;; I find I can't live without the default M-r command -- rms.
390 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
391 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
392 (define-key rmail-mode-map "\es" 'rmail-search)
393 (define-key rmail-mode-map "t" 'rmail-toggle-header)
394 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
395 (define-key rmail-mode-map "w" 'rmail-edit-current-message)
396 (define-key rmail-mode-map "x" 'rmail-expunge)
397 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
398 (define-key rmail-mode-map "<" 'rmail-first-message)
399 (define-key rmail-mode-map ">" 'rmail-last-message)
400 (define-key rmail-mode-map " " 'scroll-up)
401 (define-key rmail-mode-map "\177" 'scroll-down)
402 (define-key rmail-mode-map "?" 'describe-mode)
403 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
404 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
405 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
406 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
407 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
408 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
409 (define-key rmail-mode-map "\C-c\C-s\C-k" 'rmail-sort-by-keywords)
410 )
411 \f
412 (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
413
414 (define-key rmail-mode-map [menu-bar classify]
415 (cons "Classify" (make-sparse-keymap "Classify")))
416
417 (define-key rmail-mode-map [menu-bar classify input-menu]
418 nil)
419
420 (define-key rmail-mode-map [menu-bar classify output-menu]
421 nil)
422
423 (define-key rmail-mode-map [menu-bar classify output-inbox]
424 '("Output (inbox)..." . rmail-output))
425
426 (define-key rmail-mode-map [menu-bar classify output]
427 '("Output (Rmail)..." . rmail-output-to-rmail-file))
428
429 (define-key rmail-mode-map [menu-bar classify kill-label]
430 '("Kill Label..." . rmail-kill-label))
431
432 (define-key rmail-mode-map [menu-bar classify add-label]
433 '("Add Label..." . rmail-add-label))
434
435 (define-key rmail-mode-map [menu-bar summary]
436 (cons "Summary" (make-sparse-keymap "Summary")))
437
438 (define-key rmail-mode-map [menu-bar summary labels]
439 '("By Labels..." . rmail-summary-by-labels))
440
441 (define-key rmail-mode-map [menu-bar summary recipients]
442 '("By Recipients..." . rmail-summary-by-recipients))
443
444 (define-key rmail-mode-map [menu-bar summary topic]
445 '("By Topic..." . rmail-summary-by-topic))
446
447 (define-key rmail-mode-map [menu-bar summary regexp]
448 '("By Regexp..." . rmail-summary-by-regexp))
449
450 (define-key rmail-mode-map [menu-bar summary all]
451 '("All" . rmail-summary))
452
453 (define-key rmail-mode-map [menu-bar mail]
454 (cons "Mail" (make-sparse-keymap "Mail")))
455
456 (define-key rmail-mode-map [menu-bar mail rmail-get-new-mail]
457 '("Get New Mail" . rmail-get-new-mail))
458
459 (define-key rmail-mode-map [menu-bar mail lambda]
460 '("----"))
461
462 (define-key rmail-mode-map [menu-bar mail continue]
463 '("Continue" . rmail-continue))
464
465 (define-key rmail-mode-map [menu-bar mail resend]
466 '("Re-send..." . rmail-resend))
467
468 (define-key rmail-mode-map [menu-bar mail forward]
469 '("Forward" . rmail-forward))
470
471 (define-key rmail-mode-map [menu-bar mail retry]
472 '("Retry" . rmail-retry-failure))
473
474 (define-key rmail-mode-map [menu-bar mail reply]
475 '("Reply" . rmail-reply))
476
477 (define-key rmail-mode-map [menu-bar mail mail]
478 '("Mail" . rmail-mail))
479
480 (define-key rmail-mode-map [menu-bar delete]
481 (cons "Delete" (make-sparse-keymap "Delete")))
482
483 (define-key rmail-mode-map [menu-bar delete expunge/save]
484 '("Expunge/Save" . rmail-expunge-and-save))
485
486 (define-key rmail-mode-map [menu-bar delete expunge]
487 '("Expunge" . rmail-expunge))
488
489 (define-key rmail-mode-map [menu-bar delete undelete]
490 '("Undelete" . rmail-undelete-previous-message))
491
492 (define-key rmail-mode-map [menu-bar delete delete]
493 '("Delete" . rmail-delete-forward))
494
495 (define-key rmail-mode-map [menu-bar move]
496 (cons "Move" (make-sparse-keymap "Move")))
497
498 (define-key rmail-mode-map [menu-bar move search-back]
499 '("Search Back..." . rmail-search-backward))
500
501 (define-key rmail-mode-map [menu-bar move search]
502 '("Search..." . rmail-search))
503
504 (define-key rmail-mode-map [menu-bar move previous]
505 '("Previous Nondeleted" . rmail-previous-undeleted-message))
506
507 (define-key rmail-mode-map [menu-bar move next]
508 '("Next Nondeleted" . rmail-next-undeleted-message))
509
510 (define-key rmail-mode-map [menu-bar move last]
511 '("Last" . rmail-last-message))
512
513 (define-key rmail-mode-map [menu-bar move first]
514 '("First" . rmail-first-message))
515
516 (define-key rmail-mode-map [menu-bar move previous]
517 '("Previous" . rmail-previous-message))
518
519 (define-key rmail-mode-map [menu-bar move next]
520 '("Next" . rmail-next-message))
521 \f
522 ;; Rmail mode is suitable only for specially formatted data.
523 (put 'rmail-mode 'mode-class 'special)
524
525 (defun rmail-mode-kill-summary ()
526 (if rmail-summary-buffer (kill-buffer rmail-summary-buffer)))
527
528 ;;;###autoload
529 (defun rmail-mode ()
530 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
531 All normal editing commands are turned off.
532 Instead, these commands are available:
533
534 \\[rmail-beginning-of-message] Move point to front of this message (same as \\[beginning-of-buffer]).
535 \\[scroll-up] Scroll to next screen of this message.
536 \\[scroll-down] Scroll to previous screen of this message.
537 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
538 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
539 \\[rmail-next-message] Move to Next message whether deleted or not.
540 \\[rmail-previous-message] Move to Previous message whether deleted or not.
541 \\[rmail-first-message] Move to the first message in Rmail file.
542 \\[rmail-last-message] Move to the last message in Rmail file.
543 \\[rmail-show-message] Jump to message specified by numeric position in file.
544 \\[rmail-search] Search for string and show message it is found in.
545 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
546 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
547 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
548 till a deleted message is found.
549 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
550 \\[rmail-expunge] Expunge deleted messages.
551 \\[rmail-expunge-and-save] Expunge and save the file.
552 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
553 \\[save-buffer] Save without expunging.
554 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
555 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
556 \\[rmail-continue] Continue composing outgoing message started before.
557 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
558 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
559 \\[rmail-forward] Forward this message to another user.
560 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
561 \\[rmail-output] Output this message to a Unix-format mail file (append it).
562 \\[rmail-input] Input Rmail file. Run Rmail on that file.
563 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
564 \\[rmail-kill-label] Kill label. Remove a label from current message.
565 \\[rmail-next-labeled-message] Move to Next message with specified label
566 (label defaults to last one specified).
567 Standard labels: filed, unseen, answered, forwarded, deleted.
568 Any other label is present only if you add it with \\[rmail-add-label].
569 \\[rmail-previous-labeled-message] Move to Previous message with specified label
570 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
571 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
572 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
573 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
574 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
575 \\[rmail-toggle-header] Toggle display of complete header."
576 (interactive)
577 (rmail-mode-2)
578 (rmail-set-message-counters)
579 (rmail-show-message rmail-total-messages))
580
581 (defun rmail-mode-2 ()
582 (kill-all-local-variables)
583 (rmail-mode-1)
584 (rmail-variables)
585 (run-hooks 'rmail-mode-hook))
586
587 (defun rmail-mode-1 ()
588 (setq major-mode 'rmail-mode)
589 (setq mode-name "RMAIL")
590 (setq buffer-read-only t)
591 ;; No need to auto save RMAIL files in normal circumstances
592 ;; because they contain no info except attribute changes
593 ;; and deletion of messages.
594 ;; The one exception is when messages are copied into an Rmail mode buffer.
595 ;; rmail-output-to-rmail-file enables auto save when you do that.
596 (setq buffer-auto-save-file-name nil)
597 (if (boundp 'mode-line-modified)
598 (setq mode-line-modified "--- ")
599 (setq mode-line-format
600 (cons "--- " (cdr (default-value 'mode-line-format)))))
601 (use-local-map rmail-mode-map)
602 (set-syntax-table text-mode-syntax-table)
603 (setq local-abbrev-table text-mode-abbrev-table))
604
605 (defun rmail-variables ()
606 (make-local-variable 'revert-buffer-function)
607 (setq revert-buffer-function 'rmail-revert)
608 (make-local-variable 'rmail-last-label)
609 (make-local-variable 'rmail-last-regexp)
610 (make-local-variable 'rmail-deleted-vector)
611 (make-local-variable 'rmail-summary-buffer)
612 (make-local-variable 'rmail-summary-vector)
613 (make-local-variable 'rmail-current-message)
614 (make-local-variable 'rmail-total-messages)
615 (make-local-variable 'require-final-newline)
616 (setq require-final-newline nil)
617 (make-local-variable 'rmail-overlay-list)
618 (setq rmail-overlay-list nil)
619 (make-local-variable 'version-control)
620 (setq version-control 'never)
621 (make-local-variable 'kill-buffer-hook)
622 (add-hook 'kill-buffer-hook 'rmail-mode-kill-summary)
623 (make-local-variable 'file-precious-flag)
624 (setq file-precious-flag t)
625 (make-local-variable 'rmail-message-vector)
626 (make-local-variable 'rmail-inbox-list)
627 (setq rmail-inbox-list (rmail-parse-file-inboxes))
628 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
629 (and (null rmail-inbox-list)
630 (or (equal buffer-file-name (expand-file-name rmail-file-name))
631 (equal buffer-file-truename
632 (abbreviate-file-name (file-truename rmail-file-name))))
633 (setq rmail-inbox-list
634 (or rmail-primary-inbox-list
635 (list (or (getenv "MAIL")
636 (concat rmail-spool-directory
637 (user-login-name)))))))
638 (make-local-variable 'rmail-keywords)
639 ;; this gets generated as needed
640 (setq rmail-keywords nil))
641
642 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
643 (defun rmail-revert (arg noconfirm)
644 (let (revert-buffer-function)
645 ;; Call our caller again, but this time it does the default thing.
646 (if (revert-buffer arg noconfirm)
647 ;; If the user said "yes", and we changed something,
648 ;; reparse the messages.
649 (progn
650 (rmail-convert-file)
651 (goto-char (point-max))
652 (rmail-set-message-counters)
653 (rmail-show-message)))))
654
655 ;; Return a list of files from this buffer's Mail: option.
656 ;; Does not assume that messages have been parsed.
657 ;; Just returns nil if buffer does not look like Babyl format.
658 (defun rmail-parse-file-inboxes ()
659 (save-excursion
660 (save-restriction
661 (widen)
662 (goto-char 1)
663 (cond ((looking-at "BABYL OPTIONS:")
664 (search-forward "\n\^_" nil 'move)
665 (narrow-to-region 1 (point))
666 (goto-char 1)
667 (if (search-forward "\nMail:" nil t)
668 (progn
669 (narrow-to-region (point) (progn (end-of-line) (point)))
670 (goto-char (point-min))
671 (mail-parse-comma-list))))))))
672
673 (defun rmail-expunge-and-save ()
674 "Expunge and save RMAIL file."
675 (interactive)
676 (rmail-expunge)
677 (save-buffer)
678 (if (rmail-summary-exists)
679 (rmail-select-summary (set-buffer-modified-p nil))))
680
681 (defun rmail-quit ()
682 "Quit out of RMAIL."
683 (interactive)
684 (rmail-expunge-and-save)
685 ;; Don't switch to the summary buffer even if it was recently visible.
686 (if rmail-summary-buffer
687 (progn
688 (replace-buffer-in-windows rmail-summary-buffer)
689 (bury-buffer rmail-summary-buffer)))
690 (let ((obuf (current-buffer)))
691 (replace-buffer-in-windows obuf)
692 (bury-buffer obuf)))
693
694 ;;;###autoload
695 (defun rmail-input (filename)
696 "Run Rmail on file FILENAME."
697 (interactive "FRun rmail on RMAIL file: ")
698 (rmail filename))
699
700 (defun rmail-find-all-files (start)
701 (if (file-accessible-directory-p start)
702 (let ((files (directory-files start nil
703 rmail-secondary-file-regexp))
704 (ret nil))
705 (while files
706 (setq file (car files))
707 (setq files (cdr files))
708 (setq ret (cons
709 (rmail-find-all-files (concat start "/" file))
710 ret)))
711 (cons (file-name-nondirectory start) ret))
712 (file-name-nondirectory start)))
713
714 (defun rmail-list-to-menu (menu-name l action &optional full-name)
715 (let ((menu (make-sparse-keymap menu-name)))
716 (mapcar
717 (function (lambda (item)
718 (if (consp item)
719 (progn
720 (setq command
721 (rmail-list-to-menu (car item) (cdr item)
722 action
723 (if full-name
724 (concat full-name "/"
725 (car item))
726 (car item))))
727 (setq name (car item)))
728 (progn
729 (setq name item)
730 (setq command
731 (list 'lambda () '(interactive)
732 (list action
733 (expand-file-name
734 (if full-name
735 (concat full-name "/" item)
736 item)
737 rmail-secondary-file-directory))))))
738 (define-key menu (vector (intern name))
739 (cons name command))))
740 l)
741 menu))
742
743 (defun rmail-construct-io-menu ()
744 (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
745 (if (listp files)
746 (progn
747 (define-key rmail-mode-map [menu-bar classify input-menu]
748 (cons "Input Rmail File"
749 (rmail-list-to-menu "Input Rmail File"
750 (cdr files)
751 'rmail-input)))
752 (define-key rmail-mode-map [menu-bar classify output-menu]
753 (cons "Output Rmail File"
754 (rmail-list-to-menu "Output Rmail File"
755 (cdr files)
756 'rmail-output-to-rmail-file)))))
757 (message "No files matching %s/%s found"
758 rmail-secondary-file-directory rmail-secondary-file-regexp)))
759
760 \f
761 ;;;; *** Rmail input ***
762
763 ;; RLK feature not added in this version:
764 ;; argument specifies inbox file or files in various ways.
765
766 (defun rmail-get-new-mail (&optional file-name)
767 "Move any new mail from this RMAIL file's inbox files.
768 The inbox files can be specified with the file's Mail: option. The
769 variable `rmail-primary-inbox-list' specifies the inboxes for your
770 primary RMAIL file if it has no Mail: option. By default, this is
771 your /usr/spool/mail/$USER.
772
773 You can also specify the file to get new mail from. In this case, the
774 file of new mail is not changed or deleted. Noninteractively, you can
775 pass the inbox file name as an argument. Interactively, a prefix
776 argument causes us to read a file name and use that file as the inbox.
777
778 This function runs `rmail-get-new-mail-hook' before saving the updated file."
779 (interactive
780 (list (if current-prefix-arg
781 (read-file-name "Get new mail from file: "))))
782 (or (verify-visited-file-modtime (current-buffer))
783 (progn
784 (find-file (buffer-file-name))
785 (setq buffer-read-only t)
786 (if (verify-visited-file-modtime (current-buffer))
787 (rmail-forget-messages))))
788 (rmail-maybe-set-message-counters)
789 (widen)
790 ;; Get rid of all undo records for this buffer.
791 (or (eq buffer-undo-list t)
792 (setq buffer-undo-list nil))
793 (unwind-protect
794 (let ((opoint (point))
795 (new-messages 0)
796 (delete-files ())
797 ;; If buffer has not changed yet, and has not been saved yet,
798 ;; don't replace the old backup file now.
799 (make-backup-files (and make-backup-files (buffer-modified-p)))
800 (buffer-read-only nil)
801 ;; Don't make undo records for what we do in getting mail.
802 (buffer-undo-list t))
803 (goto-char (point-max))
804 (skip-chars-backward " \t\n") ; just in case of brain damage
805 (delete-region (point) (point-max)) ; caused by require-final-newline
806 (save-excursion
807 (save-restriction
808 (narrow-to-region (point) (point))
809 ;; Read in the contents of the inbox files,
810 ;; renaming them as necessary,
811 ;; and adding to the list of files to delete eventually.
812 (if file-name
813 (rmail-insert-inbox-text (list file-name) nil)
814 (setq delete-files (rmail-insert-inbox-text rmail-inbox-list t)))
815 ;; Scan the new text and convert each message to babyl format.
816 (goto-char (point-min))
817 (save-excursion
818 (setq new-messages (rmail-convert-to-babyl-format)))
819 (or (zerop new-messages)
820 (let (success)
821 (widen)
822 (search-backward "\n\^_" nil t)
823 (narrow-to-region (point) (point-max))
824 (goto-char (1+ (point-min)))
825 (rmail-count-new-messages)
826 (run-hooks 'rmail-get-new-mail-hook)
827 (save-buffer)))
828 ;; Delete the old files, now that babyl file is saved.
829 (while delete-files
830 (condition-case ()
831 ;; First, try deleting.
832 (condition-case ()
833 (delete-file (car delete-files))
834 (file-error
835 ;; If we can't delete it, truncate it.
836 (write-region (point) (point) (car delete-files))))
837 (file-error nil))
838 (setq delete-files (cdr delete-files)))))
839 (if (= new-messages 0)
840 (progn (goto-char opoint)
841 (if (or file-name rmail-inbox-list)
842 (message "(No new mail has arrived)")))
843 (if (rmail-summary-exists)
844 (rmail-select-summary
845 (rmail-update-summary)))
846 (message "%d new message%s read"
847 new-messages (if (= 1 new-messages) "" "s"))
848 (and (boundp 'display-time-string)
849 (stringp display-time-string)
850 (string-match " Mail" display-time-string)
851 (setq display-time-string
852 (concat
853 (substring display-time-string 0 (match-beginning 0))
854 (substring display-time-string (match-end 0))))
855 (force-mode-line-update 'all))))
856 ;; Don't leave the buffer screwed up if we get a disk-full error.
857 (rmail-show-message)))
858
859 (defun rmail-insert-inbox-text (files renamep)
860 (let (file tofile delete-files movemail popmail)
861 (while files
862 (setq file (file-truename
863 (expand-file-name (substitute-in-file-name (car files))))
864 ;;>> un*x specific <<
865 ;; The "+" used to be "~", which is an extremely poor choice;
866 ;; it might accidentally be deleted when space is low
867 ;; (as happened to me!).
868 tofile (concat file "+"))
869 ;; If getting from mail spool directory,
870 ;; use movemail to move rather than just renaming,
871 ;; so as to interlock with the mailer.
872 (setq movemail (string= (file-name-directory file)
873 (file-truename rmail-spool-directory))
874 popmail (string-match "^po:" (file-name-nondirectory file)))
875 (if popmail (setq file (file-name-nondirectory file)
876 renamep t))
877 (if movemail
878 (progn
879 (setq tofile (expand-file-name
880 ;; Generate name to move to from inbox name,
881 ;; in case of multiple inboxes that need moving.
882 (concat ".newmail-" (file-name-nondirectory file))
883 ;; Use the directory of this rmail file
884 ;; because it's a nuisance to use the homedir
885 ;; if that is on a full disk and this rmail
886 ;; file isn't.
887 (file-name-directory
888 (expand-file-name buffer-file-name))))
889 ;; On some systems, /usr/spool/mail/foo is a directory
890 ;; and the actual inbox is /usr/spool/mail/foo/foo.
891 (if (file-directory-p file)
892 (setq file (expand-file-name (user-login-name)
893 file)))))
894 (if popmail
895 (message "Getting mail from post office ...")
896 (if (or (and (file-exists-p tofile)
897 (/= 0 (nth 7 (file-attributes tofile))))
898 (and (file-exists-p file)
899 (/= 0 (nth 7 (file-attributes file)))))
900 (message "Getting mail from %s..." file)))
901 ;; Set TOFILE if have not already done so, and
902 ;; rename or copy the file FILE to TOFILE if and as appropriate.
903 (cond ((not renamep)
904 (setq tofile file))
905 ((or (file-exists-p tofile) (and (not popmail)
906 (not (file-exists-p file))))
907 nil)
908 ((and (not movemail) (not popmail))
909 ;; Try copying. If that fails (perhaps no space),
910 ;; rename instead.
911 (condition-case nil
912 (copy-file file tofile nil)
913 (error
914 ;; Third arg is t so we can replace existing file TOFILE.
915 (rename-file file tofile t)))
916 ;; Make the real inbox file empty.
917 ;; Leaving it deleted could cause lossage
918 ;; because mailers often won't create the file.
919 (condition-case ()
920 (write-region (point) (point) file)
921 (file-error nil)))
922 (t
923 (let ((errors nil))
924 (unwind-protect
925 (save-excursion
926 (setq errors (generate-new-buffer " *rmail loss*"))
927 (buffer-disable-undo errors)
928 (call-process
929 (or rmail-movemail-program
930 (expand-file-name "movemail" exec-directory))
931 nil errors nil file tofile)
932 (if (not (buffer-modified-p errors))
933 ;; No output => movemail won
934 nil
935 (set-buffer errors)
936 (subst-char-in-region (point-min) (point-max)
937 ?\n ?\ )
938 (goto-char (point-max))
939 (skip-chars-backward " \t")
940 (delete-region (point) (point-max))
941 (goto-char (point-min))
942 (if (looking-at "movemail: ")
943 (delete-region (point-min) (match-end 0)))
944 (beep t)
945 (message (concat "movemail: "
946 (buffer-substring (point-min)
947 (point-max))))
948 (sit-for 3)
949 nil))
950 (if errors (kill-buffer errors))))))
951 ;; At this point, TOFILE contains the name to read:
952 ;; Either the alternate name (if we renamed)
953 ;; or the actual inbox (if not renaming).
954 (if (file-exists-p tofile)
955 (let (size)
956 (goto-char (point-max))
957 (setq size (nth 1 (insert-file-contents tofile)))
958 (goto-char (point-max))
959 (or (= (preceding-char) ?\n)
960 (zerop size)
961 (insert ?\n))
962 (setq delete-files (cons tofile delete-files))))
963 (message "")
964 (setq files (cdr files)))
965 delete-files))
966
967 ;; the rmail-break-forwarded-messages feature is not implemented
968 (defun rmail-convert-to-babyl-format ()
969 (let ((count 0) start
970 (case-fold-search nil)
971 (invalid-input-resync
972 (function (lambda ()
973 (message "Invalid Babyl format in inbox!")
974 (sit-for 1)
975 ;; Try to get back in sync with a real message.
976 (if (re-search-forward
977 (concat mmdf-delim1 "\\|^From") nil t)
978 (beginning-of-line)
979 (goto-char (point-max)))))))
980 (goto-char (point-min))
981 (save-restriction
982 (while (not (eobp))
983 (cond ((looking-at "BABYL OPTIONS:");Babyl header
984 (if (search-forward "\n\^_" nil t)
985 ;; If we find the proper terminator, delete through there.
986 (delete-region (point-min) (point))
987 (funcall invalid-input-resync)
988 (delete-region (point-min) (point))))
989 ;; Babyl format message
990 ((looking-at "\^L")
991 (or (search-forward "\n\^_" nil t)
992 (funcall invalid-input-resync))
993 (setq count (1+ count))
994 ;; Make sure there is no extra white space after the ^_
995 ;; at the end of the message.
996 ;; Narrowing will make sure that whatever follows the junk
997 ;; will be treated properly.
998 (delete-region (point)
999 (save-excursion
1000 (skip-chars-forward " \t\n")
1001 (point)))
1002 (narrow-to-region (point) (point-max)))
1003 ;;*** MMDF format
1004 ((let ((case-fold-search t))
1005 (looking-at mmdf-delim1))
1006 (let ((case-fold-search t))
1007 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
1008 (setq start (point))
1009 (re-search-forward mmdf-delim2 nil t)
1010 (replace-match "\^_"))
1011 (save-excursion
1012 (save-restriction
1013 (narrow-to-region start (1- (point)))
1014 (goto-char (point-min))
1015 (while (search-forward "\n\^_" nil t); single char "\^_"
1016 (replace-match "\n^_")))); 2 chars: "^" and "_"
1017 (narrow-to-region (point) (point-max))
1018 (setq count (1+ count)))
1019 ;;*** Mail format
1020 ((looking-at "^From ")
1021 (setq start (point))
1022 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
1023 (rmail-nuke-pinhead-header)
1024 ;; If this message has a Content-Length field,
1025 ;; skip to the end of the contents.
1026 (let* ((header-end (save-excursion
1027 (and (re-search-forward "\n\n" nil t)
1028 (1- (point)))))
1029 (case-fold-search t)
1030 (size
1031 ;; Get the numeric value from the Content-Length field.
1032 (save-excursion
1033 ;; Back up to end of prev line,
1034 ;; in case the Content-Length field comes first.
1035 (forward-char -1)
1036 (and (search-forward "\ncontent-length: "
1037 header-end t)
1038 (let ((beg (point))
1039 (eol (progn (end-of-line) (point))))
1040 (string-to-int (buffer-substring beg eol)))))))
1041 (and size
1042 (if (and (natnump size)
1043 (<= (+ header-end size) (point-max))
1044 ;; Make sure this would put us at a position
1045 ;; that we could continue from.
1046 (save-excursion
1047 (goto-char (+ header-end size))
1048 (skip-chars-forward "\n")
1049 (or (eobp)
1050 (and (looking-at "BABYL OPTIONS:")
1051 (search-forward "\n\^_" nil t))
1052 (and (looking-at "\^L")
1053 (search-forward "\n\^_" nil t))
1054 (let ((case-fold-search t))
1055 (looking-at mmdf-delim1))
1056 (looking-at "From "))))
1057 (goto-char (+ header-end size))
1058 (message "Ignoring invalid Content-Length field")
1059 (sit-for 1 0 t))))
1060
1061 (if (re-search-forward
1062 (concat "^[\^_]?\\("
1063 rmail-unix-mail-delimiter
1064 "\\|"
1065 mmdf-delim1 "\\|"
1066 "^BABYL OPTIONS:\\|"
1067 "\^L\n[01],\\)") nil t)
1068 (goto-char (match-beginning 1))
1069 (goto-char (point-max)))
1070 (setq count (1+ count))
1071 (save-excursion
1072 (save-restriction
1073 (narrow-to-region start (point))
1074 (goto-char (point-min))
1075 (while (search-forward "\n\^_" nil t); single char
1076 (replace-match "\n^_")))); 2 chars: "^" and "_"
1077 (insert ?\^_)
1078 (narrow-to-region (point) (point-max)))
1079 ;;
1080 ;; This kludge is because some versions of sendmail.el
1081 ;; insert an extra newline at the beginning that shouldn't
1082 ;; be there. sendmail.el has been fixed, but old versions
1083 ;; may still be in use. -- rms, 7 May 1993.
1084 ((eolp) (delete-char 1))
1085 (t (error "Cannot convert to babyl format")))))
1086 count))
1087
1088 ;; Delete the "From ..." line, creating various other headers with
1089 ;; information from it if they don't already exist. Now puts the
1090 ;; original line into a mail-from: header line for debugging and for
1091 ;; use by the rmail-output function.
1092 (defun rmail-nuke-pinhead-header ()
1093 (save-excursion
1094 (save-restriction
1095 (let ((start (point))
1096 (end (progn
1097 (condition-case ()
1098 (search-forward "\n\n")
1099 (error
1100 (goto-char (point-max))
1101 (insert "\n\n")))
1102 (point)))
1103 has-from has-date)
1104 (narrow-to-region start end)
1105 (let ((case-fold-search t))
1106 (goto-char start)
1107 (setq has-from (search-forward "\nFrom:" nil t))
1108 (goto-char start)
1109 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
1110 (goto-char start))
1111 (let ((case-fold-search nil))
1112 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
1113 (replace-match
1114 (concat
1115 "Mail-from: \\&"
1116 ;; Keep and reformat the date if we don't
1117 ;; have a Date: field.
1118 (if has-date
1119 ""
1120 (concat
1121 "Date: \\3, \\5 \\4 \\9 \\6 "
1122
1123 ;; The timezone could be matched by group 7 or group 10.
1124 ;; If neither of them matched, assume EST, since only
1125 ;; Easterners would be so sloppy.
1126 ;; It's a shame the substitution can't use "\\10".
1127 (cond
1128 ((/= (match-beginning 7) (match-end 7)) "\\7")
1129 ((/= (match-beginning 10) (match-end 10))
1130 (buffer-substring (match-beginning 10)
1131 (match-end 10)))
1132 (t "EST"))
1133 "\n"))
1134 ;; Keep and reformat the sender if we don't
1135 ;; have a From: field.
1136 (if has-from
1137 ""
1138 "From: \\1\n"))
1139 t)))))))
1140 \f
1141 ;;;; *** Rmail Message Formatting and Header Manipulation ***
1142
1143 (defun rmail-reformat-message (beg end)
1144 (goto-char beg)
1145 (forward-line 1)
1146 (if (/= (following-char) ?0)
1147 (error "Bad format in RMAIL file."))
1148 (let ((buffer-read-only nil)
1149 (delta (- (buffer-size) end)))
1150 (delete-char 1)
1151 (insert ?1)
1152 (forward-line 1)
1153 (let ((case-fold-search t))
1154 (while (looking-at "Summary-line:\\|Mail-From:")
1155 (forward-line 1)))
1156 (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
1157 (delete-region (point)
1158 (progn (forward-line 1) (point))))
1159 (let ((str (buffer-substring (point)
1160 (save-excursion (search-forward "\n\n" end 'move)
1161 (point)))))
1162 (insert str "*** EOOH ***\n")
1163 (narrow-to-region (point) (- (buffer-size) delta)))
1164 (goto-char (point-min))
1165 (if rmail-ignored-headers (rmail-clear-headers))
1166 (if rmail-message-filter (funcall rmail-message-filter))))
1167
1168 (defun rmail-clear-headers (&optional ignored-headers)
1169 (or ignored-headers (setq ignored-headers rmail-ignored-headers))
1170 (if (search-forward "\n\n" nil t)
1171 (save-restriction
1172 (narrow-to-region (point-min) (point))
1173 (let ((buffer-read-only nil))
1174 (while (let ((case-fold-search t))
1175 (goto-char (point-min))
1176 (re-search-forward ignored-headers nil t))
1177 (beginning-of-line)
1178 (delete-region (point)
1179 (progn (re-search-forward "\n[^ \t]")
1180 (forward-char -1)
1181 (point))))))))
1182
1183 (defun rmail-toggle-header ()
1184 "Show original message header if pruned header currently shown, or vice versa."
1185 (interactive)
1186 (rmail-maybe-set-message-counters)
1187 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1188 (let ((buffer-read-only nil))
1189 (goto-char (point-min))
1190 (forward-line 1)
1191 (if (= (following-char) ?1)
1192 (progn (delete-char 1)
1193 (insert ?0)
1194 (forward-line 1)
1195 (let ((case-fold-search t))
1196 (while (looking-at "Summary-Line:\\|Mail-From:")
1197 (forward-line 1)))
1198 (insert "*** EOOH ***\n")
1199 (forward-char -1)
1200 (search-forward "\n*** EOOH ***\n")
1201 (forward-line -1)
1202 (let ((temp (point)))
1203 (and (search-forward "\n\n" nil t)
1204 (delete-region temp (point))))
1205 (goto-char (point-min))
1206 (search-forward "\n*** EOOH ***\n")
1207 (narrow-to-region (point) (point-max)))
1208 (rmail-reformat-message (point-min) (point-max))))
1209 (rmail-highlight-headers))
1210 \f
1211 ;;;; *** Rmail Attributes and Keywords ***
1212
1213 ;; Make a string describing current message's attributes and keywords
1214 ;; and set it up as the name of a minor mode
1215 ;; so it will appear in the mode line.
1216 (defun rmail-display-labels ()
1217 (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
1218 (save-excursion
1219 (unwind-protect
1220 (progn
1221 (widen)
1222 (goto-char (rmail-msgbeg rmail-current-message))
1223 (forward-line 1)
1224 (if (looking-at "[01],")
1225 (progn
1226 (narrow-to-region (point) (progn (end-of-line) (point)))
1227 ;; Truly valid BABYL format requires a space before each
1228 ;; attribute or keyword name. Put them in if missing.
1229 (let (buffer-read-only)
1230 (goto-char (point-min))
1231 (while (search-forward "," nil t)
1232 (or (looking-at "[ ,]") (eobp)
1233 (insert " "))))
1234 (goto-char (point-max))
1235 (if (search-backward ",," nil 'move)
1236 (progn
1237 (if (> (point) (1+ (point-min)))
1238 (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
1239 (if (> (- (point-max) (point)) 2)
1240 (setq blurb
1241 (concat blurb
1242 ";"
1243 (buffer-substring (+ (point) 3)
1244 (1- (point-max)))))))))))
1245 ;; Note: we don't use save-restriction because that does not work right
1246 ;; if changes are made outside the saved restriction
1247 ;; before that restriction is restored.
1248 (narrow-to-region beg end)
1249 (set-marker beg nil)
1250 (set-marker end nil)))
1251 (while (string-match " +," blurb)
1252 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1253 (substring blurb (match-end 0)))))
1254 (while (string-match ", +" blurb)
1255 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1256 (substring blurb (match-end 0)))))
1257 (setq mode-line-process
1258 (concat " " rmail-current-message "/" rmail-total-messages
1259 blurb))))
1260
1261 ;; Turn an attribute of a message on or off according to STATE.
1262 ;; ATTR is the name of the attribute, as a string.
1263 ;; MSGNUM is message number to change; nil means current message.
1264 (defun rmail-set-attribute (attr state &optional msgnum)
1265 (let ((omax (point-max-marker))
1266 (omin (point-min-marker))
1267 (buffer-read-only nil))
1268 (or msgnum (setq msgnum rmail-current-message))
1269 (if (> msgnum 0)
1270 (unwind-protect
1271 (save-excursion
1272 (widen)
1273 (goto-char (+ 3 (rmail-msgbeg msgnum)))
1274 (let ((curstate
1275 (not
1276 (null (search-backward (concat ", " attr ",")
1277 (prog1 (point) (end-of-line)) t)))))
1278 (or (eq curstate (not (not state)))
1279 (if curstate
1280 (delete-region (point) (1- (match-end 0)))
1281 (beginning-of-line)
1282 (forward-char 2)
1283 (insert " " attr ","))))
1284 (if (string= attr "deleted")
1285 (rmail-set-message-deleted-p msgnum state)))
1286 ;; Note: we don't use save-restriction because that does not work right
1287 ;; if changes are made outside the saved restriction
1288 ;; before that restriction is restored.
1289 (narrow-to-region omin omax)
1290 (set-marker omin nil)
1291 (set-marker omax nil)
1292 (if (= msgnum rmail-current-message)
1293 (rmail-display-labels))))))
1294
1295 ;; Return t if the attributes/keywords line of msg number MSG
1296 ;; contains a match for the regexp LABELS.
1297 (defun rmail-message-labels-p (msg labels)
1298 (save-excursion
1299 (save-restriction
1300 (widen)
1301 (goto-char (rmail-msgbeg msg))
1302 (forward-char 3)
1303 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
1304 \f
1305 ;;;; *** Rmail Message Selection And Support ***
1306
1307 (defun rmail-msgend (n)
1308 (marker-position (aref rmail-message-vector (1+ n))))
1309
1310 (defun rmail-msgbeg (n)
1311 (marker-position (aref rmail-message-vector n)))
1312
1313 (defun rmail-widen-to-current-msgbeg (function)
1314 "Call FUNCTION with point at start of internal data of current message.
1315 Assumes that bounds were previously narrowed to display the message in Rmail.
1316 The bounds are widened enough to move point where desired, then narrowed
1317 again afterward.
1318
1319 FUNCTION may not change the visible text of the message, but it may
1320 change the invisible header text."
1321 (save-excursion
1322 (let ((obeg (- (point-max) (point-min))))
1323 (unwind-protect
1324 (progn
1325 (narrow-to-region (rmail-msgbeg rmail-current-message)
1326 (point-max))
1327 (goto-char (point-min))
1328 (funcall function))
1329 ;; Note: we don't use save-restriction because that does not work right
1330 ;; if changes are made outside the saved restriction
1331 ;; before that restriction is restored.
1332 ;; Here we assume that changes made by FUNCTION
1333 ;; occur before the visible region of the message.
1334 (narrow-to-region (- (point-max) obeg) (point-max))))))
1335
1336 (defun rmail-forget-messages ()
1337 (unwind-protect
1338 (if (vectorp rmail-message-vector)
1339 (let* ((i 0)
1340 (v rmail-message-vector)
1341 (n (length v)))
1342 (while (< i n)
1343 (move-marker (aref v i) nil)
1344 (setq i (1+ i)))))
1345 (setq rmail-message-vector nil)
1346 (setq rmail-deleted-vector nil)))
1347
1348 (defun rmail-maybe-set-message-counters ()
1349 (if (not (and rmail-deleted-vector
1350 rmail-message-vector
1351 rmail-current-message
1352 rmail-total-messages))
1353 (rmail-set-message-counters)))
1354
1355 (defun rmail-count-new-messages (&optional nomsg)
1356 (let* ((case-fold-search nil)
1357 (total-messages 0)
1358 (messages-head nil)
1359 (deleted-head nil))
1360 (or nomsg (message "Counting new messages..."))
1361 (goto-char (point-max))
1362 ;; Put at the end of messages-head
1363 ;; the entry for message N+1, which marks
1364 ;; the end of message N. (N = number of messages).
1365 (search-backward "\n\^_")
1366 (forward-char 1)
1367 (setq messages-head (list (point-marker)))
1368 (rmail-set-message-counters-counter (point-min))
1369 (setq rmail-current-message (1+ rmail-total-messages))
1370 (setq rmail-total-messages
1371 (+ rmail-total-messages total-messages))
1372 (setq rmail-message-vector
1373 (vconcat rmail-message-vector (cdr messages-head)))
1374 (aset rmail-message-vector
1375 rmail-current-message (car messages-head))
1376 (setq rmail-deleted-vector
1377 (concat rmail-deleted-vector deleted-head))
1378 (setq rmail-summary-vector
1379 (vconcat rmail-summary-vector (make-vector total-messages nil)))
1380 (goto-char (point-min))
1381 (or nomsg (message "Counting new messages...done (%d)" total-messages))))
1382
1383 (defun rmail-set-message-counters ()
1384 (rmail-forget-messages)
1385 (save-excursion
1386 (save-restriction
1387 (widen)
1388 (let* ((point-save (point))
1389 (total-messages 0)
1390 (messages-after-point)
1391 (case-fold-search nil)
1392 (messages-head nil)
1393 (deleted-head nil))
1394 (message "Counting messages...")
1395 (goto-char (point-max))
1396 ;; Put at the end of messages-head
1397 ;; the entry for message N+1, which marks
1398 ;; the end of message N. (N = number of messages).
1399 (search-backward "\n\^_" nil t)
1400 (if (/= (point) (point-max)) (forward-char 1))
1401 (setq messages-head (list (point-marker)))
1402 (rmail-set-message-counters-counter (min (point) point-save))
1403 (setq messages-after-point total-messages)
1404 (rmail-set-message-counters-counter)
1405 (setq rmail-total-messages total-messages)
1406 (setq rmail-current-message
1407 (min total-messages
1408 (max 1 (- total-messages messages-after-point))))
1409 (setq rmail-message-vector
1410 (apply 'vector (cons (point-min-marker) messages-head))
1411 rmail-deleted-vector (concat "D" deleted-head)
1412 rmail-summary-vector (make-vector rmail-total-messages nil))
1413 (message "Counting messages...done")))))
1414
1415 (defun rmail-set-message-counters-counter (&optional stop)
1416 (while (search-backward "\n\^_\^L\n" stop t)
1417 (forward-char 1)
1418 (setq messages-head (cons (point-marker) messages-head))
1419 (save-excursion
1420 (setq deleted-head
1421 (cons (if (search-backward ", deleted,"
1422 (prog1 (point)
1423 (forward-line 2))
1424 t)
1425 ?D ?\ )
1426 deleted-head)))
1427 (if (zerop (% (setq total-messages (1+ total-messages)) 20))
1428 (message "Counting messages...%d" total-messages))))
1429
1430 (defun rmail-beginning-of-message ()
1431 "Show current message starting from the beginning."
1432 (interactive)
1433 (rmail-show-message rmail-current-message))
1434
1435 (defun rmail-show-message (&optional n)
1436 "Show message number N (prefix argument), counting from start of file.
1437 If summary buffer is currently displayed, update current message there also."
1438 (interactive "p")
1439 (rmail-maybe-set-message-counters)
1440 (widen)
1441 (if (zerop rmail-total-messages)
1442 (progn (narrow-to-region (point-min) (1- (point-max)))
1443 (goto-char (point-min))
1444 (setq mode-line-process nil))
1445 (let (blurb)
1446 (if (not n)
1447 (setq n rmail-current-message)
1448 (cond ((<= n 0)
1449 (setq n 1
1450 rmail-current-message 1
1451 blurb "No previous message"))
1452 ((> n rmail-total-messages)
1453 (setq n rmail-total-messages
1454 rmail-current-message rmail-total-messages
1455 blurb "No following message"))
1456 (t
1457 (setq rmail-current-message n))))
1458 (let ((beg (rmail-msgbeg n))
1459 (end (rmail-msgend n)))
1460 (goto-char beg)
1461 (forward-line 1)
1462 (if (= (following-char) ?0)
1463 (progn
1464 (rmail-reformat-message beg end)
1465 (rmail-set-attribute "unseen" nil))
1466 (search-forward "\n*** EOOH ***\n" end t)
1467 (narrow-to-region (point) end))
1468 (goto-char (point-min))
1469 (rmail-display-labels)
1470 (rmail-highlight-headers)
1471 (if transient-mark-mode (deactivate-mark))
1472 (run-hooks 'rmail-show-message-hook)
1473 ;; If there is a summary buffer, try to move to this message
1474 ;; in that buffer. But don't complain if this message
1475 ;; is not mentioned in the summary.
1476 (if (rmail-summary-exists)
1477 (let ((curr-msg rmail-current-message))
1478 (rmail-select-summary
1479 (rmail-summary-goto-msg curr-msg t t))))
1480 (if blurb
1481 (message blurb))))))
1482
1483 ;; Find all occurrences of certain fields, and highlight them.
1484 (defun rmail-highlight-headers ()
1485 ;; Do this only if the system supports faces.
1486 (if (and (fboundp 'internal-find-face)
1487 rmail-highlighted-headers)
1488 (save-excursion
1489 (search-forward "\n\n" nil 'move)
1490 (save-restriction
1491 (narrow-to-region (point-min) (point))
1492 (let ((case-fold-search t)
1493 (inhibit-read-only t)
1494 ;; Highlight with boldface if that is available.
1495 ;; Otherwise use the `highlight' face.
1496 (face (or rmail-highlight-face
1497 (if (face-differs-from-default-p 'bold)
1498 'bold 'highlight)))
1499 ;; List of overlays to reuse.
1500 (overlays rmail-overlay-list))
1501 (goto-char (point-min))
1502 (while (re-search-forward rmail-highlighted-headers nil t)
1503 (skip-chars-forward " \t")
1504 (let ((beg (point))
1505 overlay)
1506 (while (progn (forward-line 1)
1507 (looking-at "[ \t]")))
1508 ;; Back up over newline, then trailing spaces or tabs
1509 (forward-char -1)
1510 (while (member (preceding-char) '(? ?\t))
1511 (forward-char -1))
1512 (if overlays
1513 ;; Reuse an overlay we already have.
1514 (progn
1515 (setq overlay (car overlays)
1516 overlays (cdr overlays))
1517 (overlay-put overlay 'face face)
1518 (move-overlay overlay beg (point)))
1519 ;; Make a new overlay and add it to
1520 ;; rmail-overlay-list.
1521 (setq overlay (make-overlay beg (point)))
1522 (overlay-put overlay 'face face)
1523 (setq rmail-overlay-list
1524 (cons overlay rmail-overlay-list))))))))))
1525
1526 (defun rmail-next-message (n)
1527 "Show following message whether deleted or not.
1528 With prefix arg N, moves forward N messages, or backward if N is negative."
1529 (interactive "p")
1530 (rmail-maybe-set-message-counters)
1531 (rmail-show-message (+ rmail-current-message n)))
1532
1533 (defun rmail-previous-message (n)
1534 "Show previous message whether deleted or not.
1535 With prefix arg N, moves backward N messages, or forward if N is negative."
1536 (interactive "p")
1537 (rmail-next-message (- n)))
1538
1539 (defun rmail-next-undeleted-message (n)
1540 "Show following non-deleted message.
1541 With prefix arg N, moves forward N non-deleted messages,
1542 or backward if N is negative.
1543
1544 Returns t if a new message is being shown, nil otherwise."
1545 (interactive "p")
1546 (rmail-maybe-set-message-counters)
1547 (let ((lastwin rmail-current-message)
1548 (current rmail-current-message))
1549 (while (and (> n 0) (< current rmail-total-messages))
1550 (setq current (1+ current))
1551 (if (not (rmail-message-deleted-p current))
1552 (setq lastwin current n (1- n))))
1553 (while (and (< n 0) (> current 1))
1554 (setq current (1- current))
1555 (if (not (rmail-message-deleted-p current))
1556 (setq lastwin current n (1+ n))))
1557 (if (/= lastwin rmail-current-message)
1558 (progn (rmail-show-message lastwin)
1559 t)
1560 (if (< n 0)
1561 (message "No previous nondeleted message"))
1562 (if (> n 0)
1563 (message "No following nondeleted message"))
1564 nil)))
1565
1566 (defun rmail-previous-undeleted-message (n)
1567 "Show previous non-deleted message.
1568 With prefix argument N, moves backward N non-deleted messages,
1569 or forward if N is negative."
1570 (interactive "p")
1571 (rmail-next-undeleted-message (- n)))
1572
1573 (defun rmail-first-message ()
1574 "Show first message in file."
1575 (interactive)
1576 (rmail-maybe-set-message-counters)
1577 (rmail-show-message 1))
1578
1579 (defun rmail-last-message ()
1580 "Show last message in file."
1581 (interactive)
1582 (rmail-maybe-set-message-counters)
1583 (rmail-show-message rmail-total-messages))
1584
1585 (defun rmail-what-message ()
1586 (let ((where (point))
1587 (low 1)
1588 (high rmail-total-messages)
1589 (mid (/ rmail-total-messages 2)))
1590 (while (> (- high low) 1)
1591 (if (>= where (rmail-msgbeg mid))
1592 (setq low mid)
1593 (setq high mid))
1594 (setq mid (+ low (/ (- high low) 2))))
1595 (if (>= where (rmail-msgbeg high)) high low)))
1596
1597 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
1598 (save-restriction
1599 (goto-char (rmail-msgbeg msg))
1600 (search-forward "\n*** EOOH ***\n")
1601 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
1602 (or (string-match recipients (or (mail-fetch-field "To") ""))
1603 (string-match recipients (or (mail-fetch-field "From") ""))
1604 (if (not primary-only)
1605 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
1606
1607 (defun rmail-message-regexp-p (msg regexp)
1608 "Return t, if for message number MSG, regexp REGEXP matches in the header."
1609 (goto-char (rmail-msgbeg msg))
1610 (let ((end
1611 (save-excursion
1612 (search-forward "*** EOOH ***" (point-max)) (point))))
1613 (re-search-forward regexp end t)))
1614
1615 (defun rmail-search-backward (regexp &optional n)
1616 "Show message containing next match for REGEXP.
1617 Prefix argument gives repeat count; negative argument means search
1618 backwards (through earlier messages).
1619 Interactively, empty argument means use same regexp used last time."
1620 (interactive
1621 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1622 (prompt
1623 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1624 regexp)
1625 (if rmail-search-last-regexp
1626 (setq prompt (concat prompt
1627 "(default "
1628 rmail-search-last-regexp
1629 ") ")))
1630 (setq regexp (read-string prompt))
1631 (cond ((not (equal regexp ""))
1632 (setq rmail-search-last-regexp regexp))
1633 ((not rmail-search-last-regexp)
1634 (error "No previous Rmail search string")))
1635 (list rmail-search-last-regexp
1636 (prefix-numeric-value current-prefix-arg))))
1637 (rmail-search regexp (- n)))
1638
1639 (defvar rmail-search-last-regexp nil)
1640 (defun rmail-search (regexp &optional n)
1641 "Show message containing next match for REGEXP.
1642 Prefix argument gives repeat count; negative argument means search
1643 backwards (through earlier messages).
1644 Interactively, empty argument means use same regexp used last time."
1645 (interactive
1646 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1647 (prompt
1648 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1649 regexp)
1650 (if rmail-search-last-regexp
1651 (setq prompt (concat prompt
1652 "(default "
1653 rmail-search-last-regexp
1654 ") ")))
1655 (setq regexp (read-string prompt))
1656 (cond ((not (equal regexp ""))
1657 (setq rmail-search-last-regexp regexp))
1658 ((not rmail-search-last-regexp)
1659 (error "No previous Rmail search string")))
1660 (list rmail-search-last-regexp
1661 (prefix-numeric-value current-prefix-arg))))
1662 (or n (setq n 1))
1663 (message "%sRmail search for %s..."
1664 (if (< n 0) "Reverse " "")
1665 regexp)
1666 (rmail-maybe-set-message-counters)
1667 (let ((omin (point-min))
1668 (omax (point-max))
1669 (opoint (point))
1670 win
1671 (reversep (< n 0))
1672 (msg rmail-current-message))
1673 (unwind-protect
1674 (progn
1675 (widen)
1676 (while (/= n 0)
1677 ;; Check messages one by one, advancing message number up or down
1678 ;; but searching forward through each message.
1679 (if reversep
1680 (while (and (null win) (> msg 1))
1681 (goto-char (rmail-msgbeg (setq msg (1- msg))))
1682 (setq win (re-search-forward
1683 regexp (rmail-msgend msg) t)))
1684 (while (and (null win) (< msg rmail-total-messages))
1685 (goto-char (rmail-msgbeg (setq msg (1+ msg))))
1686 (setq win (re-search-forward regexp (rmail-msgend msg) t))))
1687 (setq n (+ n (if reversep 1 -1)))))
1688 (if win
1689 (progn
1690 ;; If this is a reverse search and we found a message,
1691 ;; search backward thru this message to position point.
1692 (if reversep
1693 (progn
1694 (goto-char (rmail-msgend msg))
1695 (re-search-backward
1696 regexp (rmail-msgbeg msg) t)))
1697 (setq win (point))
1698 (rmail-show-message msg)
1699 (message "%sRmail search for %s...done"
1700 (if reversep "Reverse " "")
1701 regexp)
1702 (goto-char win))
1703 (goto-char opoint)
1704 (narrow-to-region omin omax)
1705 (ding)
1706 (message "Search failed: %s" regexp)))))
1707
1708 (defun rmail-search-backwards (regexp &optional n)
1709 "Show message containing previous match for REGEXP.
1710 Prefix argument gives repeat count; negative argument means search
1711 forward (through later messages).
1712 Interactively, empty argument means use same regexp used last time."
1713 (interactive
1714 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1715 (prompt
1716 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1717 regexp)
1718 (if rmail-search-last-regexp
1719 (setq prompt (concat prompt
1720 "(default "
1721 rmail-search-last-regexp
1722 ") ")))
1723 (setq regexp (read-string prompt))
1724 (cond ((not (equal regexp ""))
1725 (setq rmail-search-last-regexp regexp))
1726 ((not rmail-search-last-regexp)
1727 (error "No previous Rmail search string")))
1728 (list rmail-search-last-regexp
1729 (prefix-numeric-value current-prefix-arg))))
1730 (rmail-search regexp (- (or n -1))))
1731
1732 ;; Show the first message which has the `unseen' attribute.
1733 (defun rmail-first-unseen-message ()
1734 (rmail-maybe-set-message-counters)
1735 (let ((current 1)
1736 found)
1737 (save-restriction
1738 (widen)
1739 (while (and (not found) (< current rmail-total-messages))
1740 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
1741 (setq found current))
1742 (setq current (1+ current))))
1743 ;; Let the caller show the message.
1744 ;; (if found
1745 ;; (rmail-show-message found))
1746 found))
1747 \f
1748 ;;;; *** Rmail Message Deletion Commands ***
1749
1750 (defun rmail-message-deleted-p (n)
1751 (= (aref rmail-deleted-vector n) ?D))
1752
1753 (defun rmail-set-message-deleted-p (n state)
1754 (aset rmail-deleted-vector n (if state ?D ?\ )))
1755
1756 (defun rmail-delete-message ()
1757 "Delete this message and stay on it."
1758 (interactive)
1759 (rmail-set-attribute "deleted" t))
1760
1761 (defun rmail-undelete-previous-message ()
1762 "Back up to deleted message, select it, and undelete it."
1763 (interactive)
1764 (let ((msg rmail-current-message))
1765 (while (and (> msg 0)
1766 (not (rmail-message-deleted-p msg)))
1767 (setq msg (1- msg)))
1768 (if (= msg 0)
1769 (error "No previous deleted message")
1770 (if (/= msg rmail-current-message)
1771 (rmail-show-message msg))
1772 (rmail-set-attribute "deleted" nil)
1773 (if (rmail-summary-exists)
1774 (save-excursion
1775 (set-buffer rmail-summary-buffer)
1776 (rmail-summary-mark-undeleted msg)))
1777 (rmail-maybe-display-summary))))
1778
1779 (defun rmail-delete-forward (&optional backward)
1780 "Delete this message and move to next nondeleted one.
1781 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
1782 With prefix argument, delete and move backward.
1783
1784 Returns t if a new message is displayed after the delete, or nil otherwise."
1785 (interactive "P")
1786 (rmail-set-attribute "deleted" t)
1787 (let ((del-msg rmail-current-message))
1788 (if (rmail-summary-exists)
1789 (save-excursion
1790 (set-buffer rmail-summary-buffer)
1791 (rmail-summary-mark-deleted del-msg)))
1792 (prog1 (rmail-next-undeleted-message (if backward -1 1))
1793 (rmail-maybe-display-summary))))
1794
1795 (defun rmail-delete-backward ()
1796 "Delete this message and move to previous nondeleted one.
1797 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1798 (interactive)
1799 (rmail-delete-forward t))
1800
1801 (defun rmail-only-expunge ()
1802 "Actually erase all deleted messages in the file."
1803 (interactive)
1804 (message "Expunging deleted messages...")
1805 ;; Discard all undo records for this buffer.
1806 (or (eq buffer-undo-list t)
1807 (setq buffer-undo-list nil))
1808 (rmail-maybe-set-message-counters)
1809 (let* ((omax (- (buffer-size) (point-max)))
1810 (omin (- (buffer-size) (point-min)))
1811 (opoint (if (and (> rmail-current-message 0)
1812 (rmail-message-deleted-p rmail-current-message))
1813 0
1814 (- (point) (point-min))))
1815 (messages-head (cons (aref rmail-message-vector 0) nil))
1816 (messages-tail messages-head)
1817 ;; Don't make any undo records for the expunging.
1818 (buffer-undo-list t)
1819 (win))
1820 (unwind-protect
1821 (save-excursion
1822 (widen)
1823 (goto-char (point-min))
1824 (let ((counter 0)
1825 (number 1)
1826 (total rmail-total-messages)
1827 (new-message-number rmail-current-message)
1828 (new-summary nil)
1829 (buffer-read-only nil)
1830 (messages rmail-message-vector)
1831 (deleted rmail-deleted-vector)
1832 (summary rmail-summary-vector))
1833 (setq rmail-total-messages nil
1834 rmail-current-message nil
1835 rmail-message-vector nil
1836 rmail-deleted-vector nil
1837 rmail-summary-vector nil)
1838 (while (<= number total)
1839 (if (= (aref deleted number) ?D)
1840 (progn
1841 (delete-region
1842 (marker-position (aref messages number))
1843 (marker-position (aref messages (1+ number))))
1844 (move-marker (aref messages number) nil)
1845 (if (> new-message-number counter)
1846 (setq new-message-number (1- new-message-number))))
1847 (setq counter (1+ counter))
1848 (setq messages-tail
1849 (setcdr messages-tail
1850 (cons (aref messages number) nil)))
1851 (setq new-summary
1852 (cons (if (= counter number) (aref summary (1- number)))
1853 new-summary)))
1854 (if (zerop (% (setq number (1+ number)) 20))
1855 (message "Expunging deleted messages...%d" number)))
1856 (setq messages-tail
1857 (setcdr messages-tail
1858 (cons (aref messages number) nil)))
1859 (setq rmail-current-message new-message-number
1860 rmail-total-messages counter
1861 rmail-message-vector (apply 'vector messages-head)
1862 rmail-deleted-vector (make-string (1+ counter) ?\ )
1863 rmail-summary-vector (vconcat (nreverse new-summary))
1864 win t)))
1865 (message "Expunging deleted messages...done")
1866 (if (not win)
1867 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
1868 (rmail-show-message
1869 (if (zerop rmail-current-message) 1 nil))
1870 (forward-char opoint))))
1871
1872 (defun rmail-expunge ()
1873 "Erase deleted messages from Rmail file and summary buffer."
1874 (interactive)
1875 (rmail-only-expunge)
1876 (if (rmail-summary-exists)
1877 (rmail-select-summary
1878 (rmail-update-summary))))
1879 \f
1880 ;;;; *** Rmail Mailing Commands ***
1881
1882 (defun rmail-start-mail (&rest args)
1883 (if (and window-system rmail-mail-new-frame)
1884 (prog1
1885 (apply 'mail-other-frame args)
1886 (modify-frame-parameters (selected-frame)
1887 '((dedicated . t))))
1888 (apply 'mail-other-window args)))
1889
1890 (defun rmail-mail ()
1891 "Send mail in another window.
1892 While composing the message, use \\[mail-yank-original] to yank the
1893 original message into it."
1894 (interactive)
1895 (rmail-start-mail nil nil nil nil nil (current-buffer)))
1896
1897 (defun rmail-continue ()
1898 "Continue composing outgoing message previously being composed."
1899 (interactive)
1900 (rmail-start-mail t))
1901
1902 (defun rmail-reply (just-sender)
1903 "Reply to the current message.
1904 Normally include CC: to all other recipients of original message;
1905 prefix argument means ignore them. While composing the reply,
1906 use \\[mail-yank-original] to yank the original message into it."
1907 (interactive "P")
1908 (let (from reply-to cc subject date to message-id resent-reply-to)
1909 (save-excursion
1910 (save-restriction
1911 (widen)
1912 (goto-char (rmail-msgbeg rmail-current-message))
1913 (forward-line 1)
1914 (if (= (following-char) ?0)
1915 (narrow-to-region
1916 (progn (forward-line 2)
1917 (point))
1918 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
1919 'move)
1920 (point)))
1921 (narrow-to-region (point)
1922 (progn (search-forward "\n*** EOOH ***\n")
1923 (beginning-of-line) (point))))
1924 (setq resent-reply-to (mail-fetch-field "resent-reply-to" t)
1925 from (mail-fetch-field "from")
1926 reply-to (or resent-reply-to
1927 (mail-fetch-field "reply-to" nil t)
1928 from)
1929 cc (cond (just-sender nil)
1930 (resent-reply-to (mail-fetch-field "resent-cc" t))
1931 (t (mail-fetch-field "cc" nil t)))
1932 subject (or (and resent-reply-to
1933 (mail-fetch-field "resent-subject" t))
1934 (mail-fetch-field "subject"))
1935 date (or (and resent-reply-to
1936 (mail-fetch-field "resent-date" t))
1937 (mail-fetch-field "date"))
1938 to (cond (resent-reply-to
1939 (or (mail-fetch-field "resent-to" t)) "")
1940 ((mail-fetch-field "to" nil t))
1941 ;((mail-fetch-field "apparently-to")) ack gag barf
1942 (t ""))
1943 message-id (cond (resent-reply-to
1944 (mail-fetch-field "resent-message-id" t))
1945 ((mail-fetch-field "message-id"))))))
1946 (and (stringp subject)
1947 (or (string-match (concat "\\`" (regexp-quote rmail-reply-prefix))
1948 subject)
1949 (setq subject (concat rmail-reply-prefix subject))))
1950 (rmail-start-mail nil
1951 (mail-strip-quoted-names reply-to)
1952 subject
1953 (rmail-make-in-reply-to-field from date message-id)
1954 (if just-sender
1955 nil
1956 (let* ((cc-list (rmail-dont-reply-to
1957 (mail-strip-quoted-names
1958 (if (null cc) to (concat to ", " cc))))))
1959 (if (string= cc-list "") nil cc-list)))
1960 (current-buffer)
1961 (list (list '(lambda (buf msgnum)
1962 (save-excursion
1963 (set-buffer buf)
1964 (rmail-set-attribute "answered" t msgnum)))
1965 (current-buffer) rmail-current-message)))))
1966
1967 (defun rmail-make-in-reply-to-field (from date message-id)
1968 (cond ((not from)
1969 (if message-id
1970 message-id
1971 nil))
1972 (mail-use-rfc822
1973 (require 'rfc822)
1974 (let ((tem (car (rfc822-addresses from))))
1975 (if message-id
1976 (if (string-match
1977 (regexp-quote (if (string-match "@[^@]*\\'" tem)
1978 (substring tem 0 (match-beginning 0))
1979 tem))
1980 message-id)
1981 ;; Message-ID is sufficiently informative
1982 message-id
1983 (concat message-id " (" tem ")"))
1984 ;; Copy TEM, discarding text properties.
1985 (setq tem (copy-sequence tem))
1986 (set-text-properties 0 (length tem) nil tem)
1987 (setq tem (copy-sequence tem))
1988 ;; Use prin1 to fake RFC822 quoting
1989 (let ((field (prin1-to-string tem)))
1990 (if date
1991 (concat field "'s message of " date)
1992 field)))))
1993 ((let* ((foo "[^][\000-\037\177-\377()<>@,;:\\\" ]+")
1994 (bar "[^][\000-\037\177-\377()<>@,;:\\\"]+"))
1995 ;; Can't use format because format loses on \000 (unix *^&%*^&%$!!)
1996 (or (string-match (concat "\\`[ \t]*\\(" bar
1997 "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
1998 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
1999 from)
2000 (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
2001 bar "\\))[ \t]*\\'")
2002 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
2003 from)))
2004 (let ((start (match-beginning 1))
2005 (end (match-end 1)))
2006 ;; Trim whitespace which above regexp match allows
2007 (while (and (< start end)
2008 (memq (aref from start) '(?\t ?\ )))
2009 (setq start (1+ start)))
2010 (while (and (< start end)
2011 (memq (aref from (1- end)) '(?\t ?\ )))
2012 (setq end (1- end)))
2013 (let ((field (substring from start end)))
2014 (if date (setq field (concat "message from " field " on " date)))
2015 (if message-id
2016 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
2017 (concat message-id " (" field ")")
2018 field))))
2019 (t
2020 ;; If we can't kludge it simply, do it correctly
2021 (let ((mail-use-rfc822 t))
2022 (rmail-make-in-reply-to-field from date message-id)))))
2023
2024 (defun rmail-forward (resend)
2025 "Forward the current message to another user.
2026 With prefix argument, \"resend\" the message instead of forwarding it;
2027 see the documentation of `rmail-resend'."
2028 (interactive "P")
2029 (if resend
2030 (call-interactively 'rmail-resend)
2031 (let ((forward-buffer (current-buffer))
2032 (subject (concat "["
2033 (let ((from (or (mail-fetch-field "From")
2034 (mail-fetch-field ">From"))))
2035 (if from
2036 (concat (mail-strip-quoted-names from) ": ")
2037 ""))
2038 (or (mail-fetch-field "Subject") "")
2039 "]")))
2040 ;; If only one window, use it for the mail buffer.
2041 ;; Otherwise, use another window for the mail buffer
2042 ;; so that the Rmail buffer remains visible
2043 ;; and sending the mail will get back to it.
2044 (if (funcall (if (and (not rmail-mail-new-frame) (one-window-p t))
2045 (function mail)
2046 (function rmail-start-mail))
2047 nil nil subject nil nil nil
2048 (list (list (function (lambda (buf msgnum)
2049 (save-excursion
2050 (set-buffer buf)
2051 (rmail-set-attribute
2052 "forwarded" t msgnum))))
2053 (current-buffer)
2054 rmail-current-message)))
2055 (save-excursion
2056 ;; Insert after header separator--before signature if any.
2057 (goto-char (point-min))
2058 (search-forward-regexp
2059 (concat "^" (regexp-quote mail-header-separator) "$"))
2060 (forward-line 1)
2061 (insert "------- Start of forwarded message -------\n")
2062 (insert-buffer forward-buffer)
2063 (forward-line -1)
2064 (exchange-point-and-mark)
2065 (insert "------- End of forwarded message -------\n")
2066 (forward-line -1)
2067 (exchange-point-and-mark))))))
2068
2069 (defun rmail-resend (address &optional from comment mail-alias-file)
2070 "Resend current message to ADDRESSES.
2071 ADDRESSES should be a single address, a string consisting of several
2072 addresses separated by commas, or a list of addresses.
2073
2074 Optional FROM is the address to resend the message from, and
2075 defaults to the username of the person redistributing the message.
2076 Optional COMMENT is a string that will be inserted as a comment in the
2077 resent message.
2078 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
2079 typically for purposes of moderating a list."
2080 (interactive "sResend to: ")
2081 (require 'sendmail)
2082 (require 'mailalias)
2083 (if (not from) (setq from (user-login-name)))
2084 (let ((tembuf (generate-new-buffer " sendmail temp"))
2085 (mail-header-separator "")
2086 (case-fold-search nil)
2087 (mailbuf (current-buffer)))
2088 (unwind-protect
2089 (save-excursion
2090 ;;>> Copy message into temp buffer
2091 (set-buffer tembuf)
2092 (insert-buffer-substring mailbuf)
2093 (goto-char (point-min))
2094 ;; Delete any Sender field, since that's not specifyable.
2095 ; Only delete Sender fields in the actual header.
2096 (re-search-forward "^$" nil 'move)
2097 ; Using "while" here rather than "if" because some buggy mail
2098 ; software may have inserted multiple Sender fields.
2099 (while (re-search-backward "^Sender:" nil t)
2100 (let (beg)
2101 (setq beg (point))
2102 (forward-line 1)
2103 (while (looking-at "[ \t]")
2104 (forward-line 1))
2105 (delete-region beg (point))))
2106 ; Go back to the beginning of the buffer so the Resent- fields
2107 ; are inserted there.
2108 (goto-char (point-min))
2109 ;;>> Insert resent-from:
2110 (insert "Resent-From: " from "\n")
2111 (insert "Resent-Date: " (mail-rfc822-date) "\n")
2112 ;;>> Insert resent-to: and bcc if need be.
2113 (let ((before (point)))
2114 (if mail-self-blind
2115 (insert "Resent-Bcc: " (user-login-name) "\n"))
2116 (insert "Resent-To: " (if (stringp address)
2117 address
2118 (mapconcat 'identity address ",\n\t"))
2119 "\n")
2120 (save-excursion
2121 (expand-mail-aliases before (point))))
2122 ;;>> Set up comment, if any.
2123 (if (and (sequencep comment) (not (zerop (length comment))))
2124 (let ((before (point))
2125 after)
2126 (insert comment)
2127 (or (eolp) (insert "\n"))
2128 (setq after (point))
2129 (goto-char before)
2130 (while (< (point) after)
2131 (insert "Resent-Comment: ")
2132 (forward-line 1))))
2133 ;; Don't expand aliases in the destination fields
2134 ;; of the original message.
2135 (let (mail-aliases)
2136 (funcall send-mail-function)))
2137 (kill-buffer tembuf))
2138 (rmail-set-attribute "resent" t rmail-current-message)))
2139
2140 (defvar mail-unsent-separator
2141 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
2142 "^ *---+ +Returned message +---+ *$\\|"
2143 "^ *---+ +Original message +---+ *$\\|"
2144 "^ *--+ +begin message +--+ *$\\|"
2145 "^ *---+ +Original message follows +---+ *$\\|"
2146 "^|? *---+ +Message text follows: +---+ *|?$")
2147 "A regexp that matches the separator before the text of a failed message.")
2148
2149 (defun rmail-retry-failure ()
2150 "Edit a mail message which is based on the contents of the current message.
2151 For a message rejected by the mail system, extract the interesting headers and
2152 the body of the original message.
2153 The variable `mail-unsent-separator' should match the string that
2154 delimits the returned original message.
2155 The variable `rmail-retry-ignored-headers' is a regular expression
2156 specifying headers which should not be copied into the new message."
2157 (interactive)
2158 (require 'mail-utils)
2159 (let (mail-buffer bounce-start bounce-end resending)
2160 (save-excursion
2161 ;; Narrow down to just the quoted original message
2162 (rmail-beginning-of-message)
2163 (let ((case-fold-search t))
2164 (or (re-search-forward mail-unsent-separator nil t)
2165 (error "Cannot parse this as a failure message")))
2166 (save-restriction
2167 (let ((old-end (point-max)))
2168 ;; One message contained a few random lines before the old
2169 ;; message header. The first line of the message started with
2170 ;; two hyphens. A blank line follows these random lines.
2171 (skip-chars-forward "\n")
2172 (if (looking-at "^--")
2173 (progn
2174 (search-forward "\n\n")
2175 (skip-chars-forward "\n")))
2176 (beginning-of-line)
2177 (narrow-to-region (point) (point-max))
2178 (setq mail-buffer (current-buffer)
2179 bounce-start (point)
2180 bounce-end (point-max))
2181 (or (search-forward "\n\n" nil t)
2182 (error "Cannot find end of header in failed message")))))
2183 ;; Start sending a new message; default header fields from the original.
2184 ;; Turn off the usual actions for initializing the message body
2185 ;; because we want to get only the text from the failure message.
2186 (let (mail-signature mail-setup-hook)
2187 (if (rmail-start-mail nil nil nil nil nil mail-buffer)
2188 ;; Insert original text as initial text of new draft message.
2189 (progn
2190 (erase-buffer)
2191 (insert-buffer-substring mail-buffer bounce-start bounce-end)
2192 (goto-char (point-min))
2193 (rmail-clear-headers rmail-retry-ignored-headers)
2194 (rmail-clear-headers "^sender:")
2195 (goto-char (point-min))
2196 (save-restriction
2197 (search-forward "\n\n")
2198 (forward-line -1)
2199 (narrow-to-region (point-min) (point))
2200 (setq resending (mail-fetch-field "resent-to"))
2201 (if mail-self-blind
2202 (if resending
2203 (insert "Resent-Bcc: " (user-login-name) "\n")
2204 (insert "BCC: " (user-login-name) "\n"))))
2205 (insert mail-header-separator)
2206 (mail-position-on-field (if resending "Resent-To" "To") t)
2207 (set-buffer mail-buffer)
2208 (rmail-beginning-of-message))))))
2209
2210 (defun rmail-bury ()
2211 "Bury current Rmail buffer and its summary buffer."
2212 (interactive)
2213 ;; This let var was called rmail-buffer, but that interfered
2214 ;; with the buffer-local var used in summary buffers.
2215 (let ((buffer-to-bury (current-buffer)))
2216 (if (rmail-summary-exists)
2217 (let (window)
2218 (while (setq window (get-buffer-window rmail-summary-buffer))
2219 (set-window-buffer window (other-buffer rmail-summary-buffer)))
2220 (bury-buffer rmail-summary-buffer)))
2221 (switch-to-buffer (other-buffer (current-buffer)))
2222 (bury-buffer buffer-to-bury)))
2223
2224 (defun rmail-summary-exists ()
2225 "Non-nil iff in an RMAIL buffer and an associated summary buffer exists.
2226 In fact, the non-nil value returned is the summary buffer itself."
2227 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2228 rmail-summary-buffer))
2229
2230 (defun rmail-summary-displayed ()
2231 "t iff in RMAIL buffer and an associated summary buffer is displayed."
2232 (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
2233
2234 (defvar rmail-redisplay-summary nil
2235 "*Non-nil means Rmail should show the summary when it changes.
2236 This has an effect only if a summary buffer exists.")
2237
2238 (defvar rmail-summary-window-size nil
2239 "*Non-nil means specify the height for an Rmail summary window.")
2240
2241 ;; Put the summary buffer back on the screen, if user wants that.
2242 (defun rmail-maybe-display-summary ()
2243 (let ((selected (selected-window))
2244 window)
2245 ;; If requested, make sure the summary is displayed.
2246 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2247 rmail-redisplay-summary
2248 (if (get-buffer-window rmail-summary-buffer 0)
2249 ;; It's already in some frame; show that one.
2250 (let ((frame (window-frame
2251 (get-buffer-window rmail-summary-buffer 0))))
2252 (make-frame-visible frame)
2253 (raise-frame frame))
2254 (display-buffer rmail-summary-buffer)))
2255 ;; If requested, set the height of the summary window.
2256 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2257 rmail-summary-window-size
2258 (setq window (get-buffer-window rmail-summary-buffer))
2259 ;; Don't try to change the size if just one window in frame.
2260 (not (eq window (frame-root-window (window-frame window))))
2261 (unwind-protect
2262 (progn
2263 (select-window window)
2264 (enlarge-window (- rmail-summary-window-size
2265 (window-height))))
2266 (select-window selected)))))
2267 \f
2268 ;;;; *** Rmail Specify Inbox Files ***
2269
2270 (autoload 'set-rmail-inbox-list "rmailmsc"
2271 "Set the inbox list of the current RMAIL file to FILE-NAME.
2272 This may be a list of file names separated by commas.
2273 If FILE-NAME is empty, remove any inbox list."
2274 t)
2275
2276 ;;;; *** Rmail Commands for Labels ***
2277
2278 (autoload 'rmail-add-label "rmailkwd"
2279 "Add LABEL to labels associated with current RMAIL message.
2280 Completion is performed over known labels when reading."
2281 t)
2282
2283 (autoload 'rmail-kill-label "rmailkwd"
2284 "Remove LABEL from labels associated with current RMAIL message.
2285 Completion is performed over known labels when reading."
2286 t)
2287
2288 (autoload 'rmail-next-labeled-message "rmailkwd"
2289 "Show next message with LABEL. Defaults to last label used.
2290 With prefix argument N moves forward N messages with this label."
2291 t)
2292
2293 (autoload 'rmail-previous-labeled-message "rmailkwd"
2294 "Show previous message with LABEL. Defaults to last label used.
2295 With prefix argument N moves backward N messages with this label."
2296 t)
2297
2298 (autoload 'rmail-read-label "rmailkwd"
2299 "PROMPT and read with completion an Rmail message label."
2300 t)
2301
2302 ;;;; *** Rmail Edit Mode ***
2303
2304 (autoload 'rmail-edit-current-message "rmailedit"
2305 "Edit the contents of the current message"
2306 t)
2307
2308 ;;;; *** Rmail Sorting ***
2309
2310 (autoload 'rmail-sort-by-date "rmailsort"
2311 "Sort messages of current Rmail file by date.
2312 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2313
2314 (autoload 'rmail-sort-by-subject "rmailsort"
2315 "Sort messages of current Rmail file by subject.
2316 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2317
2318 (autoload 'rmail-sort-by-author "rmailsort"
2319 "Sort messages of current Rmail file by author.
2320 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2321
2322 (autoload 'rmail-sort-by-recipient "rmailsort"
2323 "Sort messages of current Rmail file by recipient.
2324 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2325
2326 (autoload 'rmail-sort-by-correspondent "rmailsort"
2327 "Sort messages of current Rmail file by other correspondent.
2328 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2329
2330 (autoload 'rmail-sort-by-lines "rmailsort"
2331 "Sort messages of current Rmail file by number of lines.
2332 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2333
2334 (autoload 'rmail-sort-by-keywords "rmailsort"
2335 "Sort messages of current Rmail file by labels.
2336 If prefix argument REVERSE is non-nil, sort them in reverse order.
2337 KEYWORDS is a comma-separated list of labels." t)
2338 \f
2339 ;;;; *** Rmail Summary Mode ***
2340
2341 (autoload 'rmail-summary "rmailsum"
2342 "Display a summary of all messages, one line per message."
2343 t)
2344
2345 (autoload 'rmail-summary-by-labels "rmailsum"
2346 "Display a summary of all messages with one or more LABELS.
2347 LABELS should be a string containing the desired labels, separated by commas."
2348 t)
2349
2350 (autoload 'rmail-summary-by-recipients "rmailsum"
2351 "Display a summary of all messages with the given RECIPIENTS.
2352 Normally checks the To, From and Cc fields of headers; but if PRIMARY-ONLY
2353 is non-nil (prefix arg given), only look in the To and From fields.
2354 RECIPIENTS is a string of regexps separated by commas."
2355 t)
2356
2357 (autoload 'rmail-summary-by-regexp "rmailsum"
2358 "Display a summary of all messages according to regexp REGEXP.
2359 If the regular expression is found in the header of the message
2360 \(including in the date and other lines, as well as the subject line),
2361 Emacs will list the header line in the RMAIL-summary."
2362 t)
2363
2364 (autoload 'rmail-summary-by-topic "rmailsum"
2365 "Display a summary of all messages with the given SUBJECT.
2366 Normally checks the Subject field of headers;
2367 but if WHOLE-MESSAGE is non-nil (prefix arg given),
2368 look in the whole message.
2369 SUBJECT is a string of regexps separated by commas."
2370 t)
2371 \f
2372 ;;;; *** Rmail output messages to files ***
2373
2374 (autoload 'rmail-output-to-rmail-file "rmailout"
2375 "Append the current message to an Rmail file named FILE-NAME.
2376 If the file does not exist, ask if it should be created.
2377 If file is being visited, the message is appended to the Emacs
2378 buffer visiting that file."
2379 t)
2380
2381 (autoload 'rmail-output "rmailout"
2382 "Append this message to Unix mail file named FILE-NAME."
2383 t)
2384
2385 ;;;; *** Rmail undigestification ***
2386
2387 (autoload 'undigestify-rmail-message "undigest"
2388 "Break up a digest message into its constituent messages.
2389 Leaves original message, deleted, before the undigestified messages."
2390 t)
2391
2392 (provide 'rmail)
2393
2394 ;;; rmail.el ends here