* mu4e-view.el: be a bit smarter about inline attachments

This commit is contained in:
djcb 2012-09-06 10:20:51 +03:00
parent 58a90e4a5d
commit 4508417e34
1 changed files with 13 additions and 10 deletions

View File

@ -361,10 +361,10 @@ is nil, and otherwise open it."
(defun mu4e~view-construct-attachments-header (msg) (defun mu4e~view-construct-attachments-header (msg)
"Display attachment information; the field looks like something like: "Display attachment information; the field looks like something like:
:parts ((:index 1 :name \"test123.doc\" :parts ((:index 1 :name \"1.part\" :mime-type \"text/plain\"
:mime-type \"application/msword\" :attachment t :size 1234) :type (leaf) :attachment nil :size 228)
(:index 2 :name \"test456.pdf\" (:index 2 :name \"analysis.doc\" :mime-type \"application/msword\"
:mime-type \"application/pdf\" :attachment t :size 12234))." :type (leaf attachment) :attachment nil :size 605196))"
(setq mu4e~view-attach-map ;; buffer local (setq mu4e~view-attach-map ;; buffer local
(make-hash-table :size 64 :weakness nil)) (make-hash-table :size 64 :weakness nil))
(let* ((id 0) (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 ;; we only list parts that look like attachments, ie. that have a
;; non-nil :attachment property; we record a mapping between user-visible ;; non-nil :attachment property; we record a mapping between user-visible
;; numbers and the part indices ;; numbers and the part indices
(remove-if (remove-if-not
(lambda (part) (lambda (part)
(or ;; remove if it's not an attachment, unless it's an image (let ((mtype (plist-get part :mime-type))
(and (not (member 'attachment (plist-get part :type))) (isattach (member 'attachment (plist-get part :type))))
(not (string-match "^image" (plist-get part :mime-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))) (plist-get msg :parts)))
(attstr (attstr
(mapconcat (mapconcat