Function: rmail

rmail is an autoloaded, interactive and byte-compiled function defined in rmail.el.gz.

Signature

(rmail &optional FILE-NAME-ARG)

Documentation

Read and edit incoming mail.

Moves messages into file named by rmail-file-name and edits that file in RMAIL Mode. Type C-h m (describe-mode) once editing that file, for a list of RMAIL commands.

May be called with file name as argument; then performs rmail editing on that file, but does not copy any new mail into the file. Interactively, if you supply a prefix argument, then you have a chance to specify a file name with the minibuffer.

If rmail-display-summary is non-nil, make a summary for this RMAIL file.

View in manual

Probably introduced at or before Emacs version 1.10.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
;;;###autoload
(defun rmail (&optional file-name-arg)
  "Read and edit incoming mail.
Moves messages into file named by `rmail-file-name' and edits that
file in RMAIL Mode.
Type \\[describe-mode] once editing that file, for a list of RMAIL commands.

May be called with file name as argument; then performs rmail editing on
that file, but does not copy any new mail into the file.
Interactively, if you supply a prefix argument, then you
have a chance to specify a file name with the minibuffer.

If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
  (interactive (if current-prefix-arg
		   (list (read-file-name "Run rmail on RMAIL file: "))))
  (rmail-require-mime-maybe)
  (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
	 ;; Use find-buffer-visiting, not get-file-buffer, for those users
	 ;; who have find-file-visit-truename set to t.
	 (existed (find-buffer-visiting file-name))
	 run-mail-hook mail-buf msg-shown)
    ;; Determine if an existing mail file has been changed behind the
    ;; scene...
    (if (and existed (not (verify-visited-file-modtime existed)))
	;; The mail file has been changed.  Revisit it and reset the
	;; message state variables when in rmail mode.
	(progn
	  (find-file file-name)
	  (when (and (verify-visited-file-modtime existed)
		     (eq major-mode 'rmail-mode))
	    (rmail-swap-buffers-maybe)
	    (rmail-set-message-counters)))
      ;; The mail file is either unchanged or not visited.  Visit it.
      (switch-to-buffer
       (let ((enable-local-variables nil)
	     ;; Force no-conversion by default, since that's what
	     ;; pre-mbox Rmail did with BABYL files (via
	     ;; auto-coding-regexp-alist).
	     (coding-system-for-read
	      (or coding-system-for-read 'no-conversion)))
	 (find-file-noselect file-name))))
    ;; Ensure that the collection and view buffers are in sync and
    ;; ensure that a message is not being edited.
    (if (eq major-mode 'rmail-mode)
	(rmail-swap-buffers-maybe))
    (if (eq major-mode 'rmail-edit-mode)
	(error "Exit Rmail Edit mode before getting new mail"))
    (or (and existed (> (buffer-size) 0))
	(setq run-mail-hook t))
    ;; Ensure that the Rmail file is in mbox format, the buffer is in
    ;; Rmail mode and has been scanned to find all the messages
    ;; (setting the global message variables in the process).
    (rmail-convert-file-maybe)
    (unless (eq major-mode 'rmail-mode)
      (rmail-mode-2))
    (goto-char (point-max))
    (rmail-maybe-set-message-counters)
    (setq mail-buf rmail-buffer)
    ;; Show the first unread message and process summary mode.
    (unwind-protect
	;; Only get new mail when there is not a file name argument.
	(unless file-name-arg
	  (setq msg-shown (rmail-get-new-mail)))
      (progn
	(set-buffer mail-buf)
	(or msg-shown
	    (rmail-show-message (rmail-first-unseen-message)))
	(if rmail-display-summary (rmail-summary))
	(rmail-construct-io-menu)
	(if run-mail-hook
	    (run-hooks 'rmail-mode-hook))))))