1 Return-Path: <amdragon@mit.edu>
\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 EFB50431FBD
\r
6 for <notmuch@notmuchmail.org>; Mon, 10 Mar 2014 19:29:40 -0700 (PDT)
\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 MNz8lro1YOaN for <notmuch@notmuchmail.org>;
\r
16 Mon, 10 Mar 2014 19:29:34 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu
\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 33FF8431FBC
\r
22 for <notmuch@notmuchmail.org>; Mon, 10 Mar 2014 19:29:34 -0700 (PDT)
\r
23 X-AuditID: 12074425-f79906d000000cf9-c6-531e750d4639
\r
24 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id D5.01.03321.D057E135; Mon, 10 Mar 2014 22:29:33 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s2B2TWWb018615;
\r
31 Mon, 10 Mar 2014 22:29:33 -0400
\r
32 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
33 (authenticated bits=0)
\r
34 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
35 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s2B2TUaK015699
\r
36 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);
\r
37 Mon, 10 Mar 2014 22:29:31 -0400
\r
38 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)
\r
39 (envelope-from <amdragon@mit.edu>)
\r
40 id 1WNCRe-0008P9-CK; Mon, 10 Mar 2014 22:29:30 -0400
\r
41 From: Austin Clements <amdragon@MIT.EDU>
\r
42 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
\r
43 Subject: Re: [PATCH v2 4/7] emacs: show: mark tags changed since buffer loaded
\r
44 In-Reply-To: <1392841212-8494-5-git-send-email-markwalters1009@gmail.com>
\r
45 References: <1392841212-8494-1-git-send-email-markwalters1009@gmail.com>
\r
46 <1392841212-8494-5-git-send-email-markwalters1009@gmail.com>
\r
47 User-Agent: Notmuch/0.17~rc2+14~g06f47e0 (http://notmuchmail.org) Emacs/23.4.1
\r
49 Date: Mon, 10 Mar 2014 22:29:30 -0400
\r
50 Message-ID: <878ush31th.fsf@awakening.csail.mit.edu>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
53 X-Brightmail-Tracker:
\r
54 H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsUixG6nrstbKhdsMPWVqMXquTwW12/OZHZg
\r
55 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mg5umcdYMMGzYvmVXqYGxoeWXYycHBICJhL/
\r
56 3t5mh7DFJC7cW8/WxcjFISQwm0li/r/dTBDORkaJ35dvQjmnmSS+HNnNCuEsYZRou9LACtLP
\r
57 JqAhsW3/ckYQW0TAVeLpt8/MILawgJ/EnEtdTCA2p4CnxM5Ns9khmlsZJeYtfwDWICqQJHF6
\r
58 6m+wQSwCqhLzj04Fs3mBDny09igjhC0ocXLmExYQm1lAS+LGv5dMExgFZiFJzUKSWsDItIpR
\r
59 NiW3Sjc3MTOnODVZtzg5MS8vtUjXQi83s0QvNaV0EyM4KF1UdzBOOKR0iFGAg1GJhzfAVy5Y
\r
60 iDWxrLgy9xCjJAeTkiivUDFQiC8pP6UyI7E4I76oNCe1+BCjBAezkgjvaQugHG9KYmVValE+
\r
61 TEqag0VJnLfvrESwkEB6YklqdmpqQWoRTFaGg0NJgrcQZKhgUWp6akVaZk4JQpqJgxNkOA/Q
\r
62 cBOQGt7igsTc4sx0iPwpRkUpcd5jIAkBkERGaR5cLyxpvGIUB3pFmNcTpIoHmHDgul8BDWYC
\r
63 Gtx8XApkcEkiQkqqgXH6A6bLfjqptroXl3VevrH84V/TlynSnkLxd+85qtz86HLSSdSh7CZn
\r
64 /5Wil+fWLgy+Ynzyc3HZjXUqf5ysX7BHqHN4Vy0NNNn5TJXz6qIJDp952Fv55VYxtPX6bHSa
\r
65 ziXF+P6mm5WYYP3lx0frHzM9qJ0UM+G3VG3QOp4+1o6f/AUVU8Ij/JVYijMSDbWYi4oTAbrW
\r
67 X-BeenThere: notmuch@notmuchmail.org
\r
68 X-Mailman-Version: 2.1.13
\r
70 List-Id: "Use and development of the notmuch mail system."
\r
71 <notmuch.notmuchmail.org>
\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
75 List-Post: <mailto:notmuch@notmuchmail.org>
\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
78 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
79 X-List-Received-Date: Tue, 11 Mar 2014 02:29:41 -0000
\r
81 On Wed, 19 Feb 2014, Mark Walters <markwalters1009@gmail.com> wrote:
\r
82 > This allows (and requires) the original-tags to be passed along with
\r
83 > the current-tags to be passed to notmuch-tag-format-tags. This allows
\r
84 > the tag formatting to show added and deleted tags.By default a removed
\r
85 > tag is displayed with strike-through in red (if strike-through is not
\r
86 > available, eg on a terminal, inverse video is used instead) and an
\r
87 > added tag is displayed underlined in green.
\r
89 > If the caller does not wish to use the new feature it can pass
\r
90 > current-tags for both arguments and, at this point, we do exactly that
\r
91 > in the three callers of this function.
\r
93 > Note, we cannot tidily allow original-tags to be optional because we would
\r
94 > need to distinguish nil meaning "we are not specifying original-tags"
\r
95 > from nil meaning there were no original-tags (an empty list).
\r
97 > We use this in subsequent patches to make it clear when a message was
\r
98 > unread when you first loaded a show buffer (previously the unread tag
\r
99 > could be removed before a user realised that it had been unread).
\r
101 > The code adds into the existing tag formatting code. The user can
\r
102 > specify exactly how a tag should be displayed normally, when deleted,
\r
103 > or when added. For convenience an entry for the empty string in the
\r
104 > notmuch-tag-formats (and the corresponding notmuch-tag-deleted-formats
\r
105 > notmuch-tag-added-formats) is applied to all tags which do not have an
\r
108 > This means that a user can tell notmuch not to show deleted tags at
\r
109 > all by setting notmuch-tag-deleted-formats to
\r
111 > or not to show any deleted tags except "unread" by setting it to
\r
114 Same comment about ".*" on these two.
\r
116 > ("unread" (propertize tag 'face '(strike-through "red"))))
\r
118 > All the variables are customizable; however, more complicated cases
\r
119 > like changing the face depending on the type of display will require
\r
122 > Currently this overrides notmuch-tag-deleted-formats for the tests
\r
123 > setting it to '(("" nil)) so that they get removed from the display
\r
127 > and, thus, all tests still pass.
\r
129 > emacs/notmuch-show.el | 4 +-
\r
130 > emacs/notmuch-tag.el | 65 ++++++++++++++++++++++++++++++++++++++----------
\r
131 > emacs/notmuch-tree.el | 2 +-
\r
132 > emacs/notmuch.el | 2 +-
\r
133 > test/test-lib.el | 5 ++++
\r
134 > 5 files changed, 60 insertions(+), 18 deletions(-)
\r
136 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
137 > index 4bddf6c..719e7d1 100644
\r
138 > --- a/emacs/notmuch-show.el
\r
139 > +++ b/emacs/notmuch-show.el
\r
140 > @@ -344,7 +344,7 @@ operation on the contents of the current buffer."
\r
141 > (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
142 > (let ((inhibit-read-only t))
\r
143 > (replace-match (concat "("
\r
144 > - (notmuch-tag-format-tags tags)
\r
145 > + (notmuch-tag-format-tags tags tags)
\r
148 > (defun notmuch-clean-address (address)
\r
149 > @@ -423,7 +423,7 @@ message at DEPTH in the current thread."
\r
153 > - (notmuch-tag-format-tags tags)
\r
154 > + (notmuch-tag-format-tags tags tags)
\r
156 > (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
\r
158 > diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
159 > index 064fbdb..869b97d 100644
\r
160 > --- a/emacs/notmuch-tag.el
\r
161 > +++ b/emacs/notmuch-tag.el
\r
162 > @@ -185,36 +185,73 @@ This can be used with `notmuch-tag-format-image-data'."
\r
166 > -(defun notmuch-tag-format-tag (tag)
\r
167 > - "Format TAG by looking into `notmuch-tag-formats'."
\r
168 > - (let ((formatted (gethash tag notmuch-tag--format-cache 'missing)))
\r
169 > +(defun notmuch-tag-format-tag-by-state (tag formatted-tag tag-state)
\r
170 > + "Format TAG by looking into the appropriate `notmuch-tag-formats`.
\r
172 Since you're rewriting the docstrings, you might as well change "by
\r
173 looking into" to "according to".
\r
176 > +Applies formats for TAG from the appropriate one of
\r
177 > +`notmuch-tag-formats`, `notmuch-tag-deleted-formats` and
\r
178 > +`notmuch-tag-added-formats` based on TAG-STATE to the partially
\r
179 > +formatted tag FORMATTED-TAG."
\r
180 > + (let ((formatted (gethash (cons tag tag-state) notmuch-tag--format-cache 'missing)))
\r
181 > (when (eq formatted 'missing)
\r
182 > - (let* ((formats
\r
183 > + (let* ((tag-formats (cond ((null tag-state) notmuch-tag-formats)
\r
184 > + ((eq 'deleted tag-state) notmuch-tag-deleted-formats)
\r
185 > + ((eq 'added tag-state) notmuch-tag-added-formats)))
\r
187 Use `case' instead of `cond'?
\r
191 > - (assoc* tag notmuch-tag-formats
\r
192 > + (assoc* tag tag-formats
\r
193 > :test (lambda (tag key)
\r
194 > (and (eq (string-match key tag) 0)
\r
195 > (= (match-end 0) (length tag))))))))
\r
198 > - ((null formats) ;; - Tag not in `notmuch-tag-formats',
\r
199 > - tag) ;; the format is the tag itself.
\r
200 > + ((null formats) ;; - Tag not in `tag-formats',
\r
201 > + formatted-tag) ;; the format is the tag itself.
\r
202 > ((null (cdr formats)) ;; - Tag was deliberately hidden,
\r
203 > nil) ;; no format must be returned
\r
204 > - (t ;; - Tag was found and has formats,
\r
205 > - (let ((tag tag)) ;; we must apply all the formats.
\r
207 > + ;; Tag was found and has formats, we must apply all
\r
208 > + ;; the formats. FORMATTED-TAG may be null so treat
\r
209 > + ;; that as a special case.
\r
210 > + (let ((tag (or formatted-tag "")))
\r
211 > (dolist (format (cdr formats) tag)
\r
212 > - (setq tag (eval format)))))))
\r
213 > - (puthash tag formatted notmuch-tag--format-cache)))
\r
214 > + (setq tag (eval format)))
\r
215 > + (if (and (null formatted-tag)
\r
216 > + (equal tag ""))
\r
219 > + (puthash (cons tag tag-state) formatted notmuch-tag--format-cache)))
\r
222 > -(defun notmuch-tag-format-tags (tags &optional face)
\r
223 > +(defun notmuch-tag-format-tag (tags orig-tags tag)
\r
224 > + "Format TAG by looking into `notmuch-tag-formats'.
\r
226 s/by looking into/according to/ here, too.
\r
229 > +TAGS and ORIG-TAGS are lists of the current tags and the original
\r
230 > +tags; tags which have been deleted (i.e., are in ORIG-TAGS but
\r
231 > +are not in TAGS) are shown using formats from
\r
232 > +`notmuch-tag-deleted-formats'; tags which have been added (i.e.,
\r
233 > +are in TAGS but are not in ORIG-TAGS) are shown using formats
\r
234 > +from `notmuch-tag-added-formats' and tags which have not been
\r
235 > +changed (the normal case) are shown using formats from
\r
236 > +`notmuch-tag-formats'"
\r
237 > + (let* ((formatted-tag (notmuch-tag-format-tag-by-state tag tag nil)))
\r
238 > + (cond ((not (member tag tags))
\r
239 > + (notmuch-tag-format-tag-by-state tag formatted-tag 'deleted))
\r
240 > + ((not (member tag orig-tags))
\r
241 > + (notmuch-tag-format-tag-by-state tag formatted-tag 'added))
\r
243 > + formatted-tag))))
\r
245 > +(defun notmuch-tag-format-tags (tags orig-tags &optional face)
\r
246 > "Return a string representing formatted TAGS."
\r
247 > - (let ((face (or face 'notmuch-tag-face)))
\r
248 > + (let ((face (or face 'notmuch-tag-face))
\r
249 > + (all-tags (sort (delete-dups (append tags orig-tags nil)) #'string<)))
\r
250 > (notmuch-combine-face-text-property-string
\r
251 > (mapconcat #'identity
\r
252 > ;; nil indicated that the tag was deliberately hidden
\r
253 > - (delq nil (mapcar #'notmuch-tag-format-tag tags))
\r
254 > + (delq nil (mapcar
\r
255 > + (apply-partially #'notmuch-tag-format-tag tags orig-tags)
\r
260 > diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
\r
261 > index a106e09..7080e6f 100644
\r
262 > --- a/emacs/notmuch-tree.el
\r
263 > +++ b/emacs/notmuch-tree.el
\r
264 > @@ -704,7 +704,7 @@ unchanged ADDRESS if parsing fails."
\r
266 > 'notmuch-tree-match-tag-face
\r
267 > 'notmuch-tree-no-match-tag-face)))
\r
268 > - (format format-string (notmuch-tag-format-tags tags face)))))))
\r
269 > + (format format-string (notmuch-tag-format-tags tags tags face)))))))
\r
271 > (defun notmuch-tree-format-field-list (field-list msg)
\r
272 > "Format fields of MSG according to FIELD-LIST and return string"
\r
273 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
274 > index 0c767f7..04587c0 100644
\r
275 > --- a/emacs/notmuch.el
\r
276 > +++ b/emacs/notmuch.el
\r
277 > @@ -754,7 +754,7 @@ non-authors is found, assume that all of the authors match."
\r
279 > ((string-equal field "tags")
\r
280 > (let ((tags (plist-get result :tags)))
\r
281 > - (insert (format format-string (notmuch-tag-format-tags tags)))))))
\r
282 > + (insert (format format-string (notmuch-tag-format-tags tags tags)))))))
\r
284 > (defun notmuch-search-show-result (result &optional pos)
\r
285 > "Insert RESULT at POS or the end of the buffer if POS is null."
\r
286 > diff --git a/test/test-lib.el b/test/test-lib.el
\r
287 > index 37fcb3d..437f83f 100644
\r
288 > --- a/test/test-lib.el
\r
289 > +++ b/test/test-lib.el
\r
290 > @@ -165,3 +165,8 @@ nothing."
\r
293 > (notmuch-test-report-unexpected output expected)))))
\r
295 > +;; For historical reasons, we hide deleted tags by default in the test
\r
297 > +(setq notmuch-tag-deleted-formats
\r
302 > _______________________________________________
\r
303 > notmuch mailing list
\r
304 > notmuch@notmuchmail.org
\r
305 > http://notmuchmail.org/mailman/listinfo/notmuch
\r