This allows header-lines `notmuch-show-mode' buffers to be coloured based on the flags (match/excluded) of the message. It supplies the line colouring function with a list of tags each prefixed with "tag:" and a list of flags ("match" or "excluded") each prefixed with "flag:". The match flag is obviously not equivalent to a tag; the excluded flag looks equivalent but is subtly different: a message is not marked excluded if that tag appeared in the query. --- emacs/notmuch-show.el | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index bb7db6e..f09de26 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -96,14 +96,16 @@ any given message." (defcustom notmuch-show-line-faces nil "Tag to face mapping for header line highlighting in `notmuch-show-mode'. -Here is an example of how to color search results based on tags. +Here is an example of how to color search results based on tags +and flags (match and excluded). (the following text would be placed in your ~/.emacs file): - (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\" + (setq notmuch-search-line-faces '((\"tag:delete\" . (:foreground \"red\" :background \"blue\")) - (\"unread\" . (:foreground \"green\")))) + (\"tag:unread\" . (:foreground \"green\")) + (\"flag:excluded\" . (:background \"grey\")))) -The attributes defined for matching tags are merged, with later +The attributes defined for matching tags/flags are merged, with later attributes overriding earlier. A message having both \"delete\" and \"unread\" tags with the above settings would have a green foreground and blue background." @@ -871,11 +873,20 @@ current buffer, if possible." content-start content-end headers-start headers-end body-start body-end + tags-and-flags (headers-invis-spec (notmuch-show-make-symbol "header")) (message-invis-spec (notmuch-show-make-symbol "message")) (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))) (tags (plist-get msg :tags))) + (mapc (lambda (tag) + (setq tags-and-flags (cons (concat "tag:" tag) tags-and-flags))) + tags) + (if (plist-get msg :match) + (setq tags-and-flags (cons "flag:match" tags-and-flags))) + (if (plist-get msg :excluded) + (setq tags-and-flags (cons "flag:excluded" tags-and-flags))) + ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise ;; removing items from `buffer-invisibility-spec' (which is what ;; `notmuch-show-headers-visible' and @@ -904,7 +915,7 @@ current buffer, if possible." (setq content-start (point-marker)) ;; Colour the header line according to the tags of the message. - (notmuch-color-line message-start content-start tags notmuch-show-line-faces) + (notmuch-color-line message-start content-start tags-and-flags notmuch-show-line-faces) (plist-put msg :headers-invis-spec headers-invis-spec) (plist-put msg :message-invis-spec message-invis-spec) -- 1.7.9.1