Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B8E16429E2D for ; Fri, 27 May 2011 03:28:01 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.921 X-Spam-Level: X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5 tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dBKklaqou4fo for ; Fri, 27 May 2011 03:28:00 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id BA81B429E4C for ; Fri, 27 May 2011 03:27:52 -0700 (PDT) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id 838E6328392; Fri, 27 May 2011 03:21:31 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com [98.149.172.122]) (Authenticated sender: jrollins) by fire-doxen-submit (Postfix) with ESMTP id 3D9BD328394; Fri, 27 May 2011 03:21:24 -0700 (PDT) Received: by servo.finestructure.net (Postfix, from userid 1000) id 293B92FF; Fri, 27 May 2011 03:27:43 -0700 (PDT) From: Jameson Graef Rollins To: notmuch@notmuchmail.org Subject: [PATCH 4/4] emacs: Give mutlipart/{signed, encrypted} their own part handler. Date: Fri, 27 May 2011 03:27:39 -0700 Message-Id: <1306492059-7706-5-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1306492059-7706-4-git-send-email-jrollins@finestructure.net> References: <1306371680-19441-1-git-send-email-jrollins@finestructure.net> <1306492059-7706-1-git-send-email-jrollins@finestructure.net> <1306492059-7706-2-git-send-email-jrollins@finestructure.net> <1306492059-7706-3-git-send-email-jrollins@finestructure.net> <1306492059-7706-4-git-send-email-jrollins@finestructure.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2011 10:28:02 -0000 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 | 12 ++++---- emacs/notmuch-show.el | 61 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index 944452b..cb02840 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -46,7 +46,7 @@ search." (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") @@ -82,17 +82,17 @@ search." (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") - (setq label "decryption successful")) + (setq label "Decryption successful")) ((string= status "bad") - (setq label "decryption error")) + (setq label "Decryption error")) (t - (setq label (concat "unknown encstatus \"" status "\"")))) + (setq label (concat "Unknown encstatus \"" status "\"")))) (insert-button - (concat "[ multipart/encrypted: " label " ]") + (concat "[ " label " ]") :type 'notmuch-crypto-status-button-type 'help-echo help-msg 'face face diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index aa6ddd1..131fc85 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -446,6 +446,57 @@ current buffer, if possible." (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)) + ;; if we're not adding encstatus, tell the user how they can get it + (progn + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.") + ;; 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)))))) + + (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)) @@ -593,16 +644,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))) - ;; 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. -- 1.7.4.4