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.
This commit is contained in:
djcb 2016-11-05 12:42:28 +02:00
parent e294016e85
commit 01fe899c37
2 changed files with 14 additions and 2 deletions

View File

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

View File

@ -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