Function: rmail-show-message-1

rmail-show-message-1 is a byte-compiled function defined in rmail.el.gz.

Signature

(rmail-show-message-1 &optional MSG)

Documentation

Show message MSG (default: current message) using rmail-view-buffer.

Return text to display in the minibuffer if MSG is out of range (displaying a reasonable choice as well), nil otherwise. The current mail message becomes the message displayed.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-show-message-1 (&optional msg)
  "Show message MSG (default: current message) using `rmail-view-buffer'.
Return text to display in the minibuffer if MSG is out of
range (displaying a reasonable choice as well), nil otherwise.
The current mail message becomes the message displayed."
  (let ((mbox-buf rmail-buffer)
	(view-buf rmail-view-buffer)
	blurb beg end body-start coding-system character-coding
	is-text-message header-style
	showing-message)
    (if (not msg)
	(setq msg rmail-current-message))
    (unless (setq blurb (rmail-no-mail-p))
      (cond ((<= msg 0)
	     (setq msg 1
		   rmail-current-message 1
		   blurb "No previous message"))
	    ((> msg rmail-total-messages)
	     (setq msg rmail-total-messages
		   rmail-current-message rmail-total-messages
		   blurb "No following message"))
	    (t (setq rmail-current-message msg)))
      (with-current-buffer rmail-buffer
	(setq header-style rmail-header-style)
	;; Mark the message as seen, but preserve buffer modified flag.
	(let ((modiff (buffer-modified-p)))
	  (rmail-set-attribute rmail-unseen-attr-index nil)
          (and rmail-show-message-set-modified
               (setq modiff t))
	  (unless modiff
	    (restore-buffer-modified-p modiff)))
	;; bracket the message in the mail
	;; buffer and determine the coding system the transfer encoding.
	(rmail-swap-buffers-maybe)
	(setq beg (rmail-msgbeg msg)
	      end (rmail-msgend msg))
	(when (> (- end beg) rmail-show-message-verbose-min)
	  (setq showing-message t)
	  (message "Showing message %d..." msg))
	(narrow-to-region beg end)
	(goto-char beg)
	(with-current-buffer rmail-view-buffer
	  ;; We give the view buffer a buffer-local value of
	  ;; rmail-header-style based on the binding in effect when
          ;; this function is called; `rmail-toggle-header' can
	  ;; inspect this value to determine how to toggle.
          (setq-local rmail-header-style header-style)
          ;; In case viewing the previous message sets the paragraph
          ;; direction non-nil, we reset it here to allow independent
          ;; dynamic determination of paragraph direction in every
          ;; message.
          (setq bidi-paragraph-direction nil))
	(if (and rmail-enable-mime
		 rmail-show-mime-function
		 (re-search-forward "mime-version: 1.0" nil t))
	    (let ((rmail-buffer mbox-buf)
		  (rmail-view-buffer view-buf))
              (setq-local rmail-mime-decoded t)
	      (funcall rmail-show-mime-function))
	  (setq body-start (search-forward "\n\n" nil t))
	  (narrow-to-region beg (point))
	  (goto-char beg)
	  (save-excursion
	    (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
		(setq coding-system (intern (match-string 1)))
	      (setq coding-system (rmail-get-coding-system))))
	  (setq character-coding (mail-fetch-field "content-transfer-encoding")
		is-text-message (rmail-is-text-p))
	  (if character-coding
	      (setq character-coding (downcase character-coding)))
	  (narrow-to-region beg end)
	  ;; Decode the message body into an empty view buffer using a
	  ;; unibyte temporary buffer where the character decoding takes
	  ;; place.
	  (with-current-buffer rmail-view-buffer
	    (erase-buffer))
	  (if (null character-coding)
	      ;; Do it directly since that is fast.
	      (rmail-decode-region body-start end coding-system view-buf)
	    ;; Can this be done directly, skipping the temp buffer?
	    (with-temp-buffer
	      (set-buffer-multibyte nil)
	      (insert-buffer-substring mbox-buf body-start end)
	      (cond
	       ((string= character-coding "quoted-printable")
		;; See bug#5441.
		(or (mail-unquote-printable-region (point-min) (point-max)
						   nil t 'unibyte)
		    (message "Malformed MIME quoted-printable message")))
	       ((and (string= character-coding "base64") is-text-message)
		(condition-case err
		    (base64-decode-region (point-min) (point-max))
		  (error (message "%s" (cdr err)))))
	       ((eq character-coding 'uuencode)
		(error "uuencoded messages are not supported yet"))
	       (t))
	      (rmail-decode-region (point-min) (point-max)
				   coding-system view-buf)))
	  (with-current-buffer rmail-view-buffer
	    ;; Prepare the separator (blank line) before the body.
	    (goto-char (point-min))
	    (insert "\n")
	    ;; Unquote quoted From lines.
	    (let ((fromline (if (eq 'mboxrd rmail-mbox-format)
				"^>+From "
			      "^>From "))
		  case-fold-search)
	      (while (re-search-forward fromline nil t)
		(beginning-of-line)
		(delete-char 1)
		(forward-line)))
	    (goto-char (point-min)))
	  ;; Copy the headers to the front of the message view buffer.
	  (rmail-copy-headers beg end)
	  ;; Decode any RFC2047 encoded message headers.
	  (if rmail-enable-mime
	      (with-current-buffer rmail-view-buffer
		(rfc2047-decode-region
		 (point-min)
		 (progn
		   (search-forward "\n\n" nil 'move)
		   (point))))))
	;; highlight the message, activate any URL like text and add
	;; special highlighting for and quoted material.
	(with-current-buffer rmail-view-buffer
	  (goto-char (point-min))
	  (rmail-highlight-headers)
					;(rmail-activate-urls)
					;(rmail-process-quoted-material)
	  )
	;; Update the mode-line with message status information and swap
	;; the view buffer/mail buffer contents.
	(rmail-display-labels)
	(rmail-swap-buffers)
	(setq rmail-buffer-swapped t)
	(when showing-message
	  (setq blurb (format "Showing message %d...done" msg)))
	(run-hooks 'rmail-show-message-hook)))
    blurb))