aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch-show.el
diff options
context:
space:
mode:
authorGravatar David Edmondson <dme@dme.org>2010-03-23 11:54:05 +0000
committerGravatar Carl Worth <cworth@cworth.org>2010-04-21 13:10:51 -0700
commit4488cf30f6f266bbfae2a5cd330422ce8b831484 (patch)
treec1eb53aba9346053fccfb827d68bc2d0afa6dd91 /emacs/notmuch-show.el
parentb93c5749fd43d384630e16c373ae8e372cc3ae1c (diff)
emacs: Use `mm-display-part' when possible
For parts that the mm-decode/mm-view functions can inline and we have the content, use `mm-display-part' to insert the part in the buffer.
Diffstat (limited to 'emacs/notmuch-show.el')
-rw-r--r--emacs/notmuch-show.el30
1 files changed, 22 insertions, 8 deletions
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f5822a03..7d25dd57 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -24,6 +24,7 @@
(require 'cl)
(require 'mm-view)
(require 'message)
+(require 'mm-decode)
(require 'notmuch-lib)
(require 'notmuch-query)
@@ -214,6 +215,24 @@ message at DEPTH in the current thread."
;; Functions handling particular MIME parts.
+(defun notmuch-show-mm-display-part-inline (part content-type)
+ "Use the mm-decode/mm-view functions to display a part inline, if possible."
+ (let ((handle (mm-make-handle nil (list content-type))))
+ (if (and (mm-inlinable-p handle)
+ (mm-inlined-p handle))
+ (progn
+ (insert (with-temp-buffer
+ (let ((display-buffer (current-buffer)))
+ (with-temp-buffer
+ (let ((work-buffer (current-buffer)))
+ (insert (plist-get part :content))
+ (set-buffer display-buffer)
+ (mm-display-part (mm-make-handle work-buffer
+ (list content-type)))
+ (buffer-string))))))
+ t)))
+ nil)
+
(defun notmuch-show-insert-part-text/plain (part content-type nth depth)
(let ((start (point)))
;; If this text/plain part is not the first part in the message,
@@ -227,16 +246,11 @@ message at DEPTH in the current thread."
(run-hook-with-args 'notmuch-show-insert-text/plain-hook depth))))
t)
-(defun notmuch-show-insert-part-text/* (part content-type nth depth)
- ;; Handle all text types other than text/html.
- (if (string-equal "text/html" content-type)
- nil
- (notmuch-show-insert-part-header content-type (plist-get part :filename))
- (insert (plist-get part :content))
- t))
-
(defun notmuch-show-insert-part-*/* (part content-type nth depth)
(notmuch-show-insert-part-header content-type (plist-get part :filename))
+ ;; If we have the content for the part, attempt to inline it.
+ (if (plist-get part :content)
+ (notmuch-show-mm-display-part-inline part content-type))
t)
;; Functions for determining how to handle MIME parts.