From 4508417e34a00ac917ce3dec8f16e09be03fbb26 Mon Sep 17 00:00:00 2001 From: djcb Date: Thu, 6 Sep 2012 10:20:51 +0300 Subject: [PATCH] * mu4e-view.el: be a bit smarter about inline attachments --- mu4e/mu4e-view.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index b51b3018..8cfda623 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -361,10 +361,10 @@ is nil, and otherwise open it." (defun mu4e~view-construct-attachments-header (msg) "Display attachment information; the field looks like something like: - :parts ((:index 1 :name \"test123.doc\" - :mime-type \"application/msword\" :attachment t :size 1234) - (:index 2 :name \"test456.pdf\" - :mime-type \"application/pdf\" :attachment t :size 12234))." + :parts ((:index 1 :name \"1.part\" :mime-type \"text/plain\" + :type (leaf) :attachment nil :size 228) + (:index 2 :name \"analysis.doc\" :mime-type \"application/msword\" + :type (leaf attachment) :attachment nil :size 605196))" (setq mu4e~view-attach-map ;; buffer local (make-hash-table :size 64 :weakness nil)) (let* ((id 0) @@ -372,13 +372,16 @@ is nil, and otherwise open it." ;; we only list parts that look like attachments, ie. that have a ;; non-nil :attachment property; we record a mapping between user-visible ;; numbers and the part indices - (remove-if + (remove-if-not (lambda (part) - (or ;; remove if it's not an attachment, unless it's an image - (and (not (member 'attachment (plist-get part :type))) - (not (string-match "^image" (plist-get part :mime-type)))) - ;; - )) + (let ((mtype (plist-get part :mime-type)) + (isattach (member 'attachment (plist-get part :type)))) + (or ;; remove if it's not an attach *or* if it's an image/audio/application type + ;; (but not a signature) + isattach + (string-match "^\\(image\\|audio\\)" mtype) + (and (string-match "^application" mtype) + (not (string-match "signature" mtype)))))) (plist-get msg :parts))) (attstr (mapconcat