1 Return-Path: <jrollins@finestructure.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 3C24F431FBD
\r
6 for <notmuch@notmuchmail.org>; Thu, 4 Feb 2010 16:38:22 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.976 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.377, BAYES_00=-2.599] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id xM9bvqegwjPU for <notmuch@notmuchmail.org>;
\r
16 Thu, 4 Feb 2010 16:38:21 -0800 (PST)
\r
17 Received: from tarap.cc.columbia.edu (tarap.cc.columbia.edu [128.59.29.7])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 86E08431FAE
\r
19 for <notmuch@notmuchmail.org>; Thu, 4 Feb 2010 16:38:21 -0800 (PST)
\r
20 Received: from servo.finestructure.net (geco.phys.columbia.edu
\r
22 (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0)
\r
23 by tarap.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id o150cKHD021997
\r
24 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT)
\r
25 for <notmuch@notmuchmail.org>; Thu, 4 Feb 2010 19:38:20 -0500 (EST)
\r
26 Received: from jrollins by servo.finestructure.net with local (Exim 4.71)
\r
27 (envelope-from <jrollins@finestructure.net>) id 1NdCDE-000288-63
\r
28 for notmuch@notmuchmail.org; Thu, 04 Feb 2010 19:38:20 -0500
\r
29 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
30 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
31 In-Reply-To: <87aavpb3wh.fsf@servo.finestructure.net>
\r
32 References: <87aavpb3wh.fsf@servo.finestructure.net>
\r
33 Date: Thu, 04 Feb 2010 19:38:20 -0500
\r
34 Message-ID: <87r5p01pqb.fsf@servo.finestructure.net>
\r
36 Content-Type: text/plain; charset=us-ascii
\r
37 X-No-Spam-Score: Local
\r
38 X-Scanned-By: MIMEDefang 2.68 on 128.59.29.7
\r
39 Subject: [notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search
\r
40 based on thread tags.
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Fri, 05 Feb 2010 00:38:22 -0000
\r
55 Arbitrary font faces can be specified for given thread tags. By
\r
56 default, no coloring is applied. To specify coloring, place something
\r
57 like this in your .emacs:
\r
59 (setq notmuch-search-line-faces '(("delete" . (:foreground "red"))
\r
60 ("unread" . (:foreground "green"))))
\r
62 Order matters: line faces listed first will take precedence (in the
\r
63 example above, a thread tagged both "delete" and "unread" will be
\r
64 colored red, since the "delete" face is listed before the "unread").
\r
66 notmuch.el | 34 +++++++++++++++++++++++++++++++++-
\r
67 1 files changed, 33 insertions(+), 1 deletions(-)
\r
69 diff --git a/notmuch.el b/notmuch.el
\r
70 index a21c6a6..6c42b37 100644
\r
73 @@ -1203,6 +1203,36 @@ This function advances the next thread when finished."
\r
74 (insert (format " (process returned %d)" exit-status)))
\r
75 (insert "\n"))))))))))
\r
77 +(defcustom notmuch-search-line-faces
\r
78 + '(("delete" . (:foreground "DarkGrey")))
\r
79 + "Tag/face mapping for line highlighting in notmuch-search.
\r
81 +Here is an example of how to color search results based on tags.
\r
82 +(the following text would be placed in your ~/.emacs file):
\r
84 +(setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"))
\r
85 + (\"unread\" . (:foreground \"green\"))))
\r
87 +Order matters: for lines with multiple tags, the the first
\r
88 +matching will be applied."
\r
89 + :type '(alist :value-type (string face))
\r
92 +(defun notmuch-search-color-line (start end line-tag-list)
\r
93 + "Colorize lines in notmuch-search based on tags"
\r
94 + (if notmuch-search-line-faces
\r
95 + (let ((overlay (make-overlay start end))
\r
96 + (tags-faces (copy-alist notmuch-search-line-faces)))
\r
98 + (let* ((tag-face (car tags-faces))
\r
99 + (tag (car tag-face))
\r
100 + (face (cdr tag-face)))
\r
101 + (cond ((member tag line-tag-list)
\r
102 + (overlay-put overlay 'face face)
\r
103 + (setq tags-faces nil))
\r
105 + (setq tags-faces (cdr tags-faces)))))))))
\r
107 (defun notmuch-search-process-filter (proc string)
\r
108 "Process and filter the output of \"notmuch search\""
\r
109 (let ((buffer (process-buffer proc)))
\r
110 @@ -1220,12 +1250,14 @@ This function advances the next thread when finished."
\r
111 (authors (match-string 4 string))
\r
112 (authors-length (length authors))
\r
113 (subject (match-string 5 string))
\r
114 - (tags (match-string 6 string)))
\r
115 + (tags (match-string 6 string))
\r
116 + (tag-list (if tags (save-match-data (split-string tags)))))
\r
117 (if (> authors-length 40)
\r
118 (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
\r
119 (goto-char (point-max))
\r
120 (let ((beg (point-marker)))
\r
121 (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
122 + (notmuch-search-color-line beg (point-marker) tag-list)
\r
123 (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
\r
124 (put-text-property beg (point-marker) 'notmuch-search-authors authors)
\r
125 (put-text-property beg (point-marker) 'notmuch-search-subject subject))
\r