Function: rmail-mime-insert-decoded-text
rmail-mime-insert-decoded-text is a byte-compiled function defined in
rmailmm.el.gz.
Signature
(rmail-mime-insert-decoded-text ENTITY)
Documentation
Decode and insert the text body of MIME-entity ENTITY.
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rmailmm.el.gz
(defun rmail-mime-insert-decoded-text (entity)
"Decode and insert the text body of MIME-entity ENTITY."
(let* ((content-type (rmail-mime-entity-type entity))
(charset (cdr (assq 'charset (cdr content-type))))
(coding-system (if charset
(coding-system-from-name charset)))
(body (rmail-mime-entity-body entity))
(pos (point)))
(or (and coding-system (coding-system-p coding-system))
(setq coding-system 'undecided))
(if (stringp (aref body 0))
(insert (aref body 0))
(let ((transfer-encoding (rmail-mime-entity-transfer-encoding entity)))
(insert-buffer-substring rmail-mime-mbox-buffer
(aref body 0) (aref body 1))
(cond ((string= transfer-encoding "base64")
(ignore-errors (base64-decode-region pos (point))))
((string= transfer-encoding "quoted-printable")
(quoted-printable-decode-region pos (point))))))
;; If the text is empty, we don't have anything to decode.
(and (/= pos (point))
(decode-coding-region
pos (point)
;; Use -dos decoding, to remove ^M characters left from base64
;; or rogue qp-encoded text.
(coding-system-change-eol-conversion coding-system 1)))
(if (and
(or (not rmail-mime-coding-system) (consp rmail-mime-coding-system))
(not (eq (coding-system-base coding-system) 'us-ascii)))
(setq rmail-mime-coding-system coding-system))
(or (bolp) (insert "\n"))))