Re: [Patch v2] Minor correction to devel/schemata
[notmuch-archives.git] / 09 / 9e234c455640afec49c1d8fe7144ff1687c4ac
1 Return-Path: <m.walters@qmul.ac.uk>\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 6F88C431FB6\r
6         for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 03:06:51 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id JztbtZz+Ihgw for <notmuch@notmuchmail.org>;\r
17         Sat, 28 Jan 2012 03:06:50 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 349AC431FAE\r
22         for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 03:06:50 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1Rr67M-0000Qt-5u; Sat, 28 Jan 2012 11:06:48 +0000\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1Rr67L-0001XR-OF; Sat, 28 Jan 2012 11:06:48 +0000\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: David Edmondson <dme@dme.org>\r
34 Subject: Re: [PATCH] emacs: add default value to notmuch-search-line-faces\r
35 In-Reply-To: <cunhazhjurs.fsf@hotblack-desiato.hh.sledj.net>\r
36 References: <1327605679-15213-1-git-send-email-jani@nikula.org>\r
37         <87y5st4ewt.fsf@qmul.ac.uk>\r
38         <cunhazhjurs.fsf@hotblack-desiato.hh.sledj.net>\r
39 User-Agent: Notmuch/0.11+107~g185f859 (http://notmuchmail.org) Emacs/23.2.1\r
40         (i486-pc-linux-gnu)\r
41 Date: Sat, 28 Jan 2012 11:07:51 +0000\r
42 Message-ID: <871uqk6q60.fsf@qmul.ac.uk>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain; charset=us-ascii\r
45 X-Sender-Host-Address: 94.192.233.223\r
46 X-QM-SPAM-Info: Sender has good ham record.  :)\r
47 X-QM-Body-MD5: 046f23133340c558ed1a97dc0491b70a (of first 20000 bytes)\r
48 X-SpamAssassin-Score: -1.8\r
49 X-SpamAssassin-SpamBar: -\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
51         determine if it is\r
52         spam. We require at least 5.0 points to mark a message as spam.\r
53         This message scored -1.8 points.\r
54         Summary of the scoring: \r
55         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
56         *      medium trust\r
57         *      [138.37.6.40 listed in list.dnswl.org]\r
58         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
59         provider *      (markwalters1009[at]gmail.com)\r
60         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
61         *      domain\r
62         *  0.5 AWL AWL: From: address is in the auto white-list\r
63 X-QM-Scan-Virus: ClamAV says the message is clean\r
64 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sat, 28 Jan 2012 11:06:51 -0000\r
78 \r
79 \r
80 On Fri, 27 Jan 2012 10:37:43 +0000, David Edmondson <dme@dme.org> wrote:\r
81 > On Fri, 27 Jan 2012 10:29:22 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
82 > > I am not sure if this is the place\r
83\r
84 > Here or #notmuch.\r
85\r
86 > > to ask but is there a corresponding option for colouring the summary\r
87 > > line in notmuch-show depending on tags/flags?\r
88\r
89 > There's id:"1325006003-27152-1-git-send-email-dme@dme.org", but it's a\r
90 > bit old and may not apply cleanly any more.\r
91 \r
92 That's great! One hunk didn't apply but the merge was so trivial I am not sure\r
93 why it did not apply. Anyway in case anyone else wants it I include the\r
94 rebased version below (I also moved the defcustom under notmuch-show).\r
95 \r
96 Best wishes\r
97 \r
98 Mark\r
99 \r
100 Subject: [PATCH] rebased id:"1325006003-27152-1-git-send-email-dme@dme.org"\r
101 \r
102 ---\r
103  emacs/notmuch-lib.el  |   18 ++++++++++++++++++\r
104  emacs/notmuch-show.el |   33 +++++++++++++++++++++++++++++----\r
105  emacs/notmuch.el      |   17 ++---------------\r
106  3 files changed, 49 insertions(+), 19 deletions(-)\r
107 \r
108 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
109 index c906ca7..ab1d8e8 100644\r
110 --- a/emacs/notmuch-lib.el\r
111 +++ b/emacs/notmuch-lib.el\r
112 @@ -133,6 +133,24 @@ the user hasn't set this variable with the old or new value."\r
113    (interactive)\r
114    (kill-buffer (current-buffer)))\r
115  \r
116 +(defun notmuch-color-line (start end line-tag-list spec)\r
117 +  "Colorize a line based on tags."\r
118 +  ;; Create the overlay only if the message has tags which match one\r
119 +  ;; of those specified in `spec'.\r
120 +  (let (overlay)\r
121 +    (mapc (lambda (elem)\r
122 +           (let ((tag (car elem))\r
123 +                 (attributes (cdr elem)))\r
124 +             (when (member tag line-tag-list)\r
125 +               (when (not overlay)\r
126 +                 (setq overlay (make-overlay start end))\r
127 +                 (overlay-put overlay 'priority 5))\r
128 +               ;; Merge the specified properties with any already\r
129 +               ;; applied from an earlier match.\r
130 +               (overlay-put overlay 'face\r
131 +                            (append (overlay-get overlay 'face) attributes)))))\r
132 +         spec)))\r
133 +\r
134  ;;\r
135  \r
136  (defun notmuch-common-do-stash (text)\r
137 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
138 index 84ac624..c448ab2 100644\r
139 --- a/emacs/notmuch-show.el\r
140 +++ b/emacs/notmuch-show.el\r
141 @@ -92,6 +92,24 @@ any given message."\r
142    :group 'notmuch-show\r
143    :group 'notmuch-hooks)\r
144  \r
145 +(defcustom notmuch-show-line-faces nil\r
146 +  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.\r
147 +\r
148 +Here is an example of how to color search results based on tags.\r
149 + (the following text would be placed in your ~/.emacs file):\r
150 +\r
151 + (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"\r
152 +                                                 :background \"blue\"))\r
153 +                                   (\"unread\" . (:foreground \"green\"))))\r
154 +\r
155 +The attributes defined for matching tags are merged, with later\r
156 +attributes overriding earlier. A message having both \"delete\"\r
157 +and \"unread\" tags with the above settings would have a green\r
158 +foreground and blue background."\r
159 +  :type '(alist :key-type (string) :value-type (custom-face-edit))\r
160 +  :group 'notmuch-show\r
161 +  :group 'notmuch-faces)\r
162 +\r
163  ;; Mostly useful for debugging.\r
164  (defcustom notmuch-show-all-multipart/alternative-parts t\r
165    "Should all parts of multipart/alternative parts be shown?"\r
166 @@ -340,7 +358,8 @@ unchanged ADDRESS if parsing fails."\r
167  (defun notmuch-show-insert-headerline (headers date tags depth)\r
168    "Insert a notmuch style headerline based on HEADERS for a\r
169  message at DEPTH in the current thread."\r
170 -  (let ((start (point)))\r
171 +  (let ((start (point))\r
172 +       overlay)\r
173      (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
174             (notmuch-show-clean-address (plist-get headers :From))\r
175             " ("\r
176 @@ -349,7 +368,9 @@ message at DEPTH in the current thread."\r
177             (propertize (mapconcat 'identity tags " ")\r
178                         'face 'notmuch-tag-face)\r
179             ")\n")\r
180 -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
181 +    (setq overlay (make-overlay start (point)))\r
182 +    (overlay-put overlay 'face 'notmuch-message-summary-face)\r
183 +    (overlay-put overlay 'priority 2)))\r
184  \r
185  (defun notmuch-show-insert-header (header header-value)\r
186    "Insert a single header."\r
187 @@ -818,7 +839,8 @@ current buffer, if possible."\r
188          body-start body-end\r
189          (headers-invis-spec (notmuch-show-make-symbol "header"))\r
190          (message-invis-spec (notmuch-show-make-symbol "message"))\r
191 -        (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))\r
192 +        (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))\r
193 +        (tags (plist-get msg :tags)))\r
194  \r
195      ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise\r
196      ;; removing items from `buffer-invisibility-spec' (which is what\r
197 @@ -843,10 +865,13 @@ current buffer, if possible."\r
198                                             (plist-get msg :date_relative)\r
199                                           nil)\r
200                                         (plist-get headers :Date))\r
201 -                                   (plist-get msg :tags) depth)\r
202 +                                   tags depth)\r
203  \r
204      (setq content-start (point-marker))\r
205  \r
206 +    ;; Colour the header line according to the tags of the message.\r
207 +    (notmuch-color-line message-start content-start tags notmuch-show-line-faces)\r
208 +\r
209      (plist-put msg :headers-invis-spec headers-invis-spec)\r
210      (plist-put msg :message-invis-spec message-invis-spec)\r
211  \r
212 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
213 index 72f78ed..244fafa 100644\r
214 --- a/emacs/notmuch.el\r
215 +++ b/emacs/notmuch.el\r
216 @@ -690,7 +690,7 @@ This function advances the next thread when finished."\r
217                   (forward-line (1- notmuch-search-target-line))))))))\r
218  \r
219  (defcustom notmuch-search-line-faces nil\r
220 -  "Tag/face mapping for line highlighting in notmuch-search.\r
221 +  "Tag to face mapping for line highlighting in `notmuch-search-mode'.\r
222  \r
223  Here is an example of how to color search results based on tags.\r
224   (the following text would be placed in your ~/.emacs file):\r
225 @@ -709,20 +709,7 @@ foreground and blue background."\r
226  \r
227  (defun notmuch-search-color-line (start end line-tag-list)\r
228    "Colorize lines in `notmuch-show' based on tags."\r
229 -  ;; Create the overlay only if the message has tags which match one\r
230 -  ;; of those specified in `notmuch-search-line-faces'.\r
231 -  (let (overlay)\r
232 -    (mapc (lambda (elem)\r
233 -           (let ((tag (car elem))\r
234 -                 (attributes (cdr elem)))\r
235 -             (when (member tag line-tag-list)\r
236 -               (when (not overlay)\r
237 -                 (setq overlay (make-overlay start end)))\r
238 -               ;; Merge the specified properties with any already\r
239 -               ;; applied from an earlier match.\r
240 -               (overlay-put overlay 'face\r
241 -                            (append (overlay-get overlay 'face) attributes)))))\r
242 -         notmuch-search-line-faces)))\r
243 +  (notmuch-color-line start end line-tag-list notmuch-search-line-faces))\r
244  \r
245  (defun notmuch-search-author-propertize (authors)\r
246    "Split `authors' into matching and non-matching authors and\r
247 -- \r
248 1.7.2.3\r
249 \r
250 \r
251 \r