Re: search query "replytoid:<blah>"
[notmuch-archives.git] / 99 / 2f7ee543bc5232377d49d61351352deebd2e1a
1 Return-Path: <jani@nikula.org>\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 6818F431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 27 Dec 2011 11:57:42 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 EQXk+FQmZklk for <notmuch@notmuchmail.org>;\r
16         Tue, 27 Dec 2011 11:57:41 -0800 (PST)\r
17 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
18  [74.125.83.53])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  2E6C7431FB6    for <notmuch@notmuchmail.org>; Tue, 27 Dec 2011 11:57:40 -0800\r
21  (PST)\r
22 Received: by eekd41 with SMTP id d41so14397251eek.26\r
23         for <notmuch@notmuchmail.org>; Tue, 27 Dec 2011 11:57:40 -0800 (PST)\r
24 Received: by 10.213.14.131 with SMTP id g3mr5970331eba.63.1325015858370;\r
25         Tue, 27 Dec 2011 11:57:38 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
27         [80.220.92.23])\r
28         by mx.google.com with ESMTPS id z43sm110750221eef.7.2011.12.27.11.57.35\r
29         (version=SSLv3 cipher=OTHER); Tue, 27 Dec 2011 11:57:37 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH] emacs: Add `notmuch-show-line-faces' and apply it.\r
33 In-Reply-To: <1325006003-27152-1-git-send-email-dme@dme.org>\r
34 References: <1325006003-27152-1-git-send-email-dme@dme.org>\r
35 User-Agent: Notmuch/0.10.2+133~gb08a3ab (http://notmuchmail.org) Emacs/23.3.1\r
36         (i686-pc-linux-gnu)\r
37 Date: Tue, 27 Dec 2011 21:57:33 +0200\r
38 Message-ID: <87d3b923f6.fsf@nikula.org>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain; charset=us-ascii\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\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: Tue, 27 Dec 2011 19:57:42 -0000\r
54 \r
55 On Tue, 27 Dec 2011 17:13:23 +0000, David Edmondson <dme@dme.org> wrote:\r
56 > Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'\r
57 > allows the header line in `notmuch-show-mode' buffers to be coloured\r
58 > according to the tags of the message.\r
59 \r
60 Hi David, I've only given this a quick test drive, but so far it seems\r
61 to work as expected. I think this would be a useful feature to have.\r
62 \r
63 The patch failed to apply cleanly without "emacs: Don't attempt to\r
64 colour tags in `notmuch-show-mode'." Is there a dependency, or was this\r
65 accidental?\r
66 \r
67 \r
68 BR,\r
69 Jani.\r
70 \r
71 \r
72 > ---\r
73 >  emacs/notmuch-lib.el  |   18 ++++++++++++++++++\r
74 >  emacs/notmuch-show.el |   32 ++++++++++++++++++++++++++++----\r
75 >  emacs/notmuch.el      |   17 ++---------------\r
76 >  3 files changed, 48 insertions(+), 19 deletions(-)\r
77\r
78 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
79 > index 0f856bf..1f00fe0 100644\r
80 > --- a/emacs/notmuch-lib.el\r
81 > +++ b/emacs/notmuch-lib.el\r
82 > @@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new value."\r
83 >    (interactive)\r
84 >    (kill-buffer (current-buffer)))\r
85 >  \r
86 > +(defun notmuch-color-line (start end line-tag-list spec)\r
87 > +  "Colorize a line based on tags."\r
88 > +  ;; Create the overlay only if the message has tags which match one\r
89 > +  ;; of those specified in `spec'.\r
90 > +  (let (overlay)\r
91 > +    (mapc (lambda (elem)\r
92 > +         (let ((tag (car elem))\r
93 > +               (attributes (cdr elem)))\r
94 > +           (when (member tag line-tag-list)\r
95 > +             (when (not overlay)\r
96 > +               (setq overlay (make-overlay start end))\r
97 > +               (overlay-put overlay 'priority 5))\r
98 > +             ;; Merge the specified properties with any already\r
99 > +             ;; applied from an earlier match.\r
100 > +             (overlay-put overlay 'face\r
101 > +                          (append (overlay-get overlay 'face) attributes)))))\r
102 > +       spec)))\r
103 > +\r
104 >  ;;\r
105 >  \r
106 >  (defun notmuch-common-do-stash (text)\r
107 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
108 > index 24f0b40..0885bd5 100644\r
109 > --- a/emacs/notmuch-show.el\r
110 > +++ b/emacs/notmuch-show.el\r
111 > @@ -88,6 +88,23 @@ any given message."\r
112 >            notmuch-wash-elide-blank-lines\r
113 >            notmuch-wash-excerpt-citations))\r
114 >  \r
115 > +(defcustom notmuch-show-line-faces nil\r
116 > +  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.\r
117 > +\r
118 > +Here is an example of how to color search results based on tags.\r
119 > + (the following text would be placed in your ~/.emacs file):\r
120 > +\r
121 > + (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"\r
122 > +                                               :background \"blue\"))\r
123 > +                                   (\"unread\" . (:foreground \"green\"))))\r
124 > +\r
125 > +The attributes defined for matching tags are merged, with later\r
126 > +attributes overriding earlier. A message having both \"delete\"\r
127 > +and \"unread\" tags with the above settings would have a green\r
128 > +foreground and blue background."\r
129 > +  :type '(alist :key-type (string) :value-type (custom-face-edit))\r
130 > +  :group 'notmuch)\r
131 > +\r
132 >  ;; Mostly useful for debugging.\r
133 >  (defcustom notmuch-show-all-multipart/alternative-parts t\r
134 >    "Should all parts of multipart/alternative parts be shown?"\r
135 > @@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails."\r
136 >  (defun notmuch-show-insert-headerline (headers date tags depth)\r
137 >    "Insert a notmuch style headerline based on HEADERS for a\r
138 >  message at DEPTH in the current thread."\r
139 > -  (let ((start (point)))\r
140 > +  (let ((start (point))\r
141 > +     overlay)\r
142 >      (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))\r
143 >           (notmuch-show-clean-address (plist-get headers :From))\r
144 >           " ("\r
145 > @@ -277,7 +295,9 @@ message at DEPTH in the current thread."\r
146 >           ") ("\r
147 >           (mapconcat 'identity tags " ")\r
148 >           ")\n")\r
149 > -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
150 > +    (setq overlay (make-overlay start (point)))\r
151 > +    (overlay-put overlay 'face 'notmuch-message-summary-face)\r
152 > +    (overlay-put overlay 'priority 2)))\r
153 >  \r
154 >  (defun notmuch-show-insert-header (header header-value)\r
155 >    "Insert a single header."\r
156 > @@ -712,7 +732,8 @@ current buffer, if possible."\r
157 >        body-start body-end\r
158 >        (headers-invis-spec (notmuch-show-make-symbol "header"))\r
159 >        (message-invis-spec (notmuch-show-make-symbol "message"))\r
160 > -      (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))\r
161 > +      (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))\r
162 > +      (tags (plist-get msg :tags)))\r
163 >  \r
164 >      ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise\r
165 >      ;; removing items from `buffer-invisibility-spec' (which is what\r
166 > @@ -737,10 +758,13 @@ current buffer, if possible."\r
167 >                                           (plist-get msg :date_relative)\r
168 >                                         nil)\r
169 >                                       (plist-get headers :Date))\r
170 > -                                 (plist-get msg :tags) depth)\r
171 > +                                 tags depth)\r
172 >  \r
173 >      (setq content-start (point-marker))\r
174 >  \r
175 > +    ;; Colour the header line according to the tags of the message.\r
176 > +    (notmuch-color-line message-start content-start tags notmuch-show-line-faces)\r
177 > +\r
178 >      (plist-put msg :headers-invis-spec headers-invis-spec)\r
179 >      (plist-put msg :message-invis-spec message-invis-spec)\r
180 >  \r
181 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
182 > index 4844385..56d35d0 100644\r
183 > --- a/emacs/notmuch.el\r
184 > +++ b/emacs/notmuch.el\r
185 > @@ -641,7 +641,7 @@ This function advances the next thread when finished."\r
186 >                 (forward-line (1- notmuch-search-target-line))))))))\r
187 >  \r
188 >  (defcustom notmuch-search-line-faces nil\r
189 > -  "Tag/face mapping for line highlighting in notmuch-search.\r
190 > +  "Tag to face mapping for line highlighting in `notmuch-search-mode'.\r
191 >  \r
192 >  Here is an example of how to color search results based on tags.\r
193 >   (the following text would be placed in your ~/.emacs file):\r
194 > @@ -659,20 +659,7 @@ foreground and blue background."\r
195 >  \r
196 >  (defun notmuch-search-color-line (start end line-tag-list)\r
197 >    "Colorize lines in `notmuch-show' based on tags."\r
198 > -  ;; Create the overlay only if the message has tags which match one\r
199 > -  ;; of those specified in `notmuch-search-line-faces'.\r
200 > -  (let (overlay)\r
201 > -    (mapc (lambda (elem)\r
202 > -         (let ((tag (car elem))\r
203 > -               (attributes (cdr elem)))\r
204 > -           (when (member tag line-tag-list)\r
205 > -             (when (not overlay)\r
206 > -               (setq overlay (make-overlay start end)))\r
207 > -             ;; Merge the specified properties with any already\r
208 > -             ;; applied from an earlier match.\r
209 > -             (overlay-put overlay 'face\r
210 > -                          (append (overlay-get overlay 'face) attributes)))))\r
211 > -       notmuch-search-line-faces)))\r
212 > +  (notmuch-color-line start end line-tag-list notmuch-search-line-faces))\r
213 >  \r
214 >  (defun notmuch-search-author-propertize (authors)\r
215 >    "Split `authors' into matching and non-matching authors and\r
216 > -- \r
217 > 1.7.7.3\r
218\r
219 > _______________________________________________\r
220 > notmuch mailing list\r
221 > notmuch@notmuchmail.org\r
222 > http://notmuchmail.org/mailman/listinfo/notmuch\r