From: Jameson Rollins <jrollins@finestructure.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags.
Date: Thu, 04 Feb 2010 07:07:26 -0500 [thread overview]
Message-ID: <87aavpb3wh.fsf@servo.finestructure.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 3063 bytes --]
Arbitrary font faces can be specified for given thread tags. By
default, no coloring is applied. To specify coloring, place something
like this in your .emacs:
(setq notmuch-search-line-faces '(("delete" . '(:foreground "red"))
("unread" . '(:foreground "green"))))
Order matters: line faces listed first will take precedence (in the
example above, a thread tagged both "delete" and "unread" will be
colored red, since the "delete" face is listed before the "unread").
---
notmuch.el | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index a21c6a6..4f8840a 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1203,6 +1203,35 @@ This function advances the next thread when finished."
(insert (format " (process returned %d)" exit-status)))
(insert "\n"))))))))))
+(defcustom notmuch-search-line-faces nil
+ "Tag/face mapping for line highlighting in notmuch-search.
+
+Here is an example of how to color search results based on tags.
+(the following text would be placed in your ~/.emacs file):
+
+(setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))
+ (\"unread\" . '(:foreground \"green\"))))
+
+Order matters: for lines with multiple tags, the the first
+matching will be applied."
+ :type '(alist :key-type (string) :value-type (list))
+ :group 'notmuch)
+
+(defun notmuch-search-color-line (start end line-tag-list)
+ "Colorize lines in notmuch-show based on tags"
+ (if notmuch-search-line-faces
+ (let ((overlay (make-overlay start end))
+ (tags-faces (copy-alist notmuch-search-line-faces)))
+ (while tags-faces
+ (let* ((tag-face (car tags-faces))
+ (tag (car tag-face))
+ (face (cdr tag-face)))
+ (cond ((member tag line-tag-list)
+ (overlay-put overlay 'face face)
+ (setq tags-faces nil))
+ (t
+ (setq tags-faces (cdr tags-faces)))))))))
+
(defun notmuch-search-process-filter (proc string)
"Process and filter the output of \"notmuch search\""
(let ((buffer (process-buffer proc)))
@@ -1220,12 +1249,14 @@ This function advances the next thread when finished."
(authors (match-string 4 string))
(authors-length (length authors))
(subject (match-string 5 string))
- (tags (match-string 6 string)))
+ (tags (match-string 6 string))
+ (tag-list (if tags (save-match-data (split-string tags)))))
(if (> authors-length 40)
(set 'authors (concat (substring authors 0 (- 40 3)) "...")))
(goto-char (point-max))
(let ((beg (point-marker)))
(insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
+ (notmuch-search-color-line beg (point-marker) tag-list)
(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
(put-text-property beg (point-marker) 'notmuch-search-authors authors)
(put-text-property beg (point-marker) 'notmuch-search-subject subject))
--
1.6.5
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next reply other threads:[~2010-02-04 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 12:07 Jameson Rollins [this message]
2010-02-05 0:38 ` [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags Jameson Graef Rollins
2010-02-05 15:05 ` Jameson Graef Rollins
2010-02-07 1:21 ` [PATCH] Further improvements to tag-based coloring in search Aaron Ecay
2010-04-07 18:20 ` Carl Worth
2010-04-11 23:27 ` Aaron Ecay
2010-04-07 18:19 ` [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags Carl Worth
2010-02-07 15:44 ` [PATCH] " Aneesh Kumar K. V
2010-02-07 22:17 ` Aaron Ecay
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=87aavpb3wh.fsf@servo.finestructure.net \
--to=jrollins@finestructure.net \
--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).