From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [Patch v3 4/4] emacs: allow notmuch-show-line-faces to use flags for colouring
Date: Sat, 5 May 2012 14:39:47 +0100 [thread overview]
Message-ID: <1336225187-8772-5-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1336225187-8772-1-git-send-email-markwalters1009@gmail.com>
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 | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e62f0a0..94399c5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -96,17 +96,24 @@ 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-show-line-faces '((\"deleted\" . (:foreground \"red\"
+ (setq notmuch-show-line-faces '((\"tag:deleted\" . (: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."
+foreground and blue background.
+
+Alternatively, here is an example of colouring using the same
+criteria as for search results:
+ (setq notmuch-show-line-faces notmuch-search-line-faces)"
+
:type '(alist :key-type (string) :value-type (custom-face-edit))
:group 'notmuch-show
:group 'notmuch-faces)
@@ -871,11 +878,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,8 +920,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
next prev parent reply other threads:[~2012-05-05 13:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-05 13:39 [Patch v3 0/5] emacs: allow show to colour based on tags and flags Mark Walters
2012-05-05 13:39 ` [Patch v3 1/4] emacs: Move colour line from search to lib Mark Walters
2012-05-05 13:39 ` [Patch v3 2/4] emacs: Add `notmuch-show-line-faces' and apply it Mark Walters
2012-05-05 13:39 ` [Patch v3 3/4] emacs: move notmuch-search-line-faces to "tag:" style Mark Walters
2012-05-05 13:39 ` Mark Walters [this message]
2012-05-05 13:42 ` [Patch v3 0/5] emacs: allow show to colour based on tags and flags Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336225187-8772-5-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).