Function: rmail-get-new-mail
rmail-get-new-mail is an interactive and byte-compiled function
defined in rmail.el.gz.
Signature
(rmail-get-new-mail &optional FILE-NAME)
Documentation
Move any new mail from this Rmail file's inbox files.
The buffer-local variable rmail-inbox-list specifies the list
of inbox files. By default, this is nil, except for your primary
Rmail file rmail-file-name. In this case, when you first visit
the Rmail file it is initialized using either
rmail-primary-inbox-list, or the "MAIL" environment variable,
or the function user-login-name(var)/user-login-name(fun) and the directory
rmail-spool-directory (whose value depends on the operating system).
The command set-rmail-inbox-list sets rmail-inbox-list to the
value you specify.
You can also specify the file to get new mail from just for one instance of this command. In this case, the file of new mail is not changed or deleted. Noninteractively, you can pass the inbox file name as an argument. Interactively, a prefix argument causes us to read a file name and use that file as the inbox.
If the variable rmail-preserve-inbox is non-nil, new mail will
always be left in inbox files rather than deleted.
Before doing anything, this runs rmail-before-get-new-mail-hook.
Just before returning, it runs rmail-after-get-new-mail-hook,
whether or not there is new mail.
If there is new mail, it runs rmail-get-new-mail-hook, saves
the updated file, and shows the first unseen message (which might
not be a new one). It returns non-nil if it got any new messages.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
;; RLK feature not added in this version:
;; argument specifies inbox file or files in various ways.
;; In Babyl, the Mail: header in the preamble overrode rmail-inbox-list.
;; Mbox does not have this feature.
(defun rmail-get-new-mail (&optional file-name)
"Move any new mail from this Rmail file's inbox files.
The buffer-local variable `rmail-inbox-list' specifies the list
of inbox files. By default, this is nil, except for your primary
Rmail file `rmail-file-name'. In this case, when you first visit
the Rmail file it is initialized using either
`rmail-primary-inbox-list', or the \"MAIL\" environment variable,
or the function `user-login-name' and the directory
`rmail-spool-directory' (whose value depends on the operating system).
The command `set-rmail-inbox-list' sets `rmail-inbox-list' to the
value you specify.
You can also specify the file to get new mail from just for one
instance of this command. In this case, the file of new mail is
not changed or deleted. Noninteractively, you can pass the inbox
file name as an argument. Interactively, a prefix argument
causes us to read a file name and use that file as the inbox.
If the variable `rmail-preserve-inbox' is non-nil, new mail will
always be left in inbox files rather than deleted.
Before doing anything, this runs `rmail-before-get-new-mail-hook'.
Just before returning, it runs `rmail-after-get-new-mail-hook',
whether or not there is new mail.
If there is new mail, it runs `rmail-get-new-mail-hook', saves
the updated file, and shows the first unseen message (which might
not be a new one). It returns non-nil if it got any new messages."
(interactive
(list (if current-prefix-arg
(read-file-name "Get new mail from file: "))))
(run-hooks 'rmail-before-get-new-mail-hook)
;; If the disk file has been changed from under us,
;; revert to it before we get new mail.
(or (verify-visited-file-modtime (current-buffer))
(find-file (buffer-file-name)))
(set-buffer rmail-buffer)
(rmail-modify-format)
(rmail-swap-buffers-maybe)
(rmail-maybe-set-message-counters)
(widen)
;; Get rid of all undo records for this buffer.
(or (eq buffer-undo-list t)
(setq buffer-undo-list nil))
(let ((all-files (if file-name (list file-name) rmail-inbox-list))
(rmail-enable-multibyte t)
found)
(unwind-protect
(progn
;; This loops if any members of the inbox list have the same
;; basename (see "name conflict" below).
(while all-files
(let (;; If buffer has not changed yet, and has not been
;; saved yet, don't replace the old backup file now.
(make-backup-files (and make-backup-files
(buffer-modified-p)))
(buffer-read-only nil)
;; Don't make undo records while getting mail.
(buffer-undo-list t)
files file-last-names) ;; delete-files
;; Pull files off all-files onto files as long as there is
;; no name conflict. A conflict happens when two inbox
;; file names have the same last component.
;; The reason this careful handling is necessary seems
;; to be that rmail-insert-inbox-text uses .newmail-BASENAME.
(while (and all-files
(not (member (file-name-nondirectory (car all-files))
file-last-names)))
(setq files (cons (car all-files) files)
file-last-names
(cons (file-name-nondirectory (car all-files)) files))
(setq all-files (cdr all-files)))
;; Put them back in their original order.
(setq files (nreverse files))
(goto-char (point-max))
;; Make sure we end with a blank line unless there are
;; no messages, as required by mbox format (Bug#9974).
(unless (bobp)
(while (not (looking-back "\n\n" (- (point) 2)))
(insert "\n")))
(setq found (or
(rmail-get-new-mail-1 file-name files nil) ;; delete-files
found))))
;; Move to the first new message unless we have other unseen
;; messages before it.
(if found (rmail-show-message (rmail-first-unseen-message)))
(run-hooks 'rmail-after-get-new-mail-hook)
found)
;; Don't leave the buffer screwed up if we get a disk-full error.
(rmail-show-message))))