Function: rmail-summary-goto-msg

rmail-summary-goto-msg is an interactive and byte-compiled function defined in rmailsum.el.gz.

Signature

(rmail-summary-goto-msg &optional N NOWARN SKIP-RMAIL)

Documentation

Go to message N in the summary buffer and the Rmail buffer.

If N is nil, use the message corresponding to point in the summary and move to that message in the Rmail buffer.

If NOWARN, don't say anything if N is out of range. If SKIP-RMAIL, don't do anything to the Rmail buffer. Returns non-nil if message N was found.

Probably introduced at or before Emacs version 21.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailsum.el.gz
(defun rmail-summary-goto-msg (&optional n nowarn skip-rmail)
  "Go to message N in the summary buffer and the Rmail buffer.
If N is nil, use the message corresponding to point in the summary
and move to that message in the Rmail buffer.

If NOWARN, don't say anything if N is out of range.
If SKIP-RMAIL, don't do anything to the Rmail buffer.
Returns non-nil if message N was found."
  (interactive "P")
  (if (consp n) (setq n (prefix-numeric-value n)))
  (if (eobp) (forward-line -1))
  (beginning-of-line)
  (let* ((obuf (current-buffer))
	 (buf rmail-buffer)
	 (cur (point))
	 message-not-found
	 (curmsg (string-to-number
		  (buffer-substring (point)
				    (min (point-max) (+ 6 (point))))))
	 (total (with-current-buffer buf rmail-total-messages)))
    ;; CURMSG should be nil when there's no current summary message
    ;; (for instance, if the summary is empty).
    (if (= curmsg 0)
	(setq curmsg nil))
    ;; If message number N was specified, find that message's line
    ;; or set message-not-found.
    ;; If N wasn't specified or that message can't be found.
    ;; set N by default.
    (if (not n)
	(setq n curmsg)
      (if (< n 1)
	  (progn (message "No preceding message")
		 (setq n 1)))
      (if (and (> n total)
	       (> total 0))
	  (progn (message "No following message")
		 (goto-char (point-max))
		 (rmail-summary-goto-msg nil nowarn skip-rmail)))
      (goto-char (point-min))
      (if (not (re-search-forward (format "^%5d[^0-9]" n) nil t))
	  (progn (or nowarn (message "Message %d not found" n))
		 (setq n curmsg)
		 (setq message-not-found t)
		 (goto-char cur))))
    ;; N can be nil now, along with CURMSG,
    ;; if the summary is empty.
    (when n
      (rmail-summary-mark-seen n)
      (rmail-summary-update-highlight message-not-found)
      (beginning-of-line)
      (unless skip-rmail
	(let ((selwin (selected-window)))
	  (unwind-protect
	      (progn (rmail-pop-to-buffer buf)
		     (rmail-show-message n))
	    (select-window selwin)
	    ;; The actions above can alter the current buffer.  Preserve it.
	    (set-buffer obuf)))))
    (not message-not-found)))