Re: Emacs: Crypto: How to get automatic encryption?
[notmuch-archives.git] / a9 / 1557eb034b89d4834dcfaaef92a6019322cfc7
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 55EA8421192\r
6         for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 12:38:28 -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: -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 TQCRSRbkckOB for <notmuch@notmuchmail.org>;\r
16         Thu, 30 Jun 2011 12:38:27 -0700 (PDT)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  E213A42118E    for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 12:38:26 -0700\r
21  (PDT)\r
22 Received: by wwj40 with SMTP id 40so2109832wwj.2\r
23         for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 12:38:25 -0700 (PDT)\r
24 Received: by 10.227.55.130 with SMTP id u2mr2226777wbg.41.1309462705402;\r
25         Thu, 30 Jun 2011 12:38:25 -0700 (PDT)\r
26 Received: from localhost ([109.131.21.173])\r
27         by mx.google.com with ESMTPS id ei4sm1850193wbb.43.2011.06.30.12.38.23\r
28         (version=TLSv1/SSLv3 cipher=OTHER);\r
29         Thu, 30 Jun 2011 12:38:24 -0700 (PDT)\r
30 From: Pieter Praet <pieter@praet.org>\r
31 To: Carl Worth <cworth@cworth.org>, Mark Anderson <ma.skies@gmail.com>,\r
32         Robin Green <greenrd@greenrd.org>\r
33 Subject: Re: [PATCH 2/2] [RFC] possible solution for "Race condition for '*'\r
34         command"\r
35 In-Reply-To: <1309450108-2793-2-git-send-email-pieter@praet.org>\r
36 References: <8739itagad.fsf@yoom.home.cworth.org>\r
37         <1309450108-2793-1-git-send-email-pieter@praet.org>\r
38         <1309450108-2793-2-git-send-email-pieter@praet.org>\r
39 User-Agent: Notmuch/0.5-315-g34bd5eb (http://notmuchmail.org) Emacs/23.1.50.1\r
40         (x86_64-pc-linux-gnu)\r
41 Date: Thu, 30 Jun 2011 21:38:22 +0200\r
42 Message-ID: <87r56brtxt.fsf@praet.org>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain; charset=us-ascii\r
45 Cc: notmuch@notmuchmail.org\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Thu, 30 Jun 2011 19:38:28 -0000\r
59 \r
60 On Thu, 30 Jun 2011 18:08:28 +0200, Pieter Praet <pieter@praet.org> wrote:\r
61 > `notmuch-search-operate-all' may cause a race condition because\r
62 > repeatedly running `notmuch-tag' with the *original* query string\r
63 > makes the result list a moving target.\r
64\r
65 > One approach to resolving this, is to feed `notmuch-tag' a static result\r
66 > list based on the original query string, instead of the latter itself.\r
67\r
68 > See discussion @ id:"86d3i1d06r.fsf@dragonfly.greenrd.org"\r
69\r
70 > Signed-off-by: Pieter Praet <pieter@praet.org>\r
71 > ---\r
72\r
73 > Carl,\r
74\r
75 > I've gone along a different route which assures only matched messages\r
76 > are touched, but it does come with quite a performance hit.\r
77\r
78 > Since there isn't a test for the actual race condition(s), I can't be\r
79 > sure, but theoretically, at least one of them should be fixed now.\r
80\r
81 > Peace\r
82\r
83 >  emacs/notmuch.el |   11 +++++++++--\r
84 >  1 files changed, 9 insertions(+), 2 deletions(-)\r
85\r
86 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
87 > index f11ec24..84c3ee6 100644\r
88 > --- a/emacs/notmuch.el\r
89 > +++ b/emacs/notmuch.el\r
90 > @@ -845,7 +845,8 @@ Each character of the tag name may consist of alphanumeric\r
91 >  characters as well as `_.+-'.\r
92 >  "\r
93 >    (interactive "sOperation (+add -drop): notmuch tag ")\r
94 > -  (let ((action-split (split-string action " +")))\r
95 > +  (let ((action-split (split-string action " +"))\r
96 > +        (query notmuch-search-query-string))\r
97 >      ;; Perform some validation\r
98 >      (let ((words action-split))\r
99 >        (when (null words) (error "No operation given"))\r
100 > @@ -853,7 +854,13 @@ characters as well as `_.+-'.\r
101 >       (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
102 >         (error "Action must be of the form `+thistag -that_tag'"))\r
103 >       (setq words (cdr words))))\r
104 > -    (apply 'notmuch-tag notmuch-search-query-string action-split)))\r
105 > +    (dolist (msgid\r
106 > +            (split-string\r
107 > +              (with-output-to-string\r
108 > +                (with-current-buffer standard-output\r
109 > +                  (apply 'call-process notmuch-command nil t nil "search" "--output=messages" (list query))))\r
110 > +            "\n+" t))\r
111 > +            (apply 'notmuch-tag msgid action-split))))\r
112 >  \r
113 >  (defun notmuch-search-buffer-title (query)\r
114 >    "Returns the title for a buffer with notmuch search results."\r
115 > -- \r
116 > 1.7.4.1\r
117\r
118 \r
119 Ok, even though my very first reply [1] may have created the impression\r
120 that I understood the issue, I clearly didn't...\r
121 \r
122 The test [2] needs a more applicable commit message, and the subsequent\r
123 patch [3] points more or less in the right direction, but the Message-Id\r
124 list should be local to the *search buffer* rather than to the\r
125 `notmuch-search-operate-all' function.\r
126 \r
127 `notmuch-search' could:\r
128   - run "notmuch-command search" with the "--output=messages" option\r
129     instead of a plain search,\r
130   - maintain a buffer-local var with a list of returned Message-Id's,\r
131   - ...and populate the buffer based on that list.\r
132 \r
133 As such we'd have -for each individual search buffer- a canonical list\r
134 of Message-Id's (i.e. messages which actually *match* the query AND are\r
135 currently visible in the search buffer), to be used by\r
136 `notmuch-search-operate-all' et al.\r
137 \r
138 \r
139 Peace\r
140 \r
141 -- \r
142 Pieter\r
143 \r
144 [1] id:"87fwmuxxgd.fsf@praet.org"\r
145 [2] id:"1309450108-2793-2-git-send-email-pieter@praet.org"\r
146 [3] id:"1309450108-2793-1-git-send-email-pieter@praet.org"\r