unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/3] emacs: Don't return the button from `notmuch-show-insert-part-header'.
Date: Fri, 20 Jan 2012 09:43:31 +0000	[thread overview]
Message-ID: <1327052612-1040-2-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1327052612-1040-1-git-send-email-dme@dme.org>

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, moving
most of the code into a common
`notmuch-show-insert-part-multipart/signed-or-encrypted' to reduce
duplication.
---

The buttons inserted for encrypted parts are slightly different now -
previously the logic was that if a part was encrypted it would have
the signature status inserted only if the encryption status was
specified. Now the signature status will be inserted even without
encryption status. My reading of the documentation says that this is
correct, but I'm no expert. Comments?

 emacs/notmuch-show.el |   88 +++++++++++++++++++++---------------------------
 1 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f62f8ac..97e2a15 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -285,22 +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 (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.
 
@@ -458,42 +459,31 @@ 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.")))
-
-  (let ((inner-parts (plist-get part :content))
-	(start (point)))
-    ;; Show all of the parts.
-    (mapc (lambda (inner-part)
-	    (notmuch-show-insert-bodypart msg inner-part depth))
-	  inner-parts)
-
-    (when notmuch-show-indent-multipart
-      (indent-rigidly start (point) 1)))
-  t)
+  (notmuch-show-insert-part-multipart/signed-or-encrypted msg part content-type nth depth declared-type
+							 (plist-get part :sigstatus)
+							 nil))
 
 (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.")))
+  (notmuch-show-insert-part-multipart/signed-or-encrypted msg part content-type nth depth declared-type
+							 (plist-get part :sigstatus)
+							 (plist-get part :encstatus)))
 
+(defun notmuch-show-insert-part-multipart/signed-or-encrypted (msg part content-type nth depth declared-type sigstatus-tuple encstatus-tuple)
+  (if (or encstatus-tuple sigstatus-tuple)
+      (progn
+	(notmuch-show-insert-part-header nth declared-type content-type
+					 nil nil 'face 'notmuch-crypto-part-header)
+	(if encstatus-tuple
+	    (notmuch-crypto-insert-encstatus-button (car encstatus-tuple)))
+	(if sigstatus-tuple
+	    (notmuch-crypto-insert-sigstatus-button (car sigstatus-tuple)
+						    (notmuch-show-get-header :From msg))))
+    ;; If we're not adding status buttons, tell the user how they can
+    ;; enable them.
+    (notmuch-show-insert-part-header nth declared-type content-type
+				     nil nil 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))
+
+  ;; Insert the enclosed parts.
   (let ((inner-parts (plist-get part :content))
 	(start (point)))
     ;; Show all of the parts.
-- 
1.7.8.3

  reply	other threads:[~2012-01-20 10:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20  9:43 [PATCH 1/3] emacs: Tidy `notmuch-show-insert-part-header' David Edmondson
2012-01-20  9:43 ` David Edmondson [this message]
2012-01-20 20:20   ` [PATCH 2/3] emacs: Don't return the button from `notmuch-show-insert-part-header' Jameson Graef Rollins
2012-01-22 21:38   ` Jameson Graef Rollins
2012-01-23  8:16     ` David Edmondson
2012-01-23  8:52       ` Jameson Graef Rollins
2012-01-23  9:12         ` David Edmondson
2012-01-23 10:33           ` [PATCH 1/3 v2] " David Edmondson
2012-01-23 10:33             ` [PATCH 2/3 v2] emacs: Optionally hide some part headers David Edmondson
2012-01-23 10:33             ` [PATCH 3/3 v2] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-01-23 11:32             ` [PATCH 1/3 v2] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-01-20  9:43 ` [PATCH 3/3] emacs: Optionally hide some part headers David Edmondson
2012-01-24 12:53 ` optional hiding of some part headers v3 David Edmondson
2012-01-24 12:53   ` [PATCH 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-01-24 18:46     ` Jameson Graef Rollins
2012-01-24 19:25       ` David Edmondson
2012-01-24 19:52         ` Jameson Graef Rollins
2012-01-25  6:15           ` David Edmondson
2012-01-24 19:33     ` Tomi Ollila
2012-01-24 12:53   ` [PATCH 2/3] emacs: Optionally hide some part headers David Edmondson
2012-01-24 19:34     ` Tomi Ollila
2012-01-24 12:53   ` [PATCH 3/3] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-01-24 19:46     ` Tomi Ollila
2012-02-06 15:39 ` [PATCH v3 0/3] part header code tidying and options David Edmondson
2012-02-06 15:39   ` [PATCH v2] emacs: Add more processing of displayed headers David Edmondson
2012-02-14 12:30     ` David Bremner
2012-02-14 13:28       ` David Edmondson
2012-10-12 19:11     ` Ethan Glasser-Camp
2012-02-06 15:39   ` [PATCH v3 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-02-06 15:39   ` [PATCH v3 2/3] emacs: Optionally hide some part headers David Edmondson
2012-02-12  9:21     ` Mark Walters
2012-02-06 15:39   ` [PATCH v3 3/3] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-02-12  9:24     ` Mark Walters
2012-02-12  9:39       ` Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327052612-1040-2-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).