-(defun mime-preview/decode-text-buffer (charset encoding)
- (mime-decode-region (point-min) (point-max) encoding)
- (let* ((mode mime::preview/original-major-mode)
- (m (or (save-excursion
- (set-buffer mime::preview/article-buffer)
- mime::article/code-converter)
- (cdr (or (assq mode mime-text-decoder-alist)
- (assq t mime-text-decoder-alist)))
- ))
- )
- (and (functionp m)
- (funcall m charset encoding)
- )))
+(defun mime-text-insert-decoded-body (entity situation)
+ "Insert text body of ENTITY in SITUATION.
+It decodes MIME-encoding then code-converts as MIME-charset.
+MIME-encoding is value of field 'encoding of SITUATION. It must be
+'nil or string. MIME-charset is value of field \"charset\" of
+SITUATION. It must be symbol.
+This function calls text-decoder for MIME-charset specified by buffer
+local variable `mime-text-decoder' and variable
+`mime-text-decoder-alist'."
+ (insert-buffer-substring mime-raw-buffer
+ (mime-entity-body-start entity)
+ (mime-entity-body-end entity))
+ (let ((encoding (cdr (assq 'encoding situation))))
+ (mime-decode-region (point-min) (point-max) encoding)
+ (goto-char (point-min))
+ (while (search-forward "\r\n" nil t)
+ (replace-match "\n")
+ )
+ (let ((text-decoder
+ (save-excursion
+ (set-buffer mime-raw-buffer)
+ (or mime-text-decoder
+ (cdr (or (assq major-mode mime-text-decoder-alist)
+ (assq t mime-text-decoder-alist)))
+ ))))
+ (and (functionp text-decoder)
+ (funcall text-decoder (cdr (assoc "charset" situation)) encoding)
+ ))
+ (run-hooks 'mime-text-decode-hook)
+ ))