[PATCH 2/3 v2] emacs: Optionally hide some part headers.

David Edmondson dme at dme.org
Mon Jan 23 02:33:03 PST 2012


Add a regexp, `notmuch-show-part-headers-hidden' and if the
content-type of a part matches, don't show the part header.
---
 emacs/notmuch-show.el |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9144484..39f35ed 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -110,6 +110,12 @@ indentation."
   :group 'notmuch
   :type 'boolean)
 
+(defcustom notmuch-show-part-headers-hidden nil
+  "Headers for parts whose content-type matches this regexp will
+not be shown."
+  :group 'notmuch
+  :type 'regexp)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -285,23 +291,30 @@ message at DEPTH in the current thread."
   'follow-link t
   'face 'message-mml)
 
+(defun notmuch-show-hidden-part-header (content-type)
+  "Return non-nil if a part header should be hidden for
+CONTENT-TYPE parts."
+  (and notmuch-show-part-headers-hidden
+       (string-match notmuch-show-part-headers-hidden content-type)))
+
 (defun notmuch-show-insert-part-header (nth content-type declared-type
 					    &optional name comment
 					    &rest button-parameters)
-  (apply #'insert-button
-	 (concat "[ "
-		 (if name (concat name ": ") "")
-		 declared-type
-		 (if (not (string-equal declared-type content-type))
-		     (concat " (as " content-type ")")
-		   "")
-		 (or comment "")
-		 " ]")
-	 :type 'notmuch-show-part-button-type
-	 :notmuch-part nth
-	 :notmuch-filename name
-	 button-parameters)
-  (insert "\n"))
+  (unless (notmuch-show-hidden-part-header content-type)
+    (apply #'insert-button
+	   (concat "[ "
+		   (if name (concat name ": ") "")
+		   declared-type
+		   (if (not (string-equal declared-type content-type))
+		       (concat " (as " content-type ")")
+		     "")
+		   (or comment "")
+		   " ]")
+	   :type 'notmuch-show-part-button-type
+	   :notmuch-part nth
+	   :notmuch-filename name
+	   button-parameters)
+    (insert "\n")))
 
 ;; Functions handling particular MIME parts.
 
-- 
1.7.8.3



More information about the notmuch mailing list