From 01fe899c370adcd9c14c1a0dc0c93744f2d7c33a Mon Sep 17 00:00:00 2001 From: djcb Date: Sat, 5 Nov 2016 12:42:28 +0200 Subject: [PATCH] mu4e: better error for non-supported header fields Some fields (eg. :attachments and :user-agent) require a full message and are not supported in headers-mode. Document this and give a clearer error message when they are added to `mu4e-headers-fields'. Fixes issue #933. --- mu4e/mu4e-headers.el | 5 ++++- mu4e/mu4e-vars.el | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index d2866b0a..bf32bd73 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -851,7 +851,8 @@ after the end of the search results." (let* ((field (car item)) (width (cdr item)) (info (cdr (assoc field (append mu4e-header-info mu4e-header-info-custom)))) - (sortable (plist-get info :sortable)) + (require-full (plist-get info :require-full)) + (sortable (plist-get info :sortable)) ;; if sortable, it is either t (when field is sortable itself) ;; or a symbol (if another field is used for sorting) (sortfield (when sortable (if (booleanp sortable) field sortable))) @@ -862,6 +863,8 @@ after the end of the search results." (if (eq mu4e-headers-sort-direction 'descending) downarrow uparrow))) (name (concat (plist-get info :shortname) arrow)) (map (make-sparse-keymap))) + (when require-full + (mu4e-error "Field %S is not supported in mu4e-headers-mode" field)) (when sortable (define-key map [header-line mouse-1] (lambda (&optional e) diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 4d6373a7..c2463f6a 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -689,6 +689,7 @@ mu4e-compose-mode." ( :name "Attachments" :shortname "Atts" :help "Message attachments" + :require-full t :sortable nil)) (:bcc . ( :name "Bcc" @@ -749,11 +750,13 @@ mu4e-compose-mode." ( :name "Signature" :shortname "Sgn" :help "Check for the cryptographic signature" + :require-full t :sortable nil)) (:decryption . ( :name "Decryption" :shortname "Dec" :help "Check the cryptographic decryption status" + :require-full t :sortable nil)) (:size . ( :name "Size" @@ -784,6 +787,7 @@ mu4e-compose-mode." ( :name "User-Agent" :shortname "UA" :help "Program used for writing this message" + :require-full t :sortable t))) "An alist of all possible header fields and information about them. This is used in the user-interface (the column headers in the header list, and @@ -799,7 +803,12 @@ sort by this field. This can be either a boolean (nil or t), or a symbol for /another/ field. For example, the `:human-date' field uses `:date' for that. -Note, `:sortable' does not work for custom header fields.") +Fields with which have the property `:require-full' set to +non-nil require a full message; in practice this means that you +cannot use such fieds as part of `mu4e-headers-fields', but only +in `mu4e-view-fields.' + +Note, `:sortable' is not supported for custom header fields.") (defvar mu4e-header-info-custom