]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
emacs/show: Make the insertion of part headers overridable.
authorDavid Edmondson <dme@dme.org>
Sat, 20 Feb 2016 18:24:36 +0000 (18:24 +0000)
committerDavid Bremner <david@tethera.net>
Sun, 21 Feb 2016 12:37:08 +0000 (08:37 -0400)
This allows callers of notmuch-show-insert-bodypart to use a `let'
binding to override the default function for specifying when part
headers should be inserted.

We also add an option to never show part buttons which will be used by
the test suites for the reply tests.

emacs/notmuch-show.el

index 9d9c89fcf834dc724e6c670ab539a4f444450050..ddb9c65c6d05c43319df0e08752f0f44bbdcffc9 100644 (file)
@@ -930,13 +930,23 @@ will return nil if the CID is unknown or cannot be retrieved."
             "text/x-diff")
        content-type)))
 
             "text/x-diff")
        content-type)))
 
+;; The following variable can be overridden by let bindings.
+(defvar notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p
+  "Specify which function decides which part headers get inserted.
+
+The function should take two parameters, PART and HIDE, and
+should return non-NIL if a header button should be inserted for
+this part.")
+
 (defun notmuch-show-insert-header-p (part hide)
 (defun notmuch-show-insert-header-p (part hide)
-  "Return non-NIL if a header button should be inserted for this part."
   ;; Show all part buttons except for the first part if it is text/plain.
   (let ((mime-type (notmuch-show-mime-type part)))
     (not (and (string= mime-type "text/plain")
              (<= (plist-get part :id) 1)))))
 
   ;; Show all part buttons except for the first part if it is text/plain.
   (let ((mime-type (notmuch-show-mime-type 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-insert-bodypart (msg part depth &optional hide)
   "Insert the body part PART at depth DEPTH in the current thread.
 
 (defun notmuch-show-insert-bodypart (msg part depth &optional hide)
   "Insert the body part PART at depth DEPTH in the current thread.
 
@@ -953,10 +963,10 @@ useful for quoting in replies)."
                    (> notmuch-show-max-text-part-size 0)
                    (> (length (plist-get part :content)) notmuch-show-max-text-part-size)))
         (beg (point))
                    (> notmuch-show-max-text-part-size 0)
                    (> (length (plist-get part :content)) notmuch-show-max-text-part-size)))
         (beg (point))
-        ;; We show the part button if notmuch-show-insert-header-p
-        ;; says to, unless HIDE is 'no-buttons.
+        ;; This default header-p function omits the part button for
+        ;; the first (or only) part if this is text/plain.
         (button (when (and (not (equal hide 'no-buttons))
         (button (when (and (not (equal hide 'no-buttons))
-                           (notmuch-show-insert-header-p part hide))
+                    (funcall notmuch-show-insert-header-p-function part hide))
                   (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
         ;; Hide the part initially if HIDE is t, or if it is too long
         ;; and we have a button to allow toggling (thus reply which
                   (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
         ;; Hide the part initially if HIDE is t, or if it is too long
         ;; and we have a button to allow toggling (thus reply which