[PATCH 1/3 v2] emacs: Don't return the button from `notmuch-show-insert-part-header'.
David Edmondson
dme at dme.org
Mon Jan 23 02:33:02 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.
---
Removed the merge of multipart/signed and multipart/encrypted.
emacs/notmuch-show.el | 84 +++++++++++++++++++++++++-----------------------
1 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 03c1f6b..9144484 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -285,24 +285,23 @@ message at DEPTH in the current thread."
'follow-link t
'face 'message-mml)
-(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))
- (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
+ button-parameters)
+ (insert "\n"))
;; Functions handling particular MIME parts.
@@ -460,15 +459,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)))
@@ -482,19 +484,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