]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
emacs/mua: Let user specify which parts get a header in citations.
authorDavid Edmondson <dme@dme.org>
Sat, 20 Feb 2016 18:24:40 +0000 (18:24 +0000)
committerDavid Bremner <david@tethera.net>
Sun, 21 Feb 2016 12:37:48 +0000 (08:37 -0400)
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.

emacs/notmuch-mua.el
emacs/notmuch-show.el
test/test-lib.el

index ecc5bece86e3454d92a14b01327a7444ef265a14..fcb3e951f9dc7af174297d917b069d2ff959db19 100644 (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)))))
 
index 2a81ec1fe072fa76d138c85fa7a28e57306be365..371e62df95bd9d30b7020768ca6215122dd474d7 100644 (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.
 
index 596a705103ef1a3bd1c7902fa7d58f97f9902344..02e020c10d3aef0db283308bc6ea283914491874 100644 (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