1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs.
3 ;; Copyright (C) 1985, 1986, 1987, 1988, 1993 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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
27 ;; New features include attribute and keyword support, message
28 ;; selection by dispatch table, summary by attributes and keywords,
29 ;; expunging by dispatch table, sticky options for file commands.
31 ;; Extended by Bob Weiner of Motorola
32 ;; New features include: rmail and rmail-summary buffers remain
33 ;; synchronized and key bindings basically operate the same way in both
34 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
35 ;; variable, and a bury rmail buffer (wipe) command.
40 ;; For Emacs V18 compatibility
41 (and (not (fboundp 'user-original-login-name))
42 (fboundp 'user-real-login-name)
43 (defalias 'user-original-login-name 'user-real-login-name))
44 (and (not (fboundp 'buffer-disable-undo))
45 (fboundp 'buffer-flush-undo)
46 (defalias 'buffer-disable-undo 'buffer-flush-undo))
48 ; These variables now declared in paths.el.
49 ;(defvar rmail-spool-directory "/usr/spool/mail/"
50 ; "This is the name of the directory used by the system mailer for\n\
51 ;delivering new mail. It's name should end with a slash.")
52 ;(defvar rmail-file-name
53 ; (expand-file-name "~/RMAIL")
57 (defvar rmail-dont-reply-to-names nil "\
58 *A regexp specifying names to prune of reply to messages.
59 A value of nil means exclude your own name only.")
62 (defvar rmail-default-dont-reply-to-names "info-" "\
63 A regular expression specifying part of the value of the default value of
64 the variable `rmail-dont-reply-to-names', for when the user does not set
65 `rmail-dont-reply-to-names' explicitly. (The other part of the default
66 value is the user's name.)
67 It is useful to set this variable in the site customization file.")
70 (defvar rmail-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^received:\\|^message-id:\\|^summary-line:" "\
71 *Gubbish headers one would rather not see.")
74 (defvar rmail-delete-after-output nil "\
75 *Non-nil means automatically delete a message that is copied to a file.")
78 (defvar rmail-primary-inbox-list nil "\
79 *List of files which are inboxes for user's primary mail file `~/RMAIL'.
80 `nil' means the default, which is (\"/usr/spool/mail/$USER\")
81 \(the name varies depending on the operating system,
82 and the value of the environment variable MAIL overrides it).")
85 (defvar rmail-mail-new-frame nil
86 "*Non-nil means Rmail makes a new frame for composing outgoing mail.")
89 (defvar rmail-retry-setup-hook nil
90 "Hook that `rmail-retry-failure' uses in place of `mail-setup-hook'.")
92 ;; These may be altered by site-init.el to match the format of mmdf files
93 ;; delimiting used on a given host (delim1 and delim2 from the config
96 (defvar mmdf-delim1 "^\001\001\001\001\n"
97 "Regexp marking the start of an mmdf message")
98 (defvar mmdf-delim2 "^\001\001\001\001\n"
99 "Regexp marking the end of an mmdf message")
101 (defvar rmail-message-filter nil
102 "If non nil, is a filter function for new headers in RMAIL.
103 Called with region narrowed to unformatted header.")
105 (defvar rmail-reply-prefix "Re: "
106 "String to prepend to Subject line when replying to a message.")
108 (defvar rmail-mode-map nil)
110 (defvar rmail-inbox-list nil)
111 (defvar rmail-keywords nil)
113 ;; Message counters and markers. Deleted flags.
115 (defvar rmail-current-message nil)
116 (defvar rmail-total-messages nil)
117 (defvar rmail-message-vector nil)
118 (defvar rmail-deleted-vector nil)
120 ;; These are used by autoloaded rmail-summary.
122 (defvar rmail-summary-buffer nil)
123 (defvar rmail-summary-vector nil)
125 ;; `Sticky' default variables.
127 ;; Last individual label specified to a or k.
128 (defvar rmail-last-label nil)
129 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
130 (defvar rmail-last-multi-labels nil)
131 (defvar rmail-last-regexp nil)
132 (defvar rmail-default-file nil
133 "*Default file name for \\[rmail-output].")
134 (defvar rmail-default-rmail-file (expand-file-name "~/XMAIL")
135 "*Default file name for \\[rmail-output-to-rmail-file].")
137 ;;; Regexp matching the delimiter of messages in UNIX mail format
138 ;;; (UNIX From lines), minus the initial ^. Note that if you change
139 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
140 ;;; that knows the exact ordering of the \\( \\) subexpressions.
141 (defvar rmail-unix-mail-delimiter
142 (let ((time-zone-regexp
143 (concat "\\([A-Z]?[A-Z][A-Z][A-Z]\\( DST\\)?"
144 "\\|[-+]?[0-9][0-9][0-9][0-9]"
150 ;; Username, perhaps with a quoted section that can contain spaces.
153 "\\(\\|\".*\"[^ \n]*\\)"
156 ;; The time the message was sent.
157 "\\([^ \n]*\\) *" ; day of the week
158 "\\([^ ]*\\) *" ; month
159 "\\([0-9]*\\) *" ; day of month
160 "\\([0-9:]*\\) *" ; time of day
162 ;; Perhaps a time zone, specified by an abbreviation, or by a
167 " [0-9][0-9]\\([0-9]*\\) *"
169 ;; On some systems the time zone can appear after the year, too.
172 ;; I'm not sure what this is.
173 "\\(remote from [^\n]*\\)?"
178 ;; Perform BODY in the summary buffer
179 ;; in such a way that its cursor is properly updated in its own window.
180 (defmacro rmail-select-summary (&rest body)
181 (` (progn (if (rmail-summary-displayed)
182 (let ((window (selected-window)))
186 (pop-to-buffer rmail-summary-buffer)
188 (select-window window))))
190 (set-buffer rmail-summary-buffer)
192 (rmail-maybe-display-summary))))
194 ;;;; *** Rmail Mode ***
197 (defun rmail (&optional file-name-arg)
198 "Read and edit incoming mail.
199 Moves messages into file named by `rmail-file-name' (a babyl format file)
200 and edits that file in RMAIL Mode.
201 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
203 May be called with file name as argument; then performs rmail editing on
204 that file, but does not copy any new mail into the file.
205 Interactively, if you supply a prefix argument, then you
206 have a chance to specify a file name with the minibuffer."
207 (interactive (if current-prefix-arg
208 (list (read-file-name "Run rmail on RMAIL file: "
210 (or rmail-default-file
211 (setq rmail-default-file (expand-file-name "~/xmail")))
212 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
213 (existed (get-file-buffer file-name)))
214 ;; Like find-file, but in the case where a buffer existed
215 ;; and the file was reverted, recompute the message-data.
216 (if (and existed (not (verify-visited-file-modtime existed)))
218 ;; Don't be confused by apparent local-variables spec
219 ;; in the last message in the RMAIL file.
220 (let ((enable-local-variables nil))
221 (find-file file-name))
222 (if (and (verify-visited-file-modtime existed)
223 (eq major-mode 'rmail-mode))
224 (progn (rmail-forget-messages)
225 (rmail-set-message-counters))))
226 (let ((enable-local-variables nil))
227 (find-file file-name)))
228 (if (eq major-mode 'rmail-edit-mode)
229 (error "Exit Rmail Edit mode before getting new mail."))
230 (if (and existed (> (buffer-size) 0))
231 ;; Buffer not new and not empty; ensure in proper mode, but that's all.
232 (or (eq major-mode 'rmail-mode)
235 ;; Convert all or part to Babyl file if possible.
237 (goto-char (point-max))
238 (if (null rmail-inbox-list)
240 (rmail-set-message-counters)
241 (rmail-show-message))))
242 (let ((existing-unseen (rmail-first-unseen-message)))
244 (rmail-get-new-mail))
245 ;; Show the first unseen message, which might be from a previous session
246 ;; or might have been just read in by rmail-get-new-mail. Must
247 ;; determine already unseen messages first, as rmail-get-new-mail
248 ;; positions on the first new message, thus marking it as seen.
249 (rmail-show-message existing-unseen))))
251 ;; Given the value of MAILPATH, return a list of inbox file names.
252 ;; This is turned off because it is not clear that the user wants
253 ;; all these inboxes to feed into the primary rmail file.
254 ; (defun rmail-convert-mailpath (string)
256 ; (while (setq idx (string-match "[%:]" string))
257 ; (let ((this (substring string 0 idx)))
258 ; (setq string (substring string (1+ idx)))
259 ; (setq list (cons (if (string-match "%" this)
260 ; (substring this 0 (string-match "%" this))
265 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
266 ; will not cause emacs 18.55 problems.
268 (defun rmail-convert-file ()
271 (goto-char (point-min))
272 ;; If file doesn't start like a Babyl file,
273 ;; convert it to one, by adding a header and converting each message.
274 (cond ((looking-at "BABYL OPTIONS:"))
275 ((looking-at "Version: 5\n")
276 ;; Losing babyl file made by old version of Rmail.
277 ;; Just fix the babyl file header; don't make a new one,
278 ;; so we don't lose the Labels: file attribute, etc.
279 (let ((buffer-read-only nil))
280 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
281 ((equal (point-min) (point-max))
282 ;; Empty RMAIL file. Just insert the header.
283 (rmail-insert-rmail-file-header))
285 ;; Non-empty file in non-RMAIL format. Add header and convert.
287 (rmail-insert-rmail-file-header)))
288 ;; If file was not a Babyl file or if there are
289 ;; Unix format messages added at the end,
290 ;; convert file as necessary.
293 (goto-char (point-max))
294 (search-backward "\^_")
296 (looking-at "\n*From ")))
297 (let ((buffer-read-only nil))
298 (message "Converting to Babyl format...")
299 ;; If file needs conversion, convert it all,
300 ;; except for the BABYL header.
301 ;; (rmail-convert-to-babyl-format would delete the header.)
302 (goto-char (point-min))
303 (search-forward "\n\^_" nil t)
304 (narrow-to-region (point) (point-max))
305 (rmail-convert-to-babyl-format)
306 (message "Converting to Babyl format...done")))))
308 ;;; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
309 ;;; will not cause emacs 18.55 problems.
311 (defun rmail-insert-rmail-file-header ()
312 (let ((buffer-read-only nil))
313 (insert "BABYL OPTIONS: -*- rmail -*-
316 Note: This is the header of an rmail file.
317 Note: If you are seeing it in rmail,
318 Note: it means the file has no messages in it.\n\^_")))
322 (setq rmail-mode-map (make-keymap))
323 (suppress-keymap rmail-mode-map)
324 (define-key rmail-mode-map "a" 'rmail-add-label)
325 (define-key rmail-mode-map "b" 'rmail-bury)
326 (define-key rmail-mode-map "c" 'rmail-continue)
327 (define-key rmail-mode-map "d" 'rmail-delete-forward)
328 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward)
329 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
330 (define-key rmail-mode-map "f" 'rmail-forward)
331 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
332 (define-key rmail-mode-map "h" 'rmail-summary)
333 (define-key rmail-mode-map "i" 'rmail-input)
334 (define-key rmail-mode-map "j" 'rmail-show-message)
335 (define-key rmail-mode-map "k" 'rmail-kill-label)
336 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
337 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
338 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
339 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
340 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
341 (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
342 (define-key rmail-mode-map "m" 'rmail-mail)
343 (define-key rmail-mode-map "\em" 'rmail-retry-failure)
344 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
345 (define-key rmail-mode-map "\en" 'rmail-next-message)
346 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
347 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
348 (define-key rmail-mode-map "\C-o" 'rmail-output)
349 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
350 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
351 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
352 (define-key rmail-mode-map "q" 'rmail-quit)
353 (define-key rmail-mode-map "r" 'rmail-reply)
354 ;; I find I can't live without the default M-r command -- rms.
355 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
356 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
357 (define-key rmail-mode-map "\es" 'rmail-search)
358 (define-key rmail-mode-map "t" 'rmail-toggle-header)
359 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
360 (define-key rmail-mode-map "w" 'rmail-edit-current-message)
361 (define-key rmail-mode-map "x" 'rmail-expunge)
362 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
363 (define-key rmail-mode-map "<" 'rmail-first-message)
364 (define-key rmail-mode-map ">" 'rmail-last-message)
365 (define-key rmail-mode-map " " 'scroll-up)
366 (define-key rmail-mode-map "\177" 'scroll-down)
367 (define-key rmail-mode-map "?" 'describe-mode)
368 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
369 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
370 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
371 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
372 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
373 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
376 (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
378 (define-key rmail-mode-map [menu-bar classify]
379 (cons "Classify" (make-sparse-keymap "Classify")))
381 (define-key rmail-mode-map [menu-bar classify output-inbox]
382 '("Output (inbox)" . rmail-output))
384 (define-key rmail-mode-map [menu-bar classify output]
385 '("Output (Rmail)" . rmail-output-to-rmail-file))
387 (define-key rmail-mode-map [menu-bar classify kill-label]
388 '("Kill Label" . rmail-kill-label))
390 (define-key rmail-mode-map [menu-bar classify add-label]
391 '("Add Label" . rmail-add-label))
393 (define-key rmail-mode-map [menu-bar summary]
394 (cons "Summary" (make-sparse-keymap "Summary")))
396 (define-key rmail-mode-map [menu-bar summary labels]
397 '("By Labels" . rmail-summary-by-labels))
399 (define-key rmail-mode-map [menu-bar summary recipients]
400 '("By Recipients" . rmail-summary-by-recipients))
402 (define-key rmail-mode-map [menu-bar summary topic]
403 '("By Topic" . rmail-summary-by-topic))
405 (define-key rmail-mode-map [menu-bar summary regexp]
406 '("By Regexp" . rmail-summary-by-regexp))
408 (define-key rmail-mode-map [menu-bar summary all]
409 '("All" . rmail-summary))
411 (define-key rmail-mode-map [menu-bar mail]
412 (cons "Mail" (make-sparse-keymap "Mail")))
414 (define-key rmail-mode-map [menu-bar mail continue]
415 '("Continue" . rmail-continue))
417 (define-key rmail-mode-map [menu-bar mail forward]
418 '("Forward" . rmail-forward))
420 (define-key rmail-mode-map [menu-bar mail retry]
421 '("Retry" . rmail-retry-failure))
423 (define-key rmail-mode-map [menu-bar mail reply]
424 '("Reply" . rmail-reply))
426 (define-key rmail-mode-map [menu-bar mail mail]
427 '("Mail" . rmail-mail))
429 (define-key rmail-mode-map [menu-bar delete]
430 (cons "Delete" (make-sparse-keymap "Delete")))
432 (define-key rmail-mode-map [menu-bar delete expunge/save]
433 '("Expunge/Save" . rmail-expunge-and-save))
435 (define-key rmail-mode-map [menu-bar delete expunge]
436 '("Expunge" . rmail-expunge))
438 (define-key rmail-mode-map [menu-bar delete undelete]
439 '("Undelete" . rmail-undelete-previous-message))
441 (define-key rmail-mode-map [menu-bar delete delete]
442 '("Delete" . rmail-delete-forward))
444 (define-key rmail-mode-map [menu-bar move]
445 (cons "Move" (make-sparse-keymap "Move")))
447 (define-key rmail-mode-map [menu-bar move search-back]
448 '("Search Back" . rmail-search-backward))
450 (define-key rmail-mode-map [menu-bar move search]
451 '("Search" . rmail-search))
453 (define-key rmail-mode-map [menu-bar move previous]
454 '("Previous Nondeleted" . rmail-previous-undeleted-message))
456 (define-key rmail-mode-map [menu-bar move next]
457 '("Next Nondeleted" . rmail-next-undeleted-message))
459 (define-key rmail-mode-map [menu-bar move last]
460 '("Last" . rmail-last-message))
462 (define-key rmail-mode-map [menu-bar move first]
463 '("First" . rmail-first-message))
465 (define-key rmail-mode-map [menu-bar move previous]
466 '("Previous" . rmail-previous-message))
468 (define-key rmail-mode-map [menu-bar move next]
469 '("Next" . rmail-next-message))
471 ;; Rmail mode is suitable only for specially formatted data.
472 (put 'rmail-mode 'mode-class 'special)
476 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
477 All normal editing commands are turned off.
478 Instead, these commands are available:
480 \\[rmail-beginning-of-message] Move point to front of this message (same as \\[beginning-of-buffer]).
481 \\[scroll-up] Scroll to next screen of this message.
482 \\[scroll-down] Scroll to previous screen of this message.
483 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
484 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
485 \\[rmail-next-message] Move to Next message whether deleted or not.
486 \\[rmail-previous-message] Move to Previous message whether deleted or not.
487 \\[rmail-first-message] Move to the first message in Rmail file.
488 \\[rmail-last-message] Move to the last message in Rmail file.
489 \\[rmail-show-message] Jump to message specified by numeric position in file.
490 \\[rmail-search] Search for string and show message it is found in.
491 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
492 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
493 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
494 till a deleted message is found.
495 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
496 \\[rmail-expunge] Expunge deleted messages.
497 \\[rmail-expunge-and-save] Expunge and save the file.
498 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
499 \\[save-buffer] Save without expunging.
500 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
501 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
502 \\[rmail-continue] Continue composing outgoing message started before.
503 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
504 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
505 \\[rmail-forward] Forward this message to another user.
506 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
507 \\[rmail-output] Output this message to a Unix-format mail file (append it).
508 \\[rmail-input] Input Rmail file. Run Rmail on that file.
509 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
510 \\[rmail-kill-label] Kill label. Remove a label from current message.
511 \\[rmail-next-labeled-message] Move to Next message with specified label
512 (label defaults to last one specified).
513 Standard labels: filed, unseen, answered, forwarded, deleted.
514 Any other label is present only if you add it with \\[rmail-add-label].
515 \\[rmail-previous-labeled-message] Move to Previous message with specified label
516 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
517 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
518 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
519 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
520 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
521 \\[rmail-toggle-header] Toggle display of complete header."
524 (rmail-set-message-counters)
525 (rmail-show-message rmail-total-messages))
527 (defun rmail-mode-2 ()
528 (kill-all-local-variables)
531 (run-hooks 'rmail-mode-hook))
533 (defun rmail-mode-1 ()
534 (setq major-mode 'rmail-mode)
535 (setq mode-name "RMAIL")
536 (setq buffer-read-only t)
537 ;; No need to auto save RMAIL files in normal circumstances
538 ;; because they contain no info except attribute changes
539 ;; and deletion of messages.
540 ;; The one exception is when messages are copied into an Rmail mode buffer.
541 ;; rmail-output-to-rmail-file enables auto save when you do that.
542 (setq buffer-auto-save-file-name nil)
543 (if (boundp 'mode-line-modified)
544 (setq mode-line-modified "--- ")
545 (setq mode-line-format
546 (cons "--- " (cdr (default-value 'mode-line-format)))))
547 (use-local-map rmail-mode-map)
548 (set-syntax-table text-mode-syntax-table)
549 (setq local-abbrev-table text-mode-abbrev-table))
551 (defun rmail-variables ()
552 (make-local-variable 'revert-buffer-function)
553 (setq revert-buffer-function 'rmail-revert)
554 (make-local-variable 'rmail-last-label)
555 (make-local-variable 'rmail-last-regexp)
556 (make-local-variable 'rmail-deleted-vector)
557 (make-local-variable 'rmail-summary-buffer)
558 (make-local-variable 'rmail-summary-vector)
559 (make-local-variable 'rmail-current-message)
560 (make-local-variable 'rmail-total-messages)
561 (make-local-variable 'require-final-newline)
562 (setq require-final-newline nil)
563 (make-local-variable 'version-control)
564 (setq version-control 'never)
565 (make-local-variable 'file-precious-flag)
566 (setq file-precious-flag t)
567 (make-local-variable 'rmail-message-vector)
568 (make-local-variable 'rmail-last-file)
569 (make-local-variable 'rmail-inbox-list)
570 (setq rmail-inbox-list (rmail-parse-file-inboxes))
571 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
572 (and (null rmail-inbox-list)
573 (or (equal buffer-file-name (expand-file-name rmail-file-name))
574 (equal buffer-file-truename
575 (abbreviate-file-name (file-truename rmail-file-name))))
576 (setq rmail-inbox-list
577 (or rmail-primary-inbox-list
578 (list (or (getenv "MAIL")
579 (concat rmail-spool-directory
580 (user-original-login-name)))))))
581 (make-local-variable 'rmail-keywords)
582 ;; this gets generated as needed
583 (setq rmail-keywords nil))
585 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
586 (defun rmail-revert (arg noconfirm)
587 (let (revert-buffer-function)
588 ;; Call our caller again, but this time it does the default thing.
589 (if (revert-buffer arg noconfirm)
590 ;; If the user said "yes", and we changed something,
591 ;; reparse the messages.
594 (goto-char (point-max))
595 (rmail-set-message-counters)
596 (rmail-show-message)))))
598 ;; Return a list of files from this buffer's Mail: option.
599 ;; Does not assume that messages have been parsed.
600 ;; Just returns nil if buffer does not look like Babyl format.
601 (defun rmail-parse-file-inboxes ()
606 (cond ((looking-at "BABYL OPTIONS:")
607 (search-forward "\n\^_" nil 'move)
608 (narrow-to-region 1 (point))
610 (if (search-forward "\nMail:" nil t)
612 (narrow-to-region (point) (progn (end-of-line) (point)))
613 (goto-char (point-min))
614 (mail-parse-comma-list))))))))
616 (defun rmail-expunge-and-save ()
617 "Expunge and save RMAIL file."
625 (rmail-expunge-and-save)
626 ;; Don't switch to the summary buffer even if it was recently visible.
627 (if rmail-summary-buffer
628 (bury-buffer rmail-summary-buffer))
629 (let ((obuf (current-buffer)))
630 (switch-to-buffer (other-buffer))
634 (defun rmail-input (filename)
635 "Run Rmail on file FILENAME."
636 (interactive "FRun rmail on RMAIL file: ")
640 ;;;; *** Rmail input ***
642 ;; RLK feature not added in this version:
643 ;; argument specifies inbox file or files in various ways.
645 (defun rmail-get-new-mail (&optional file-name)
646 "Move any new mail from this RMAIL file's inbox files.
647 The inbox files can be specified with the file's Mail: option. The
648 variable `rmail-primary-inbox-list' specifies the inboxes for your
649 primary RMAIL file if it has no Mail: option. By default, this is
650 your /usr/spool/mail/$USER.
652 You can also specify the file to get new mail from. In this case, the
653 file of new mail is not changed or deleted. Noninteractively, you can
654 pass the inbox file name as an argument. Interactively, a prefix
655 argument causes us to read a file name and use that file as the inbox."
657 (list (if current-prefix-arg
658 (read-file-name "Get new mail from file: "))))
659 (or (verify-visited-file-modtime (current-buffer))
661 (find-file (buffer-file-name))
662 (setq buffer-read-only t)
663 (if (verify-visited-file-modtime (current-buffer))
664 (rmail-forget-messages))))
665 (rmail-maybe-set-message-counters)
667 ;; Get rid of all undo records for this buffer.
668 (or (eq buffer-undo-list t)
669 (setq buffer-undo-list nil))
671 (let ((opoint (point))
674 ;; If buffer has not changed yet, and has not been saved yet,
675 ;; don't replace the old backup file now.
676 (make-backup-files (and make-backup-files (buffer-modified-p)))
677 (buffer-read-only nil)
678 ;; Don't make undo records for what we do in getting mail.
679 (buffer-undo-list t))
680 (goto-char (point-max))
681 (skip-chars-backward " \t\n") ; just in case of brain damage
682 (delete-region (point) (point-max)) ; caused by require-final-newline
685 (narrow-to-region (point) (point))
686 ;; Read in the contents of the inbox files,
687 ;; renaming them as necessary,
688 ;; and adding to the list of files to delete eventually.
690 (rmail-insert-inbox-text (list file-name) nil)
691 (setq delete-files (rmail-insert-inbox-text rmail-inbox-list t)))
692 ;; Scan the new text and convert each message to babyl format.
693 (goto-char (point-min))
695 (setq new-messages (rmail-convert-to-babyl-format)))
696 (or (zerop new-messages)
699 (search-backward "\n\^_" nil t)
700 (narrow-to-region (point) (point-max))
701 (goto-char (1+ (point-min)))
702 (rmail-count-new-messages)
704 ;; Delete the old files, now that babyl file is saved.
707 ;; First, try deleting.
709 (delete-file (car delete-files))
711 ;; If we can't delete it, truncate it.
712 (write-region (point) (point) (car delete-files))))
714 (setq delete-files (cdr delete-files)))))
715 (if (= new-messages 0)
716 (progn (goto-char opoint)
717 (if (or file-name rmail-inbox-list)
718 (message "(No new mail has arrived)")))
719 (if (rmail-summary-exists)
720 (rmail-select-summary
721 (rmail-update-summary)))
722 (message "%d new message%s read"
723 new-messages (if (= 1 new-messages) "" "s"))
724 (and (boundp 'display-time-string)
725 (stringp display-time-string)
726 (string-match " Mail" display-time-string)
727 (setq display-time-string
729 (substring display-time-string 0 (match-beginning 0))
730 (substring display-time-string (match-end 0))))
731 (force-mode-line-update 'all))))
732 ;; Don't leave the buffer screwed up if we get a disk-full error.
733 (rmail-show-message)))
735 (defun rmail-insert-inbox-text (files renamep)
736 (let (file tofile delete-files movemail popmail)
738 (setq file (expand-file-name (substitute-in-file-name (car files)))
739 ;;>> un*x specific <<
740 ;; The "+" used to be "~", which is an extremely poor choice;
741 ;; it might accidentally be deleted when space is low
742 ;; (as happened to me!).
743 tofile (concat file "+"))
744 ;; If getting from mail spool directory,
745 ;; use movemail to move rather than just renaming,
746 ;; so as to interlock with the mailer.
747 (setq movemail (equal (file-name-directory file) rmail-spool-directory)
748 popmail (string-match "^po:" (file-name-nondirectory file)))
749 (if popmail (setq file (file-name-nondirectory file)
753 (setq tofile (expand-file-name
754 ;; Generate name to move to from inbox name,
755 ;; in case of multiple inboxes that need moving.
756 (concat ".newmail-" (file-name-nondirectory file))
757 ;; Use the directory of this rmail file
758 ;; because it's a nuisance to use the homedir
759 ;; if that is on a full disk and this rmail
762 (expand-file-name buffer-file-name))))
763 ;; On some systems, /usr/spool/mail/foo is a directory
764 ;; and the actual inbox is /usr/spool/mail/foo/foo.
765 (if (file-directory-p file)
766 (setq file (expand-file-name (user-original-login-name)
769 (message "Getting mail from post office ...")
770 (if (or (and (file-exists-p tofile)
771 (/= 0 (nth 7 (file-attributes tofile))))
772 (and (file-exists-p file)
773 (/= 0 (nth 7 (file-attributes file)))))
774 (message "Getting mail from %s..." file)))
775 ;; Set TOFILE if have not already done so, and
776 ;; rename or copy the file FILE to TOFILE if and as appropriate.
779 ((or (file-exists-p tofile) (and (not popmail)
780 (not (file-exists-p file))))
782 ((and (not movemail) (not popmail))
783 ;; Try copying. If that fails (perhaps no space),
786 (copy-file file tofile nil)
788 ;; Third arg is t so we can replace existing file TOFILE.
789 (rename-file file tofile t)))
790 ;; Make the real inbox file empty.
791 ;; Leaving it deleted could cause lossage
792 ;; because mailers often won't create the file.
794 (write-region (point) (point) file)
800 (setq errors (generate-new-buffer " *rmail loss*"))
801 (buffer-disable-undo errors)
803 (expand-file-name "movemail" exec-directory)
804 nil errors nil file tofile)
805 (if (not (buffer-modified-p errors))
806 ;; No output => movemail won
809 (subst-char-in-region (point-min) (point-max)
811 (goto-char (point-max))
812 (skip-chars-backward " \t")
813 (delete-region (point) (point-max))
814 (goto-char (point-min))
815 (if (looking-at "movemail: ")
816 (delete-region (point-min) (match-end 0)))
818 (message (concat "movemail: "
819 (buffer-substring (point-min)
823 (if errors (kill-buffer errors))))))
824 ;; At this point, TOFILE contains the name to read:
825 ;; Either the alternate name (if we renamed)
826 ;; or the actual inbox (if not renaming).
827 (if (file-exists-p tofile)
829 (goto-char (point-max))
830 (setq size (nth 1 (insert-file-contents tofile)))
831 (goto-char (point-max))
832 (or (= (preceding-char) ?\n)
835 (setq delete-files (cons tofile delete-files))))
837 (setq files (cdr files)))
840 ;; the rmail-break-forwarded-messages feature is not implemented
841 (defun rmail-convert-to-babyl-format ()
842 (let ((count 0) start
843 (case-fold-search nil)
844 (invalid-input-resync
846 (message "Invalid Babyl format in inbox!")
848 ;; Try to get back in sync with a real message.
849 (if (re-search-forward
850 (concat mmdf-delim1 "\\|^From") nil t)
852 (goto-char (point-max)))))))
853 (goto-char (point-min))
856 (cond ((looking-at "BABYL OPTIONS:");Babyl header
857 (if (search-forward "\n\^_" nil t)
858 ;; If we find the proper terminator, delete through there.
859 (delete-region (point-min) (point))
860 (funcall invalid-input-resync)
861 (delete-region (point-min) (point))))
862 ;; Babyl format message
864 (or (search-forward "\n\^_" nil t)
865 (funcall invalid-input-resync))
866 (setq count (1+ count))
867 ;; Make sure there is no extra white space after the ^_
868 ;; at the end of the message.
869 ;; Narrowing will make sure that whatever follows the junk
870 ;; will be treated properly.
871 (delete-region (point)
873 (skip-chars-forward " \t\n")
875 (narrow-to-region (point) (point-max)))
877 ((let ((case-fold-search t))
878 (looking-at mmdf-delim1))
879 (let ((case-fold-search t))
880 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
882 (re-search-forward mmdf-delim2 nil t)
883 (replace-match "\^_"))
886 (narrow-to-region start (1- (point)))
887 (goto-char (point-min))
888 (while (search-forward "\n\^_" nil t); single char "\^_"
889 (replace-match "\n^_")))); 2 chars: "^" and "_"
890 (narrow-to-region (point) (point-max))
891 (setq count (1+ count)))
893 ((looking-at "^From ")
895 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
896 (rmail-nuke-pinhead-header)
897 ;; If this message has a Content-Length field,
898 ;; skip to the end of the contents.
899 (let* ((header-end (save-excursion
900 (and (re-search-forward "\n\n" nil t)
904 ;; Get the numeric value from the Content-Length field.
906 ;; Back up to end of prev line,
907 ;; in case the Content-Length field comes first.
909 (and (search-forward "\ncontent-length: "
912 (eol (progn (end-of-line) (point))))
913 (read (buffer-substring beg eol)))))))
914 (and size (numberp size) (>= size 0)
915 (goto-char (+ header-end size))))
917 (if (re-search-forward
919 rmail-unix-mail-delimiter
923 "\^L\n[01],\\)") nil t)
924 (goto-char (match-beginning 1))
925 (goto-char (point-max)))
926 (setq count (1+ count))
929 (narrow-to-region start (point))
930 (goto-char (point-min))
931 (while (search-forward "\n\^_" nil t); single char
932 (replace-match "\n^_")))); 2 chars: "^" and "_"
934 (narrow-to-region (point) (point-max)))
936 ;; This kludge is because some versions of sendmail.el
937 ;; insert an extra newline at the beginning that shouldn't
938 ;; be there. sendmail.el has been fixed, but old versions
939 ;; may still be in use. -- rms, 7 May 1993.
940 ((eolp) (delete-char 1))
941 (t (error "Cannot convert to babyl format")))))
944 ;; Delete the "From ..." line, creating various other headers with
945 ;; information from it if they don't already exist. Now puts the
946 ;; original line into a mail-from: header line for debugging and for
947 ;; use by the rmail-output function.
948 (defun rmail-nuke-pinhead-header ()
951 (let ((start (point))
954 (search-forward "\n\n")
956 (goto-char (point-max))
960 (narrow-to-region start end)
961 (let ((case-fold-search t))
963 (setq has-from (search-forward "\nFrom:" nil t))
965 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
967 (let ((case-fold-search nil))
968 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
972 ;; Keep and reformat the date if we don't
973 ;; have a Date: field.
977 "Date: \\3, \\5 \\4 \\9 \\6 "
979 ;; The timezone could be matched by group 7 or group 10.
980 ;; If neither of them matched, assume EST, since only
981 ;; Easterners would be so sloppy.
982 ;; It's a shame the substitution can't use "\\10".
984 ((/= (match-beginning 7) (match-end 7)) "\\7")
985 ((/= (match-beginning 10) (match-end 10))
986 (buffer-substring (match-beginning 10)
990 ;; Keep and reformat the sender if we don't
991 ;; have a From: field.
997 ;;;; *** Rmail Message Formatting and Header Manipulation ***
999 (defun rmail-reformat-message (beg end)
1002 (if (/= (following-char) ?0)
1003 (error "Bad format in RMAIL file."))
1004 (let ((buffer-read-only nil)
1005 (delta (- (buffer-size) end)))
1009 (let ((case-fold-search t))
1010 (while (looking-at "Summary-line:\\|Mail-From:")
1012 (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
1013 (delete-region (point)
1014 (progn (forward-line 1) (point))))
1015 (let ((str (buffer-substring (point)
1016 (save-excursion (search-forward "\n\n" end 'move)
1018 (insert str "*** EOOH ***\n")
1019 (narrow-to-region (point) (- (buffer-size) delta)))
1020 (goto-char (point-min))
1021 (if rmail-ignored-headers (rmail-clear-headers))
1022 (if rmail-message-filter (funcall rmail-message-filter))))
1024 (defun rmail-clear-headers ()
1025 (if (search-forward "\n\n" nil t)
1027 (narrow-to-region (point-min) (point))
1028 (let ((buffer-read-only nil))
1029 (while (let ((case-fold-search t))
1030 (goto-char (point-min))
1031 (re-search-forward rmail-ignored-headers nil t))
1033 (delete-region (point)
1034 (progn (re-search-forward "\n[^ \t]")
1038 (defun rmail-toggle-header ()
1039 "Show original message header if pruned header currently shown, or vice versa."
1041 (rmail-maybe-set-message-counters)
1042 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1043 (let ((buffer-read-only nil))
1044 (goto-char (point-min))
1046 (if (= (following-char) ?1)
1047 (progn (delete-char 1)
1050 (let ((case-fold-search t))
1051 (while (looking-at "Summary-Line:\\|Mail-From:")
1053 (insert "*** EOOH ***\n")
1055 (search-forward "\n*** EOOH ***\n")
1057 (let ((temp (point)))
1058 (and (search-forward "\n\n" nil t)
1059 (delete-region temp (point))))
1060 (goto-char (point-min))
1061 (search-forward "\n*** EOOH ***\n")
1062 (narrow-to-region (point) (point-max)))
1063 (rmail-reformat-message (point-min) (point-max)))))
1065 ;;;; *** Rmail Attributes and Keywords ***
1067 ;; Make a string describing current message's attributes and keywords
1068 ;; and set it up as the name of a minor mode
1069 ;; so it will appear in the mode line.
1070 (defun rmail-display-labels ()
1071 (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
1076 (goto-char (rmail-msgbeg rmail-current-message))
1078 (if (looking-at "[01],")
1080 (narrow-to-region (point) (progn (end-of-line) (point)))
1081 ;; Truly valid BABYL format requires a space before each
1082 ;; attribute or keyword name. Put them in if missing.
1083 (let (buffer-read-only)
1084 (goto-char (point-min))
1085 (while (search-forward "," nil t)
1086 (or (looking-at "[ ,]") (eobp)
1088 (goto-char (point-max))
1089 (if (search-backward ",," nil 'move)
1091 (if (> (point) (1+ (point-min)))
1092 (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
1093 (if (> (- (point-max) (point)) 2)
1097 (buffer-substring (+ (point) 3)
1098 (1- (point-max)))))))))))
1099 ;; Note: we don't use save-restriction because that does not work right
1100 ;; if changes are made outside the saved restriction
1101 ;; before that restriction is restored.
1102 (narrow-to-region beg end)
1103 (set-marker beg nil)
1104 (set-marker end nil)))
1105 (while (string-match " +," blurb)
1106 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1107 (substring blurb (match-end 0)))))
1108 (while (string-match ", +" blurb)
1109 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1110 (substring blurb (match-end 0)))))
1111 (setq mode-line-process
1112 (concat " " rmail-current-message "/" rmail-total-messages
1115 ;; Turn an attribute of a message on or off according to STATE.
1116 ;; ATTR is the name of the attribute, as a string.
1117 ;; MSGNUM is message number to change; nil means current message.
1118 (defun rmail-set-attribute (attr state &optional msgnum)
1119 (let ((omax (point-max-marker))
1120 (omin (point-min-marker))
1121 (buffer-read-only nil))
1122 (or msgnum (setq msgnum rmail-current-message))
1127 (goto-char (+ 3 (rmail-msgbeg msgnum)))
1130 (null (search-backward (concat ", " attr ",")
1131 (prog1 (point) (end-of-line)) t)))))
1132 (or (eq curstate (not (not state)))
1134 (delete-region (point) (1- (match-end 0)))
1137 (insert " " attr ","))))
1138 (if (string= attr "deleted")
1139 (rmail-set-message-deleted-p msgnum state)))
1140 ;; Note: we don't use save-restriction because that does not work right
1141 ;; if changes are made outside the saved restriction
1142 ;; before that restriction is restored.
1143 (narrow-to-region omin omax)
1144 (set-marker omin nil)
1145 (set-marker omax nil)
1146 (if (= msgnum rmail-current-message)
1147 (rmail-display-labels))))))
1149 ;; Return t if the attributes/keywords line of msg number MSG
1150 ;; contains a match for the regexp LABELS.
1151 (defun rmail-message-labels-p (msg labels)
1155 (goto-char (rmail-msgbeg msg))
1157 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
1159 ;;;; *** Rmail Message Selection And Support ***
1161 (defun rmail-msgend (n)
1162 (marker-position (aref rmail-message-vector (1+ n))))
1164 (defun rmail-msgbeg (n)
1165 (marker-position (aref rmail-message-vector n)))
1167 (defun rmail-widen-to-current-msgbeg (function)
1168 "Call FUNCTION with point at start of internal data of current message.
1169 Assumes that bounds were previously narrowed to display the message in Rmail.
1170 The bounds are widened enough to move point where desired, then narrowed
1173 FUNCTION may not change the visible text of the message, but it may
1174 change the invisible header text."
1176 (let ((obeg (- (point-max) (point-min))))
1179 (narrow-to-region (rmail-msgbeg rmail-current-message)
1181 (goto-char (point-min))
1183 ;; Note: we don't use save-restriction because that does not work right
1184 ;; if changes are made outside the saved restriction
1185 ;; before that restriction is restored.
1186 ;; Here we assume that changes made by FUNCTION
1187 ;; occur before the visible region of the message.
1188 (narrow-to-region (- (point-max) obeg) (point-max))))))
1190 (defun rmail-forget-messages ()
1192 (if (vectorp rmail-message-vector)
1194 (v rmail-message-vector)
1197 (move-marker (aref v i) nil)
1199 (setq rmail-message-vector nil)
1200 (setq rmail-deleted-vector nil)))
1202 (defun rmail-maybe-set-message-counters ()
1203 (if (not (and rmail-deleted-vector
1204 rmail-message-vector
1205 rmail-current-message
1206 rmail-total-messages))
1207 (rmail-set-message-counters)))
1209 (defun rmail-count-new-messages (&optional nomsg)
1210 (let* ((case-fold-search nil)
1214 (or nomsg (message "Counting new messages..."))
1215 (goto-char (point-max))
1216 ;; Put at the end of messages-head
1217 ;; the entry for message N+1, which marks
1218 ;; the end of message N. (N = number of messages).
1219 (search-backward "\n\^_")
1221 (setq messages-head (list (point-marker)))
1222 (rmail-set-message-counters-counter (point-min))
1223 (setq rmail-current-message (1+ rmail-total-messages))
1224 (setq rmail-total-messages
1225 (+ rmail-total-messages total-messages))
1226 (setq rmail-message-vector
1227 (vconcat rmail-message-vector (cdr messages-head)))
1228 (aset rmail-message-vector
1229 rmail-current-message (car messages-head))
1230 (setq rmail-deleted-vector
1231 (concat rmail-deleted-vector deleted-head))
1232 (setq rmail-summary-vector
1233 (vconcat rmail-summary-vector (make-vector total-messages nil)))
1234 (goto-char (point-min))
1235 (or nomsg (message "Counting new messages...done (%d)" total-messages))))
1237 (defun rmail-set-message-counters ()
1238 (rmail-forget-messages)
1242 (let* ((point-save (point))
1244 (messages-after-point)
1245 (case-fold-search nil)
1248 (message "Counting messages...")
1249 (goto-char (point-max))
1250 ;; Put at the end of messages-head
1251 ;; the entry for message N+1, which marks
1252 ;; the end of message N. (N = number of messages).
1253 (search-backward "\n\^_" nil t)
1254 (if (/= (point) (point-max)) (forward-char 1))
1255 (setq messages-head (list (point-marker)))
1256 (rmail-set-message-counters-counter (min (point) point-save))
1257 (setq messages-after-point total-messages)
1258 (rmail-set-message-counters-counter)
1259 (setq rmail-total-messages total-messages)
1260 (setq rmail-current-message
1262 (max 1 (- total-messages messages-after-point))))
1263 (setq rmail-message-vector
1264 (apply 'vector (cons (point-min-marker) messages-head))
1265 rmail-deleted-vector (concat "D" deleted-head)
1266 rmail-summary-vector (make-vector rmail-total-messages nil))
1267 (message "Counting messages...done")))))
1269 (defun rmail-set-message-counters-counter (&optional stop)
1270 (while (search-backward "\n\^_\^L\n" stop t)
1272 (setq messages-head (cons (point-marker) messages-head))
1275 (cons (if (search-backward ", deleted,"
1281 (if (zerop (% (setq total-messages (1+ total-messages)) 20))
1282 (message "Counting messages...%d" total-messages))))
1284 (defun rmail-beginning-of-message ()
1285 "Show current message starting from the beginning."
1287 (rmail-show-message rmail-current-message))
1289 (defun rmail-show-message (&optional n)
1290 "Show message number N (prefix argument), counting from start of file.
1291 If summary buffer is currently displayed, update current message there also."
1293 (rmail-maybe-set-message-counters)
1295 (if (zerop rmail-total-messages)
1296 (progn (narrow-to-region (point-min) (1- (point-max)))
1297 (goto-char (point-min))
1298 (setq mode-line-process nil))
1301 (setq n rmail-current-message)
1304 rmail-current-message 1
1305 blurb "No previous message"))
1306 ((> n rmail-total-messages)
1307 (setq n rmail-total-messages
1308 rmail-current-message rmail-total-messages
1309 blurb "No following message"))
1311 (setq rmail-current-message n))))
1312 (let ((beg (rmail-msgbeg n))
1313 (end (rmail-msgend n)))
1316 (if (= (following-char) ?0)
1318 (rmail-reformat-message beg end)
1319 (rmail-set-attribute "unseen" nil))
1320 (search-forward "\n*** EOOH ***\n" end t)
1321 (narrow-to-region (point) end))
1322 (goto-char (point-min))
1323 (rmail-display-labels)
1324 (run-hooks 'rmail-show-message-hook)
1325 ;; If there is a summary buffer, try to move to this message
1326 ;; in that buffer. But don't complain if this message
1327 ;; is not mentioned in the summary.
1328 (if (rmail-summary-exists)
1329 (let ((curr-msg rmail-current-message))
1330 (rmail-select-summary
1331 (rmail-summary-goto-msg curr-msg t t))))
1333 (message blurb))))))
1335 (defun rmail-next-message (n)
1336 "Show following message whether deleted or not.
1337 With prefix arg N, moves forward N messages, or backward if N is negative."
1339 (rmail-maybe-set-message-counters)
1340 (rmail-show-message (+ rmail-current-message n)))
1342 (defun rmail-previous-message (n)
1343 "Show previous message whether deleted or not.
1344 With prefix arg N, moves backward N messages, or forward if N is negative."
1346 (rmail-next-message (- n)))
1348 (defun rmail-next-undeleted-message (n)
1349 "Show following non-deleted message.
1350 With prefix arg N, moves forward N non-deleted messages,
1351 or backward if N is negative.
1353 Returns t if a new message is being shown, nil otherwise."
1355 (rmail-maybe-set-message-counters)
1356 (let ((lastwin rmail-current-message)
1357 (current rmail-current-message))
1358 (while (and (> n 0) (< current rmail-total-messages))
1359 (setq current (1+ current))
1360 (if (not (rmail-message-deleted-p current))
1361 (setq lastwin current n (1- n))))
1362 (while (and (< n 0) (> current 1))
1363 (setq current (1- current))
1364 (if (not (rmail-message-deleted-p current))
1365 (setq lastwin current n (1+ n))))
1366 (if (/= lastwin rmail-current-message)
1367 (progn (rmail-show-message lastwin)
1370 (message "No previous nondeleted message"))
1372 (message "No following nondeleted message"))
1375 (defun rmail-previous-undeleted-message (n)
1376 "Show previous non-deleted message.
1377 With prefix argument N, moves backward N non-deleted messages,
1378 or forward if N is negative."
1380 (rmail-next-undeleted-message (- n)))
1382 (defun rmail-first-message ()
1383 "Show first message in file."
1385 (rmail-maybe-set-message-counters)
1386 (rmail-show-message 1))
1388 (defun rmail-last-message ()
1389 "Show last message in file."
1391 (rmail-maybe-set-message-counters)
1392 (rmail-show-message rmail-total-messages))
1394 (defun rmail-what-message ()
1395 (let ((where (point))
1397 (high rmail-total-messages)
1398 (mid (/ rmail-total-messages 2)))
1399 (while (> (- high low) 1)
1400 (if (>= where (rmail-msgbeg mid))
1403 (setq mid (+ low (/ (- high low) 2))))
1404 (if (>= where (rmail-msgbeg high)) high low)))
1406 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
1408 (goto-char (rmail-msgbeg msg))
1409 (search-forward "\n*** EOOH ***\n")
1410 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
1411 (or (string-match recipients (or (mail-fetch-field "To") ""))
1412 (string-match recipients (or (mail-fetch-field "From") ""))
1413 (if (not primary-only)
1414 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
1416 (defun rmail-message-regexp-p (msg regexp)
1417 "Return t, if for message number MSG, regexp REGEXP matches in the header."
1418 (goto-char (rmail-msgbeg msg))
1421 (search-forward "*** EOOH ***" (point-max)) (point))))
1422 (re-search-forward regexp end t)))
1424 (defun rmail-search-backward (regexp &optional n)
1425 "Show message containing next match for REGEXP.
1426 Prefix argument gives repeat count; negative argument means search
1427 backwards (through earlier messages).
1428 Interactively, empty argument means use same regexp used last time."
1430 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1432 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1434 (if rmail-search-last-regexp
1435 (setq prompt (concat prompt
1437 rmail-search-last-regexp
1439 (setq regexp (read-string prompt))
1440 (cond ((not (equal regexp ""))
1441 (setq rmail-search-last-regexp regexp))
1442 ((not rmail-search-last-regexp)
1443 (error "No previous Rmail search string")))
1444 (list rmail-search-last-regexp
1445 (prefix-numeric-value current-prefix-arg))))
1446 (rmail-search regexp (- n)))
1448 (defvar rmail-search-last-regexp nil)
1449 (defun rmail-search (regexp &optional n)
1450 "Show message containing next match for REGEXP.
1451 Prefix argument gives repeat count; negative argument means search
1452 backwards (through earlier messages).
1453 Interactively, empty argument means use same regexp used last time."
1455 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1457 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1459 (if rmail-search-last-regexp
1460 (setq prompt (concat prompt
1462 rmail-search-last-regexp
1464 (setq regexp (read-string prompt))
1465 (cond ((not (equal regexp ""))
1466 (setq rmail-search-last-regexp regexp))
1467 ((not rmail-search-last-regexp)
1468 (error "No previous Rmail search string")))
1469 (list rmail-search-last-regexp
1470 (prefix-numeric-value current-prefix-arg))))
1472 (message "%sRmail search for %s..."
1473 (if (< n 0) "Reverse " "")
1475 (rmail-maybe-set-message-counters)
1476 (let ((omin (point-min))
1481 (msg rmail-current-message))
1486 ;; Check messages one by one, advancing message number up or down
1487 ;; but searching forward through each message.
1489 (while (and (null win) (> msg 1))
1490 (goto-char (rmail-msgbeg (setq msg (1- msg))))
1491 (setq win (re-search-forward
1492 regexp (rmail-msgend msg) t)))
1493 (while (and (null win) (< msg rmail-total-messages))
1494 (goto-char (rmail-msgbeg (setq msg (1+ msg))))
1495 (setq win (re-search-forward regexp (rmail-msgend msg) t))))
1496 (setq n (+ n (if reversep 1 -1)))))
1499 ;; If this is a reverse search and we found a message,
1500 ;; search backward thru this message to position point.
1503 (goto-char (rmail-msgend msg))
1505 regexp (rmail-msgbeg msg) t)))
1507 (rmail-show-message msg)
1508 (message "%sRmail search for %s...done"
1509 (if reversep "Reverse " "")
1513 (narrow-to-region omin omax)
1515 (message "Search failed: %s" regexp)))))
1517 (defun rmail-search-backwards (regexp &optional n)
1518 "Show message containing previous match for REGEXP.
1519 Prefix argument gives repeat count; negative argument means search
1520 forward (through later messages).
1521 Interactively, empty argument means use same regexp used last time."
1523 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1525 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1527 (if rmail-search-last-regexp
1528 (setq prompt (concat prompt
1530 rmail-search-last-regexp
1532 (setq regexp (read-string prompt))
1533 (cond ((not (equal regexp ""))
1534 (setq rmail-search-last-regexp regexp))
1535 ((not rmail-search-last-regexp)
1536 (error "No previous Rmail search string")))
1537 (list rmail-search-last-regexp
1538 (prefix-numeric-value current-prefix-arg))))
1539 (rmail-search regexp (- (or n -1))))
1541 ;; Show the first message which has the `unseen' attribute.
1542 (defun rmail-first-unseen-message ()
1543 (rmail-maybe-set-message-counters)
1548 (while (and (not found) (< current rmail-total-messages))
1549 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
1550 (setq found current))
1551 (setq current (1+ current))))
1552 ;; Let the caller show the message.
1554 ;; (rmail-show-message found))
1557 ;;;; *** Rmail Message Deletion Commands ***
1559 (defun rmail-message-deleted-p (n)
1560 (= (aref rmail-deleted-vector n) ?D))
1562 (defun rmail-set-message-deleted-p (n state)
1563 (aset rmail-deleted-vector n (if state ?D ?\ )))
1565 (defun rmail-delete-message ()
1566 "Delete this message and stay on it."
1568 (rmail-set-attribute "deleted" t))
1570 (defun rmail-undelete-previous-message ()
1571 "Back up to deleted message, select it, and undelete it."
1573 (let ((msg rmail-current-message))
1574 (while (and (> msg 0)
1575 (not (rmail-message-deleted-p msg)))
1576 (setq msg (1- msg)))
1578 (error "No previous deleted message")
1579 (if (/= msg rmail-current-message)
1580 (rmail-show-message msg))
1581 (rmail-set-attribute "deleted" nil)
1582 (if (rmail-summary-exists)
1584 (set-buffer rmail-summary-buffer)
1585 (rmail-summary-mark-undeleted msg)))
1586 (rmail-maybe-display-summary))))
1588 (defun rmail-delete-forward (&optional backward)
1589 "Delete this message and move to next nondeleted one.
1590 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
1591 With prefix argument, delete and move backward.
1593 Returns t if a new message is displayed after the delete, or nil otherwise."
1595 (rmail-set-attribute "deleted" t)
1596 (let ((del-msg rmail-current-message))
1597 (if (rmail-summary-exists)
1599 (set-buffer rmail-summary-buffer)
1600 (rmail-summary-mark-deleted del-msg)))
1601 (prog1 (rmail-next-undeleted-message (if backward -1 1))
1602 (rmail-maybe-display-summary))))
1604 (defun rmail-delete-backward ()
1605 "Delete this message and move to previous nondeleted one.
1606 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1608 (rmail-delete-forward t))
1610 (defun rmail-only-expunge ()
1611 "Actually erase all deleted messages in the file."
1613 (message "Expunging deleted messages...")
1614 ;; Discard all undo records for this buffer.
1615 (or (eq buffer-undo-list t)
1616 (setq buffer-undo-list nil))
1617 (rmail-maybe-set-message-counters)
1618 (let* ((omax (- (buffer-size) (point-max)))
1619 (omin (- (buffer-size) (point-min)))
1620 (opoint (if (and (> rmail-current-message 0)
1621 (= ?D (aref rmail-deleted-vector rmail-current-message)))
1622 0 (- (point) (point-min))))
1623 (messages-head (cons (aref rmail-message-vector 0) nil))
1624 (messages-tail messages-head)
1625 ;; Don't make any undo records for the expunging.
1626 (buffer-undo-list t)
1631 (goto-char (point-min))
1634 (total rmail-total-messages)
1635 (new-message-number rmail-current-message)
1637 (buffer-read-only nil)
1638 (messages rmail-message-vector)
1639 (deleted rmail-deleted-vector)
1640 (summary rmail-summary-vector))
1641 (setq rmail-total-messages nil
1642 rmail-current-message nil
1643 rmail-message-vector nil
1644 rmail-deleted-vector nil
1645 rmail-summary-vector nil)
1646 (while (<= number total)
1647 (if (= (aref deleted number) ?D)
1650 (marker-position (aref messages number))
1651 (marker-position (aref messages (1+ number))))
1652 (move-marker (aref messages number) nil)
1653 (if (> new-message-number counter)
1654 (setq new-message-number (1- new-message-number))))
1655 (setq counter (1+ counter))
1657 (setcdr messages-tail
1658 (cons (aref messages number) nil)))
1660 (cons (if (= counter number) (aref summary (1- number)))
1662 (if (zerop (% (setq number (1+ number)) 20))
1663 (message "Expunging deleted messages...%d" number)))
1665 (setcdr messages-tail
1666 (cons (aref messages number) nil)))
1667 (setq rmail-current-message new-message-number
1668 rmail-total-messages counter
1669 rmail-message-vector (apply 'vector messages-head)
1670 rmail-deleted-vector (make-string (1+ counter) ?\ )
1671 rmail-summary-vector (vconcat (nreverse new-summary))
1673 (message "Expunging deleted messages...done")
1675 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
1677 (if (zerop rmail-current-message) 1 nil))
1678 (forward-char opoint))))
1680 (defun rmail-expunge ()
1681 "Erase deleted messages from Rmail file and summary buffer."
1683 (rmail-only-expunge)
1684 (if (rmail-summary-exists)
1685 (rmail-select-summary
1686 (rmail-update-summary))))
1688 ;;;; *** Rmail Mailing Commands ***
1690 (defun rmail-start-mail (&rest args)
1691 (if (and window-system rmail-mail-new-frame)
1693 (apply 'mail-other-frame args)
1694 (modify-frame-parameters (selected-frame)
1695 '((dedicated . t))))
1696 (apply 'mail-other-window args)))
1698 (defun rmail-mail ()
1699 "Send mail in another window.
1700 While composing the message, use \\[mail-yank-original] to yank the
1701 original message into it."
1703 (rmail-start-mail nil nil nil nil nil (current-buffer)))
1705 (defun rmail-continue ()
1706 "Continue composing outgoing message previously being composed."
1708 (rmail-start-mail t))
1710 (defun rmail-reply (just-sender)
1711 "Reply to the current message.
1712 Normally include CC: to all other recipients of original message;
1713 prefix argument means ignore them. While composing the reply,
1714 use \\[mail-yank-original] to yank the original message into it."
1716 (let (from reply-to cc subject date to message-id resent-reply-to)
1720 (goto-char (rmail-msgbeg rmail-current-message))
1722 (if (= (following-char) ?0)
1724 (progn (forward-line 2)
1726 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
1729 (narrow-to-region (point)
1730 (progn (search-forward "\n*** EOOH ***\n")
1731 (beginning-of-line) (point))))
1732 (setq resent-reply-to (mail-fetch-field "resent-reply-to" t)
1733 from (mail-fetch-field "from")
1734 reply-to (or resent-reply-to
1735 (mail-fetch-field "reply-to" nil t)
1737 cc (cond (just-sender nil)
1738 (resent-reply-to (mail-fetch-field "resent-cc" t))
1739 (t (mail-fetch-field "cc" nil t)))
1740 subject (or (and resent-reply-to
1741 (mail-fetch-field "resent-subject" t))
1742 (mail-fetch-field "subject"))
1743 date (cond (resent-reply-to
1744 (mail-fetch-field "resent-date" t))
1745 ((mail-fetch-field "date")))
1746 to (cond (resent-reply-to
1747 (mail-fetch-field "resent-to" t))
1748 ((mail-fetch-field "to" nil t))
1749 ;((mail-fetch-field "apparently-to")) ack gag barf
1751 message-id (cond (resent-reply-to
1752 (mail-fetch-field "resent-message-id" t))
1753 ((mail-fetch-field "message-id"))))))
1754 (and (stringp subject)
1755 (or (string-match (concat "\\`" (regexp-quote rmail-reply-prefix))
1757 (setq subject (concat rmail-reply-prefix subject))))
1758 (rmail-start-mail nil
1759 (mail-strip-quoted-names reply-to)
1761 (rmail-make-in-reply-to-field from date message-id)
1764 (let* ((cc-list (rmail-dont-reply-to
1765 (mail-strip-quoted-names
1766 (if (null cc) to (concat to ", " cc))))))
1767 (if (string= cc-list "") nil cc-list)))
1769 (list (list '(lambda (buf msgnum)
1772 (rmail-set-attribute "answered" t msgnum)))
1773 (current-buffer) rmail-current-message)))))
1775 (defun rmail-make-in-reply-to-field (from date message-id)
1782 (let ((tem (car (rfc822-addresses from))))
1785 (regexp-quote (if (string-match "@[^@]*\\'" tem)
1786 (substring tem 0 (match-beginning 0))
1789 ;; Message-ID is sufficiently informative
1791 (concat message-id " (" tem ")"))
1792 ;; Use prin1 to fake RFC822 quoting
1793 (let ((field (prin1-to-string tem)))
1795 (concat field "'s message of " date)
1797 ((let* ((foo "[^][\000-\037\177-\377()<>@,;:\\\" ]+")
1798 (bar "[^][\000-\037\177-\377()<>@,;:\\\"]+"))
1799 ;; Can't use format because format loses on \000 (unix *^&%*^&%$!!)
1800 (or (string-match (concat "\\`[ \t]*\\(" bar
1801 "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
1802 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
1804 (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
1805 bar "\\))[ \t]*\\'")
1806 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
1808 (let ((start (match-beginning 1))
1809 (end (match-end 1)))
1810 ;; Trim whitespace which above regexp match allows
1811 (while (and (< start end)
1812 (memq (aref from start) '(?\t ?\ )))
1813 (setq start (1+ start)))
1814 (while (and (< start end)
1815 (memq (aref from (1- end)) '(?\t ?\ )))
1816 (setq end (1- end)))
1817 (let ((field (substring from start end)))
1818 (if date (setq field (concat "message from " field " on " date)))
1820 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
1821 (concat message-id " (" field ")")
1824 ;; If we can't kludge it simply, do it correctly
1825 (let ((mail-use-rfc822 t))
1826 (rmail-make-in-reply-to-field from date message-id)))))
1828 (defun rmail-forward (resend)
1829 "Forward the current message to another user.
1830 With prefix argument, \"resend\" the message instead of forwarding it;
1831 see the documentation of `rmail-resend'."
1834 (call-interactively 'rmail-resend)
1835 (let ((forward-buffer (current-buffer))
1836 (subject (concat "["
1837 (let ((from (or (mail-fetch-field "From")
1838 (mail-fetch-field ">From"))))
1840 (concat (mail-strip-quoted-names from) ": ")
1842 (or (mail-fetch-field "Subject") "")
1844 ;; If only one window, use it for the mail buffer.
1845 ;; Otherwise, use another window for the mail buffer
1846 ;; so that the Rmail buffer remains visible
1847 ;; and sending the mail will get back to it.
1848 (if (funcall (if (and (not rmail-mail-new-frame) (one-window-p t))
1850 (function rmail-start-mail))
1851 nil nil subject nil nil nil
1852 (list (list (function (lambda (buf msgnum)
1855 (rmail-set-attribute
1856 "forwarded" t msgnum))))
1858 rmail-current-message)))
1860 ;; Insert after header separator--before signature if any.
1861 (goto-char (point-min))
1862 (search-forward-regexp
1863 (concat "^" (regexp-quote mail-header-separator)))
1865 (insert-buffer forward-buffer))))))
1867 (defun rmail-resend (address &optional from comment mail-alias-file)
1868 "Resend current message to ADDRESSES.
1869 ADDRESSES should be a single address, a string consisting of several
1870 addresses separated by commas, or a list of addresses.
1872 Optional FROM is the address to resend the message from, and
1873 defaults to the username of the person redistributing the message.
1874 Optional COMMENT is a string that will be inserted as a comment in the
1876 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
1877 typically for purposes of moderating a list."
1878 (interactive "sResend to: ")
1880 (require 'mailalias)
1881 (if (not from) (setq from (user-login-name)))
1882 (let ((tembuf (generate-new-buffer " sendmail temp"))
1883 (mail-header-separator "")
1884 (case-fold-search nil)
1885 (mailbuf (current-buffer)))
1888 ;;>> Copy message into temp buffer
1890 (insert-buffer-substring mailbuf)
1891 (goto-char (point-min))
1892 ;; Delete any Sender field, since that's not specifyable.
1893 ; Only delete Sender fields in the actual header.
1894 (re-search-forward "^$" nil 'move)
1895 ; Using "while" here rather than "if" because some buggy mail
1896 ; software may have inserted multiple Sender fields.
1897 (while (re-search-backward "^Sender:" nil t)
1901 (while (looking-at "[ \t]")
1903 (delete-region beg (point))))
1904 ; Go back to the beginning of the buffer so the Resent- fields
1905 ; are inserted there.
1906 (goto-char (point-min))
1907 ;;>> Insert resent-from:
1908 (insert "Resent-From: " from "\n")
1909 (insert "Resent-Date: " (mail-rfc822-date) "\n")
1910 ;;>> Insert resent-to: and bcc if need be.
1911 (let ((before (point)))
1913 (insert "Resent-Bcc: " (user-login-name) "\n"))
1914 (insert "Resent-To: " (if (stringp address)
1916 (mapconcat 'identity address ",\n\t"))
1918 (expand-mail-aliases before (point)))
1919 ;;>> Set up comment, if any.
1920 (if (and (sequencep comment) (not (zerop (length comment))))
1921 (let ((before (point))
1924 (or (eolp) (insert "\n"))
1925 (setq after (point))
1927 (while (< (point) after)
1928 (insert "Resent-Comment: ")
1930 ;; Don't expand aliases in the destination fields
1931 ;; of the original message.
1933 (funcall send-mail-function)))
1934 (kill-buffer tembuf))
1935 (rmail-set-attribute "resent" t rmail-current-message)))
1937 (defvar mail-unsent-separator
1938 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1939 "^ *---+ +Returned message +---+ *$\\|"
1940 "^ *---+ +Original message +---+ *$\\|"
1941 "^ *--+ +begin message +--+ *$\\|"
1942 "^ *---+ +Original message follows +---+ *$\\|"
1943 "^|? *---+ +Message text follows: +---+ *|?$"))
1945 (defun rmail-retry-failure ()
1946 "Edit a mail message which is based on the contents of the current message.
1947 For a message rejected by the mail system, extract the interesting headers and
1948 the body of the original message."
1950 (require 'mail-utils)
1951 (let (to subj irp2 cc orig-message)
1953 ;; Narrow down to just the quoted original message
1954 (rmail-beginning-of-message)
1955 (let ((case-fold-search t))
1956 (or (re-search-forward mail-unsent-separator nil t)
1957 (error "Cannot parse this as a failure message")))
1959 (narrow-to-region (point) (point-max))
1960 ;; Now mail-fetch-field will get from headers of the original message,
1961 ;; not from the headers of the rejection.
1962 (setq to (mail-fetch-field "To")
1963 subj (mail-fetch-field "Subject")
1964 irp2 (mail-fetch-field "In-reply-to")
1965 cc (mail-fetch-field "Cc"))
1966 ;; Get the entire text (not headers) of the original message.
1969 (progn (search-forward "\n\n") (point))
1971 ;; Start sending a new message; default header fields from the original.
1972 ;; Turn off the usual actions for initializing the message body
1973 ;; because we want to get only the text from the failure message.
1974 (let (mail-signature
1975 (mail-setup-hook rmail-retry-setup-hook))
1976 (if (rmail-start-mail nil to subj irp2 cc (current-buffer))
1977 ;; Insert original text as initial text of new draft message.
1979 (goto-char (point-max))
1980 (insert orig-message)
1981 (goto-char (point-min))
1984 (defun rmail-bury ()
1985 "Bury current Rmail buffer and its summary buffer."
1987 ;; This let var was called rmail-buffer, but that interfered
1988 ;; with the buffer-local var used in summary buffers.
1989 (let ((buffer-to-bury (current-buffer)))
1990 (if (rmail-summary-exists)
1992 (while (setq window (get-buffer-window rmail-summary-buffer))
1993 (set-window-buffer window (other-buffer rmail-summary-buffer)))
1994 (bury-buffer rmail-summary-buffer)))
1995 (switch-to-buffer (other-buffer (current-buffer)))
1996 (bury-buffer buffer-to-bury)))
1998 (defun rmail-summary-exists ()
1999 "Non-nil iff in an RMAIL buffer and an associated summary buffer exists.
2000 Non-nil value returned is the summary buffer."
2001 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2002 rmail-summary-buffer))
2004 (defun rmail-summary-displayed ()
2005 "t iff in RMAIL buffer and an associated summary buffer is displayed."
2006 (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
2008 (defvar rmail-redisplay-summary nil
2009 "*Non-nil means Rmail should show the summary when it changes.
2010 This has an effect only if a summary buffer exists.")
2012 ;; Put the summary buffer back on the screen, if user wants that.
2013 (defun rmail-maybe-display-summary ()
2014 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
2015 rmail-redisplay-summary
2016 (display-buffer rmail-summary-buffer)))
2018 ;;;; *** Rmail Specify Inbox Files ***
2020 (autoload 'set-rmail-inbox-list "rmailmsc"
2021 "Set the inbox list of the current RMAIL file to FILE-NAME.
2022 This may be a list of file names separated by commas.
2023 If FILE-NAME is empty, remove any inbox list."
2026 ;;;; *** Rmail Commands for Labels ***
2028 (autoload 'rmail-add-label "rmailkwd"
2029 "Add LABEL to labels associated with current RMAIL message.
2030 Completion is performed over known labels when reading."
2033 (autoload 'rmail-kill-label "rmailkwd"
2034 "Remove LABEL from labels associated with current RMAIL message.
2035 Completion is performed over known labels when reading."
2038 (autoload 'rmail-next-labeled-message "rmailkwd"
2039 "Show next message with LABEL. Defaults to last label used.
2040 With prefix argument N moves forward N messages with this label."
2043 (autoload 'rmail-previous-labeled-message "rmailkwd"
2044 "Show previous message with LABEL. Defaults to last label used.
2045 With prefix argument N moves backward N messages with this label."
2048 (autoload 'rmail-read-label "rmailkwd"
2049 "PROMPT and read with completion an Rmail message label."
2052 ;;;; *** Rmail Edit Mode ***
2054 (autoload 'rmail-edit-current-message "rmailedit"
2055 "Edit the contents of the current message"
2058 ;;;; *** Rmail Sorting ***
2060 (autoload 'rmail-sort-by-date "rmailsort"
2061 "Sort messages of current Rmail file by date.
2062 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2064 (autoload 'rmail-sort-by-subject "rmailsort"
2065 "Sort messages of current Rmail file by subject.
2066 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2068 (autoload 'rmail-sort-by-author "rmailsort"
2069 "Sort messages of current Rmail file by author.
2070 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2072 (autoload 'rmail-sort-by-recipient "rmailsort"
2073 "Sort messages of current Rmail file by recipient.
2074 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2076 (autoload 'rmail-sort-by-correspondent "rmailsort"
2077 "Sort messages of current Rmail file by other correspondent.
2078 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2080 (autoload 'rmail-sort-by-lines "rmailsort"
2081 "Sort messages of current Rmail file by number of lines.
2082 If prefix argument REVERSE is non-nil, sort them in reverse order." t)
2084 ;;;; *** Rmail Summary Mode ***
2086 (autoload 'rmail-summary "rmailsum"
2087 "Display a summary of all messages, one line per message."
2090 (autoload 'rmail-summary-by-labels "rmailsum"
2091 "Display a summary of all messages with one or more LABELS.
2092 LABELS should be a string containing the desired labels, separated by commas."
2095 (autoload 'rmail-summary-by-recipients "rmailsum"
2096 "Display a summary of all messages with the given RECIPIENTS.
2097 Normally checks the To, From and Cc fields of headers; but if PRIMARY-ONLY
2098 is non-nil (prefix arg given), only look in the To and From fields.
2099 RECIPIENTS is a string of regexps separated by commas."
2102 (autoload 'rmail-summary-by-regexp "rmailsum"
2103 "Display a summary of all messages according to regexp REGEXP.
2104 If the regular expression is found in the header of the message
2105 \(including in the date and other lines, as well as the subject line),
2106 Emacs will list the header line in the RMAIL-summary."
2109 (autoload 'rmail-summary-by-topic "rmailsum"
2110 "Display a summary of all messages with the given SUBJECT.
2111 Normally checks the Subject field of headers;
2112 but if WHOLE-MESSAGE is non-nil (prefix arg given),
2113 look in the whole message.
2114 SUBJECT is a string of regexps separated by commas."
2117 ;;;; *** Rmail output messages to files ***
2119 (autoload 'rmail-output-to-rmail-file "rmailout"
2120 "Append the current message to an Rmail file named FILE-NAME.
2121 If the file does not exist, ask if it should be created.
2122 If file is being visited, the message is appended to the Emacs
2123 buffer visiting that file."
2126 (autoload 'rmail-output "rmailout"
2127 "Append this message to Unix mail file named FILE-NAME."
2130 ;;;; *** Rmail undigestification ***
2132 (autoload 'undigestify-rmail-message "undigest"
2133 "Break up a digest message into its constituent messages.
2134 Leaves original message, deleted, before the undigestified messages."
2139 ;;; rmail.el ends here