1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs.
3 ;; Copyright (C) 1985,86,87,88,93,94,95,96 Free Software Foundation, Inc.
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)
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
28 ;; New features include attribute and keyword support, message
29 ;; selection by dispatch table, summary by attributes and keywords,
30 ;; expunging by dispatch table, sticky options for file commands.
32 ;; Extended by Bob Weiner of Motorola
33 ;; New features include: rmail and rmail-summary buffers remain
34 ;; synchronized and key bindings basically operate the same way in both
35 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
36 ;; variable, and a bury rmail buffer (wipe) command.
41 ;; For Emacs V18 compatibility
42 (and (not (fboundp 'buffer-disable-undo))
43 (fboundp 'buffer-flush-undo)
44 (defalias 'buffer-disable-undo 'buffer-flush-undo))
46 ; These variables now declared in paths.el.
47 ;(defvar rmail-spool-directory "/usr/spool/mail/"
48 ; "This is the name of the directory used by the system mailer for\n\
49 ;delivering new mail. It's name should end with a slash.")
50 ;(defvar rmail-file-name
51 ; (expand-file-name "~/RMAIL")
54 (defvar rmail-movemail-program nil
55 "If non-nil, name of program for fetching new mail.")
57 (defvar rmail-pop-password nil
58 "*Password to use when reading mail from a POP server, if required.")
60 (defvar rmail-pop-password-required nil
61 "*Non-nil if a password is required when reading mail using POP.")
64 (defvar rmail-dont-reply-to-names nil "\
65 *A regexp specifying names to prune of reply to messages.
66 A value of nil means exclude your own name only.")
69 (defvar rmail-default-dont-reply-to-names "info-" "\
70 A regular expression specifying part of the value of the default value of
71 the variable `rmail-dont-reply-to-names', for when the user does not set
72 `rmail-dont-reply-to-names' explicitly. (The other part of the default
73 value is the user's name.)
74 It is useful to set this variable in the site customization file.")
77 (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:\\|^resent-date:\\|^nntp-posting-host:"
78 "*Regexp to match Header fields that Rmail should normally hide.")
81 (defvar rmail-displayed-headers nil
82 "*Regexp to match Header fields that Rmail should display.
83 If nil, display all header fields except those matched by
84 `rmail-ignored-headers'.")
87 (defvar rmail-retry-ignored-headers nil "\
88 *Headers that should be stripped when retrying a failed message.")
91 (defvar rmail-highlighted-headers "^From:\\|^Subject:" "\
92 *Regexp to match Header fields that Rmail should normally highlight.
93 A value of nil means don't highlight.
94 See also `rmail-highlight-face'.")
97 (defvar rmail-highlight-face nil "\
98 *Face used by Rmail for highlighting headers.")
101 (defvar rmail-delete-after-output nil "\
102 *Non-nil means automatically delete a message that is copied to a file.")
105 (defvar rmail-primary-inbox-list nil "\
106 *List of files which are inboxes for user's primary mail file `~/RMAIL'.
107 `nil' means the default, which is (\"/usr/spool/mail/$USER\")
108 \(the name varies depending on the operating system,
109 and the value of the environment variable MAIL overrides it).")
112 (defvar rmail-mail-new-frame nil
113 "*Non-nil means Rmail makes a new frame for composing outgoing mail.")
116 (defvar rmail-secondary-file-directory "~/"
117 "*Directory for additional secondary Rmail files.")
119 (defvar rmail-secondary-file-regexp "\\.xmail$"
120 "*Regexp for which files are secondary Rmail files.")
123 (defvar rmail-mode-hook nil
124 "List of functions to call when Rmail is invoked.")
127 (defvar rmail-get-new-mail-hook nil
128 "List of functions to call when Rmail has retrieved new mail.")
131 (defvar rmail-show-message-hook nil
132 "List of functions to call when Rmail displays a message.")
135 (defvar rmail-delete-message-hook nil
136 "List of functions to call when Rmail deletes a message.
137 When the hooks are called, the message has been marked deleted but is
138 still the current message in the Rmail buffer.")
140 ;; These may be altered by site-init.el to match the format of mmdf files
141 ;; delimiting used on a given host (delim1 and delim2 from the config
144 (defvar mmdf-delim1 "^\001\001\001\001\n"
145 "Regexp marking the start of an mmdf message")
146 (defvar mmdf-delim2 "^\001\001\001\001\n"
147 "Regexp marking the end of an mmdf message")
149 (defvar rmail-message-filter nil
150 "If non nil, a filter function for new messages in RMAIL.
151 Called with region narrowed to the message, including headers.")
153 (defvar rmail-reply-prefix "Re: "
154 "String to prepend to Subject line when replying to a message.")
156 ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:".
157 ;; This pattern should catch all the common variants.
158 (defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\^[0-9]+\\)?: *\\)*"
159 "Regexp to delete from Subject line before inserting rmail-reply-prefix.")
161 (defvar rmail-display-summary nil
162 "If non nil, the summary buffer is always displayed.")
164 (defvar rmail-mode-map nil)
166 (defvar rmail-inbox-list nil)
167 (defvar rmail-keywords nil)
169 ;; Message counters and markers. Deleted flags.
171 (defvar rmail-current-message nil)
172 (defvar rmail-total-messages nil)
173 (defvar rmail-message-vector nil)
174 (defvar rmail-deleted-vector nil)
176 (defvar rmail-overlay-list nil)
178 (defvar rmail-font-lock-keywords
180 (let* ((cite-prefix "A-Za-z") (cite-suffix (concat cite-prefix "0-9_.@-")))
182 '("^\\(From\\|Sender\\):" . font-lock-function-name-face)
183 '("^Reply-To:.*$" . font-lock-function-name-face)
184 '("^Subject:" . font-lock-comment-face)
185 '("^\\(To\\|Apparently-To\\|Cc\\):" . font-lock-keyword-face)
186 (cons (concat "^[ \t]*"
187 "\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
189 'font-lock-reference-face)
190 '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\|Date\\):.*$"
191 . font-lock-string-face))))
192 "Additional expressions to highlight in Rmail mode.")
194 ;; These are used by autoloaded rmail-summary.
196 (defvar rmail-summary-buffer nil)
197 (defvar rmail-summary-vector nil)
199 ;; `Sticky' default variables.
201 ;; Last individual label specified to a or k.
202 (defvar rmail-last-label nil)
203 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
204 (defvar rmail-last-multi-labels nil)
205 (defvar rmail-last-regexp nil)
206 (defvar rmail-default-file "~/xmail"
207 "*Default file name for \\[rmail-output].")
208 (defvar rmail-default-rmail-file "~/XMAIL"
209 "*Default file name for \\[rmail-output-to-rmail-file].")
211 ;;; Regexp matching the delimiter of messages in UNIX mail format
212 ;;; (UNIX From lines), minus the initial ^. Note that if you change
213 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
214 ;;; that knows the exact ordering of the \\( \\) subexpressions.
215 (defvar rmail-unix-mail-delimiter
216 (let ((time-zone-regexp
217 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
218 "\\|[-+]?[0-9][0-9][0-9][0-9]"
224 ;; Username, perhaps with a quoted section that can contain spaces.
227 "\\(\\|\".*\"[^ \n]*\\)"
231 ;; The time the message was sent.
232 "\\([^ \n]*\\) *" ; day of the week
233 "\\([^ \n]*\\) *" ; month
234 "\\([0-9]*\\) *" ; day of month
235 "\\([0-9:]*\\) *" ; time of day
237 ;; Perhaps a time zone, specified by an abbreviation, or by a
242 " [0-9][0-9]\\([0-9]*\\) *"
244 ;; On some systems the time zone can appear after the year, too.
248 "\\(remote from .*\\)?"
253 ;; Perform BODY in the summary buffer
254 ;; in such a way that its cursor is properly updated in its own window.
255 (defmacro rmail-select-summary (&rest body)
256 (` (let ((total rmail-total-messages))
257 (if (rmail-summary-displayed)
258 (let ((window (selected-window)))
262 (pop-to-buffer rmail-summary-buffer)
263 ;; rmail-total-messages is a buffer-local var
264 ;; in the rmail buffer.
265 ;; This way we make it available for the body
266 ;; even tho the rmail buffer is not current.
267 (let ((rmail-total-messages total))
269 (select-window window))))
271 (set-buffer rmail-summary-buffer)
272 (let ((rmail-total-messages total))
274 (rmail-maybe-display-summary))))
276 ;;;; *** Rmail Mode ***
279 (defun rmail (&optional file-name-arg)
280 "Read and edit incoming mail.
281 Moves messages into file named by `rmail-file-name' (a babyl format file)
282 and edits that file in RMAIL Mode.
283 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
285 May be called with file name as argument; then performs rmail editing on
286 that file, but does not copy any new mail into the file.
287 Interactively, if you supply a prefix argument, then you
288 have a chance to specify a file name with the minibuffer.
290 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
291 (interactive (if current-prefix-arg
292 (list (read-file-name "Run rmail on RMAIL file: "))))
293 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
294 (existed (get-file-buffer file-name)))
295 ;; Like find-file, but in the case where a buffer existed
296 ;; and the file was reverted, recompute the message-data.
297 (if (and existed (not (verify-visited-file-modtime existed)))
299 ;; Don't be confused by apparent local-variables spec
300 ;; in the last message in the RMAIL file.
301 (let ((enable-local-variables nil))
302 (find-file file-name))
303 (if (and (verify-visited-file-modtime existed)
304 (eq major-mode 'rmail-mode))
305 (progn (rmail-forget-messages)
306 (rmail-set-message-counters))))
307 (let ((enable-local-variables nil))
308 (find-file file-name)))
309 (if (eq major-mode 'rmail-edit-mode)
310 (error "Exit Rmail Edit mode before getting new mail."))
311 (if (and existed (> (buffer-size) 0))
312 ;; Buffer not new and not empty; ensure in proper mode, but that's all.
313 (or (eq major-mode 'rmail-mode)
316 ;; Convert all or part to Babyl file if possible.
318 (goto-char (point-max))
319 (if (null rmail-inbox-list)
321 (rmail-set-message-counters)
322 (rmail-show-message))))
323 (or (and (null file-name-arg)
324 (rmail-get-new-mail))
325 (rmail-show-message (rmail-first-unseen-message)))
326 (if rmail-display-summary (rmail-summary))
327 (rmail-construct-io-menu)))
329 ;; Given the value of MAILPATH, return a list of inbox file names.
330 ;; This is turned off because it is not clear that the user wants
331 ;; all these inboxes to feed into the primary rmail file.
332 ; (defun rmail-convert-mailpath (string)
334 ; (while (setq idx (string-match "[%:]" string))
335 ; (let ((this (substring string 0 idx)))
336 ; (setq string (substring string (1+ idx)))
337 ; (setq list (cons (if (string-match "%" this)
338 ; (substring this 0 (string-match "%" this))
343 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
344 ; will not cause emacs 18.55 problems.
346 (defun rmail-convert-file ()
349 (goto-char (point-min))
350 ;; If file doesn't start like a Babyl file,
351 ;; convert it to one, by adding a header and converting each message.
352 (cond ((looking-at "BABYL OPTIONS:"))
353 ((looking-at "Version: 5\n")
354 ;; Losing babyl file made by old version of Rmail.
355 ;; Just fix the babyl file header; don't make a new one,
356 ;; so we don't lose the Labels: file attribute, etc.
357 (let ((buffer-read-only nil))
358 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
359 ((equal (point-min) (point-max))
360 ;; Empty RMAIL file. Just insert the header.
361 (rmail-insert-rmail-file-header))
363 ;; Non-empty file in non-RMAIL format. Add header and convert.
365 (rmail-insert-rmail-file-header)))
366 ;; If file was not a Babyl file or if there are
367 ;; Unix format messages added at the end,
368 ;; convert file as necessary.
371 (goto-char (point-max))
372 (search-backward "\n\^_")
374 (looking-at "\n*From ")))
375 (let ((buffer-read-only nil))
376 (message "Converting to Babyl format...")
377 ;; If file needs conversion, convert it all,
378 ;; except for the BABYL header.
379 ;; (rmail-convert-to-babyl-format would delete the header.)
380 (goto-char (point-min))
381 (search-forward "\n\^_" nil t)
382 (narrow-to-region (point) (point-max))
383 (rmail-convert-to-babyl-format)
384 (message "Converting to Babyl format...done")))))
386 ;;; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
387 ;;; will not cause emacs 18.55 problems.
389 (defun rmail-insert-rmail-file-header ()
390 (let ((buffer-read-only nil))
391 (insert "BABYL OPTIONS: -*- rmail -*-
394 Note: This is the header of an rmail file.
395 Note: If you are seeing it in rmail,
396 Note: it means the file has no messages in it.\n\^_")))
400 (setq rmail-mode-map (make-keymap))
401 (suppress-keymap rmail-mode-map)
402 (define-key rmail-mode-map "a" 'rmail-add-label)
403 (define-key rmail-mode-map "b" 'rmail-bury)
404 (define-key rmail-mode-map "c" 'rmail-continue)
405 (define-key rmail-mode-map "d" 'rmail-delete-forward)
406 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward)
407 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
408 (define-key rmail-mode-map "f" 'rmail-forward)
409 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
410 (define-key rmail-mode-map "h" 'rmail-summary)
411 (define-key rmail-mode-map "i" 'rmail-input)
412 (define-key rmail-mode-map "j" 'rmail-show-message)
413 (define-key rmail-mode-map "k" 'rmail-kill-label)
414 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
415 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
416 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
417 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
418 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
419 (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
420 (define-key rmail-mode-map "m" 'rmail-mail)
421 (define-key rmail-mode-map "\em" 'rmail-retry-failure)
422 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
423 (define-key rmail-mode-map "\en" 'rmail-next-message)
424 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
425 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
426 (define-key rmail-mode-map "\C-o" 'rmail-output)
427 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
428 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
429 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
430 (define-key rmail-mode-map "q" 'rmail-quit)
431 (define-key rmail-mode-map "r" 'rmail-reply)
432 ;; I find I can't live without the default M-r command -- rms.
433 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
434 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
435 (define-key rmail-mode-map "\es" 'rmail-search)
436 (define-key rmail-mode-map "t" 'rmail-toggle-header)
437 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
438 (define-key rmail-mode-map "w" 'rmail-edit-current-message)
439 (define-key rmail-mode-map "x" 'rmail-expunge)
440 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
441 (define-key rmail-mode-map "<" 'rmail-first-message)
442 (define-key rmail-mode-map ">" 'rmail-last-message)
443 (define-key rmail-mode-map " " 'scroll-up)
444 (define-key rmail-mode-map "\177" 'scroll-down)
445 (define-key rmail-mode-map "?" 'describe-mode)
446 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
447 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
448 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
449 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
450 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
451 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
452 (define-key rmail-mode-map "\C-c\C-s\C-k" 'rmail-sort-by-keywords)
453 (define-key rmail-mode-map "\C-c\C-n" 'rmail-next-same-subject)
454 (define-key rmail-mode-map "\C-c\C-p" 'rmail-previous-same-subject)
457 (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
459 (define-key rmail-mode-map [menu-bar classify]
460 (cons "Classify" (make-sparse-keymap "Classify")))
462 (define-key rmail-mode-map [menu-bar classify input-menu]
465 (define-key rmail-mode-map [menu-bar classify output-menu]
468 (define-key rmail-mode-map [menu-bar classify output-inbox]
469 '("Output (inbox)..." . rmail-output))
471 (define-key rmail-mode-map [menu-bar classify output]
472 '("Output (Rmail)..." . rmail-output-to-rmail-file))
474 (define-key rmail-mode-map [menu-bar classify kill-label]
475 '("Kill Label..." . rmail-kill-label))
477 (define-key rmail-mode-map [menu-bar classify add-label]
478 '("Add Label..." . rmail-add-label))
480 (define-key rmail-mode-map [menu-bar summary]
481 (cons "Summary" (make-sparse-keymap "Summary")))
483 (define-key rmail-mode-map [menu-bar summary senders]
484 '("By Senders..." . rmail-summary-by-senders))
486 (define-key rmail-mode-map [menu-bar summary labels]
487 '("By Labels..." . rmail-summary-by-labels))
489 (define-key rmail-mode-map [menu-bar summary recipients]
490 '("By Recipients..." . rmail-summary-by-recipients))
492 (define-key rmail-mode-map [menu-bar summary topic]
493 '("By Topic..." . rmail-summary-by-topic))
495 (define-key rmail-mode-map [menu-bar summary regexp]
496 '("By Regexp..." . rmail-summary-by-regexp))
498 (define-key rmail-mode-map [menu-bar summary all]
499 '("All" . rmail-summary))
501 (define-key rmail-mode-map [menu-bar mail]
502 (cons "Mail" (make-sparse-keymap "Mail")))
504 (define-key rmail-mode-map [menu-bar mail rmail-get-new-mail]
505 '("Get New Mail" . rmail-get-new-mail))
507 (define-key rmail-mode-map [menu-bar mail lambda]
510 (define-key rmail-mode-map [menu-bar mail continue]
511 '("Continue" . rmail-continue))
513 (define-key rmail-mode-map [menu-bar mail resend]
514 '("Re-send..." . rmail-resend))
516 (define-key rmail-mode-map [menu-bar mail forward]
517 '("Forward" . rmail-forward))
519 (define-key rmail-mode-map [menu-bar mail retry]
520 '("Retry" . rmail-retry-failure))
522 (define-key rmail-mode-map [menu-bar mail reply]
523 '("Reply" . rmail-reply))
525 (define-key rmail-mode-map [menu-bar mail mail]
526 '("Mail" . rmail-mail))
528 (define-key rmail-mode-map [menu-bar delete]
529 (cons "Delete" (make-sparse-keymap "Delete")))
531 (define-key rmail-mode-map [menu-bar delete expunge/save]
532 '("Expunge/Save" . rmail-expunge-and-save))
534 (define-key rmail-mode-map [menu-bar delete expunge]
535 '("Expunge" . rmail-expunge))
537 (define-key rmail-mode-map [menu-bar delete undelete]
538 '("Undelete" . rmail-undelete-previous-message))
540 (define-key rmail-mode-map [menu-bar delete delete]
541 '("Delete" . rmail-delete-forward))
543 (define-key rmail-mode-map [menu-bar move]
544 (cons "Move" (make-sparse-keymap "Move")))
546 (define-key rmail-mode-map [menu-bar move search-back]
547 '("Search Back..." . rmail-search-backwards))
549 (define-key rmail-mode-map [menu-bar move search]
550 '("Search..." . rmail-search))
552 (define-key rmail-mode-map [menu-bar move previous]
553 '("Previous Nondeleted" . rmail-previous-undeleted-message))
555 (define-key rmail-mode-map [menu-bar move next]
556 '("Next Nondeleted" . rmail-next-undeleted-message))
558 (define-key rmail-mode-map [menu-bar move last]
559 '("Last" . rmail-last-message))
561 (define-key rmail-mode-map [menu-bar move first]
562 '("First" . rmail-first-message))
564 (define-key rmail-mode-map [menu-bar move previous]
565 '("Previous" . rmail-previous-message))
567 (define-key rmail-mode-map [menu-bar move next]
568 '("Next" . rmail-next-message))
570 ;; Rmail mode is suitable only for specially formatted data.
571 (put 'rmail-mode 'mode-class 'special)
573 (defun rmail-mode-kill-summary ()
574 (if rmail-summary-buffer (kill-buffer rmail-summary-buffer)))
578 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
579 All normal editing commands are turned off.
580 Instead, these commands are available:
582 \\[rmail-beginning-of-message] Move point to front of this message (same as \\[beginning-of-buffer]).
583 \\[scroll-up] Scroll to next screen of this message.
584 \\[scroll-down] Scroll to previous screen of this message.
585 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
586 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
587 \\[rmail-next-message] Move to Next message whether deleted or not.
588 \\[rmail-previous-message] Move to Previous message whether deleted or not.
589 \\[rmail-first-message] Move to the first message in Rmail file.
590 \\[rmail-last-message] Move to the last message in Rmail file.
591 \\[rmail-show-message] Jump to message specified by numeric position in file.
592 \\[rmail-search] Search for string and show message it is found in.
593 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
594 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
595 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
596 till a deleted message is found.
597 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
598 \\[rmail-expunge] Expunge deleted messages.
599 \\[rmail-expunge-and-save] Expunge and save the file.
600 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
601 \\[save-buffer] Save without expunging.
602 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
603 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
604 \\[rmail-continue] Continue composing outgoing message started before.
605 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
606 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
607 \\[rmail-forward] Forward this message to another user.
608 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
609 \\[rmail-output] Output this message to a Unix-format mail file (append it).
610 \\[rmail-input] Input Rmail file. Run Rmail on that file.
611 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
612 \\[rmail-kill-label] Kill label. Remove a label from current message.
613 \\[rmail-next-labeled-message] Move to Next message with specified label
614 (label defaults to last one specified).
615 Standard labels: filed, unseen, answered, forwarded, deleted.
616 Any other label is present only if you add it with \\[rmail-add-label].
617 \\[rmail-previous-labeled-message] Move to Previous message with specified label
618 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
619 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
620 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
621 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
622 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
623 \\[rmail-toggle-header] Toggle display of complete header."
626 (rmail-set-message-counters)
627 (rmail-show-message rmail-total-messages))
629 (defun rmail-mode-2 ()
630 (kill-all-local-variables)
633 (run-hooks 'rmail-mode-hook))
635 (defun rmail-mode-1 ()
636 (setq major-mode 'rmail-mode)
637 (setq mode-name "RMAIL")
638 (setq buffer-read-only t)
639 ;; No need to auto save RMAIL files in normal circumstances
640 ;; because they contain no info except attribute changes
641 ;; and deletion of messages.
642 ;; The one exception is when messages are copied into an Rmail mode buffer.
643 ;; rmail-output-to-rmail-file enables auto save when you do that.
644 (setq buffer-auto-save-file-name nil)
645 (if (boundp 'mode-line-modified)
646 (setq mode-line-modified "--- ")
647 (setq mode-line-format
648 (cons "--- " (cdr (default-value 'mode-line-format)))))
649 (use-local-map rmail-mode-map)
650 (set-syntax-table text-mode-syntax-table)
651 (setq local-abbrev-table text-mode-abbrev-table))
653 (defun rmail-variables ()
654 (make-local-variable 'revert-buffer-function)
655 (setq revert-buffer-function 'rmail-revert)
656 (make-local-variable 'font-lock-defaults)
657 (setq font-lock-defaults
658 '(rmail-font-lock-keywords t nil nil nil
659 (font-lock-fontify-buffer-function . rmail-fontify-buffer-function)
660 (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function)
661 (font-lock-inhibit-thing-lock . (lazy-lock-mode fast-lock-mode))))
662 (make-local-variable 'rmail-last-label)
663 (make-local-variable 'rmail-last-regexp)
664 (make-local-variable 'rmail-deleted-vector)
665 (make-local-variable 'rmail-summary-buffer)
666 (make-local-variable 'rmail-summary-vector)
667 (make-local-variable 'rmail-current-message)
668 (make-local-variable 'rmail-total-messages)
669 (make-local-variable 'require-final-newline)
670 (setq require-final-newline nil)
671 (make-local-variable 'rmail-overlay-list)
672 (setq rmail-overlay-list nil)
673 (make-local-variable 'version-control)
674 (setq version-control 'never)
675 (make-local-variable 'kill-buffer-hook)
676 (add-hook 'kill-buffer-hook 'rmail-mode-kill-summary)
677 (make-local-variable 'file-precious-flag)
678 (setq file-precious-flag t)
679 (make-local-variable 'rmail-message-vector)
680 (make-local-variable 'rmail-inbox-list)
681 (setq rmail-inbox-list (rmail-parse-file-inboxes))
682 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
683 (and (null rmail-inbox-list)
684 (or (equal buffer-file-name (expand-file-name rmail-file-name))
685 (equal buffer-file-truename
686 (abbreviate-file-name (file-truename rmail-file-name))))
687 (setq rmail-inbox-list
688 (or rmail-primary-inbox-list
689 (list (or (getenv "MAIL")
690 (concat rmail-spool-directory
691 (user-login-name)))))))
692 (make-local-variable 'rmail-keywords)
693 ;; this gets generated as needed
694 (setq rmail-keywords nil))
696 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
697 (defun rmail-revert (arg noconfirm)
698 (let ((revert-buffer-function (default-value 'revert-buffer-function)))
699 ;; Call our caller again, but this time it does the default thing.
700 (if (revert-buffer arg noconfirm)
701 ;; If the user said "yes", and we changed something,
702 ;; reparse the messages.
705 (goto-char (point-max))
708 ;; Return a list of files from this buffer's Mail: option.
709 ;; Does not assume that messages have been parsed.
710 ;; Just returns nil if buffer does not look like Babyl format.
711 (defun rmail-parse-file-inboxes ()
716 (cond ((looking-at "BABYL OPTIONS:")
717 (search-forward "\n\^_" nil 'move)
718 (narrow-to-region 1 (point))
720 (if (search-forward "\nMail:" nil t)
722 (narrow-to-region (point) (progn (end-of-line) (point)))
723 (goto-char (point-min))
724 (mail-parse-comma-list))))))))
726 (defun rmail-expunge-and-save ()
727 "Expunge and save RMAIL file."
731 (if (rmail-summary-exists)
732 (rmail-select-summary (set-buffer-modified-p nil))))
737 (rmail-expunge-and-save)
738 ;; Don't switch to the summary buffer even if it was recently visible.
739 (if rmail-summary-buffer
741 (replace-buffer-in-windows rmail-summary-buffer)
742 (bury-buffer rmail-summary-buffer)))
743 (let ((obuf (current-buffer)))
744 (replace-buffer-in-windows obuf)
748 "Bury current Rmail buffer and its summary buffer."
750 ;; This let var was called rmail-buffer, but that interfered
751 ;; with the buffer-local var used in summary buffers.
752 (let ((buffer-to-bury (current-buffer)))
753 (if (rmail-summary-exists)
755 (while (setq window (get-buffer-window rmail-summary-buffer))
756 (set-window-buffer window (other-buffer rmail-summary-buffer)))
757 (bury-buffer rmail-summary-buffer)))
758 (switch-to-buffer (other-buffer (current-buffer)))
759 (bury-buffer buffer-to-bury)))
761 (defun rmail-duplicate-message ()
762 "Create a duplicated copy of the current message.
763 The duplicate copy goes into the Rmail file just after the
767 (let ((buffer-read-only nil)
768 (number rmail-current-message)
769 (string (buffer-substring (rmail-msgbeg rmail-current-message)
770 (rmail-msgend rmail-current-message))))
771 (goto-char (rmail-msgend rmail-current-message))
773 (rmail-forget-messages)
774 (rmail-show-message number)
775 (message "Message duplicated")))
778 (defun rmail-input (filename)
779 "Run Rmail on file FILENAME."
780 (interactive "FRun rmail on RMAIL file: ")
783 ;; Return a list of file names for all files in or under START
784 ;; whose names match rmail-secondary-file-regexp.
785 ;; This includes START itself, if that name matches.
786 ;; But normally START is a directory.
787 (defun rmail-find-all-files (start)
788 (if (file-accessible-directory-p start)
790 (let ((files (directory-files start t
791 rmail-secondary-file-regexp t))
795 (setq file (car files))
796 (setq files (cdr files))
797 (or (member (file-name-nondirectory start) '("." ".."))
799 (rmail-find-all-files file)
801 ;; Sort here instead of in directory-files
802 ;; because this list is usually much shorter.
804 (let ((case-fold-search nil))
805 (if (string-match rmail-secondary-file-regexp start)
806 (list (file-name-nondirectory start))))))
808 (defun rmail-list-to-menu (menu-name l action &optional full-name)
809 (let ((menu (make-sparse-keymap menu-name)))
811 (function (lambda (item)
816 (rmail-list-to-menu (car item) (cdr item)
819 (concat full-name "/"
822 (setq name (car item)))
826 (list 'lambda () '(interactive)
830 (concat full-name "/" item)
832 rmail-secondary-file-directory))))))
833 (define-key menu (vector (intern name))
834 (cons name command)))))
838 ;; This command is always "disabled" when it appears in a menu.
839 (put 'rmail-disable-menu 'menu-enable ''nil)
841 (defun rmail-construct-io-menu ()
842 (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
845 (define-key rmail-mode-map [menu-bar classify input-menu]
846 (cons "Input Rmail File"
847 (rmail-list-to-menu "Input Rmail File"
850 (define-key rmail-mode-map [menu-bar classify output-menu]
851 (cons "Output Rmail File"
852 (rmail-list-to-menu "Output Rmail File"
854 'rmail-output-to-rmail-file))))
856 (define-key rmail-mode-map [menu-bar classify input-menu]
857 '("Input Rmail File" . rmail-disable-menu))
858 (define-key rmail-mode-map [menu-bar classify output-menu]
859 '("Output Rmail File" . rmail-disable-menu)))))
862 ;;;; *** Rmail input ***
864 ;; RLK feature not added in this version:
865 ;; argument specifies inbox file or files in various ways.
867 (defun rmail-get-new-mail (&optional file-name)
868 "Move any new mail from this RMAIL file's inbox files.
869 The inbox files can be specified with the file's Mail: option. The
870 variable `rmail-primary-inbox-list' specifies the inboxes for your
871 primary RMAIL file if it has no Mail: option. By default, this is
872 your /usr/spool/mail/$USER.
874 You can also specify the file to get new mail from. In this case, the
875 file of new mail is not changed or deleted. Noninteractively, you can
876 pass the inbox file name as an argument. Interactively, a prefix
877 argument causes us to read a file name and use that file as the inbox.
879 This function runs `rmail-get-new-mail-hook' before saving the updated file.
880 It returns t if it got any new messages."
882 (list (if current-prefix-arg
883 (read-file-name "Get new mail from file: "))))
884 ;; If the disk file has been changed from under us,
885 ;; revert to it before we get new mail.
886 (or (verify-visited-file-modtime (current-buffer))
887 (find-file (buffer-file-name)))
888 (rmail-maybe-set-message-counters)
890 ;; Get rid of all undo records for this buffer.
891 (or (eq buffer-undo-list t)
892 (setq buffer-undo-list nil))
894 (let ((opoint (point))
897 ;; If buffer has not changed yet, and has not been saved yet,
898 ;; don't replace the old backup file now.
899 (make-backup-files (and make-backup-files (buffer-modified-p)))
900 (buffer-read-only nil)
901 ;; Don't make undo records for what we do in getting mail.
902 (buffer-undo-list t))
903 (goto-char (point-max))
904 (skip-chars-backward " \t\n") ; just in case of brain damage
905 (delete-region (point) (point-max)) ; caused by require-final-newline
908 (narrow-to-region (point) (point))
909 ;; Read in the contents of the inbox files,
910 ;; renaming them as necessary,
911 ;; and adding to the list of files to delete eventually.
913 (rmail-insert-inbox-text (list file-name) nil)
914 (setq delete-files (rmail-insert-inbox-text rmail-inbox-list t)))
915 ;; Scan the new text and convert each message to babyl format.
916 (goto-char (point-min))
918 (setq new-messages (rmail-convert-to-babyl-format)))
919 (or (zerop new-messages)
922 (search-backward "\n\^_" nil t)
923 (narrow-to-region (point) (point-max))
924 (goto-char (1+ (point-min)))
925 (rmail-count-new-messages)
926 (run-hooks 'rmail-get-new-mail-hook)
928 ;; Delete the old files, now that babyl file is saved.
931 ;; First, try deleting.
933 (delete-file (car delete-files))
935 ;; If we can't delete it, truncate it.
936 (write-region (point) (point) (car delete-files))))
938 (setq delete-files (cdr delete-files)))))
939 (if (= new-messages 0)
940 (progn (goto-char opoint)
941 (if (or file-name rmail-inbox-list)
942 (message "(No new mail has arrived)"))
944 (if (rmail-summary-exists)
945 (rmail-select-summary
946 (rmail-update-summary)))
947 (message "%d new message%s read"
948 new-messages (if (= 1 new-messages) "" "s"))
949 ;; Move to the first new message
950 ;; unless we have other unseen messages before it.
951 (rmail-show-message (rmail-first-unseen-message))
952 (run-hooks 'rmail-after-get-new-mail-hook)
954 ;; Don't leave the buffer screwed up if we get a disk-full error.
955 (rmail-show-message)))
957 (defun rmail-insert-inbox-text (files renamep)
958 (let (file tofile delete-files movemail popmail)
960 (setq file (file-truename
961 (expand-file-name (substitute-in-file-name (car files))))
962 tofile (expand-file-name
963 ;; Generate name to move to from inbox name,
964 ;; in case of multiple inboxes that need moving.
965 (concat ".newmail-" (file-name-nondirectory file))
966 ;; Use the directory of this rmail file
967 ;; because it's a nuisance to use the homedir
968 ;; if that is on a full disk and this rmail
971 (expand-file-name buffer-file-name))))
972 ;; Always use movemail to rename the file,
973 ;; since there can be mailboxes in various directories.
975 ;;; ;; If getting from mail spool directory,
976 ;;; ;; use movemail to move rather than just renaming,
977 ;;; ;; so as to interlock with the mailer.
978 ;;; (setq movemail (string= file
980 ;;; (concat rmail-spool-directory
981 ;;; (file-name-nondirectory file)))))
982 (setq popmail (string-match "^po:" (file-name-nondirectory file)))
983 (if popmail (setq file (file-name-nondirectory file)
987 ;; On some systems, /usr/spool/mail/foo is a directory
988 ;; and the actual inbox is /usr/spool/mail/foo/foo.
989 (if (file-directory-p file)
990 (setq file (expand-file-name (user-login-name)
993 (if (and rmail-pop-password-required (not rmail-pop-password))
994 (setq rmail-pop-password
996 (format "Password for %s: "
997 (substring file (+ popmail 3))))))
998 (if (eq system-type 'windows-nt)
999 ;; cannot have "po:" in file name
1002 (concat ".newmail-pop-" (substring file (+ popmail 3)))
1003 (file-name-directory
1004 (expand-file-name buffer-file-name)))))
1005 (message "Getting mail from post office ..."))
1006 ((and (file-exists-p tofile)
1007 (/= 0 (nth 7 (file-attributes tofile))))
1008 (message "Getting mail from %s..." tofile))
1009 ((and (file-exists-p file)
1010 (/= 0 (nth 7 (file-attributes file))))
1011 (message "Getting mail from %s..." file)))
1012 ;; Set TOFILE if have not already done so, and
1013 ;; rename or copy the file FILE to TOFILE if and as appropriate.
1014 (cond ((not renamep)
1016 ((or (file-exists-p tofile) (and (not popmail)
1017 (not (file-exists-p file))))
1019 ((and (not movemail) (not popmail))
1020 ;; Try copying. If that fails (perhaps no space),
1023 (copy-file file tofile nil)
1025 ;; Third arg is t so we can replace existing file TOFILE.
1026 (rename-file file tofile t)))
1027 ;; Make the real inbox file empty.
1028 ;; Leaving it deleted could cause lossage
1029 ;; because mailers often won't create the file.
1031 (write-region (point) (point) file)
1037 (setq errors (generate-new-buffer " *rmail loss*"))
1038 (buffer-disable-undo errors)
1039 (if rmail-pop-password
1041 (or rmail-movemail-program
1042 (expand-file-name "movemail" exec-directory))
1043 nil errors nil file tofile rmail-pop-password)
1045 (or rmail-movemail-program
1046 (expand-file-name "movemail" exec-directory))
1047 nil errors nil file tofile))
1048 (if (not (buffer-modified-p errors))
1049 ;; No output => movemail won
1052 (subst-char-in-region (point-min) (point-max)
1054 (goto-char (point-max))
1055 (skip-chars-backward " \t")
1056 (delete-region (point) (point-max))
1057 (goto-char (point-min))
1058 (if (looking-at "movemail: ")
1059 (delete-region (point-min) (match-end 0)))
1061 (message "movemail: %s"
1062 (buffer-substring (point-min)
1066 (if errors (kill-buffer errors))))))
1067 ;; At this point, TOFILE contains the name to read:
1068 ;; Either the alternate name (if we renamed)
1069 ;; or the actual inbox (if not renaming).
1070 (if (file-exists-p tofile)
1072 (goto-char (point-max))
1073 (setq size (nth 1 (insert-file-contents tofile)))
1074 (goto-char (point-max))
1075 (or (= (preceding-char) ?\n)
1078 (setq delete-files (cons tofile delete-files))))
1080 (setq files (cdr files)))
1083 (defun rmail-read-passwd (prompt &optional default)
1084 "Read a password, echoing `.' for each character typed.
1085 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
1086 Optional DEFAULT is password to start with."
1087 (let ((pass (if default default ""))
1090 (cursor-in-echo-area t))
1091 (while (progn (message "%s%s"
1093 (make-string (length pass) ?.))
1094 (setq c (read-char))
1095 (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
1098 (if (and (/= c ?\b) (/= c ?\177))
1099 (setq pass (concat pass (char-to-string c)))
1100 (if (> (length pass) 0)
1101 (setq pass (substring pass 0 -1))))))
1106 ;; the rmail-break-forwarded-messages feature is not implemented
1107 (defun rmail-convert-to-babyl-format ()
1108 (let ((count 0) start
1109 (case-fold-search nil)
1110 (invalid-input-resync
1111 (function (lambda ()
1112 (message "Invalid Babyl format in inbox!")
1114 ;; Try to get back in sync with a real message.
1115 (if (re-search-forward
1116 (concat mmdf-delim1 "\\|^From") nil t)
1118 (goto-char (point-max)))))))
1119 (goto-char (point-min))
1122 (cond ((looking-at "BABYL OPTIONS:");Babyl header
1123 (if (search-forward "\n\^_" nil t)
1124 ;; If we find the proper terminator, delete through there.
1125 (delete-region (point-min) (point))
1126 (funcall invalid-input-resync)
1127 (delete-region (point-min) (point))))
1128 ;; Babyl format message
1130 (or (search-forward "\n\^_" nil t)
1131 (funcall invalid-input-resync))
1132 (setq count (1+ count))
1133 ;; Make sure there is no extra white space after the ^_
1134 ;; at the end of the message.
1135 ;; Narrowing will make sure that whatever follows the junk
1136 ;; will be treated properly.
1137 (delete-region (point)
1139 (skip-chars-forward " \t\n")
1141 (narrow-to-region (point) (point-max)))
1143 ((let ((case-fold-search t))
1144 (looking-at mmdf-delim1))
1145 (let ((case-fold-search t))
1146 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
1147 (setq start (point))
1148 (re-search-forward mmdf-delim2 nil t)
1149 (replace-match "\^_"))
1152 (narrow-to-region start (1- (point)))
1153 (goto-char (point-min))
1154 (while (search-forward "\n\^_" nil t); single char "\^_"
1155 (replace-match "\n^_")))); 2 chars: "^" and "_"
1156 (narrow-to-region (point) (point-max))
1157 (setq count (1+ count)))
1159 ((looking-at "^From ")
1160 (setq start (point))
1161 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
1162 (rmail-nuke-pinhead-header)
1163 ;; If this message has a Content-Length field,
1164 ;; skip to the end of the contents.
1165 (let* ((header-end (save-excursion
1166 (and (re-search-forward "\n\n" nil t)
1168 (case-fold-search t)
1170 ;; Get the numeric value from the Content-Length field.
1172 ;; Back up to end of prev line,
1173 ;; in case the Content-Length field comes first.
1175 (and (search-forward "\ncontent-length: "
1178 (eol (progn (end-of-line) (point))))
1179 (string-to-int (buffer-substring beg eol)))))))
1181 (if (and (natnump size)
1182 (<= (+ header-end size) (point-max))
1183 ;; Make sure this would put us at a position
1184 ;; that we could continue from.
1186 (goto-char (+ header-end size))
1187 (skip-chars-forward "\n")
1189 (and (looking-at "BABYL OPTIONS:")
1190 (search-forward "\n\^_" nil t))
1191 (and (looking-at "\^L")
1192 (search-forward "\n\^_" nil t))
1193 (let ((case-fold-search t))
1194 (looking-at mmdf-delim1))
1195 (looking-at "From "))))
1196 (goto-char (+ header-end size))
1197 (message "Ignoring invalid Content-Length field")
1200 (if (re-search-forward
1201 (concat "^[\^_]?\\("
1202 rmail-unix-mail-delimiter
1205 "^BABYL OPTIONS:\\|"
1206 "\^L\n[01],\\)") nil t)
1207 (goto-char (match-beginning 1))
1208 (goto-char (point-max)))
1209 (setq count (1+ count))
1212 (narrow-to-region start (point))
1213 (goto-char (point-min))
1214 (while (search-forward "\n\^_" nil t); single char
1215 (replace-match "\n^_")))); 2 chars: "^" and "_"
1217 (narrow-to-region (point) (point-max)))
1219 ;; This kludge is because some versions of sendmail.el
1220 ;; insert an extra newline at the beginning that shouldn't
1221 ;; be there. sendmail.el has been fixed, but old versions
1222 ;; may still be in use. -- rms, 7 May 1993.
1223 ((eolp) (delete-char 1))
1224 (t (error "Cannot convert to babyl format")))))
1227 ;; Delete the "From ..." line, creating various other headers with
1228 ;; information from it if they don't already exist. Now puts the
1229 ;; original line into a mail-from: header line for debugging and for
1230 ;; use by the rmail-output function.
1231 (defun rmail-nuke-pinhead-header ()
1234 (let ((start (point))
1237 (search-forward "\n\n")
1239 (goto-char (point-max))
1243 (narrow-to-region start end)
1244 (let ((case-fold-search t))
1246 (setq has-from (search-forward "\nFrom:" nil t))
1248 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
1250 (let ((case-fold-search nil))
1251 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
1255 ;; Keep and reformat the date if we don't
1256 ;; have a Date: field.
1260 "Date: \\3, \\5 \\4 \\9 \\6 "
1262 ;; The timezone could be matched by group 7 or group 10.
1263 ;; If neither of them matched, assume EST, since only
1264 ;; Easterners would be so sloppy.
1265 ;; It's a shame the substitution can't use "\\10".
1267 ((/= (match-beginning 7) (match-end 7)) "\\7")
1268 ((/= (match-beginning 10) (match-end 10))
1269 (buffer-substring (match-beginning 10)
1273 ;; Keep and reformat the sender if we don't
1274 ;; have a From: field.
1280 ;;;; *** Rmail Message Formatting and Header Manipulation ***
1282 (defun rmail-reformat-message (beg end)
1285 (if (/= (following-char) ?0)
1286 (error "Bad format in RMAIL file."))
1287 (let ((buffer-read-only nil)
1288 (delta (- (buffer-size) end)))
1292 (let ((case-fold-search t))
1293 (while (looking-at "Summary-line:\\|Mail-From:")
1295 (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
1296 (delete-region (point)
1297 (progn (forward-line 1) (point))))
1298 (let ((str (buffer-substring (point)
1299 (save-excursion (search-forward "\n\n" end 'move)
1301 (insert str "*** EOOH ***\n")
1302 (narrow-to-region (point) (- (buffer-size) delta)))
1303 (goto-char (point-min))
1304 (if rmail-message-filter (funcall rmail-message-filter))
1305 (if (or rmail-displayed-headers rmail-ignored-headers)
1306 (rmail-clear-headers))))
1308 (defun rmail-clear-headers (&optional ignored-headers)
1309 "Delete all header fields that Rmail should not show.
1310 If the optional argument IGNORED-HEADERS is non-nil,
1311 delete all header fields whose names match that regexp.
1312 Otherwise, if `rmail-displayed-headers' is non-nil,
1313 delete all header fields *except* those whose names match that regexp.
1314 Otherwise, delete all header fields whose names match `rmail-ignored-headers'."
1315 (if (search-forward "\n\n" nil t)
1316 (let ((case-fold-search t)
1317 (buffer-read-only nil))
1318 (if (and rmail-displayed-headers (null ignored-headers))
1320 (narrow-to-region (point-min) (point))
1322 (goto-char (point-min))
1323 (while (save-excursion
1324 (re-search-forward "\n[^ \t]")
1326 (setq lim (1- (point)))))
1328 (re-search-forward rmail-displayed-headers lim t))
1330 (delete-region (point) lim))))
1331 (goto-char (point-min)))
1332 (or ignored-headers (setq ignored-headers rmail-ignored-headers))
1334 (narrow-to-region (point-min) (point))
1336 (goto-char (point-min))
1337 (re-search-forward ignored-headers nil t))
1339 (delete-region (point)
1340 (progn (re-search-forward "\n[^ \t]")
1341 (1- (point))))))))))
1343 (defun rmail-toggle-header ()
1344 "Show original message header if pruned header currently shown, or vice versa."
1346 (rmail-maybe-set-message-counters)
1347 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1348 (let ((buffer-read-only nil))
1349 (goto-char (point-min))
1351 (if (= (following-char) ?1)
1352 (progn (delete-char 1)
1355 (let ((case-fold-search t))
1356 (while (looking-at "Summary-Line:\\|Mail-From:")
1358 (insert "*** EOOH ***\n")
1360 (search-forward "\n*** EOOH ***\n")
1362 (let ((temp (point)))
1363 (and (search-forward "\n\n" nil t)
1364 (delete-region temp (point))))
1365 (goto-char (point-min))
1366 (search-forward "\n*** EOOH ***\n")
1367 (narrow-to-region (point) (point-max)))
1368 (rmail-reformat-message (point-min) (point-max))))
1369 (rmail-highlight-headers))
1371 ;;;; *** Rmail Attributes and Keywords ***
1373 ;; Make a string describing current message's attributes and keywords
1374 ;; and set it up as the name of a minor mode
1375 ;; so it will appear in the mode line.
1376 (defun rmail-display-labels ()
1377 (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
1382 (goto-char (rmail-msgbeg rmail-current-message))
1384 (if (looking-at "[01],")
1386 (narrow-to-region (point) (progn (end-of-line) (point)))
1387 ;; Truly valid BABYL format requires a space before each
1388 ;; attribute or keyword name. Put them in if missing.
1389 (let (buffer-read-only)
1390 (goto-char (point-min))
1391 (while (search-forward "," nil t)
1392 (or (looking-at "[ ,]") (eobp)
1394 (goto-char (point-max))
1395 (if (search-backward ",," nil 'move)
1397 (if (> (point) (1+ (point-min)))
1398 (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
1399 (if (> (- (point-max) (point)) 2)
1403 (buffer-substring (+ (point) 3)
1404 (1- (point-max)))))))))))
1405 ;; Note: we don't use save-restriction because that does not work right
1406 ;; if changes are made outside the saved restriction
1407 ;; before that restriction is restored.
1408 (narrow-to-region beg end)
1409 (set-marker beg nil)
1410 (set-marker end nil)))
1411 (while (string-match " +," blurb)
1412 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1413 (substring blurb (match-end 0)))))
1414 (while (string-match ", +" blurb)
1415 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1416 (substring blurb (match-end 0)))))
1417 (setq mode-line-process
1419 rmail-current-message rmail-total-messages blurb))))
1421 ;; Turn an attribute of a message on or off according to STATE.
1422 ;; ATTR is the name of the attribute, as a string.
1423 ;; MSGNUM is message number to change; nil means current message.
1424 (defun rmail-set-attribute (attr state &optional msgnum)
1425 (let ((omax (point-max-marker))
1426 (omin (point-min-marker))
1427 (buffer-read-only nil))
1428 (or msgnum (setq msgnum rmail-current-message))
1433 (goto-char (+ 3 (rmail-msgbeg msgnum)))
1436 (null (search-backward (concat ", " attr ",")
1437 (prog1 (point) (end-of-line)) t)))))
1438 (or (eq curstate (not (not state)))
1440 (delete-region (point) (1- (match-end 0)))
1443 (insert " " attr ","))))
1444 (if (string= attr "deleted")
1445 (rmail-set-message-deleted-p msgnum state)))
1446 ;; Note: we don't use save-restriction because that does not work right
1447 ;; if changes are made outside the saved restriction
1448 ;; before that restriction is restored.
1449 (narrow-to-region omin omax)
1450 (set-marker omin nil)
1451 (set-marker omax nil)
1452 (if (= msgnum rmail-current-message)
1453 (rmail-display-labels))))))
1455 ;; Return t if the attributes/keywords line of msg number MSG
1456 ;; contains a match for the regexp LABELS.
1457 (defun rmail-message-labels-p (msg labels)
1461 (goto-char (rmail-msgbeg msg))
1463 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
1465 ;;;; *** Rmail Message Selection And Support ***
1467 (defun rmail-msgend (n)
1468 (marker-position (aref rmail-message-vector (1+ n))))
1470 (defun rmail-msgbeg (n)
1471 (marker-position (aref rmail-message-vector n)))
1473 (defun rmail-widen-to-current-msgbeg (function)
1474 "Call FUNCTION with point at start of internal data of current message.
1475 Assumes that bounds were previously narrowed to display the message in Rmail.
1476 The bounds are widened enough to move point where desired, then narrowed
1479 FUNCTION may not change the visible text of the message, but it may
1480 change the invisible header text."
1482 (let ((obeg (- (point-max) (point-min))))
1485 (narrow-to-region (rmail-msgbeg rmail-current-message)
1487 (goto-char (point-min))
1489 ;; Note: we don't use save-restriction because that does not work right
1490 ;; if changes are made outside the saved restriction
1491 ;; before that restriction is restored.
1492 ;; Here we assume that changes made by FUNCTION
1493 ;; occur before the visible region of the message.
1494 (narrow-to-region (- (point-max) obeg) (point-max))))))
1496 (defun rmail-forget-messages ()
1498 (if (vectorp rmail-message-vector)
1500 (v rmail-message-vector)
1503 (move-marker (aref v i) nil)
1505 (setq rmail-message-vector nil)
1506 (setq rmail-deleted-vector nil)))
1508 (defun rmail-maybe-set-message-counters ()
1509 (if (not (and rmail-deleted-vector
1510 rmail-message-vector
1511 rmail-current-message
1512 rmail-total-messages))
1513 (rmail-set-message-counters)))
1515 (defun rmail-count-new-messages (&optional nomsg)
1516 (let* ((case-fold-search nil)
1520 (or nomsg (message "Counting new messages..."))
1521 (goto-char (point-max))
1522 ;; Put at the end of messages-head
1523 ;; the entry for message N+1, which marks
1524 ;; the end of message N. (N = number of messages).
1525 (search-backward "\n\^_")
1527 (setq messages-head (list (point-marker)))
1528 (rmail-set-message-counters-counter (point-min))
1529 (setq rmail-current-message (1+ rmail-total-messages))
1530 (setq rmail-total-messages
1531 (+ rmail-total-messages total-messages))
1532 (setq rmail-message-vector
1533 (vconcat rmail-message-vector (cdr messages-head)))
1534 (aset rmail-message-vector
1535 rmail-current-message (car messages-head))
1536 (setq rmail-deleted-vector
1537 (concat rmail-deleted-vector deleted-head))
1538 (setq rmail-summary-vector
1539 (vconcat rmail-summary-vector (make-vector total-messages nil)))
1540 (goto-char (point-min))
1541 (or nomsg (message "Counting new messages...done (%d)" total-messages))))
1543 (defun rmail-set-message-counters ()
1544 (rmail-forget-messages)
1548 (let* ((point-save (point))
1550 (messages-after-point)
1551 (case-fold-search nil)
1554 (message "Counting messages...")
1555 (goto-char (point-max))
1556 ;; Put at the end of messages-head
1557 ;; the entry for message N+1, which marks
1558 ;; the end of message N. (N = number of messages).
1559 (search-backward "\n\^_" nil t)
1560 (if (/= (point) (point-max)) (forward-char 1))
1561 (setq messages-head (list (point-marker)))
1562 (rmail-set-message-counters-counter (min (point) point-save))
1563 (setq messages-after-point total-messages)
1564 (rmail-set-message-counters-counter)
1565 (setq rmail-total-messages total-messages)
1566 (setq rmail-current-message
1568 (max 1 (- total-messages messages-after-point))))
1569 (setq rmail-message-vector
1570 (apply 'vector (cons (point-min-marker) messages-head))
1571 rmail-deleted-vector (concat "D" deleted-head)
1572 rmail-summary-vector (make-vector rmail-total-messages nil))
1573 (message "Counting messages...done")))))
1575 (defun rmail-set-message-counters-counter (&optional stop)
1576 (while (search-backward "\n\^_\^L\n" stop t)
1578 (setq messages-head (cons (point-marker) messages-head))
1581 (cons (if (search-backward ", deleted,"
1587 (if (zerop (% (setq total-messages (1+ total-messages)) 20))
1588 (message "Counting messages...%d" total-messages))))
1590 (defun rmail-beginning-of-message ()
1591 "Show current message starting from the beginning."
1593 (rmail-show-message rmail-current-message))
1595 (defun rmail-show-message (&optional n no-summary)
1596 "Show message number N (prefix argument), counting from start of file.
1597 If summary buffer is currently displayed, update current message there also."
1599 (rmail-maybe-set-message-counters)
1601 (if (zerop rmail-total-messages)
1602 (progn (narrow-to-region (point-min) (1- (point-max)))
1603 (goto-char (point-min))
1604 (setq mode-line-process nil))
1607 (setq n rmail-current-message)
1610 rmail-current-message 1
1611 blurb "No previous message"))
1612 ((> n rmail-total-messages)
1613 (setq n rmail-total-messages
1614 rmail-current-message rmail-total-messages
1615 blurb "No following message"))
1617 (setq rmail-current-message n))))
1618 (let ((beg (rmail-msgbeg n))
1619 (end (rmail-msgend n)))
1622 (if (= (following-char) ?0)
1624 (rmail-reformat-message beg end)
1625 (rmail-set-attribute "unseen" nil))
1626 (search-forward "\n*** EOOH ***\n" end t)
1627 (narrow-to-region (point) end))
1628 (goto-char (point-min))
1629 (rmail-display-labels)
1630 (rmail-highlight-headers)
1631 (if transient-mark-mode (deactivate-mark))
1632 (run-hooks 'rmail-show-message-hook)
1633 ;; If there is a summary buffer, try to move to this message
1634 ;; in that buffer. But don't complain if this message
1635 ;; is not mentioned in the summary.
1636 ;; Don't do this at all if we were called on behalf
1637 ;; of cursor motion in the summary buffer.
1638 (and (rmail-summary-exists) (not no-summary)
1639 (let ((curr-msg rmail-current-message))
1640 (rmail-select-summary
1641 (rmail-summary-goto-msg curr-msg t t))))
1643 (message blurb))))))
1645 ;; Find all occurrences of certain fields, and highlight them.
1646 (defun rmail-highlight-headers ()
1647 ;; Do this only if the system supports faces.
1648 (if (and (fboundp 'internal-find-face)
1649 rmail-highlighted-headers)
1651 (search-forward "\n\n" nil 'move)
1653 (narrow-to-region (point-min) (point))
1654 (let ((case-fold-search t)
1655 (inhibit-read-only t)
1656 ;; Highlight with boldface if that is available.
1657 ;; Otherwise use the `highlight' face.
1658 (face (or rmail-highlight-face
1659 (if (face-differs-from-default-p 'bold)
1661 ;; List of overlays to reuse.
1662 (overlays rmail-overlay-list))
1663 (goto-char (point-min))
1664 (while (re-search-forward rmail-highlighted-headers nil t)
1665 (skip-chars-forward " \t")
1668 (while (progn (forward-line 1)
1669 (looking-at "[ \t]")))
1670 ;; Back up over newline, then trailing spaces or tabs
1672 (while (member (preceding-char) '(? ?\t))
1675 ;; Reuse an overlay we already have.
1677 (setq overlay (car overlays)
1678 overlays (cdr overlays))
1679 (overlay-put overlay 'face face)
1680 (move-overlay overlay beg (point)))
1681 ;; Make a new overlay and add it to
1682 ;; rmail-overlay-list.
1683 (setq overlay (make-overlay beg (point)))
1684 (overlay-put overlay 'face face)
1685 (setq rmail-overlay-list
1686 (cons overlay rmail-overlay-list))))))))))
1688 (defun rmail-next-message (n)
1689 "Show following message whether deleted or not.
1690 With prefix arg N, moves forward N messages, or backward if N is negative."
1692 (rmail-maybe-set-message-counters)
1693 (rmail-show-message (+ rmail-current-message n)))
1695 (defun rmail-previous-message (n)
1696 "Show previous message whether deleted or not.
1697 With prefix arg N, moves backward N messages, or forward if N is negative."
1699 (rmail-next-message (- n)))
1701 (defun rmail-next-undeleted-message (n)
1702 "Show following non-deleted message.
1703 With prefix arg N, moves forward N non-deleted messages,
1704 or backward if N is negative.
1706 Returns t if a new message is being shown, nil otherwise."
1708 (rmail-maybe-set-message-counters)
1709 (let ((lastwin rmail-current-message)
1710 (current rmail-current-message))
1711 (while (and (> n 0) (< current rmail-total-messages))
1712 (setq current (1+ current))
1713 (if (not (rmail-message-deleted-p current))
1714 (setq lastwin current n (1- n))))
1715 (while (and (< n 0) (> current 1))
1716 (setq current (1- current))
1717 (if (not (rmail-message-deleted-p current))
1718 (setq lastwin current n (1+ n))))
1719 (if (/= lastwin rmail-current-message)
1720 (progn (rmail-show-message lastwin)
1723 (message "No previous nondeleted message"))
1725 (message "No following nondeleted message"))
1728 (defun rmail-previous-undeleted-message (n)
1729 "Show previous non-deleted message.
1730 With prefix argument N, moves backward N non-deleted messages,
1731 or forward if N is negative."
1733 (rmail-next-undeleted-message (- n)))
1735 (defun rmail-first-message ()
1736 "Show first message in file."
1738 (rmail-maybe-set-message-counters)
1739 (rmail-show-message 1))
1741 (defun rmail-last-message ()
1742 "Show last message in file."
1744 (rmail-maybe-set-message-counters)
1745 (rmail-show-message rmail-total-messages))
1747 (defun rmail-what-message ()
1748 (let ((where (point))
1750 (high rmail-total-messages)
1751 (mid (/ rmail-total-messages 2)))
1752 (while (> (- high low) 1)
1753 (if (>= where (rmail-msgbeg mid))
1756 (setq mid (+ low (/ (- high low) 2))))
1757 (if (>= where (rmail-msgbeg high)) high low)))
1759 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
1761 (goto-char (rmail-msgbeg msg))
1762 (search-forward "\n*** EOOH ***\n")
1763 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
1764 (or (string-match recipients (or (mail-fetch-field "To") ""))
1765 (string-match recipients (or (mail-fetch-field "From") ""))
1766 (if (not primary-only)
1767 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
1769 (defun rmail-message-regexp-p (msg regexp)
1770 "Return t, if for message number MSG, regexp REGEXP matches in the header."
1771 (goto-char (rmail-msgbeg msg))
1774 (search-forward "*** EOOH ***" (point-max)) (point))))
1775 (re-search-forward regexp end t)))
1777 (defvar rmail-search-last-regexp nil)
1778 (defun rmail-search (regexp &optional n)
1779 "Show message containing next match for REGEXP (but not the current msg).
1780 Prefix argument gives repeat count; negative argument means search
1781 backwards (through earlier messages).
1782 Interactively, empty argument means use same regexp used last time."
1784 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1786 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1788 (if rmail-search-last-regexp
1789 (setq prompt (concat prompt
1791 rmail-search-last-regexp
1793 (setq regexp (read-string prompt))
1794 (cond ((not (equal regexp ""))
1795 (setq rmail-search-last-regexp regexp))
1796 ((not rmail-search-last-regexp)
1797 (error "No previous Rmail search string")))
1798 (list rmail-search-last-regexp
1799 (prefix-numeric-value current-prefix-arg))))
1801 (message "%sRmail search for %s..."
1802 (if (< n 0) "Reverse " "")
1804 (rmail-maybe-set-message-counters)
1805 (let ((omin (point-min))
1810 (msg rmail-current-message))
1815 ;; Check messages one by one, advancing message number up or down
1816 ;; but searching forward through each message.
1818 (while (and (null win) (> msg 1))
1819 (goto-char (rmail-msgbeg (setq msg (1- msg))))
1820 (setq win (re-search-forward
1821 regexp (rmail-msgend msg) t)))
1822 (while (and (null win) (< msg rmail-total-messages))
1823 (goto-char (rmail-msgbeg (setq msg (1+ msg))))
1824 (setq win (re-search-forward regexp (rmail-msgend msg) t))))
1825 (setq n (+ n (if reversep 1 -1)))))
1828 ;; If this is a reverse search and we found a message,
1829 ;; search backward thru this message to position point.
1832 (goto-char (rmail-msgend msg))
1834 regexp (rmail-msgbeg msg) t)))
1836 (rmail-show-message msg)
1837 (message "%sRmail search for %s...done"
1838 (if reversep "Reverse " "")
1842 (narrow-to-region omin omax)
1844 (message "Search failed: %s" regexp)))))
1846 (defun rmail-search-backwards (regexp &optional n)
1847 "Show message containing previous match for REGEXP.
1848 Prefix argument gives repeat count; negative argument means search
1849 forward (through later messages).
1850 Interactively, empty argument means use same regexp used last time."
1852 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1854 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1856 (if rmail-search-last-regexp
1857 (setq prompt (concat prompt
1859 rmail-search-last-regexp
1861 (setq regexp (read-string prompt))
1862 (cond ((not (equal regexp ""))
1863 (setq rmail-search-last-regexp regexp))
1864 ((not rmail-search-last-regexp)
1865 (error "No previous Rmail search string")))
1866 (list rmail-search-last-regexp
1867 (prefix-numeric-value current-prefix-arg))))
1868 (rmail-search regexp (- (or n 1))))
1870 ;; Show the first message which has the `unseen' attribute.
1871 (defun rmail-first-unseen-message ()
1872 (rmail-maybe-set-message-counters)
1877 (while (and (not found) (<= current rmail-total-messages))
1878 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
1879 (setq found current))
1880 (setq current (1+ current))))
1881 ;; Let the caller show the message.
1883 ;; (rmail-show-message found))
1886 (defun rmail-next-same-subject (n)
1887 "Go to the next mail message having the same subject header.
1888 With prefix argument N, do this N times.
1889 If N is negative, go backwards instead."
1891 (let* ((subject (mail-fetch-field "Subject"))
1892 (search-regexp (concat "^Subject: *\\(Re: *\\)?"
1893 (regexp-quote subject)
1896 (i rmail-current-message)
1898 (if (string-match "Re:[ \t]*" subject)
1899 (setq subject (substring subject (match-end 0))))
1903 (while (and (/= n 0)
1905 (< i rmail-total-messages)
1908 (while (and (not done)
1910 (< i rmail-total-messages)
1912 (setq i (if forward (1+ i) (1- i)))
1913 (goto-char (rmail-msgbeg i))
1914 (search-forward "\n*** EOOH ***\n")
1915 (let ((beg (point)) end)
1916 (search-forward "\n\n")
1919 (setq done (re-search-forward search-regexp end t))))
1920 (if done (setq found i)))
1921 (setq n (if forward (1- n) (1+ n))))))
1923 (rmail-show-message found)
1924 (error "No %s message with same subject"
1925 (if forward "following" "previous")))))
1927 (defun rmail-previous-same-subject (n)
1928 "Go to the previous mail message having the same subject header.
1929 With prefix argument N, do this N times.
1930 If N is negative, go forwards instead."
1932 (rmail-next-same-subject (- n)))
1934 ;;;; *** Rmail Message Deletion Commands ***
1936 (defun rmail-message-deleted-p (n)
1937 (= (aref rmail-deleted-vector n) ?D))
1939 (defun rmail-set-message-deleted-p (n state)
1940 (aset rmail-deleted-vector n (if state ?D ?\ )))
1942 (defun rmail-delete-message ()
1943 "Delete this message and stay on it."
1945 (rmail-set-attribute "deleted" t)
1946 (run-hooks 'rmail-delete-message-hook))
1948 (defun rmail-undelete-previous-message ()
1949 "Back up to deleted message, select it, and undelete it."
1951 (let ((msg rmail-current-message))
1952 (while (and (> msg 0)
1953 (not (rmail-message-deleted-p msg)))
1954 (setq msg (1- msg)))
1956 (error "No previous deleted message")
1957 (if (/= msg rmail-current-message)
1958 (rmail-show-message msg))
1959 (rmail-set-attribute "deleted" nil)
1960 (if (rmail-summary-exists)
1962 (set-buffer rmail-summary-buffer)
1963 (rmail-summary-mark-undeleted msg)))
1964 (rmail-maybe-display-summary))))
1966 (defun rmail-delete-forward (&optional backward)
1967 "Delete this message and move to next nondeleted one.
1968 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
1969 With prefix argument, delete and move backward.
1971 Returns t if a new message is displayed after the delete, or nil otherwise."
1973 (rmail-set-attribute "deleted" t)
1974 (run-hooks 'rmail-delete-message-hook)
1975 (let ((del-msg rmail-current-message))
1976 (if (rmail-summary-exists)
1977 (rmail-select-summary
1978 (rmail-summary-mark-deleted del-msg)))
1979 (prog1 (rmail-next-undeleted-message (if backward -1 1))
1980 (rmail-maybe-display-summary))))
1982 (defun rmail-delete-backward ()
1983 "Delete this message and move to previous nondeleted one.
1984 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1986 (rmail-delete-forward t))
1988 ;; Compute the message number a given message would have after expunging.
1989 ;; The present number of the message is OLDNUM.
1990 ;; DELETEDVEC should be rmail-deleted-vector.
1991 ;; The value is nil for a message that would be deleted.
1992 (defun rmail-msg-number-after-expunge (deletedvec oldnum)
1993 (if (or (null oldnum) (= (aref deletedvec oldnum) ?D))
1998 (if (/= (aref deletedvec i) ?D)
1999 (setq newnum (1+ newnum)))
2003 (defun rmail-only-expunge ()
2004 "Actually erase all deleted messages in the file."
2006 (message "Expunging deleted messages...")
2007 ;; Discard all undo records for this buffer.
2008 (or (eq buffer-undo-list t)
2009 (setq buffer-undo-list nil))
2010 (rmail-maybe-set-message-counters)
2011 (let* ((omax (- (buffer-size) (point-max)))
2012 (omin (- (buffer-size) (point-min)))
2013 (opoint (if (and (> rmail-current-message 0)
2014 (rmail-message-deleted-p rmail-current-message))
2016 (- (point) (point-min))))
2017 (messages-head (cons (aref rmail-message-vector 0) nil))
2018 (messages-tail messages-head)
2019 ;; Don't make any undo records for the expunging.
2020 (buffer-undo-list t)
2025 (goto-char (point-min))
2028 (total rmail-total-messages)
2029 (new-message-number rmail-current-message)
2031 (rmailbuf (current-buffer))
2032 (buffer-read-only nil)
2033 (messages rmail-message-vector)
2034 (deleted rmail-deleted-vector)
2035 (summary rmail-summary-vector))
2036 (setq rmail-total-messages nil
2037 rmail-current-message nil
2038 rmail-message-vector nil
2039 rmail-deleted-vector nil
2040 rmail-summary-vector nil)
2042 ;; Find each sendmail buffer that is set to reply
2043 ;; to a message in this buffer, and update its
2045 (let ((bufs (buffer-list)))
2048 (set-buffer (car bufs))
2049 (and (boundp 'rmail-send-actions-rmail-buffer)
2050 (eq rmail-send-actions-rmail-buffer rmailbuf)
2051 (setq rmail-send-actions-rmail-msg-number
2052 (rmail-msg-number-after-expunge
2054 rmail-send-actions-rmail-msg-number))))
2055 (setq bufs (cdr bufs))))
2057 (while (<= number total)
2058 (if (= (aref deleted number) ?D)
2061 (marker-position (aref messages number))
2062 (marker-position (aref messages (1+ number))))
2063 (move-marker (aref messages number) nil)
2064 (if (> new-message-number counter)
2065 (setq new-message-number (1- new-message-number))))
2066 (setq counter (1+ counter))
2068 (setcdr messages-tail
2069 (cons (aref messages number) nil)))
2071 (cons (if (= counter number) (aref summary (1- number)))
2073 (if (zerop (% (setq number (1+ number)) 20))
2074 (message "Expunging deleted messages...%d" number)))
2076 (setcdr messages-tail
2077 (cons (aref messages number) nil)))
2078 (setq rmail-current-message new-message-number
2079 rmail-total-messages counter
2080 rmail-message-vector (apply 'vector messages-head)
2081 rmail-deleted-vector (make-string (1+ counter) ?\ )
2082 rmail-summary-vector (vconcat (nreverse new-summary))
2084 (message "Expunging deleted messages...done")
2086 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
2088 (if (zerop rmail-current-message) 1 nil))
2089 (forward-char opoint))))
2091 (defun rmail-expunge ()
2092 "Erase deleted messages from Rmail file and summary buffer."
2094 (rmail-only-expunge)
2095 (if (rmail-summary-exists)
2096 (rmail-select-summary
2097 (rmail-update-summary))))
2099 ;;;; *** Rmail Mailing Commands ***
2101 (defun rmail-start-mail (&rest args)
2102 (if (and window-system rmail-mail-new-frame)
2104 (apply 'mail-other-frame args)
2105 ;; This is not a standard frame parameter;
2106 ;; nothing except sendmail.el looks at it.
2107 (modify-frame-parameters (selected-frame)
2108 '((mail-dedicated-frame . t))))
2109 (apply 'mail-other-window args)))
2111 (defun rmail-mail ()
2112 "Send mail in another window.
2113 While composing the message, use \\[mail-yank-original] to yank the
2114 original message into it."
2116 (rmail-start-mail nil nil nil nil nil (current-buffer)))
2118 (defun rmail-continue ()
2119 "Continue composing outgoing message previously being composed."
2121 (rmail-start-mail t))
2123 (defun rmail-reply (just-sender)
2124 "Reply to the current message.
2125 Normally include CC: to all other recipients of original message;
2126 prefix argument means ignore them. While composing the reply,
2127 use \\[mail-yank-original] to yank the original message into it."
2129 (let (from reply-to cc subject date to message-id resent-reply-to
2130 (msgnum rmail-current-message)
2131 (rmail-buffer (current-buffer)))
2135 (goto-char (rmail-msgbeg rmail-current-message))
2137 (if (= (following-char) ?0)
2139 (progn (forward-line 2)
2141 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
2144 (narrow-to-region (point)
2145 (progn (search-forward "\n*** EOOH ***\n")
2146 (beginning-of-line) (point))))
2147 (setq resent-reply-to (mail-fetch-field "resent-reply-to" t)
2148 from (mail-fetch-field "from")
2149 reply-to (or resent-reply-to
2150 (mail-fetch-field "reply-to" nil t)
2152 cc (cond (just-sender nil)
2153 (resent-reply-to (mail-fetch-field "resent-cc" t))
2154 (t (mail-fetch-field "cc" nil t)))
2155 subject (or (and resent-reply-to
2156 (mail-fetch-field "resent-subject" t))
2157 (mail-fetch-field "subject"))
2158 date (or (and resent-reply-to
2159 (mail-fetch-field "resent-date" t))
2160 (mail-fetch-field "date"))
2161 to (cond (resent-reply-to
2162 (or (mail-fetch-field "resent-to" t)) "")
2163 ((mail-fetch-field "to" nil t))
2164 ;((mail-fetch-field "apparently-to")) ack gag barf
2166 message-id (cond (resent-reply-to
2167 (mail-fetch-field "resent-message-id" t))
2168 ((mail-fetch-field "message-id"))))))
2169 (and (stringp subject)
2171 (concat rmail-reply-prefix
2172 (if (string-match rmail-reply-regexp subject)
2173 (substring subject (match-end 0))
2175 (rmail-start-mail nil
2176 (mail-strip-quoted-names reply-to)
2178 (rmail-make-in-reply-to-field from date message-id)
2181 (let* ((cc-list (rmail-dont-reply-to
2182 (mail-strip-quoted-names
2183 (if (null cc) to (concat to ", " cc))))))
2184 (if (string= cc-list "") nil cc-list)))
2186 (list (list '(lambda ()
2187 (let ((msgnum rmail-send-actions-rmail-msg-number))
2189 (set-buffer rmail-send-actions-rmail-buffer)
2191 (rmail-set-attribute "answered" t msgnum))))))))
2192 ;; We keep the rmail buffer and message number in these
2193 ;; buffer-local vars in the sendmail buffer,
2194 ;; so that rmail-only-expunge can relocate the message number.
2195 (make-local-variable 'rmail-send-actions-rmail-buffer)
2196 (make-local-variable 'rmail-send-actions-rmail-msg-number)
2197 (setq rmail-send-actions-rmail-buffer rmail-buffer)
2198 (setq rmail-send-actions-rmail-msg-number msgnum)))
2200 (defun rmail-make-in-reply-to-field (from date message-id)
2207 (let ((tem (car (rfc822-addresses from))))
2210 (regexp-quote (if (string-match "@[^@]*\\'" tem)
2211 (substring tem 0 (match-beginning 0))
2214 ;; Message-ID is sufficiently informative
2216 (concat message-id " (" tem ")"))
2217 ;; Copy TEM, discarding text properties.
2218 (setq tem (copy-sequence tem))
2219 (set-text-properties 0 (length tem) nil tem)
2220 (setq tem (copy-sequence tem))
2221 ;; Use prin1 to fake RFC822 quoting
2222 (let ((field (prin1-to-string tem)))
2224 (concat field "'s message of " date)
2226 ((let* ((foo "[^][\000-\037\177-\377()<>@,;:\\\" ]+")
2227 (bar "[^][\000-\037\177-\377()<>@,;:\\\"]+"))
2228 ;; Can't use format because format loses on \000 (unix *^&%*^&%$!!)
2229 (or (string-match (concat "\\`[ \t]*\\(" bar
2230 "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
2231 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
2233 (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
2234 bar "\\))[ \t]*\\'")
2235 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
2237 (let ((start (match-beginning 1))
2238 (end (match-end 1)))
2239 ;; Trim whitespace which above regexp match allows
2240 (while (and (< start end)
2241 (memq (aref from start) '(?\t ?\ )))
2242 (setq start (1+ start)))
2243 (while (and (< start end)
2244 (memq (aref from (1- end)) '(?\t ?\ )))
2245 (setq end (1- end)))
2246 (let ((field (substring from start end)))
2247 (if date (setq field (concat "message from " field " on " date)))
2249 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
2250 (concat message-id " (" field ")")
2253 ;; If we can't kludge it simply, do it correctly
2254 (let ((mail-use-rfc822 t))
2255 (rmail-make-in-reply-to-field from date message-id)))))
2257 (defun rmail-forward (resend)
2258 "Forward the current message to another user.
2259 With prefix argument, \"resend\" the message instead of forwarding it;
2260 see the documentation of `rmail-resend'."
2263 (call-interactively 'rmail-resend)
2264 (let ((forward-buffer (current-buffer))
2265 (msgnum rmail-current-message)
2266 (subject (concat "["
2267 (let ((from (or (mail-fetch-field "From")
2268 (mail-fetch-field ">From"))))
2270 (concat (mail-strip-quoted-names from) ": ")
2272 (or (mail-fetch-field "Subject") "")
2274 ;; If only one window, use it for the mail buffer.
2275 ;; Otherwise, use another window for the mail buffer
2276 ;; so that the Rmail buffer remains visible
2277 ;; and sending the mail will get back to it.
2278 (if (funcall (if (and (not rmail-mail-new-frame) (one-window-p t))
2280 (function rmail-start-mail))
2281 nil nil subject nil nil nil
2282 (list (list (function
2285 rmail-send-actions-rmail-msg-number))
2287 (set-buffer rmail-send-actions-rmail-buffer)
2289 (rmail-set-attribute
2290 "forwarded" t msgnum)))))))))
2291 ;; The mail buffer is now current.
2293 ;; We keep the rmail buffer and message number in these
2294 ;; buffer-local vars in the sendmail buffer,
2295 ;; so that rmail-only-expunge can relocate the message number.
2296 (make-local-variable 'rmail-send-actions-rmail-buffer)
2297 (make-local-variable 'rmail-send-actions-rmail-msg-number)
2298 (setq rmail-send-actions-rmail-buffer forward-buffer)
2299 (setq rmail-send-actions-rmail-msg-number msgnum)
2300 ;; Insert after header separator--before signature if any.
2301 (goto-char (point-min))
2302 (search-forward-regexp
2303 (concat "^" (regexp-quote mail-header-separator) "$"))
2305 (insert "------- Start of forwarded message -------\n")
2306 ;; Quote lines with `- ' if they start with `-'.
2307 (let ((beg (point)) end)
2308 (setq end (point-marker))
2309 (set-marker-insertion-type end t)
2310 (insert-buffer-substring forward-buffer)
2312 (while (re-search-forward "^-" nil t)
2317 (skip-chars-backward "\n")
2320 (delete-region (point) end)
2321 (set-marker end nil))
2322 (insert "------- End of forwarded message -------\n")
2325 (defun rmail-resend (address &optional from comment mail-alias-file)
2326 "Resend current message to ADDRESSES.
2327 ADDRESSES should be a single address, a string consisting of several
2328 addresses separated by commas, or a list of addresses.
2330 Optional FROM is the address to resend the message from, and
2331 defaults to the username of the person redistributing the message.
2332 Optional COMMENT is a string that will be inserted as a comment in the
2334 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
2335 typically for purposes of moderating a list."
2336 (interactive "sResend to: ")
2338 (require 'mailalias)
2339 (if (not from) (setq from (user-login-name)))
2340 (let ((tembuf (generate-new-buffer " sendmail temp"))
2341 (mail-header-separator "")
2342 (case-fold-search nil)
2343 (mailbuf (current-buffer)))
2346 ;;>> Copy message into temp buffer
2348 (insert-buffer-substring mailbuf)
2349 (goto-char (point-min))
2350 ;; Delete any Sender field, since that's not specifiable.
2351 ; Only delete Sender fields in the actual header.
2352 (re-search-forward "^$" nil 'move)
2353 ; Using "while" here rather than "if" because some buggy mail
2354 ; software may have inserted multiple Sender fields.
2355 (while (re-search-backward "^Sender:" nil t)
2359 (while (looking-at "[ \t]")
2361 (delete-region beg (point))))
2362 ; Go back to the beginning of the buffer so the Resent- fields
2363 ; are inserted there.
2364 (goto-char (point-min))
2365 ;;>> Insert resent-from:
2366 (insert "Resent-From: " from "\n")
2367 (insert "Resent-Date: " (mail-rfc822-date) "\n")
2368 ;;>> Insert resent-to: and bcc if need be.
2369 (let ((before (point)))
2371 (insert "Resent-Bcc: " (user-login-name) "\n"))
2372 (insert "Resent-To: " (if (stringp address)
2374 (mapconcat 'identity address ",\n\t"))
2376 ;; Expand abbrevs in the recipients.
2378 (if (featurep 'mailabbrev)
2379 (let ((end (point-marker))
2380 (local-abbrev-table mail-abbrevs)
2381 (old-syntax-table (syntax-table)))
2382 (if (and (not (vectorp mail-abbrevs))
2383 (file-exists-p mail-personal-alias-file))
2384 (build-mail-abbrevs))
2385 (set-syntax-table mail-abbrev-syntax-table)
2387 (while (and (< (point) end)
2388 (progn (forward-word 1)
2391 (set-syntax-table old-syntax-table))
2392 (expand-mail-aliases before (point)))))
2393 ;;>> Set up comment, if any.
2394 (if (and (sequencep comment) (not (zerop (length comment))))
2395 (let ((before (point))
2398 (or (eolp) (insert "\n"))
2399 (setq after (point))
2401 (while (< (point) after)
2402 (insert "Resent-Comment: ")
2404 ;; Don't expand aliases in the destination fields
2405 ;; of the original message.
2407 (funcall send-mail-function)))
2408 (kill-buffer tembuf))
2409 (rmail-set-attribute "resent" t rmail-current-message)))
2411 (defvar mail-unsent-separator
2412 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
2413 "^ *---+ +Returned message +---+ *$\\|"
2414 "^Start of returned message$\\|"
2415 "^ *---+ +Original message +---+ *$\\|"
2416 "^ *--+ +begin message +--+ *$\\|"
2417 "^ *---+ +Original message follows +---+ *$\\|"
2418 "^|? *---+ +Message text follows: +---+ *|?$")
2419 "A regexp that matches the separator before the text of a failed message.")
2421 (defun rmail-retry-failure ()
2422 "Edit a mail message which is based on the contents of the current message.
2423 For a message rejected by the mail system, extract the interesting headers and
2424 the body of the original message.
2425 The variable `mail-unsent-separator' should match the string that
2426 delimits the returned original message.
2427 The variable `rmail-retry-ignored-headers' is a regular expression
2428 specifying headers which should not be copied into the new message."
2430 (require 'mail-utils)
2431 (let ((rmail-buffer (current-buffer))
2432 (msgnum rmail-current-message)
2433 bounce-start bounce-end bounce-indent resending)
2435 ;; Narrow down to just the quoted original message
2436 (rmail-beginning-of-message)
2437 (let ((case-fold-search t))
2438 (if (search-forward "This is a MIME-encapsulated message\n\n--" nil t)
2440 (buffer-substring (progn (beginning-of-line) (point))
2441 (progn (end-of-line) (point)))))
2442 (re-search-forward mail-unsent-separator)
2443 (search-forward codestring)
2444 (or (search-forward "\n\n" nil t)
2445 (error "Cannot find end of Mime data in failed message"))
2446 (setq bounce-start (point))
2448 (goto-char (point-max))
2449 (search-backward codestring)
2450 (setq bounce-end (point)))
2451 (or (search-forward "\n\n" nil t)
2452 (error "Cannot find end of header in failed message")))
2453 (or (re-search-forward mail-unsent-separator nil t)
2454 (error "Cannot parse this as a failure message"))
2455 (skip-chars-forward "\n")
2456 ;; Support a style of failure message in which the original
2457 ;; message is indented, and included within lines saying
2458 ;; `Start of returned message' and `End of returned message'.
2459 (if (looking-at " +Received:")
2461 (setq bounce-start (point))
2462 (skip-chars-forward " ")
2463 (setq bounce-indent (- (current-column)))
2464 (goto-char (point-max))
2465 (re-search-backward "^End of returned message$" nil t)
2466 (setq bounce-end (point)))
2467 ;; One message contained a few random lines before the old
2468 ;; message header. The first line of the message started with
2469 ;; two hyphens. A blank line followed these random lines.
2470 ;; The same line beginning with two hyphens was possibly
2471 ;; marking the end of the message.
2472 (if (looking-at "^--")
2473 (let ((boundary (buffer-substring-no-properties
2475 (progn (end-of-line) (point)))))
2476 (search-forward "\n\n")
2477 (skip-chars-forward "\n")
2478 (setq bounce-start (point))
2479 (goto-char (point-max))
2480 (search-backward (concat "\n\n" boundary) bounce-start t)
2481 (setq bounce-end (point)))
2482 (setq bounce-start (point)
2483 bounce-end (point-max)))
2484 (or (search-forward "\n\n" nil t)
2485 (error "Cannot find end of header in failed message"))
2487 ;; Start sending a new message; default header fields from the original.
2488 ;; Turn off the usual actions for initializing the message body
2489 ;; because we want to get only the text from the failure message.
2491 ;; This function will be called when the user sends the retry.
2492 ;; It will mark the bounce message as "retried".
2493 (function (lambda ()
2494 (let ((msgnum rmail-send-actions-rmail-msg-number))
2496 (set-buffer rmail-send-actions-rmail-buffer)
2498 (rmail-set-attribute "retried" t msgnum)))))))
2499 mail-signature mail-setup-hook)
2500 (if (rmail-start-mail nil nil nil nil nil rmail-buffer
2501 (list (list action)))
2502 ;; Insert original text as initial text of new draft message.
2503 ;; Bind inhibit-read-only since the header delimiter
2504 ;; of the previous message was probably read-only.
2505 (let ((inhibit-read-only t))
2506 ;; We keep the rmail buffer and message number in these
2507 ;; buffer-local vars in the sendmail buffer,
2508 ;; so that the rmail-only-expunge can relocate the message number.
2509 (make-local-variable 'rmail-send-actions-rmail-buffer)
2510 (make-local-variable 'rmail-send-actions-rmail-msg-number)
2511 (setq rmail-send-actions-rmail-buffer rmail-buffer)
2512 (setq rmail-send-actions-rmail-msg-number msgnum)
2514 (insert-buffer-substring rmail-buffer bounce-start bounce-end)
2515 (goto-char (point-min))
2517 (indent-rigidly (point-min) (point-max) bounce-indent))
2518 (rmail-clear-headers rmail-retry-ignored-headers)
2519 (rmail-clear-headers "^sender:\\|^from:\\|^return-path:")
2520 (goto-char (point-min))
2522 (search-forward "\n\n")
2524 (narrow-to-region (point-min) (point))
2525 (setq resending (mail-fetch-field "resent-to"))
2528 (insert "Resent-Bcc: " (user-login-name) "\n")
2529 (insert "BCC: " (user-login-name) "\n"))))
2530 (insert mail-header-separator)
2531 (mail-position-on-field (if resending "Resent-To" "To") t)
2532 (set-buffer rmail-buffer)
2533 (rmail-beginning-of-message))))))
2535 (defun rmail-summary-exists ()
2536 "Non-nil iff in an RMAIL buffer and an associated summary buffer exists.
2537 In fact, the non-nil value returned is the summary buffer itself."
2538 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2539 rmail-summary-buffer))
2541 (defun rmail-summary-displayed ()
2542 "t iff in RMAIL buffer and an associated summary buffer is displayed."
2543 (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
2545 (defvar rmail-redisplay-summary nil
2546 "*Non-nil means Rmail should show the summary when it changes.
2547 This has an effect only if a summary buffer exists.")
2549 (defvar rmail-summary-window-size nil
2550 "*Non-nil means specify the height for an Rmail summary window.")
2552 ;; Put the summary buffer back on the screen, if user wants that.
2553 (defun rmail-maybe-display-summary ()
2554 (let ((selected (selected-window))
2556 ;; If requested, make sure the summary is displayed.
2557 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2558 rmail-redisplay-summary
2559 (if (get-buffer-window rmail-summary-buffer 0)
2560 ;; It's already in some frame; show that one.
2561 (let ((frame (window-frame
2562 (get-buffer-window rmail-summary-buffer 0))))
2563 (make-frame-visible frame)
2564 (raise-frame frame))
2565 (display-buffer rmail-summary-buffer)))
2566 ;; If requested, set the height of the summary window.
2567 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2568 rmail-summary-window-size
2569 (setq window (get-buffer-window rmail-summary-buffer))
2570 ;; Don't try to change the size if just one window in frame.
2571 (not (eq window (frame-root-window (window-frame window))))
2574 (select-window window)
2575 (enlarge-window (- rmail-summary-window-size (window-height))))
2576 (select-window selected)))))
2578 ;;;; *** Rmail Local Fontification ***
2580 (defun rmail-fontify-buffer-function ()
2581 ;; This function's symbol is bound to font-lock-fontify-buffer-function.
2582 (make-local-hook 'rmail-show-message-hook)
2583 (add-hook 'rmail-show-message-hook 'rmail-fontify-message nil t)
2584 ;; If we're already showing a message, fontify it now.
2585 (if rmail-current-message (rmail-fontify-message))
2586 ;; Prevent Font Lock mode from kicking in.
2587 (setq font-lock-fontified t))
2589 (defun rmail-unfontify-buffer-function ()
2590 ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
2591 (let ((modified (buffer-modified-p))
2592 (buffer-undo-list t) (inhibit-read-only t)
2593 before-change-functions after-change-functions
2594 buffer-file-name buffer-file-truename)
2597 (remove-hook 'rmail-show-message-hook 'rmail-fontify-message t)
2598 (remove-text-properties (point-min) (point-max) '(rmail-fontified nil))
2599 (font-lock-default-unfontify-buffer)
2600 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))
2602 (defun rmail-fontify-message ()
2603 ;; Fontify the current message if it is not already fontified.
2604 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil)
2605 (let ((modified (buffer-modified-p))
2606 (buffer-undo-list t) (inhibit-read-only t)
2607 before-change-functions after-change-functions
2608 buffer-file-name buffer-file-truename)
2611 (add-text-properties (point-min) (point-max) '(rmail-fontified t))
2612 (font-lock-fontify-region (point-min) (point-max))
2613 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))))
2615 ;;;; *** Rmail Specify Inbox Files ***
2617 (autoload 'set-rmail-inbox-list "rmailmsc"
2618 "Set the inbox list of the current RMAIL file to FILE-NAME.
2619 This may be a list of file names separated by commas.
2620 If FILE-NAME is empty, remove any inbox list."
2623 ;;;; *** Rmail Commands for Labels ***
2625 (autoload 'rmail-add-label "rmailkwd"
2626 "Add LABEL to labels associated with current RMAIL message.
2627 Completion is performed over known labels when reading."
2630 (autoload 'rmail-kill-label "rmailkwd"
2631 "Remove LABEL from labels associated with current RMAIL message.
2632 Completion is performed over known labels when reading."
2635 (autoload 'rmail-next-labeled-message "rmailkwd"
2636 "Show next message with LABEL. Defaults to last label used.
2637 With prefix argument N moves forward N messages with this label."
2640 (autoload 'rmail-previous-labeled-message "rmailkwd"
2641 "Show previous message with LABEL. Defaults to last label used.
2642 With prefix argument N moves backward N messages with this label."
2645 (autoload 'rmail-read-label "rmailkwd"
2646 "PROMPT and read with completion an Rmail message label."
2649 ;;;; *** Rmail Edit Mode ***
2651 (autoload 'rmail-edit-current-message "rmailedit"
2652 "Edit the contents of the current message"
2655 ;;;; *** Rmail Sorting ***
2657 (autoload 'rmail-sort-by-date "rmailsort"
2658 "Sort messages of current Rmail file by date.
2659 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2661 (autoload 'rmail-sort-by-subject "rmailsort"
2662 "Sort messages of current Rmail file by subject.
2663 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2665 (autoload 'rmail-sort-by-author "rmailsort"
2666 "Sort messages of current Rmail file by author.
2667 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2669 (autoload 'rmail-sort-by-recipient "rmailsort"
2670 "Sort messages of current Rmail file by recipient.
2671 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2673 (autoload 'rmail-sort-by-correspondent "rmailsort"
2674 "Sort messages of current Rmail file by other correspondent.
2675 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2677 (autoload 'rmail-sort-by-lines "rmailsort"
2678 "Sort messages of current Rmail file by number of lines.
2679 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2681 (autoload 'rmail-sort-by-keywords "rmailsort"
2682 "Sort messages of current Rmail file by labels.
2683 If prefix argument REVERSE is non-nil, sort them in reverse order.
2684 KEYWORDS is a comma-separated list of labels." t)
2686 ;;;; *** Rmail Summary Mode ***
2688 (autoload 'rmail-summary "rmailsum"
2689 "Display a summary of all messages, one line per message."
2692 (autoload 'rmail-summary-by-labels "rmailsum"
2693 "Display a summary of all messages with one or more LABELS.
2694 LABELS should be a string containing the desired labels, separated by commas."
2697 (autoload 'rmail-summary-by-recipients "rmailsum"
2698 "Display a summary of all messages with the given RECIPIENTS.
2699 Normally checks the To, From and Cc fields of headers; but if PRIMARY-ONLY
2700 is non-nil (prefix arg given), only look in the To and From fields.
2701 RECIPIENTS is a string of regexps separated by commas."
2704 (autoload 'rmail-summary-by-regexp "rmailsum"
2705 "Display a summary of all messages according to regexp REGEXP.
2706 If the regular expression is found in the header of the message
2707 \(including in the date and other lines, as well as the subject line),
2708 Emacs will list the header line in the RMAIL-summary."
2711 (autoload 'rmail-summary-by-topic "rmailsum"
2712 "Display a summary of all messages with the given SUBJECT.
2713 Normally checks the Subject field of headers;
2714 but if WHOLE-MESSAGE is non-nil (prefix arg given),
2715 look in the whole message.
2716 SUBJECT is a string of regexps separated by commas."
2719 (autoload 'rmail-summary-by-sender "rmailsum"
2720 "Display a summary of all messages with the given SENDERS.
2721 SENDERS is a string of names separated by commas."
2724 ;;;; *** Rmail output messages to files ***
2726 (autoload 'rmail-output-to-rmail-file "rmailout"
2727 "Append the current message to an Rmail file named FILE-NAME.
2728 If the file does not exist, ask if it should be created.
2729 If file is being visited, the message is appended to the Emacs
2730 buffer visiting that file."
2733 (autoload 'rmail-output "rmailout"
2734 "Append this message to Unix mail file named FILE-NAME."
2737 ;;;; *** Rmail undigestification ***
2739 (autoload 'undigestify-rmail-message "undigest"
2740 "Break up a digest message into its constituent messages.
2741 Leaves original message, deleted, before the undigestified messages."
2744 (autoload 'unforward-rmail-message "undigest"
2745 "Extract a forwarded message from the containing message.
2746 This puts the forwarded message into a separate rmail message
2747 following the containing message."
2752 ;;; rmail.el ends here