Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / e5 / a1fa4104aaef58e01cec168860f038f13fbfaf
1 Return-Path: <m.walters@qmul.ac.uk>\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 6CB8E431FBD\r
6         for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 02:23:38 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id RNAuNtJXu0d6 for <notmuch@notmuchmail.org>;\r
17         Tue, 11 Feb 2014 02:23:34 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\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 478B8431FAF\r
22         for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 02:23:34 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1WDAUx-0000MF-8V; Tue, 11 Feb 2014 10:23:29 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WDAUw-0000h2-Tc; Tue, 11 Feb 2014 10:23:27 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats\r
34 In-Reply-To: <87txc6n84q.fsf@awakening.csail.mit.edu>\r
35 References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com>\r
36         <1390087855-26194-3-git-send-email-markwalters1009@gmail.com>\r
37         <87txc6n84q.fsf@awakening.csail.mit.edu>\r
38 User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Tue, 11 Feb 2014 10:23:26 +0000\r
41 Message-ID: <87ob2e0wyp.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 93.97.24.31\r
45 X-QM-Geographic: According to ripencc,\r
46         this message was delivered by a machine in Britain (UK) (GB).\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 1e2bcd0138791253cfbc41f74200bbb3 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: 0.0\r
50 X-SpamAssassin-SpamBar: /\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored 0.0 points. Summary of the scoring: \r
55         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
56         provider *      (markwalters1009[at]gmail.com)\r
57         *  0.0 AWL AWL: From: address is in the auto white-list\r
58 X-QM-Scan-Virus: ClamAV says the message is clean\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Tue, 11 Feb 2014 10:23:38 -0000\r
72 \r
73 \r
74 Thanks for the review.\r
75 \r
76 On Mon, 10 Feb 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
77 > On Sat, 18 Jan 2014, Mark Walters <markwalters1009@gmail.com> wrote:\r
78 >> Allow an empty string in notmuch-tag-formats which matches all tags\r
79 >> except those matched explicitly matched. This allows the user to tell\r
80 >\r
81 > Typo.\r
82 \r
83 Will fix.\r
84 \r
85 >> notmuch to hide all tags except those specified.\r
86 >>\r
87 >> This will be useful once formatting for deleted/added tags is added\r
88 >> later in the series: a user might want to hide all deleted tags for\r
89 >> example.\r
90 >> ---\r
91 >>  emacs/notmuch-tag.el |   20 +++++++++++---------\r
92 >>  1 files changed, 11 insertions(+), 9 deletions(-)\r
93 >>\r
94 >> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
95 >> index 2153068..92c1249 100644\r
96 >> --- a/emacs/notmuch-tag.el\r
97 >> +++ b/emacs/notmuch-tag.el\r
98 >> @@ -65,14 +65,15 @@\r
99 >>  This gives a list that maps from tag names to lists of formatting\r
100 >>  expressions.  The car of each element gives a tag name and the\r
101 >>  cdr gives a list of Elisp expressions that modify the tag.  If\r
102 >> -the list is empty, the tag will simply be hidden.  Otherwise,\r
103 >> -each expression will be evaluated in order: for the first\r
104 >> -expression, the variable `tag' will be bound to the tag name; for\r
105 >> -each later expression, the variable `tag' will be bound to the\r
106 >> -result of the previous expression.  In this way, each expression\r
107 >> -can build on the formatting performed by the previous expression.\r
108 >> -The result of the last expression will displayed in place of the\r
109 >> -tag.\r
110 >> +the car is an empty string it matches all tags that do not have\r
111 >> +an explicit match.  If the list is empty, the tag will simply be\r
112 >\r
113 > Hmm.  I'm not sure I like overloading of the meanings of strings.  Could\r
114 > we instead use a symbol to represent this case?  For example, `t' would\r
115 > parallel the fall-through case of `cond' and `case', or `_' would\r
116 > parallel `pcase' [1].  Or even a separate variable like\r
117 > notmuch-tag-default-format?\r
118 \r
119 I would prefer not to have a separate variable as I want the default\r
120 case for added/deleted tags too (see next patch), so it would need to be\r
121 3 separate variables. But maybe that makes things clearer and is worth\r
122 doing?\r
123 \r
124 One other possibility that would solve the customize problem would be to\r
125 allow regexps for the matches. The regexp would have to match the\r
126 complete tag and only the first match would be used. This has advantages\r
127 (the user can highlight all notmuch::.* tags or can hide all X-\r
128 tags). The downside is that finding/testing for a regexp match is about\r
129 20 times slower than using assoc, primarily because assoc is written in\r
130 C and the regexp match bit in lisp.\r
131 \r
132 > The former would require some tweaking of the customize widget, but that\r
133 > should probably happen anyway to support this special case.\r
134 > Unfortunately, we may need a custom alist widget variant to do that.  (I\r
135 > tried and failed to tweak it in a way that both worked and looked\r
136 > decent.)  Hence my suggestion of a separate variable, which would only\r
137 > require pulling out the :value-type into its own define-widget.\r
138 \r
139 If we go this route I may need some help getting this to work: pulling\r
140 out value-type didn't work on my first attempt.\r
141 \r
142 > I'm also slightly bothered that this would introduce a second way to\r
143 > control the default formatting of tags in addition to notmuch-tag-face,\r
144 > but only slightly.\r
145 \r
146 Yes that slightly bothered me but I didn't see a solution.\r
147 \r
148 > [1] It's unfortunate that pcase wasn't introduced until Emacs 24.  I've\r
149 > been tempted to backport it for notmuch multiple times now.  Then we\r
150 > could just treat notmuch-tag-formats as a list of pcase conditions.\r
151 \r
152 Would that still involve a lisp loop so would be comparable to the\r
153 regexp bit above? I haven't looked at pcase enough to work out its\r
154 details.\r
155 \r
156 Best wishes\r
157 \r
158 Mark\r
159 \r
160 \r
161 >\r
162 >> +hidden.  Otherwise, each expression will be evaluated in order:\r
163 >> +for the first expression, the variable `tag' will be bound to the\r
164 >> +tag name; for each later expression, the variable `tag' will be\r
165 >> +bound to the result of the previous expression.  In this way,\r
166 >> +each expression can build on the formatting performed by the\r
167 >> +previous expression.  The result of the last expression will\r
168 >> +displayed in place of the tag.\r
169 >>  \r
170 >>  For example, to replace a tag with another string, simply use\r
171 >>  that string as a formatting expression.  To change the foreground\r
172 >> @@ -140,7 +141,8 @@ This can be used with `notmuch-tag-format-image-data'."\r
173 >>  \r
174 >>  (defun notmuch-tag-format-tag (tag)\r
175 >>    "Format TAG by looking into `notmuch-tag-formats'."\r
176 >> -  (let ((formats (assoc tag notmuch-tag-formats)))\r
177 >> +  (let ((formats (or (assoc tag notmuch-tag-formats)\r
178 >> +                 (assoc "" notmuch-tag-formats))))\r
179 >>      (cond\r
180 >>       ((null formats)                ;; - Tag not in `notmuch-tag-formats',\r
181 >>        tag)                  ;;   the format is the tag itself.\r
182 >> -- \r
183 >> 1.7.9.1\r
184 >>\r
185 >> _______________________________________________\r
186 >> notmuch mailing list\r
187 >> notmuch@notmuchmail.org\r
188 >> http://notmuchmail.org/mailman/listinfo/notmuch\r