1 Return-Path: <markwalters1009@gmail.com>
\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 C03A4431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:20 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id xpsO+ECaZSBh for <notmuch@notmuchmail.org>;
\r
18 Sat, 24 Nov 2012 05:21:19 -0800 (PST)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 7B44E431FAF
\r
23 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:19 -0800 (PST)
\r
24 Received: by mail-we0-f181.google.com with SMTP id t11so3934097wey.26
\r
25 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:18 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=x21H9sO0YJw+KzZLVr8jpQuzQBEggwvFWQGE5F7gVNs=;
\r
29 b=qGRw7/RMtr2kjob00isFhYYC/fBngnVE9BTj1n2KG5BTuHFzjG9wHOUctpqK3lnWaC
\r
30 zP8rcjpSCN7ufeV2TL/OdpUoZTsZdbWx6MRyXvbJdxf3swNJK/cU2310e6Q+md5IOqL5
\r
31 qSubQWzwHb6znkRFtslSIG4NDwnzQwQhP354GugVcquAnbuwuvo0htGLd4cByCCLXZRF
\r
32 Xt5s5rwYvJNomjmwLoH1eUzm1XWU7cko6z4KxGbORxbHXlwuGN66QLp0XfN1Axn04HOK
\r
33 sfqFrGijn3fna6yDNg2EpNG7MWH2dRrcSegbPTDQWFuzl50lWVXcLq49Ofh2TZj3OIc1
\r
35 Received: by 10.180.81.170 with SMTP id b10mr9835809wiy.16.1353763278256;
\r
36 Sat, 24 Nov 2012 05:21:18 -0800 (PST)
\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
38 by mx.google.com with ESMTPS id b1sm14246472wix.11.2012.11.24.05.21.16
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 24 Nov 2012 05:21:17 -0800 (PST)
\r
41 From: markwalters1009 <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v2 7/7] emacs: make emacs use message-ids for tagging
\r
44 Date: Sat, 24 Nov 2012 13:20:56 +0000
\r
45 Message-Id: <1353763256-32336-8-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sat, 24 Nov 2012 13:21:21 -0000
\r
63 From: Mark Walters <markwalters1009@gmail.com>
\r
65 This makes emacs use the new --queries=true in search mode and use
\r
66 this for tagging. This fixes the race condition in tagging from
\r
67 search mode so mark the tests fixed.
\r
69 emacs/notmuch.el | 28 +++++++++++++++++++++++++---
\r
71 2 files changed, 25 insertions(+), 5 deletions(-)
\r
73 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
74 index 64b9474..6e8ef83 100644
\r
75 --- a/emacs/notmuch.el
\r
76 +++ b/emacs/notmuch.el
\r
77 @@ -473,7 +473,8 @@ BEG."
\r
79 (notmuch-search-foreach-result beg end
\r
81 - (push (plist-get (notmuch-search-get-result pos) property) output)))
\r
82 + (let ((value (plist-get (notmuch-search-get-result pos) property)))
\r
83 + (when value (push value output)))))
\r
86 (defun notmuch-search-find-thread-id (&optional bare)
\r
87 @@ -483,6 +484,7 @@ If BARE is set then do not prefix with \"thread:\""
\r
88 (let ((thread (plist-get (notmuch-search-get-result) :thread)))
\r
89 (when thread (concat (unless bare "thread:") thread))))
\r
92 (defun notmuch-search-find-thread-id-region (beg end)
\r
93 "Return a list of threads for the current region"
\r
94 (mapcar (lambda (thread) (concat "thread:" thread))
\r
95 @@ -492,6 +494,23 @@ If BARE is set then do not prefix with \"thread:\""
\r
96 "Return a search string for threads for the current region"
\r
97 (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))
\r
99 +;; The following two functions are similar to the previous two but
\r
100 +;; they only match messages that were in the the thread when the
\r
101 +;; initial search was run. This means that they can be used where it
\r
102 +;; is important to avoid races: e.g. when tagging.
\r
103 +(defun notmuch-search-find-queries-region (beg end &optional only-matching)
\r
105 + "Return a list of queries for the current region"
\r
106 + (append (notmuch-search-properties-in-region :matching_msg_query beg end)
\r
107 + (unless only-matching
\r
108 + (notmuch-search-properties-in-region :nonmatching_msg_query beg end))))
\r
110 +(defun notmuch-search-find-queries-region-search (beg end &optional only-matching)
\r
111 + "Return a search string for messages in threads in the current region"
\r
112 + (mapconcat 'identity
\r
113 + (notmuch-search-find-queries-region beg end only-matching)
\r
116 (defun notmuch-search-find-authors ()
\r
117 "Return the authors for the current thread"
\r
118 (plist-get (notmuch-search-get-result) :authors))
\r
119 @@ -575,7 +594,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
\r
121 (defun notmuch-search-tag-region (beg end &optional tag-changes)
\r
122 "Change tags for threads in the given region."
\r
123 - (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))
\r
124 + (let ((search-string (notmuch-search-find-queries-region-search beg end)))
\r
125 (setq tag-changes (funcall 'notmuch-tag search-string tag-changes))
\r
126 (notmuch-search-foreach-result beg end
\r
128 @@ -851,7 +870,9 @@ non-authors is found, assume that all of the authors match."
\r
130 See `notmuch-tag' for information on the format of TAG-CHANGES."
\r
132 - (apply 'notmuch-tag notmuch-search-query-string tag-changes))
\r
133 + (apply 'notmuch-tag (notmuch-search-find-queries-region-search
\r
134 + (point-min) (point-max) t)
\r
137 (defun notmuch-search-buffer-title (query)
\r
138 "Returns the title for a buffer with notmuch search results."
\r
139 @@ -948,6 +969,7 @@ Other optional parameters are used as follows:
\r
140 "notmuch-search" buffer
\r
141 notmuch-command "search"
\r
143 + "--output=with-queries"
\r
145 "--sort=oldest-first"
\r
146 "--sort=newest-first")
\r
147 diff --git a/test/emacs b/test/emacs
\r
148 index 3788439..132768f 100755
\r
151 @@ -123,7 +123,6 @@ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
\r
152 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
154 test_begin_subtest "Tag all matching messages from search view"
\r
155 -test_subtest_known_broken
\r
156 notmuch tag +test-tag-race from:cworth
\r
157 test_emacs "(notmuch-search \"tag:test-tag-race\")
\r
158 (notmuch-test-wait)"
\r
159 @@ -135,7 +134,6 @@ notmuch tag -test-tag-race '*'
\r
160 notmuch tag -test-tag-race-2 '*'
\r
162 test_begin_subtest "Change tags from search view: another message arriving after thread lookup"
\r
163 -test_subtest_known_broken
\r
164 typsos_id="878we4qdqf.fsf@yoom.home.cworth.org"
\r
165 typsos_thread=$(notmuch search --output=threads id:$typsos_id)
\r
166 test_emacs "(notmuch-search \"$typsos_thread\")
\r