After listening to bremner, dkg et al. from Heidelberg, I threw together
a quick patch to see how we might indicate signature validity in the
fringe. The intention is to prompt more discussion - this code is not
ready to ship.

The patch is attached. The result looks something like:
    http://dme.org/data/images/notmuch-signed-fringe.png

Thoughts?

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4dee34b..3d447af 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -646,25 +646,46 @@ will return nil if the CID is unknown or cannot be retrieved."
       (indent-rigidly start (point) 1)))
   t)
 
-(defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button)
-  (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."))
+;; None of the existing fringe bitmaps are empty.
+(define-fringe-bitmap 'notmuch-show--fringe-empty '[])
 
-  (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)
+(defun notmuch-show--sigstatus-to-fringe-string (status)
+  (let ((good-bad-ugly (plist-get status :status)))
+    (cond
+     ((string= good-bad-ugly "good")
+      (propertize "dummy" 'display
+		  '(left-fringe notmuch-show--fringe-empty notmuch-crypto-signature-good)))
+     ;; XXX dme: insert more here.
+     (t nil))))
 
-    (when notmuch-show-indent-multipart
-      (indent-rigidly start (point) 1)))
+(defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button)
+  (let ((start-of-signed (point)))
+    (button-put button 'face 'notmuch-crypto-part-header)
+
+    (let ((sigstatus (car (plist-get part :sigstatus)))
+	  (from (notmuch-show-get-header :From msg)))
+      ;; Add signature status button if status is provided.
+      (if sigstatus
+	  (notmuch-crypto-insert-sigstatus-button sigstatus from)
+	;; If we're not adding the status, 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))
+	    (fringe-string (notmuch-show--sigstatus-to-fringe-string sigstatus)))
+	;; 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))
+
+	(when fringe-string
+	  (replace-regexp "^" fringe-string nil start-of-signed (point))))
+      )
+    )
   t)
 
 (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button)

Attachment: signature.asc
Description: PGP signature

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to