From b33f1450f0b3870dd04122bc2be5bd25dec1765a Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 11 Apr 2026 11:04:04 +0300 Subject: [PATCH] mu4e-view: update field handling Restrict fields in mu4e-view-fields. Make the defcustom a bit more helpful by checking for valid fields. Add :labels to default fields Remove some unused code. --- NEWS.org | 9 +++++++++ mu4e/mu4e-headers.el | 9 ++------- mu4e/mu4e-vars.el | 7 +++++++ mu4e/mu4e-view.el | 26 +++++++++++++++++--------- mu4e/mu4e.texi | 3 +++ 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/NEWS.org b/NEWS.org index 6c28e055..7d599bed 100644 --- a/NEWS.org +++ b/NEWS.org @@ -28,6 +28,15 @@ (see docstring). E.g. when you have the "Nerd Icons" package, you can set this to ~nerd-icons-icon-for-file~. (1.14.1) + - The message-view display has been stream-lined in number of ways, removing + some of the Gnus-elements. (1.14.1) + + You can streamline the display further by suppressing the "Attachments:" + headers, since most of the information is contained in the message body (or + through ~M-x mu4e-view-mime-part-action~, 'A'); see + ~gnus-mime-display-attachment-buttons-in-header~, and + ~gnus-mime-button-line-format~ to tweak the appearance + - ~mu4e-compose-crypto-policy~ now also recognizes ~sign-signed-replies~, to automatically sign when replying to signed messages (1.14.1). diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 3e2346ef..ba27c9ce 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -68,7 +68,7 @@ "A list of header fields to show in the headers buffer. Each element has the form (HEADER . WIDTH), where HEADER is one of the available headers (see `mu4e-header-info') and WIDTH is the -respective width in characters. +respective width in characters A width of nil means \"unrestricted\", and this is best reserved for the rightmost (last) field. Note that emacs may become very @@ -83,16 +83,11 @@ altogether." mu4e-header-info) (restricted-sexp :tag "User-specified header" - :match-alternatives (mu4e--headers-header-p))) + :match-alternatives (mu4e--valid-header-p))) (choice (integer :tag "width") (const :tag "unrestricted width" nil)))) :group 'mu4e-headers) -(defun mu4e--headers-header-p (symbol) - "Is SYMBOL a valid mu4e header? -This means its either one of the build-in or user-specified headers." - (assoc symbol (append mu4e-header-info mu4e-header-info-custom))) - (defcustom mu4e-headers-date-format "%x" "Date format to use in the headers view. In the format of `format-time-string'." diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index a1753ad0..f3cd2537 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -379,6 +379,13 @@ Note that when using the gnus-based view, you only have access to a limited set of message fields: only the ones used in the header-view, not including, for instance, the message body.") +(defun mu4e--valid-header-p (symbol) + "Is SYMBOL a valid mu4e header? +This means its either one of the build-in or user-specified headers." + (assoc symbol (append mu4e-header-info mu4e-header-info-custom))) + + + ;;; Internals (defvar-local mu4e~headers-view-win nil diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index c6d3c803..ec26dc3a 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -61,17 +61,27 @@ Otherwise, don't move to the next message." :group 'mu4e-view) (defcustom mu4e-view-fields - '(:from :to :cc :subject :flags :date :maildir :mailing-list :tags) - "Header fields to display in the message view buffer. + '(:from :to :cc :subject :flags :date + :maildir :mailing-list :tags :labels) + "Mu4e header fields to display in the message view buffer. For the complete list of available headers, see `mu4e-header-info'. -Note, you can use this to add fields that are not otherwise -shown; you can further tweak the other fields using e.g., -`gnus-visible-headers' and `gnus-ignored-headers' - see the gnus -documentation for details." - :type '(repeat symbol) +In addition to the mu4e fields, Gnus _also_ can show fields; See +`gnus-visible-headers' and `gnus-ignored-headers'. A special case +is the Attachments: header: see +`gnus-mime-display-attachment-buttons-in-header', and +`gnus-mime-button-line-format' for tweaking the appearance." + :type `(repeat (choice + ,@(mapcar (lambda (h) + (list 'const :tag + (plist-get (cdr h) :help) + (car h))) + mu4e-header-info) + (restricted-sexp + :tag "User-specified header" + :match-alternatives (mu4e--valid-header-p)))) :group 'mu4e-view) (defcustom mu4e-view-actions @@ -579,7 +589,6 @@ activates URLs (in plain-text mode only)." (charset (and charset (intern charset))) (mu4e--view-rendering t) ;; needed if e.g. an ics file is buttonized (gnus-article-emulate-mime nil) ;; avoid perf problems - (gnus-mime-button-line-format "%{%([%p. %n]%)%}%e\n") (gnus-newsgroup-charset (if (and charset (coding-system-p charset)) charset (detect-coding-region (point-min) (point-max) t))) @@ -696,7 +705,6 @@ render. After inserting, highlight the headers." ;; otherwise they are handled by Gnus. (when-let* ((raw (and raw-headers (cdr (assq field raw-headers))))) (mu4e--view-gnus-insert-header field raw))) - ((or ':attachments ':signature ':decryption)) ;; skip (_ (mu4e--view-gnus-insert-header-custom msg field))))) ;; Highlight the header block we just inserted diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index 8ed9c0ef..e0920a45 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -1416,6 +1416,9 @@ from the built-in fields, you can also create custom fields using end of a message,it automatically takes you to the next one. If you want to prevent this behavior, set @code{mu4e-view-scroll-to-next} to @code{nil}. +@item Since attachments are also shown in the message-body, you can suppress the @t{Attachments:} headder; +by customizing @code{gnus-mime-display-attachment-buttons-in-header} or tweak +the appearance through @code{gnus-mime-button-line-format} @end itemize @node MSGV Keybindings