Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 0e / 4c168aad33931a0117fc95bb07de5afd6332f3
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 ECDF2431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 16:38:20 -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: -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 jlzzWHYHZOAj for <notmuch@notmuchmail.org>;\r
16         Sat, 24 Nov 2012 16:38:18 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id A220F431FAE\r
20         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 16:38:18 -0800 (PST)\r
21 X-AuditID: 12074423-b7fab6d0000008f9-65-50b1687a3def\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 9E.BA.02297.A7861B05; Sat, 24 Nov 2012 19:38:18 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAP0cHF3007359; \r
27         Sat, 24 Nov 2012 19:38:18 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAP0cFHe007027\r
32         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
33         Sat, 24 Nov 2012 19:38:16 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1TcQEh-0006c6-Ki; Sat, 24 Nov 2012 19:38:15 -0500\r
37 Date: Sat, 24 Nov 2012 19:38:15 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: markwalters1009 <markwalters1009@gmail.com>\r
40 Subject: Re: [PATCH v2 7/7] emacs: make emacs use message-ids for tagging\r
41 Message-ID: <20121125003815.GK4562@mit.edu>\r
42 References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\r
43         <1353763256-32336-8-git-send-email-markwalters1009@gmail.com>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 Content-Disposition: inline\r
47 In-Reply-To: <1353763256-32336-8-git-send-email-markwalters1009@gmail.com>\r
48 User-Agent: Mutt/1.5.21 (2010-09-15)\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT0a3K2Bhg0P+Q22L1XB6L6zdnMjsw\r
51         eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGUveLGIueKZZsba3uoHxrmIXIyeHhICJxPWD\r
52         L1kgbDGJC/fWs3UxcnEICexjlLjePIEJwtnAKLHuzC8mkCohgYtMEguaJCASSxgl9q7+zQyS\r
53         YBFQlTi89i2YzSagIbFt/3JGEFtEQF9iz4rbbCA2s4C0xLffzWCDhAU8Jdp/vwVbzSugLbHw\r
54         Wx8zxNBORolzLTtZIRKCEidnPmGBaNaSuPHvJVAzB9ig5f84QMKcAl4Se453g+0VFVCRmHJy\r
55         G9sERqFZSLpnIemehdC9gJF5FaNsSm6Vbm5iZk5xarJucXJiXl5qka6ZXm5miV5qSukmRnBQ\r
56         uyjvYPxzUOkQowAHoxIP743EjQFCrIllxZW5hxglOZiURHlz0oBCfEn5KZUZicUZ8UWlOanF\r
57         hxglOJiVRHitVYFyvCmJlVWpRfkwKWkOFiVx3mspN/2FBNITS1KzU1MLUotgsjIcHEoSvLHp\r
58         QI2CRanpqRVpmTklCGkmDk6Q4TxAw51BaniLCxJzizPTIfKnGBWlxHk9QBICIImM0jy4XljS\r
59         ecUoDvSKMO9ZkCoeYMKC634FNJgJaPDT2etABpckIqSkGhgbTC73HlZpmn/yZnnRix0iIqoL\r
60         41rLPh7ZsO/0d9amDRoKxfaBM2RlTRZyh5WIau/85Ky+VXJatrtfiplEcDeLYGm1w9XgZe4M\r
61         7QyTV3jMdRdnmS6sqG+0fWWtlciEYA/7owptLc8fyN0ua71ep7qKq+1L78RdZW/OV2aF/a69\r
62         onHi81aJNUosxRmJhlrMRcWJAHH+5CYVAwAA\r
63 Cc: notmuch@notmuchmail.org\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Sun, 25 Nov 2012 00:38:21 -0000\r
77 \r
78 Quoth markwalters1009 on Nov 24 at  1:20 pm:\r
79 > From: Mark Walters <markwalters1009@gmail.com>\r
80\r
81 > This makes emacs use the new --queries=true in search mode and use\r
82 > this for tagging.  This fixes the race condition in tagging from\r
83 > search mode so mark the tests fixed.\r
84 > ---\r
85 >  emacs/notmuch.el |   28 +++++++++++++++++++++++++---\r
86 >  test/emacs       |    2 --\r
87 >  2 files changed, 25 insertions(+), 5 deletions(-)\r
88\r
89 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
90 > index 64b9474..6e8ef83 100644\r
91 > --- a/emacs/notmuch.el\r
92 > +++ b/emacs/notmuch.el\r
93 > @@ -473,7 +473,8 @@ BEG."\r
94 >    (let (output)\r
95 >      (notmuch-search-foreach-result beg end\r
96 >        (lambda (pos)\r
97 > -     (push (plist-get (notmuch-search-get-result pos) property) output)))\r
98 > +     (let ((value (plist-get (notmuch-search-get-result pos) property)))\r
99 > +       (when value (push value output)))))\r
100 \r
101 Why is this necessary?  (Assuming it is, it could use a comment, and\r
102 probably an update to the docstring.)\r
103 \r
104 >      output))\r
105 >  \r
106 >  (defun notmuch-search-find-thread-id (&optional bare)\r
107 > @@ -483,6 +484,7 @@ If BARE is set then do not prefix with \"thread:\""\r
108 >    (let ((thread (plist-get (notmuch-search-get-result) :thread)))\r
109 >      (when thread (concat (unless bare "thread:") thread))))\r
110 >  \r
111 > +\r
112 \r
113 Unintentional?\r
114 \r
115 >  (defun notmuch-search-find-thread-id-region (beg end)\r
116 >    "Return a list of threads for the current region"\r
117 >    (mapcar (lambda (thread) (concat "thread:" thread))\r
118 > @@ -492,6 +494,23 @@ If BARE is set then do not prefix with \"thread:\""\r
119 >    "Return a search string for threads for the current region"\r
120 >    (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))\r
121 >  \r
122 > +;; The following two functions are similar to the previous two but\r
123 > +;; they only match messages that were in the the thread when the\r
124 > +;; initial search was run. This means that they can be used where it\r
125 > +;; is important to avoid races: e.g. when tagging.\r
126 > +(defun notmuch-search-find-queries-region (beg end &optional only-matching)\r
127 > +  (interactive)\r
128 > +  "Return a list of queries for the current region"\r
129 > +  (append (notmuch-search-properties-in-region :matching_msg_query beg end)\r
130 > +       (unless only-matching\r
131 > +         (notmuch-search-properties-in-region :nonmatching_msg_query beg end))))\r
132 \r
133 Two minor performance nits: Using nconc instead of append will avoid\r
134 copying the first list and swapping the two arguments will avoid\r
135 needlessly traversing the non-matching list when only-matching is nil.\r
136 \r
137 > +\r
138 > +(defun notmuch-search-find-queries-region-search (beg end &optional only-matching)\r
139 > +  "Return a search string for messages in threads in the current region"\r
140 > +  (mapconcat 'identity\r
141 \r
142 #'identity\r
143 \r
144 > +          (notmuch-search-find-queries-region beg end only-matching)\r
145 > +          " or "))\r
146 > +\r
147 >  (defun notmuch-search-find-authors ()\r
148 >    "Return the authors for the current thread"\r
149 >    (plist-get (notmuch-search-get-result) :authors))\r
150 > @@ -575,7 +594,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
151 >  \r
152 >  (defun notmuch-search-tag-region (beg end &optional tag-changes)\r
153 >    "Change tags for threads in the given region."\r
154 > -  (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))\r
155 > +  (let ((search-string (notmuch-search-find-queries-region-search beg end)))\r
156 >      (setq tag-changes (funcall 'notmuch-tag search-string tag-changes))\r
157 >      (notmuch-search-foreach-result beg end\r
158 >        (lambda (pos)\r
159 > @@ -851,7 +870,9 @@ non-authors is found, assume that all of the authors match."\r
160 >  \r
161 >  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
162 >    (interactive)\r
163 > -  (apply 'notmuch-tag notmuch-search-query-string tag-changes))\r
164 > +  (apply 'notmuch-tag (notmuch-search-find-queries-region-search\r
165 > +                    (point-min) (point-max) t)\r
166 > +      tag-changes))\r
167 >  \r
168 >  (defun notmuch-search-buffer-title (query)\r
169 >    "Returns the title for a buffer with notmuch search results."\r
170 > @@ -948,6 +969,7 @@ Other optional parameters are used as follows:\r
171 >                    "notmuch-search" buffer\r
172 >                    notmuch-command "search"\r
173 >                    "--format=json"\r
174 > +                  "--output=with-queries"\r
175 \r
176 --output=with-queries or --queries=true?\r
177 \r
178 >                    (if oldest-first\r
179 >                        "--sort=oldest-first"\r
180 >                      "--sort=newest-first")\r
181 > diff --git a/test/emacs b/test/emacs\r
182 > index 3788439..132768f 100755\r
183 > --- a/test/emacs\r
184 > +++ b/test/emacs\r
185 > @@ -123,7 +123,6 @@ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
186 >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"\r
187 >  \r
188 >  test_begin_subtest "Tag all matching messages from search view"\r
189 > -test_subtest_known_broken\r
190 >  notmuch tag +test-tag-race from:cworth\r
191 >  test_emacs "(notmuch-search \"tag:test-tag-race\")\r
192 >           (notmuch-test-wait)"\r
193 > @@ -135,7 +134,6 @@ notmuch tag -test-tag-race '*'\r
194 >  notmuch tag -test-tag-race-2 '*'\r
195 >  \r
196 >  test_begin_subtest "Change tags from search view: another message arriving after thread lookup"\r
197 > -test_subtest_known_broken\r
198 >  typsos_id="878we4qdqf.fsf@yoom.home.cworth.org"\r
199 >  typsos_thread=$(notmuch search --output=threads id:$typsos_id)\r
200 >  test_emacs "(notmuch-search \"$typsos_thread\")\r