[PATCH v5 6/7] emacs/mua: Let user specify which parts get a header in citations.
Mark Walters
markwalters1009 at gmail.com
Sun Feb 14 10:39:58 PST 2016
From: David Edmondson <dme at dme.org>
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.
---
emacs/notmuch-mua.el | 30 ++++++++++++++++++++++++++----
emacs/notmuch-show.el | 13 +++++++++++++
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index a386d43..fcb3e95 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -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 ()
@@ -223,10 +240,15 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
(insert "Date: " date "\n\n")
(insert (with-temp-buffer
- ;; Don't attempt to clean up messages, excerpt
- ;; citations, etc. in the original message before
- ;; quoting.
- (let ((notmuch-show-insert-text/plain-hook nil))
+ (let
+ ;; Don't attempt to clean up messages, excerpt
+ ;; citations, etc. in the original message before
+ ;; quoting.
+ ((notmuch-show-insert-text/plain-hook 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-mua-reply-insert-header-p-function))
(notmuch-show-insert-body original (plist-get original :body) 0)
(buffer-substring-no-properties (point-min) (point-max)))))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5654d11..ec58cac 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -957,6 +957,19 @@ this part.")
(not (and (string= mime-type "text/plain")
(<= (plist-get part :id) 1)))))
+(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.
--
2.1.4
More information about the notmuch
mailing list