[PATCH v3 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header'.

David Edmondson dme at dme.org
Mon Feb 6 07:39:06 PST 2012


Instead, allow the caller to specify some parameters for the
button. Rework `notmuch-show-insert-part-multipart/signed' and
`notmuch-show-insert-part-multipart/encrypted' accordingly.
---
 emacs/notmuch-show.el |   86 +++++++++++++++++++++++++-----------------------
 1 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..079d7cb 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -397,25 +397,24 @@ message at DEPTH in the current thread."
   "Submap for button commands")
 (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
 
-(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)
-  (let ((button))
-    (setq button
-	  (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
-	   :notmuch-content-type content-type))
-    (insert "\n")
-    ;; return button
-    button))
+(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
+	 :notmuch-content-type content-type
+	 button-parameters)
+  (insert "\n"))
 
 ;; Functions handling particular MIME parts.
 
@@ -602,15 +601,18 @@ current buffer, if possible."
   t)
 
 (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type)
-  (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil)))
-    (button-put button 'face 'notmuch-crypto-part-header)
-    ;; add signature status button if sigstatus provided
-    (if (plist-member part :sigstatus)
-	(let* ((from (notmuch-show-get-header :From msg))
-	       (sigstatus (car (plist-get part :sigstatus))))
-	  (notmuch-crypto-insert-sigstatus-button sigstatus from))
-      ;; if we're not adding sigstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+  ;; Add signature status button if sigstatus provided.
+  (if (plist-member part :sigstatus)
+      (let ((from (notmuch-show-get-header :From msg))
+	    (sigstatus (car (plist-get part :sigstatus))))
+	(notmuch-show-insert-part-header nth declared-type content-type nil nil 
+					 'face 'notmuch-crypto-part-header)
+	(notmuch-crypto-insert-sigstatus-button sigstatus from))
+
+    ;; If we're not adding sigstatus, tell the user how to enable it.
+    (notmuch-show-insert-part-header nth declared-type content-type nil nil 
+				     'face 'notmuch-crypto-part-header
+				     'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))
 
   (let ((inner-parts (plist-get part :content))
 	(start (point)))
@@ -624,19 +626,21 @@ current buffer, if possible."
   t)
 
 (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type)
-  (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil)))
-    (button-put button 'face 'notmuch-crypto-part-header)
-    ;; add encryption status button if encstatus specified
-    (if (plist-member part :encstatus)
-	(let ((encstatus (car (plist-get part :encstatus))))
-	  (notmuch-crypto-insert-encstatus-button encstatus)
-	  ;; add signature status button if sigstatus specified
-	  (if (plist-member part :sigstatus)
-	      (let* ((from (notmuch-show-get-header :From msg))
-		     (sigstatus (car (plist-get part :sigstatus))))
-		(notmuch-crypto-insert-sigstatus-button sigstatus from))))
-      ;; if we're not adding encstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+  ;; Add encryption status button if encstatus provided.
+  (if (plist-member part :encstatus)
+      (let ((encstatus (car (plist-get part :encstatus))))
+	(notmuch-show-insert-part-header nth declared-type content-type nil nil 
+					 'face 'notmuch-crypto-part-header)
+	(notmuch-crypto-insert-encstatus-button encstatus)
+	;; add signature status button if sigstatus specified
+	(if (plist-member part :sigstatus)
+	    (let* ((from (notmuch-show-get-header :From msg))
+		   (sigstatus (car (plist-get part :sigstatus))))
+	      (notmuch-crypto-insert-sigstatus-button sigstatus from))))
+    ;; If we're not adding encstatus, tell the user how to enable it.
+    (notmuch-show-insert-part-header nth declared-type content-type nil nil 
+				     'face 'notmuch-crypto-part-header
+				     'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))
 
   (let ((inner-parts (plist-get part :content))
 	(start (point)))
-- 
1.7.8.3



More information about the notmuch mailing list