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 831DD431FBF
\r
6 for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:14:36 -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 hyzUyJGqp11R for <notmuch@notmuchmail.org>;
\r
18 Sat, 25 Feb 2012 19:14:35 -0800 (PST)
\r
19 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
20 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
21 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
22 AEF3A431FAE for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:14:35 -0800
\r
24 Received: by wgbdt12 with SMTP id dt12so2784835wgb.2
\r
25 for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:14:34 -0800 (PST)
\r
26 Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates
\r
27 10.180.92.71 as permitted sender) client-ip=10.180.92.71;
\r
28 Authentication-Results: mr.google.com; spf=pass (google.com: domain of
\r
29 markwalters1009@gmail.com designates 10.180.92.71 as permitted
\r
30 sender) smtp.mail=markwalters1009@gmail.com;
\r
31 dkim=pass header.i=markwalters1009@gmail.com
\r
32 Received: from mr.google.com ([10.180.92.71])
\r
33 by 10.180.92.71 with SMTP id ck7mr21015935wib.3.1330226074546 (num_hops
\r
34 = 1); Sat, 25 Feb 2012 19:14:34 -0800 (PST)
\r
35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
36 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
37 bh=IqeCmc2ELfjZkxjYdYxRGHL3vbcGmotc+462IZgK1tU=;
\r
38 b=D75LpKiQC8n/O+GzFLoE1jhz2zc6a8ddD6HpSNofU/x4IhqAOC53dkNzsFWZUMq3pN
\r
39 OoECp9BWTdZU+JHVUziTY0eOYVINIHMq8SLILPhbajVoDz7F0iVaYWQGijFrhst90tpn
\r
40 moxMApACeNm0FeJx238zdSZpC0C18CpINWtvw=
\r
41 Received: by 10.180.92.71 with SMTP id ck7mr11461242wib.3.1330157134460;
\r
42 Sat, 25 Feb 2012 00:05:34 -0800 (PST)
\r
43 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
44 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
45 df3sm8234444wib.1.2012.02.25.00.05.33 (version=TLSv1/SSLv3 cipher=OTHER);
\r
46 Sat, 25 Feb 2012 00:05:33 -0800 (PST)
\r
47 From: Mark Walters <markwalters1009@gmail.com>
\r
48 To: notmuch@notmuchmail.org,
\r
49 Austin Clements <amdragon@MIT.EDU>
\r
50 Subject: [Patch v6 04/13] lib: Rearrange the exclude code in query.cc
\r
51 Date: Sat, 25 Feb 2012 08:06:35 +0000
\r
52 Message-Id: <1330157204-26094-5-git-send-email-markwalters1009@gmail.com>
\r
53 X-Mailer: git-send-email 1.7.2.3
\r
54 In-Reply-To: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>
\r
55 References: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Sun, 26 Feb 2012 03:14:36 -0000
\r
70 Slightly refactor the exclude code to give the callers access to the
\r
71 exclude query itself. There should be no functional change.
\r
73 lib/query.cc | 29 +++++++++++++++++++----------
\r
74 1 files changed, 19 insertions(+), 10 deletions(-)
\r
76 diff --git a/lib/query.cc b/lib/query.cc
\r
77 index 0b36602..c25b301 100644
\r
80 @@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages)
\r
84 -/* Return a query that does not match messages with the excluded tags
\r
85 - * registered with the query. Any tags that explicitly appear in
\r
86 - * xquery will not be excluded. */
\r
87 +/* Return a query that matches messages with the excluded tags
\r
88 + * registered with query. Any tags that explicitly appear in xquery
\r
89 + * will not be excluded. The caller of this function has to combine
\r
90 + * the returned query appropriately.*/
\r
91 static Xapian::Query
\r
92 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
\r
94 + Xapian::Query exclude_query = Xapian::Query::MatchNothing;
\r
96 for (notmuch_string_node_t *term = query->exclude_terms->head; term;
\r
97 term = term->next) {
\r
98 Xapian::TermIterator it = xquery.get_terms_begin ();
\r
99 @@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
\r
103 - xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
104 - xquery, Xapian::Query (term->string));
\r
105 + exclude_query = Xapian::Query (Xapian::Query::OP_OR,
\r
106 + exclude_query, Xapian::Query (term->string));
\r
109 + return exclude_query;
\r
112 notmuch_messages_t *
\r
113 @@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
114 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
115 _find_prefix ("type"),
\r
117 - Xapian::Query string_query, final_query;
\r
118 + Xapian::Query string_query, final_query, exclude_query;
\r
120 unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
\r
121 Xapian::QueryParser::FLAG_PHRASE |
\r
122 @@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
123 mail_query, string_query);
\r
126 - final_query = _notmuch_exclude_tags (query, final_query);
\r
127 + exclude_query = _notmuch_exclude_tags (query, final_query);
\r
129 + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
130 + final_query, exclude_query);
\r
132 enquire.set_weighting_scheme (Xapian::BoolWeight());
\r
134 @@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
135 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
136 _find_prefix ("type"),
\r
138 - Xapian::Query string_query, final_query;
\r
139 + Xapian::Query string_query, final_query, exclude_query;
\r
141 unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
\r
142 Xapian::QueryParser::FLAG_PHRASE |
\r
143 @@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
144 mail_query, string_query);
\r
147 - final_query = _notmuch_exclude_tags (query, final_query);
\r
148 + exclude_query = _notmuch_exclude_tags (query, final_query);
\r
150 + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
151 + final_query, exclude_query);
\r
153 enquire.set_weighting_scheme(Xapian::BoolWeight());
\r
154 enquire.set_docid_order(Xapian::Enquire::ASCENDING);
\r