Sometimes the normal headers that mu4e offers (Date, From, To, Subject etc.) may not be enough. For these cases, mu4e offers custom headers in both the headers-view and the message-view.
You can do so by adding a description of your custom header to
mu4e-header-info-custom, which is a list of custom headers.
Let’s look at an example — suppose we want to add a custom header that shows the number of recipients for a message, i.e., the sum of the number of recipients in the To: and Cc: fields. Let’s further suppose that our function takes a message-plist as its argument (Message functions).
(add-to-list 'mu4e-header-info-custom '(:recipnum . ( :name "Number of recipients" ;; long name, as seen in the message-view :shortname "Recip#" ;; short name, as seen in the headers view :help "Number of recipients for this message" ;; tooltip :function (lambda (msg) (format "%d" (+ (length (mu4e-message-field msg :to)) (length (mu4e-message-field msg :cc))))))))
Or, let’s get the full mailing-list name:
(add-to-list 'mu4e-header-info-custom '(:full-mailing-list . ( :name "Mailing-list" ;; long name, as seen in the message-view :shortname "ML" ;; short name, as seen in the headers view :help "Full name for mailing list" ;; tooltip :function (lambda (msg) (or (mu4e-message-field msg :mailing-list) "")))))
You can then add the custom header to your
just like the built-in headers. After evaluation, your headers-view
should include a new header Recip# with the number of recipients,
and/or ML with the full mailing-list name.
This function can be used in both the headers-view and the message-view; if you need something specific for one of these, you can check for the mode in your function, or create separate functions.