Function: rmail-mime

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

Signature

(rmail-mime &optional ARG STATE)

Documentation

Toggle the display of a MIME message.

The actual behavior depends on the value of rmail-enable-mime.

If rmail-enable-mime is non-nil (the default), this command toggles the display of a MIME message between decoded presentation form and raw data. With optional prefix argument ARG, it toggles the display only of the MIME entity at point, if there is one. The optional argument STATE forces a particular display state, rather than toggling. raw forces raw mode, any other non-nil value forces decoded mode.

If rmail-enable-mime is nil, this creates a temporary "*RMAIL*" buffer holding a decoded copy of the message. Inline content-types are handled according to rmail-mime-media-type-handlers-alist. By default, this displays text and multipart messages, and offers to download attachments as specified by rmail-mime-attachment-dirs-alist. The arguments ARG and STATE have no effect in this case.

Probably introduced at or before Emacs version 23.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailmm.el.gz
;;;###autoload
(defun rmail-mime (&optional _arg state)
  "Toggle the display of a MIME message.

The actual behavior depends on the value of `rmail-enable-mime'.

If `rmail-enable-mime' is non-nil (the default), this command toggles
the display of a MIME message between decoded presentation form and
raw data.  With optional prefix argument ARG, it toggles the display only
of the MIME entity at point, if there is one.  The optional argument
STATE forces a particular display state, rather than toggling.
`raw' forces raw mode, any other non-nil value forces decoded mode.

If `rmail-enable-mime' is nil, this creates a temporary \"*RMAIL*\"
buffer holding a decoded copy of the message.  Inline content-types
are handled according to `rmail-mime-media-type-handlers-alist'.
By default, this displays text and multipart messages, and offers to
download attachments as specified by `rmail-mime-attachment-dirs-alist'.
The arguments ARG and STATE have no effect in this case."
  (interactive)
  (if rmail-enable-mime
      (with-current-buffer rmail-buffer
	(if (or (rmail-mime-message-p)
		(get-text-property (point-min) 'rmail-mime-hidden))
	    (let* ((hidden (get-text-property (point-min) 'rmail-mime-hidden))
		   (desired-hidden (if state (eq state 'raw) (not hidden))))
	      (unless (eq hidden desired-hidden)
		(if (not desired-hidden)
		    (rmail-show-message rmail-current-message)
		  (let ((rmail-enable-mime nil)
			(inhibit-read-only t))
		    (rmail-show-message rmail-current-message)
		    (add-text-properties (point-min) (point-max) '(rmail-mime-hidden t))))))
	  (message "Not a MIME message, just toggling headers")
	  (rmail-toggle-header)))
    (let* ((data (rmail-apply-in-message rmail-current-message 'buffer-string))
	   (buf (get-buffer-create "*RMAIL*"))
	   (rmail-mime-mbox-buffer rmail-view-buffer)
	   (rmail-mime-view-buffer buf))
      (set-buffer buf)
      (setq buffer-undo-list t)
      (let ((inhibit-read-only t))
	;; Decoding the message in fundamental mode for speed, only
	;; switching to rmail-mime-mode at the end for display.  Eg
	;; quoted-printable-decode-region gets very slow otherwise (Bug#4993).
	(fundamental-mode)
	(erase-buffer)
	(insert data)
	(rmail-mime-show t)
	(rmail-mime-mode)
	(set-buffer-modified-p nil))
      (view-buffer buf))))