]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Give mutlipart/{signed, encrypted} their own part handler.
authorJameson Graef Rollins <jrollins@finestructure.net>
Fri, 27 May 2011 18:52:19 +0000 (11:52 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 27 May 2011 23:22:00 +0000 (16:22 -0700)
This is the best way to make the displayed output for
decrypted/verified messages clearer.  The special sigstatus and
encstatus buttons are now displayed under the part header button.  The
part header button is also tweaked to provide information to user
about how to proces crypto.

emacs/notmuch-crypto.el
emacs/notmuch-show.el

index 944452b980706a9358492090480a3e60309236ae..cb02840d14639d0a8828bdf206618e4bb304e327 100644 (file)
@@ -46,7 +46,7 @@ search."
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
         (help-msg nil)
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
         (help-msg nil)
-        (label "multipart/signed: signature not processed")
+        (label "Signature not processed")
         (face '(:background "red" :foreground "black")))
     (cond
      ((string= status "good")
         (face '(:background "red" :foreground "black")))
     (cond
      ((string= status "good")
@@ -82,17 +82,17 @@ search."
 (defun notmuch-crypto-insert-encstatus-button (encstatus)
   (let* ((status (plist-get encstatus :status))
         (help-msg nil)
 (defun notmuch-crypto-insert-encstatus-button (encstatus)
   (let* ((status (plist-get encstatus :status))
         (help-msg nil)
-        (label "multipart/encrypted: decryption not attempted")
+        (label "Decryption not attempted")
         (face '(:background "purple" :foreground "black")))
     (cond
      ((string= status "good")
         (face '(:background "purple" :foreground "black")))
     (cond
      ((string= status "good")
-      (setq label "decryption successful"))
+      (setq label "Decryption successful"))
      ((string= status "bad")
      ((string= status "bad")
-      (setq label "decryption error"))
+      (setq label "Decryption error"))
      (t
      (t
-      (setq label (concat "unknown encstatus \"" status "\""))))
+      (setq label (concat "Unknown encstatus \"" status "\""))))
     (insert-button
     (insert-button
-     (concat "[ multipart/encrypted: " label " ]")
+     (concat "[ " label " ]")
      :type 'notmuch-crypto-status-button-type
      'help-echo help-msg
      'face face
      :type 'notmuch-crypto-status-button-type
      'help-echo help-msg
      'face face
index aa6ddd1a0ac6130969ee65204b84191c76622880..6c498ab1b8cff9cd53bb8620fb34b2448b7cd81b 100644 (file)
@@ -446,6 +446,56 @@ current buffer, if possible."
       (indent-rigidly start (point) 1)))
   t)
 
       (indent-rigidly start (point) 1)))
   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 '(:foreground "blue"))
+    ;; add signature status button if sigstatus provided
+    (if (plist-member part :sigstatus)
+       (let* ((headers (plist-get msg :headers))
+              (from (plist-get headers :From))
+              (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)
+
+(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 '(:foreground "blue"))
+    ;; 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* ((headers (plist-get msg :headers))
+                    (from (plist-get headers :From))
+                    (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.")))
+
+  (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)
+
 (defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)
   (notmuch-show-insert-part-header nth declared-type content-type nil)
   (let ((inner-parts (plist-get part :content))
 (defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)
   (notmuch-show-insert-part-header nth declared-type content-type nil)
   (let ((inner-parts (plist-get part :content))
@@ -593,16 +643,6 @@ current buffer, if possible."
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
        (nth (plist-get part :id)))
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
        (nth (plist-get part :id)))
-    ;; 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* ((headers (plist-get msg :headers))
-              (from (plist-get headers :From))
-              (sigstatus (car (plist-get part :sigstatus))))
-         (notmuch-crypto-insert-sigstatus-button sigstatus from)))
     (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
     (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.