mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 05:34:11 +01:00
emacs: Add `notmuch-show-multipart/alternative-discouraged'.
Also improved implementation of indication of which parts are not shown. Signed-off-by: Jameson Rollins <jrollins@finestructure.net>
This commit is contained in:
parent
b741e4dd25
commit
0c68a5d847
1 changed files with 34 additions and 12 deletions
|
@ -236,7 +236,7 @@ message at DEPTH in the current thread."
|
||||||
'follow-link t
|
'follow-link t
|
||||||
'face 'message-mml)
|
'face 'message-mml)
|
||||||
|
|
||||||
(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name)
|
(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)
|
||||||
(insert-button
|
(insert-button
|
||||||
(concat "[ "
|
(concat "[ "
|
||||||
(if name (concat name ": ") "")
|
(if name (concat name ": ") "")
|
||||||
|
@ -244,6 +244,7 @@ message at DEPTH in the current thread."
|
||||||
(if (not (string-equal declared-type content-type))
|
(if (not (string-equal declared-type content-type))
|
||||||
(concat " (as " content-type ")")
|
(concat " (as " content-type ")")
|
||||||
"")
|
"")
|
||||||
|
(or comment "")
|
||||||
" ]\n")
|
" ]\n")
|
||||||
:type 'notmuch-show-part-button-type
|
:type 'notmuch-show-part-button-type
|
||||||
:notmuch-part nth
|
:notmuch-part nth
|
||||||
|
@ -280,19 +281,40 @@ current buffer, if possible."
|
||||||
t)
|
t)
|
||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
|
(defvar notmuch-show-multipart/alternative-discouraged
|
||||||
|
'(
|
||||||
|
;; Avoid HTML parts.
|
||||||
|
"text/html"
|
||||||
|
;; multipart/related usually contain a text/html part and some associated graphics.
|
||||||
|
"multipart/related"
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun notmuch-show-multipart/*-to-list (part)
|
||||||
|
(mapcar '(lambda (inner-part) (plist-get inner-part :content-type))
|
||||||
|
(plist-get part :content)))
|
||||||
|
|
||||||
|
(defun notmuch-show-multipart/alternative-choose (types)
|
||||||
|
;; Based on `mm-preferred-alternative-precedence'.
|
||||||
|
(let ((seq types))
|
||||||
|
(dolist (pref (reverse notmuch-show-multipart/alternative-discouraged))
|
||||||
|
(dolist (elem (copy-sequence seq))
|
||||||
|
(when (string-match pref elem)
|
||||||
|
(setq seq (nconc (delete elem seq) (list elem))))))
|
||||||
|
seq))
|
||||||
|
|
||||||
(defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)
|
(defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)
|
||||||
(let ((inner-parts (plist-get part :content)))
|
|
||||||
(notmuch-show-insert-part-header nth declared-type content-type nil)
|
(notmuch-show-insert-part-header nth declared-type content-type nil)
|
||||||
;; In most cases, multipart/alternative is used to provide both
|
(let ((chosen-type (car (notmuch-show-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
|
||||||
;; text/plain and text/html (or multipart/related with text/html
|
(inner-parts (plist-get part :content)))
|
||||||
;; and image/*) parts. We might allow the user to express a
|
;; This inserts all parts of the chosen type rather than just one,
|
||||||
;; preference about which part to show, but for the moment we just
|
;; but it's not clear that this is the wrong thing to do - which
|
||||||
;; choose the first. This is usually the text/plain part.
|
;; should be chosen if there are more than one that match?
|
||||||
(notmuch-show-insert-bodypart msg (car inner-parts) depth)
|
|
||||||
(mapc (lambda (inner-part)
|
(mapc (lambda (inner-part)
|
||||||
(let ((inner-type (concat (plist-get inner-part :content-type) " (not shown)")))
|
(let ((inner-type (plist-get inner-part :content-type)))
|
||||||
(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil)))
|
(if (string= chosen-type inner-type)
|
||||||
(cdr inner-parts)))
|
(notmuch-show-insert-bodypart msg inner-part depth)
|
||||||
|
(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
|
||||||
|
inner-parts))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
(defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)
|
(defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)
|
||||||
|
|
Loading…
Reference in a new issue