unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* using the fringe to indicate good signatures
@ 2015-08-20 13:12 David Edmondson
  2015-09-07 22:50 ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 6+ messages in thread
From: David Edmondson @ 2015-08-20 13:12 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 353 bytes --]

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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: signed-fringe.diff --]
[-- Type: text/x-patch, Size: 2863 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 292 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-08 18:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 13:12 using the fringe to indicate good signatures David Edmondson
2015-09-07 22:50 ` Daniel Kahn Gillmor
2015-09-08  6:01   ` David Edmondson
2015-09-08  6:43     ` Daniel Kahn Gillmor
2015-09-08  9:53       ` David Edmondson
2015-09-08 18:00         ` Tomi Ollila

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).