From 548ada303227a10db26f86d13f928b4762ac8c31 Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 18 Jul 2012 17:53:04 +0300 Subject: [PATCH] * crypto/mu4e: support signature check in mu4e (part 1) --- mu4e/mu4e-vars.el | 21 +++++++++++++++++++++ mu4e/mu4e-view.el | 21 +++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index bc08201f..a520e6cb 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -399,6 +399,11 @@ headers)." :shortname "Path" :help "Full filesystem path to the message" :sortable t)) + (:signature . + ( :name "Signature" + :shortname "Sgn" + :help "Check for the cryptographic signature" + :sortable nil)) (:subject . ( :name "Subject" :shortname "Subject" @@ -415,6 +420,22 @@ list, and the fields the message view). Most fields should be self-explanatory. A special one is `:from-or-to', which is equal to `:from' unless `:from' matches `mu4e-user-mail-address-regexp', in which case it will be equal to `:to'.") + + +(defvar mu4e-custom-header-info nil + "A list like `mu4e-custom-header-info', but for +custom (user-specified) headers. Each of the list items is a +property list with :name (the full-name, as displayed in the +message view), :shortname (the name as displayed in the headers +view), :help (some help information, which shows up in the +tooltip). Furthermore, there are two special fields: +:headers-func and :message-func, and the values should be functions +that take a MSG property list as argument, and return a string as +result. +Note, :sortable does not work for custom header fields.") + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 66d32f67..75bb5378 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -47,7 +47,7 @@ :group 'mu4e) (defcustom mu4e-view-fields - '(:from :to :cc :subject :flags :date :maildir :attachments) + '(:from :to :cc :subject :flags :date :maildir :attachments :signature) "Header fields to display in the message view buffer. For the complete list of available headers, see `mu4e-header-info'." :type (list 'symbol) @@ -193,7 +193,8 @@ plist." (if sizestr (mu4e~view-construct-header field sizestr)))) ;; attachments (:attachments (mu4e~view-construct-attachments-header msg)) - (t (mu4e-error "Unsupported field: %S" field))))) + (:signature (mu4e~view-construct-signature-header msg)) + (t (mu4e-error "Unsupported field: %S" field))))) mu4e-view-fields "") "\n" (mu4e-body-text msg))) @@ -331,6 +332,22 @@ at POINT, or if nil, at (point)." flags (propertize ", " 'face 'mu4e-view-header-value-face)) t)) +(defun mu4e~view-construct-signature-header (msg) + "Construct a Signature: header, if there are any signed parts." + (let* ((parts (plist-get msg :parts)) + (verdicts + (remove-if 'null + (mapcar (lambda (part) (plist-get part :signature)) parts))) + (val (when verdicts + (mapconcat (lambda (v) (symbol-name v)) verdicts ", "))) + (btn (when val + (with-temp-buffer + (insert-text-button "Details") (buffer-string)))) + (val (when val + (concat (propertize val 'face 'mu4e-view-special-header-value-face) + " (" btn ")")))) + (mu4e~view-construct-header :signature val t))) + (defun mu4e~view-open-save-attach-func (msg attachnum is-open) "Return a function that offers to save attachment NUM. If IS-OPEN is nil, and otherwise open it."