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 3955C431FBF
\r
6 for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 14:58:03 -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 m4uZDQQLNsLG for <notmuch@notmuchmail.org>;
\r
16 Tue, 11 Feb 2014 14:57:59 -0800 (PST)
\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 AA7F0431FBD
\r
22 for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 14:57:58 -0800 (PST)
\r
23 X-AuditID: 12074425-f79906d000000cf9-2b-52faaaf41278
\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\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 1E.F3.03321.4FAAAF25; Tue, 11 Feb 2014 17:57:56 -0500 (EST)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s1BMvtkg014003;
\r
31 Tue, 11 Feb 2014 17:57:56 -0500
\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 s1BMvqjZ017960
\r
36 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);
\r
37 Tue, 11 Feb 2014 17:57:54 -0500
\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 1WDMH2-0002fY-C7; Tue, 11 Feb 2014 17:57:52 -0500
\r
41 From: Austin Clements <amdragon@MIT.EDU>
\r
42 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
\r
43 Subject: Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats
\r
44 In-Reply-To: <87ob2e0wyp.fsf@qmul.ac.uk>
\r
45 References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com>
\r
46 <1390087855-26194-3-git-send-email-markwalters1009@gmail.com>
\r
47 <87txc6n84q.fsf@awakening.csail.mit.edu>
\r
48 <87ob2e0wyp.fsf@qmul.ac.uk>
\r
49 User-Agent: Notmuch/0.17~rc2+14~g06f47e0 (http://notmuchmail.org) Emacs/23.4.1
\r
51 Date: Tue, 11 Feb 2014 17:57:51 -0500
\r
52 Message-ID: <87r479mf4g.fsf@awakening.csail.mit.edu>
\r
54 Content-Type: text/plain; charset=us-ascii
\r
55 X-Brightmail-Tracker:
\r
56 H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsUixCmqrPtl1a8gg94j0har5/JYXL85k9mB
\r
57 yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyni//SRTwW69ilW/9jI2ME5T7WLk5JAQMJGY
\r
58 cWIhK4QtJnHh3no2EFtIYDaTxP7Ddl2MXED2RkaJcz/aWCASp5kkutYHQCSWMEr8WXiEHSTB
\r
59 JqAhsW3/ckYQW0TAVeLpt8/MILawgJ/Ess0bgWo4ODiBas7vEYKYc4ZRYsd6HxBbVCBJ4vTU
\r
60 32BHsAioSryfcBJsDC/QcYe7t7NA2IISJ2c+AbOZBbQkbvx7yTSBUWAWktQsJKkFjEyrGGVT
\r
61 cqt0cxMzc4pTk3WLkxPz8lKLdC30cjNL9FJTSjcxgoKR3UV1B+OEQ0qHGAU4GJV4eAUX/QoS
\r
62 Yk0sK67MPcQoycGkJMrLBgxlIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8QSuBcrwpiZVVqUX5
\r
63 MClpDhYlcd5aC6CUQHpiSWp2ampBahFMVoaDQ0mCNwKkUbAoNT21Ii0zpwQhzcTBCTKcB2j4
\r
64 EbDhxQWJucWZ6RD5U4yKUuK8zCAXCYAkMkrz4HphyeIVozjQK8K8r0DaeYCJBq77FdBgJqDB
\r
65 /dlgg0sSEVJSDYxrnV2fz7rw725WgpXF7533LaYoeVlrLufrVZvN5H2rJCxmhfXhOwe3Hszb
\r
66 ufz96a4SiXC/CVrxiu6R1q5vlBsmPXbUZ2dMqP/52Kv6l0T24ugJR94tbynqqQo+mhvD7qQz
\r
67 /+SXG7WGiuqtnKYb/3AtmhsTH3jJRHzJXt0tai1vqppL+otfXVRiKc5INNRiLipOBADTYlrH
\r
69 X-BeenThere: notmuch@notmuchmail.org
\r
70 X-Mailman-Version: 2.1.13
\r
72 List-Id: "Use and development of the notmuch mail system."
\r
73 <notmuch.notmuchmail.org>
\r
74 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
76 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
77 List-Post: <mailto:notmuch@notmuchmail.org>
\r
78 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
79 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
80 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
81 X-List-Received-Date: Tue, 11 Feb 2014 22:58:03 -0000
\r
83 On Tue, 11 Feb 2014, Mark Walters <markwalters1009@gmail.com> wrote:
\r
84 > Thanks for the review.
\r
86 > On Mon, 10 Feb 2014, Austin Clements <amdragon@MIT.EDU> wrote:
\r
87 >> On Sat, 18 Jan 2014, Mark Walters <markwalters1009@gmail.com> wrote:
\r
88 >>> Allow an empty string in notmuch-tag-formats which matches all tags
\r
89 >>> except those matched explicitly matched. This allows the user to tell
\r
95 >>> notmuch to hide all tags except those specified.
\r
97 >>> This will be useful once formatting for deleted/added tags is added
\r
98 >>> later in the series: a user might want to hide all deleted tags for
\r
101 >>> emacs/notmuch-tag.el | 20 +++++++++++---------
\r
102 >>> 1 files changed, 11 insertions(+), 9 deletions(-)
\r
104 >>> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
105 >>> index 2153068..92c1249 100644
\r
106 >>> --- a/emacs/notmuch-tag.el
\r
107 >>> +++ b/emacs/notmuch-tag.el
\r
108 >>> @@ -65,14 +65,15 @@
\r
109 >>> This gives a list that maps from tag names to lists of formatting
\r
110 >>> expressions. The car of each element gives a tag name and the
\r
111 >>> cdr gives a list of Elisp expressions that modify the tag. If
\r
112 >>> -the list is empty, the tag will simply be hidden. Otherwise,
\r
113 >>> -each expression will be evaluated in order: for the first
\r
114 >>> -expression, the variable `tag' will be bound to the tag name; for
\r
115 >>> -each later expression, the variable `tag' will be bound to the
\r
116 >>> -result of the previous expression. In this way, each expression
\r
117 >>> -can build on the formatting performed by the previous expression.
\r
118 >>> -The result of the last expression will displayed in place of the
\r
120 >>> +the car is an empty string it matches all tags that do not have
\r
121 >>> +an explicit match. If the list is empty, the tag will simply be
\r
123 >> Hmm. I'm not sure I like overloading of the meanings of strings. Could
\r
124 >> we instead use a symbol to represent this case? For example, `t' would
\r
125 >> parallel the fall-through case of `cond' and `case', or `_' would
\r
126 >> parallel `pcase' [1]. Or even a separate variable like
\r
127 >> notmuch-tag-default-format?
\r
129 > I would prefer not to have a separate variable as I want the default
\r
130 > case for added/deleted tags too (see next patch), so it would need to be
\r
131 > 3 separate variables. But maybe that makes things clearer and is worth
\r
134 Ah, I see. In that case I agree this shouldn't be a separate variable
\r
135 (that idea was just a workaround anyway).
\r
137 > One other possibility that would solve the customize problem would be to
\r
138 > allow regexps for the matches. The regexp would have to match the
\r
139 > complete tag and only the first match would be used. This has advantages
\r
140 > (the user can highlight all notmuch::.* tags or can hide all X-
\r
141 > tags). The downside is that finding/testing for a regexp match is about
\r
142 > 20 times slower than using assoc, primarily because assoc is written in
\r
143 > C and the regexp match bit in lisp.
\r
145 I really like the idea of using regexps for this. I wouldn't worry
\r
146 about the performance. We can almost certainly eliminate that problem
\r
147 with a sprinkle of caching (which would probably be even faster than
\r
148 assoc), and that can be added separately.
\r
150 >> The former would require some tweaking of the customize widget, but that
\r
151 >> should probably happen anyway to support this special case.
\r
152 >> Unfortunately, we may need a custom alist widget variant to do that. (I
\r
153 >> tried and failed to tweak it in a way that both worked and looked
\r
154 >> decent.) Hence my suggestion of a separate variable, which would only
\r
155 >> require pulling out the :value-type into its own define-widget.
\r
157 > If we go this route I may need some help getting this to work: pulling
\r
158 > out value-type didn't work on my first attempt.
\r
160 >> I'm also slightly bothered that this would introduce a second way to
\r
161 >> control the default formatting of tags in addition to notmuch-tag-face,
\r
162 >> but only slightly.
\r
164 > Yes that slightly bothered me but I didn't see a solution.
\r
166 >> [1] It's unfortunate that pcase wasn't introduced until Emacs 24. I've
\r
167 >> been tempted to backport it for notmuch multiple times now. Then we
\r
168 >> could just treat notmuch-tag-formats as a list of pcase conditions.
\r
170 > Would that still involve a lisp loop so would be comparable to the
\r
171 > regexp bit above? I haven't looked at pcase enough to work out its
\r
174 pcase compiles into a decision tree, which could in principle reduce
\r
175 this to a fast lookup when possible, though I don't know if the
\r
176 implementation is actually that smart. At any rate, I like the idea of
\r
177 using regexps for this better anyway.
\r
185 >>> +hidden. Otherwise, each expression will be evaluated in order:
\r
186 >>> +for the first expression, the variable `tag' will be bound to the
\r
187 >>> +tag name; for each later expression, the variable `tag' will be
\r
188 >>> +bound to the result of the previous expression. In this way,
\r
189 >>> +each expression can build on the formatting performed by the
\r
190 >>> +previous expression. The result of the last expression will
\r
191 >>> +displayed in place of the tag.
\r
193 >>> For example, to replace a tag with another string, simply use
\r
194 >>> that string as a formatting expression. To change the foreground
\r
195 >>> @@ -140,7 +141,8 @@ This can be used with `notmuch-tag-format-image-data'."
\r
197 >>> (defun notmuch-tag-format-tag (tag)
\r
198 >>> "Format TAG by looking into `notmuch-tag-formats'."
\r
199 >>> - (let ((formats (assoc tag notmuch-tag-formats)))
\r
200 >>> + (let ((formats (or (assoc tag notmuch-tag-formats)
\r
201 >>> + (assoc "" notmuch-tag-formats))))
\r
203 >>> ((null formats) ;; - Tag not in `notmuch-tag-formats',
\r
204 >>> tag) ;; the format is the tag itself.
\r
208 >>> _______________________________________________
\r
209 >>> notmuch mailing list
\r
210 >>> notmuch@notmuchmail.org
\r
211 >>> http://notmuchmail.org/mailman/listinfo/notmuch
\r