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