* [PATCH] emacs: notmuch-show-header-line: allow format-spec format
@ 2022-04-25 23:45 jao
0 siblings, 0 replies; only message in thread
From: jao @ 2022-04-25 23:45 UTC (permalink / raw)
To: notmuch; +Cc: jao
If a string value is assigned to notmuch-show-header-line, it's used
as a format string to be passed passed to format-spec with `%s`
substituted by the message's subject. As before, t means displaying
the subject and nil not using any header line.
Signed-off-by: jao <jao@gnu.org>
---
emacs/notmuch-show.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7c1f02c9..f31c15e6 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -85,8 +85,18 @@ visible for any given message."
:group 'notmuch-show)
(defcustom notmuch-show-header-line t
- "Show a header line with the current message's subject."
- :type 'boolean
+ "Show a header line in notmuch show buffers.
+
+If t (the default), the header line will contain the current
+message's subject. If a string, this value is interpreted as a
+format string to be passed to `format-spec` with `%s` as the
+substitution variable for the message's subject. E.g., to
+display the subject trimmed to a maximum of 80 columns, you could
+use \"%>-80s\" as format. If this variabale is set to nil, no
+header is displayed."
+ :type '(choice (const :tag "No header" ni)
+ (const :tag "Subject" t)
+ (string :tag "Format"))
:group 'notmuch-show)
(defcustom notmuch-show-relative-dates t
@@ -1351,11 +1361,14 @@ If no messages match the query return NIL."
(lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags))))
;; Set the header line to the subject of the first message.
(when notmuch-show-header-line
- (setq header-line-format
- (replace-regexp-in-string "%" "%%"
- (notmuch-sanitize
- (notmuch-show-strip-re
- (notmuch-show-get-subject))))))
+ (let* ((s (replace-regexp-in-string "%" "%%"
+ (notmuch-sanitize
+ (notmuch-show-strip-re
+ (notmuch-show-get-subject)))))
+ (h (cond ((stringp notmuch-show-header-line)
+ (format-spec notmuch-show-header-line `((?s . ,s))))
+ (notmuch-show-header-line s))))
+ (setq header-line-format h)))
(run-hooks 'notmuch-show-hook)
(if state
(notmuch-show-apply-state state)
--
2.36.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-25 23:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 23:45 [PATCH] emacs: notmuch-show-header-line: allow format-spec format jao
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).