(require 'mail-parse)
(require 'mailcap)
(require 'mm-bodies)
+(require 'mm-decode)
;;;
;;; Functions for displaying various formats inline
;;;
(defun mm-inline-image (handle)
- (let ((type (cadr (split-string (car (mm-handle-type handle)) "/")))
- buffer-read-only image)
- (mm-with-unibyte-buffer
- (insert-buffer-substring (mm-handle-buffer handle))
- (mm-decode-content-transfer-encoding (mm-handle-encoding handle))
- (setq image (make-image-specifier
- (vector (intern type) :data (buffer-string)))))
- (let ((annot (make-annotation image nil 'text)))
- (set-extent-property annot 'mm t)
- (set-extent-property annot 'duplicable t)
- (mm-handle-set-undisplayer handle annot))
- (insert " ")))
+ (let ((annot (make-annotation (mm-get-image handle) nil 'text))
+ buffer-read-only)
+ (mm-insert-inline handle ".\n")
+ (set-extent-property annot 'mm t)
+ (set-extent-property annot 'duplicable t)))
+
+(defvar mm-w3-setup nil)
+(defun mm-setup-w3 ()
+ (unless mm-w3-setup
+ (w3-do-setup)
+ (require 'url)
+ (require 'w3-vars)
+ (load "url-misc.el")
+ (setq mm-w3-setup t)))
(defun mm-inline-text (handle)
(let ((type (cadr (split-string (car (mm-handle-type handle)) "/")))
text buffer-read-only)
(cond
((equal type "plain")
- (with-temp-buffer
- (insert-buffer-substring (mm-handle-buffer handle))
- (mm-decode-content-transfer-encoding (mm-handle-encoding handle))
- (setq text (buffer-string)))
+ (setq text (mm-get-part handle))
(let ((b (point)))
(insert text)
(save-restriction
(narrow-to-region b (point))
(let ((charset (mail-content-type-get
(mm-handle-type handle) 'charset)))
- (when charset
- (mm-decode-body charset nil)))
+ (mm-decode-body charset nil))
(mm-handle-set-undisplayer
handle
`(lambda ()
,(set-marker (make-marker) (point-min))
,(set-marker (make-marker) (point-max)))))))))
((equal type "html")
- (save-excursion
- (w3-do-setup)
- (mm-with-unibyte-buffer
- (insert-buffer-substring (mm-handle-buffer handle))
- (mm-decode-content-transfer-encoding (mm-handle-encoding handle))
- (require 'url)
- (save-window-excursion
- (w3-region (point-min) (point-max))
- (setq text (buffer-string))))
- (mm-insert-inline handle text)))
+ (mm-setup-w3)
+ (setq text (mm-get-part handle))
+ (let ((b (point))
+ (width (window-width)))
+ (save-excursion
+ (insert text)
+ (save-restriction
+ (narrow-to-region b (point))
+ (save-window-excursion
+ (let ((w3-strict-width width))
+ (w3-region (point-min) (point-max)))))
+ (mm-handle-set-undisplayer
+ handle
+ `(lambda ()
+ (let (buffer-read-only)
+ (delete-region
+ ,(set-marker (make-marker) (point-min))
+ ,(set-marker (make-marker) (point-max)))))))))
((or (equal type "enriched")
(equal type "richtext"))
(save-excursion
(mm-with-unibyte-buffer
(insert-buffer-substring (mm-handle-buffer handle))
- (mm-decode-content-transfer-encoding (mm-handle-encoding handle))
+ (mm-decode-content-transfer-encoding
+ (mm-handle-encoding handle)
+ (car (mm-handle-type handle)))
(save-window-excursion
(enriched-decode (point-min) (point-max))
- (setq text (buffer-string))))
- (mm-insert-inline handle text)))
- )))
+ (setq text (buffer-string)))))
+ (mm-insert-inline handle text))
+ (t
+ (save-excursion
+ (mm-with-unibyte-buffer
+ (insert-buffer-substring (mm-handle-buffer handle))
+ (mm-decode-content-transfer-encoding
+ (mm-handle-encoding handle)
+ (car (mm-handle-type handle)))
+ (setq text (buffer-string))))
+ (mm-insert-inline handle text)))))
(defun mm-insert-inline (handle text)
"Insert TEXT inline from HANDLE."