Re: notmuch-search-toggle-order and notmuch-tree
[notmuch-archives.git] / e0 / d217f50351c625b3f27d1de6f6a4b4dab34b7e
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 0CD85429E5F\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:45 -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 FSAiCDXOW2Cp for <notmuch@notmuchmail.org>;\r
16         Sun, 22 Jan 2012 00:56:44 -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 03A63429E54\r
21         for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
22 Received: by mail-we0-f181.google.com with SMTP id b10so1658214wer.26\r
23         for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
24 MIME-Version: 1.0\r
25 Received: by 10.216.139.25 with SMTP id b25mr1616683wej.28.1327222603610;\r
26         Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
27 Received: from localhost ([109.131.95.182])\r
28         by mx.google.com with ESMTPS id fr8sm18836968wib.10.2012.01.22.00.56.42\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
31 From: Pieter Praet <pieter@praet.org>\r
32 To: Mark Anderson <MarkR.Anderson@amd.com>, Aaron Ecay <aaronecay@gmail.com>,\r
33         David Edmondson <dme@dme.org>,\r
34         Jameson Graef Rollins <jrollins@finestructure.net>\r
35 Subject: [PATCH v4 3/3] emacs: colorize buttonized 'id:' links depending on\r
36         the target message's state\r
37 Date: Sun, 22 Jan 2012 09:54:29 +0100\r
38 Message-Id: <1327222469-29487-3-git-send-email-pieter@praet.org>\r
39 X-Mailer: git-send-email 1.7.8.1\r
40 In-Reply-To: <871uqsku4h.fsf@praet.org>\r
41 References: <871uqsku4h.fsf@praet.org>\r
42 X-Gm-Message-State:\r
43  ALoCoQlt47zNumZI29cqWZEbjCuYIET23gGc4B55f2A/uEjiBIR++MTRW3Rqf4ko6D9ybJxoLvbE\r
44 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
45 X-BeenThere: notmuch@notmuchmail.org\r
46 X-Mailman-Version: 2.1.13\r
47 Precedence: list\r
48 List-Id: "Use and development of the notmuch mail system."\r
49         <notmuch.notmuchmail.org>\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
53 List-Post: <mailto:notmuch@notmuchmail.org>\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
57 X-List-Received-Date: Sun, 22 Jan 2012 08:56:45 -0000\r
58 \r
59 * emacs/notmuch-show.el\r
60 \r
61   (notmuch-show-buttonized-link-colors):\r
62     - new defcustom, allows toggling colorization of buttonized links.\r
63 \r
64   (notmuch-show-buttonized-link-available),\r
65   (notmuch-show-buttonized-link-available-and-unread),\r
66   (notmuch-show-buttonized-link-missing):\r
67     - new faces for buttonized id: links.\r
68 \r
69   (notmuch-show-found-target-p):\r
70     - add optional arg SUBQUERY to allow addition filtering,\r
71       eg. with "tag:unread".\r
72 \r
73   (notmuch-show-buttonize-links):\r
74     - tweak `Message-Id' regexp: less greedy matching.\r
75     - use different face property depending on the result of\r
76       `notmuch-show-found-target-p', causing buttons to available,\r
77       available-and-unread and missing messages to be displayed in\r
78       different colors.\r
79 ---\r
80 \r
81 Updated regexp.\r
82 \r
83  emacs/notmuch-show.el |   47 +++++++++++++++++++++++++++++++++++++++++++----\r
84  1 files changed, 43 insertions(+), 4 deletions(-)\r
85 \r
86 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
87 index 972ac79..c04fc28 100644\r
88 --- a/emacs/notmuch-show.el\r
89 +++ b/emacs/notmuch-show.el\r
90 @@ -899,6 +899,38 @@ current buffer, if possible."\r
91  (defvar notmuch-show-buffer-name nil)\r
92  (make-variable-buffer-local 'notmuch-show-buffer-name)\r
93  \r
94 +(defcustom notmuch-show-buttonized-link-colors t\r
95 +  "Colorize buttonized links depending on their target's state.\r
96 +\r
97 +Also see `notmuch-show-buttonized-link-available',\r
98 +         `notmuch-show-buttonized-link-available-and-unread',\r
99 +         `notmuch-show-buttonized-link-missing'.\r
100 +\r
101 +Might impact performance."\r
102 +  :type 'boolean\r
103 +  :group 'notmuch-show)\r
104 +\r
105 +(defface notmuch-show-buttonized-link-available\r
106 +  '((t (:inherit goto-address-mail-face :foreground "blue")))\r
107 +  "Face used for buttonized links to messages which are present\r
108 +in the mail store."\r
109 +  :group 'notmuch-show\r
110 +  :group 'notmuch-faces)\r
111 +\r
112 +(defface notmuch-show-buttonized-link-available-and-unread\r
113 +  '((t (:inherit goto-address-mail-face :foreground "green")))\r
114 +  "Face used for buttonized links to messages which are present\r
115 +in the mail store, and are tagged `unread'."\r
116 +  :group 'notmuch-show\r
117 +  :group 'notmuch-faces)\r
118 +\r
119 +(defface notmuch-show-buttonized-link-missing\r
120 +  '((t (:inherit goto-address-mail-face :foreground "red")))\r
121 +  "Face used for buttonized links to messages which are NOT\r
122 +present in in the mail store."\r
123 +  :group 'notmuch-show\r
124 +  :group 'notmuch-faces)\r
125 +\r
126  (defun notmuch-show-buttonize-links (start end)\r
127    "Buttonize URLs and mail addresses between START and END.\r
128  \r
129 @@ -907,7 +939,7 @@ a corresponding notmuch search."\r
130    (goto-address-fontify-region start end)\r
131    (save-excursion\r
132      (goto-char start)\r
133 -    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)\r
134 +    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+@[^[:space:]\"]\\{3,\\}\\1" end t)\r
135        (let ((message-id (match-string-no-properties 0))\r
136             (string-start (match-beginning 0))\r
137             (string-end (match-end 0)))\r
138 @@ -918,7 +950,14 @@ a corresponding notmuch search."\r
139                                      (notmuch-show-if-found ,message-id))\r
140                           'follow-link t\r
141                           'help-echo "Mouse-1, RET: search for this message"\r
142 -                         'face goto-address-mail-face)))))\r
143 +                         'face (if notmuch-show-buttonized-link-colors\r
144 +                                   (cond\r
145 +                                    ((notmuch-show-found-target-p message-id "and tag:unread")\r
146 +                                     'notmuch-show-buttonized-link-available-and-unread)\r
147 +                                    ((notmuch-show-found-target-p message-id nil)\r
148 +                                     'notmuch-show-buttonized-link-available)\r
149 +                                    (t 'notmuch-show-buttonized-link-missing))\r
150 +                                 'goto-address-mail-face))))))\r
151  \r
152  ;;;###autoload\r
153  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
154 @@ -1008,8 +1047,8 @@ thread id.  If a prefix is given, crypto processing is toggled."\r
155      (notmuch-kill-this-buffer)\r
156      (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))\r
157  \r
158 -(defun notmuch-show-found-target-p (target)\r
159 -  (let ((args `("count" ,target)))\r
160 +(defun notmuch-show-found-target-p (target &optional subquery)\r
161 +  (let ((args `("count" ,target ,(or subquery ""))))\r
162      (> (string-to-number\r
163         (with-output-to-string\r
164           (apply 'call-process notmuch-command nil standard-output nil args)))\r
165 -- \r
166 1.7.8.1\r
167 \r