emacs/mua: Let user specify which parts get a header in citations.

Add a customizable function specifying which parts get a header when
replying, and give some sensible possiblities. These are,

1) all parts except multipart/*. (Subparts of a multipart part do
receive a header button.)

2) only included text/* parts.

3) Exactly as in the show buffer.

4) None at all. This means the reply contains a mish-mash of all the
original message's parts.

In the test suite we set the choice to option 4 to match the
previous behaviour.
This commit is contained in:
David Edmondson 2016-02-20 18:24:40 +00:00 committed by David Bremner
parent adefa734e3
commit d27d90875d
3 changed files with 32 additions and 1 deletions

View file

@ -93,6 +93,23 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
:link '(custom-manual "(message)Insertion Variables")
:group 'notmuch-reply)
(defcustom notmuch-mua-reply-insert-header-p-function
'notmuch-show-reply-insert-header-p-trimmed
"Function to decide which parts get a header when replying.
This function specifies which parts of a mime message with
mutiple parts get a header."
:type '(radio (const :tag "All except multipart/* and hidden parts"
notmuch-show-reply-insert-header-p-trimmed)
(const :tag "Only for included text parts"
notmuch-show-reply-insert-header-p-minimal)
(const :tag "Exactly as in show view"
notmuch-show-insert-header-p)
(const :tag "No part headers"
notmuch-show-reply-insert-header-p-never)
(function :tag "Other"))
:group 'notmuch-reply)
;;
(defun notmuch-mua-get-switch-function ()
@ -231,7 +248,7 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
;; Don't omit long parts.
(notmuch-show-max-text-part-size 0)
;; Insert headers for parts as appropriate for replying.
(notmuch-show-insert-header-p-function #'notmuch-show-reply-insert-header-p-never))
(notmuch-show-insert-header-p-function notmuch-mua-reply-insert-header-p-function))
(notmuch-show-insert-body original (plist-get original :body) 0)
(buffer-substring-no-properties (point-min) (point-max)))))

View file

@ -954,6 +954,16 @@ this part.")
(defun notmuch-show-reply-insert-header-p-never (part hide)
nil)
(defun notmuch-show-reply-insert-header-p-trimmed (part hide)
(let ((mime-type (notmuch-show-mime-type part)))
(and (not (notmuch-match-content-type mime-type "multipart/*"))
(not hide))))
(defun notmuch-show-reply-insert-header-p-minimal (part hide)
(let ((mime-type (notmuch-show-mime-type part)))
(and (notmuch-match-content-type mime-type "text/*")
(not hide))))
(defun notmuch-show-insert-bodypart (msg part depth &optional hide)
"Insert the body part PART at depth DEPTH in the current thread.

View file

@ -184,6 +184,10 @@ nothing."
(setq notmuch-tag-deleted-formats
'((".*" nil)))
;; For historical reasonse we don't print part headers when replying
;; in the tests suite
(setq notmuch-mua-reply-insert-header-p-function 'notmuch-show-reply-insert-header-p-never)
;; force a common html renderer, to avoid test variations between
;; environments