Re: [PATCH 3/5] nmbug-status: Add an nmbug-status(5) man page
[notmuch-archives.git] / 62 / d539ba9f32b6b1d68ddf32636315c75ae0fd52
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 020FA40DDF8\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 11:22:34 -0700 (PDT)\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 hbH9rhrTtKqN for <notmuch@notmuchmail.org>;\r
17         Mon,  9 Apr 2012 11:22:34 -0700 (PDT)\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 0F2C540EC50\r
22         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 11:22:34 -0700 (PDT)\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 1SHJEV-00043L-Qs; Mon, 09 Apr 2012 19:22:32 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SHJEV-0003uK-Eq; Mon, 09 Apr 2012 19:22:31 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
34         Notmuch Mail <notmuch@notmuchmail.org>\r
35 Subject: Re: [PATCH 7/8] emacs: modify show tag functions to use new\r
36         notmuch-tag interface\r
37 In-Reply-To: <87d37hl6kc.fsf@servo.finestructure.net>\r
38 References: <1333354853-25729-1-git-send-email-jrollins@finestructure.net>\r
39         <1333845338-22960-1-git-send-email-jrollins@finestructure.net>\r
40         <1333845338-22960-2-git-send-email-jrollins@finestructure.net>\r
41         <1333845338-22960-3-git-send-email-jrollins@finestructure.net>\r
42         <1333845338-22960-4-git-send-email-jrollins@finestructure.net>\r
43         <1333845338-22960-5-git-send-email-jrollins@finestructure.net>\r
44         <1333845338-22960-6-git-send-email-jrollins@finestructure.net>\r
45         <1333845338-22960-7-git-send-email-jrollins@finestructure.net>\r
46         <1333845338-22960-8-git-send-email-jrollins@finestructure.net>\r
47         <87zkam6fn3.fsf@qmul.ac.uk>\r
48         <87d37hl6kc.fsf@servo.finestructure.net>\r
49 User-Agent: Notmuch/0.12+111~g5c30f66 (http://notmuchmail.org) Emacs/23.3.1\r
50         (x86_64-pc-linux-gnu)\r
51 Date: Mon, 09 Apr 2012 19:22:48 +0100\r
52 Message-ID: <874nssn4sn.fsf@qmul.ac.uk>\r
53 MIME-Version: 1.0\r
54 Content-Type: text/plain; charset=us-ascii\r
55 X-Sender-Host-Address: 94.192.233.223\r
56 X-QM-SPAM-Info: Sender has good ham record.  :)\r
57 X-QM-Body-MD5: b438f2750443f1b281dd866b915fdd97 (of first 20000 bytes)\r
58 X-SpamAssassin-Score: -1.8\r
59 X-SpamAssassin-SpamBar: -\r
60 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
61         determine if it is\r
62         spam. We require at least 5.0 points to mark a message as spam.\r
63         This message scored -1.8 points.\r
64         Summary of the scoring: \r
65         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
66         *      medium trust\r
67         *      [138.37.6.40 listed in list.dnswl.org]\r
68         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
69         provider *      (markwalters1009[at]gmail.com)\r
70         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
71         *      domain\r
72         *  0.5 AWL AWL: From: address is in the auto white-list\r
73 X-QM-Scan-Virus: ClamAV says the message is clean\r
74 X-BeenThere: notmuch@notmuchmail.org\r
75 X-Mailman-Version: 2.1.13\r
76 Precedence: list\r
77 List-Id: "Use and development of the notmuch mail system."\r
78         <notmuch.notmuchmail.org>\r
79 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
80         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
81 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
82 List-Post: <mailto:notmuch@notmuchmail.org>\r
83 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
84 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
85         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
86 X-List-Received-Date: Mon, 09 Apr 2012 18:22:35 -0000\r
87 \r
88 On Mon, 09 Apr 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:\r
89 > On Sat, Apr 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
90 >> I think this is what is making the two tests fail: they count the number\r
91 >> of invocations of notmuch and in case there is one invocation of notmuch\r
92 >> show and one of notmuch tag -unread message-id, where before it was just\r
93 >> the single notmuch show.\r
94 >\r
95 > Good call, Mark.  After a bit of testing it looks like that is what's\r
96 > going on.  I was confused, since I had thought that the call to\r
97 > notmuch-show should have involved two notmuch calls originally as well,\r
98 > one for retrieving the message and the other removing the unread tag.\r
99 > However, it appears the messages in those tests don't have unread tags\r
100 > after all.  Not sure why, but that explains it.\r
101 >\r
102 > So I guess the upshot is that moving all the common prompting and tag\r
103 > validation stuff into notmuch-tag means that in certain cases there will\r
104 > be extra notmuch calls, even if no tags are changed.  Is that a problem?\r
105 >\r
106 > What I can do, though, is add extra validation to notmuch-tag to not\r
107 > actually call notmuch tag, or any of the pre- and post- tagging hooks,\r
108 > if no tags are changing.  This will still require one call to notmuch to\r
109 > retrieve the current set of tags for the query, but at least it wont tag\r
110 > or call the hooks if nothing is changing.  That seems reasonable to me,\r
111 > but please let me know if you think it's not.\r
112 >\r
113 > I've pasted below a new version of notmuch-tag that addresses these\r
114 > issues.  Let me know what you think, and I'll resubmit the series.\r
115 >\r
116 > jamie.\r
117 >\r
118 >\r
119 > (defun notmuch-tag (query &optional tag-changes)\r
120 >   "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
121 >\r
122 > QUERY should be a string containing the search-terms.\r
123 > TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of\r
124 > strings of the form \"+tag\" or \"-tag\" then those are the tag\r
125 > changes applied.  If TAG-CHANGES is a string then it is\r
126 > interpreted as a single tag change.  If TAG-CHANGES is the string\r
127 > \"-\" or \"+\", or null, then the user is prompted to enter the\r
128 > tag changes.\r
129 >\r
130 > Note: Other code should always use this function alter tags of\r
131 > messages instead of running (notmuch-call-notmuch-process \"tag\" ..)\r
132 > directly, so that hooks specified in notmuch-before-tag-hook and\r
133 > notmuch-after-tag-hook will be run."\r
134 >   ;; Perform some validation\r
135 >   (if (string-or-null-p tag-changes)\r
136 >       (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))\r
137 >         (setq tag-changes (notmuch-read-tag-changes tag-changes query))\r
138 >       (setq tag-changes (list tag-changes))))\r
139 >   (mapc (lambda (tag-change)\r
140 >         (unless (string-match-p "^[-+]\\S-+$" tag-change)\r
141 >           (error "Tag must be of the form `+this_tag' or `-that_tag'")))\r
142 >       tag-changes)\r
143 >   (let* ((current-tags (notmuch-tag-completions (list query)))\r
144 >        (new-tags (notmuch-update-tags current-tags tag-changes)))\r
145 >     (if (equal current-tags new-tags)\r
146 >       ;; if no tags are changing, return nil\r
147 >       nil\r
148 >       (run-hooks 'notmuch-before-tag-hook)\r
149 >       (apply 'notmuch-call-notmuch-process "tag"\r
150 >            (append tag-changes (list "--" query)))\r
151 >       (run-hooks 'notmuch-after-tag-hook)\r
152 >       ;; otherwise, return the list of actual changed tags\r
153 >       tag-changes)))\r
154 \r
155 Does this actually do the right thing if tagging more than one message?\r
156 It looks to me like it would go wrong if you tried +inbox to a thread\r
157 where some messages already have tag inbox (but I could be confused)?\r
158 \r
159 Also, I was going to say that I was not sure there was much point in\r
160 optimising in the emacs code when the cli does anyway, but there is a\r
161 question with xapian locking: with the orginally posted patch you can't\r
162 use n or p in show view while the database is locked (eg a background\r
163 notmuch new) as you get "A Xapian exception occurred opening database:\r
164 Unable to get write lock on ..."\r
165 \r
166 Possibly, you could pass a current-tags variable to notmuch tag (and it\r
167 would not add anything in that list or delete anything not in the\r
168 list). But the 2 code paths might be viewed as being too different to be\r
169 worth unifying. Or possibly have a "tag-single-message" command? \r
170 \r
171 Best wishes\r
172 \r
173 Mark\r
174 \r