1 Return-Path: <pieter@praet.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 E8D97431FAF
\r
6 for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 04:50:49 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 43raw4AyDzyi for <notmuch@notmuchmail.org>;
\r
16 Wed, 18 Jan 2012 04:50:49 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 12B4B431FAE
\r
21 for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 04:50:48 -0800 (PST)
\r
22 Received: by werp13 with SMTP id p13so1364175wer.26
\r
23 for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 04:50:47 -0800 (PST)
\r
24 Received: by 10.216.134.71 with SMTP id r49mr1757137wei.49.1326891047509;
\r
25 Wed, 18 Jan 2012 04:50:47 -0800 (PST)
\r
26 Received: from localhost ([109.131.97.13])
\r
27 by mx.google.com with ESMTPS id eq5sm7095973wib.2.2012.01.18.04.50.42
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Wed, 18 Jan 2012 04:50:46 -0800 (PST)
\r
30 From: Pieter Praet <pieter@praet.org>
\r
31 To: Aaron Ecay <aaronecay@gmail.com>, David Edmondson <dme@dme.org>,
\r
32 Jameson Graef Rollins <jrollins@finestructure.net>
\r
33 Subject: [PATCH 3/3 v3] emacs: colorize buttonized 'id:' links depending on
\r
34 the target message's state
\r
35 Date: Wed, 18 Jan 2012 13:48:53 +0100
\r
36 Message-Id: <1326890933-14947-1-git-send-email-pieter@praet.org>
\r
37 X-Mailer: git-send-email 1.7.8.1
\r
38 In-Reply-To: <87aa5l8gqx.fsf@praet.org>
\r
39 References: <87aa5l8gqx.fsf@praet.org>
\r
40 Cc: Notmuch Mail <notmuch@notmuchmail.org>
\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: Wed, 18 Jan 2012 12:50:50 -0000
\r
55 * emacs/notmuch-show.el
\r
57 (notmuch-show-buttonized-link-colors):
\r
58 - new defcustom, allows toggling colorization of buttonized links.
\r
60 (notmuch-show-buttonized-link-available),
\r
61 (notmuch-show-buttonized-link-available-and-unread),
\r
62 (notmuch-show-buttonized-link-missing):
\r
63 - new faces for buttonized id: links.
\r
65 (notmuch-show-found-target-p):
\r
66 - add optional arg SUBQUERY to allow addition filtering,
\r
67 eg. with "tag:unread".
\r
69 (notmuch-show-buttonize-links):
\r
70 - tweak `Message-Id' regexp: less greedy matching.
\r
71 - use different face property depending on the result of
\r
72 `notmuch-show-found-target-p', causing buttons to available,
\r
73 available-and-unread and missing messages to be displayed in
\r
77 [Forgot to cc the list, apologies for the dupes.]
\r
79 I've also noticed that Message-Id's from `git send-email'
\r
80 don't get colorized (but do get buttonized) for some reason.
\r
81 Thus, would appreciate some assistance with the regexp.
\r
86 - add `notmuch-show-buttonized-link-colors': new defcustom, allows
\r
87 toggling colorization of buttonized links, to address unquestionable
\r
88 concerns re performance, voiced by David Edmondson [1].
\r
89 - ... and some minor refactoring
\r
93 - tweak `Message-Id' regexp: mock Message-Id's shouldn't be matched,
\r
94 as pointed out by Aaron Ecay [2].
\r
97 [1] id:"cun4nvv50s6.fsf@hotblack-desiato.hh.sledj.net"
\r
98 [2] id:"m2sjjfb9xx.fsf@gmail.com"
\r
101 emacs/notmuch-show.el | 47 +++++++++++++++++++++++++++++++++++++++++++----
\r
102 1 files changed, 43 insertions(+), 4 deletions(-)
\r
104 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
105 index 244824a..deac9a6 100644
\r
106 --- a/emacs/notmuch-show.el
\r
107 +++ b/emacs/notmuch-show.el
\r
108 @@ -798,6 +798,38 @@ current buffer, if possible."
\r
109 (defvar notmuch-show-buffer-name nil)
\r
110 (make-variable-buffer-local 'notmuch-show-buffer-name)
\r
112 +(defcustom notmuch-show-buttonized-link-colors t
\r
113 + "Colorize buttonized links depending on their target's state.
\r
115 +Also see `notmuch-show-buttonized-link-available',
\r
116 + `notmuch-show-buttonized-link-available-and-unread',
\r
117 + `notmuch-show-buttonized-link-missing'.
\r
119 +Might impact performance."
\r
121 + :group 'notmuch-show)
\r
123 +(defface notmuch-show-buttonized-link-available
\r
124 + '((t (:inherit goto-address-mail-face :foreground "blue")))
\r
125 + "Face used for buttonized links to messages which are present
\r
126 +in the mail store."
\r
127 + :group 'notmuch-show
\r
128 + :group 'notmuch-faces)
\r
130 +(defface notmuch-show-buttonized-link-available-and-unread
\r
131 + '((t (:inherit goto-address-mail-face :foreground "green")))
\r
132 + "Face used for buttonized links to messages which are present
\r
133 +in the mail store, and are tagged `unread'."
\r
134 + :group 'notmuch-show
\r
135 + :group 'notmuch-faces)
\r
137 +(defface notmuch-show-buttonized-link-missing
\r
138 + '((t (:inherit goto-address-mail-face :foreground "red")))
\r
139 + "Face used for buttonized links to messages which are NOT
\r
140 +present in in the mail store."
\r
141 + :group 'notmuch-show
\r
142 + :group 'notmuch-faces)
\r
144 (defun notmuch-show-buttonize-links (start end)
\r
145 "Buttonize URLs and mail addresses between START and END.
\r
147 @@ -806,7 +838,7 @@ a corresponding notmuch search."
\r
148 (goto-address-fontify-region start end)
\r
151 - (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)
\r
152 + (while (re-search-forward "id:\\(\"?\\)\[^ \t\"@\]\+@[^ \t\"]\+\\1" end t)
\r
153 (let ((message-id (match-string-no-properties 0))
\r
154 (string-start (match-beginning 0))
\r
155 (string-end (match-end 0)))
\r
156 @@ -817,7 +849,14 @@ a corresponding notmuch search."
\r
157 (notmuch-show-if-found ,message-id))
\r
159 'help-echo "Mouse-1, RET: search for this message"
\r
160 - 'face goto-address-mail-face)))))
\r
161 + 'face (if notmuch-show-buttonized-link-colors
\r
163 + ((notmuch-show-found-target-p message-id "and tag:unread")
\r
164 + 'notmuch-show-buttonized-link-available-and-unread)
\r
165 + ((notmuch-show-found-target-p message-id nil)
\r
166 + 'notmuch-show-buttonized-link-available)
\r
167 + (t 'notmuch-show-buttonized-link-missing))
\r
168 + 'goto-address-mail-face))))))
\r
171 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
\r
172 @@ -910,8 +949,8 @@ thread id. If a prefix is given, crypto processing is toggled."
\r
173 (notmuch-kill-this-buffer)
\r
174 (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
\r
176 -(defun notmuch-show-found-target-p (target)
\r
177 - (let ((args `("count" ,target)))
\r
178 +(defun notmuch-show-found-target-p (target &optional subquery)
\r
179 + (let ((args `("count" ,target ,(or subquery ""))))
\r
180 (> (string-to-number
\r
181 (with-output-to-string
\r
182 (apply 'call-process notmuch-command nil standard-output nil args)))
\r