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 F3D63431FB6
\r
6 for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:18 -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 3-1Fo7+SBDNN for <notmuch@notmuchmail.org>;
\r
18 Sat, 28 Jan 2012 16:03:18 -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 28D72431FAE
\r
23 for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:18 -0800 (PST)
\r
24 Received: by werb10 with SMTP id b10so2751672wer.26
\r
25 for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:15 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=rhldndG9ruLRJb+AbUY+7HqweyOclJiV//Df8mkLrLM=;
\r
29 b=AAmYdfc6jMMmmme9/1Bsr9sJmvB6sJeeNY1xgO3XD2OZQl7hexUOolHDG6CiNB8eV0
\r
30 VhNC6wNKHxqgHxAy00LYhVcyUG6s1T9dxGdqlNF+JAbzBY11R3ixU31b0nJQHoLClDX6
\r
31 NmhKcuMqtIi9KIDeCFfIXLjTxyRYSx1fYNQIU=
\r
32 Received: by 10.216.145.1 with SMTP id o1mr5185312wej.45.1327795395593;
\r
33 Sat, 28 Jan 2012 16:03:15 -0800 (PST)
\r
34 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
35 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
36 eq5sm37458024wib.2.2012.01.28.16.03.13 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Sat, 28 Jan 2012 16:03:14 -0800 (PST)
\r
38 From: Mark Walters <markwalters1009@gmail.com>
\r
39 To: notmuch@notmuchmail.org,
\r
41 Subject: [PATCH 1/4] Add exclude flag
\r
42 Date: Sun, 29 Jan 2012 00:04:01 +0000
\r
43 Message-Id: <1327795444-18745-1-git-send-email-markwalters1009@gmail.com>
\r
44 X-Mailer: git-send-email 1.7.2.3
\r
45 In-Reply-To: <8739azqt2j.fsf@qmul.ac.uk>
\r
46 References: <8739azqt2j.fsf@qmul.ac.uk>
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Sun, 29 Jan 2012 00:03:19 -0000
\r
61 Slightly refactor the exclude code to give the callers access to the
\r
62 exclude query itself. There should be no functional change.
\r
65 lib/query.cc | 29 +++++++++++++++++++----------
\r
66 1 files changed, 19 insertions(+), 10 deletions(-)
\r
68 diff --git a/lib/query.cc b/lib/query.cc
\r
69 index 0b36602..c25b301 100644
\r
72 @@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages)
\r
76 -/* Return a query that does not match messages with the excluded tags
\r
77 - * registered with the query. Any tags that explicitly appear in
\r
78 - * xquery will not be excluded. */
\r
79 +/* Return a query that matches messages with the excluded tags
\r
80 + * registered with query. Any tags that explicitly appear in xquery
\r
81 + * will not be excluded. The caller of this function has to combine
\r
82 + * the returned query appropriately.*/
\r
83 static Xapian::Query
\r
84 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
\r
86 + Xapian::Query exclude_query = Xapian::Query::MatchNothing;
\r
88 for (notmuch_string_node_t *term = query->exclude_terms->head; term;
\r
89 term = term->next) {
\r
90 Xapian::TermIterator it = xquery.get_terms_begin ();
\r
91 @@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
\r
95 - xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
96 - xquery, Xapian::Query (term->string));
\r
97 + exclude_query = Xapian::Query (Xapian::Query::OP_OR,
\r
98 + exclude_query, Xapian::Query (term->string));
\r
101 + return exclude_query;
\r
104 notmuch_messages_t *
\r
105 @@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
106 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
107 _find_prefix ("type"),
\r
109 - Xapian::Query string_query, final_query;
\r
110 + Xapian::Query string_query, final_query, exclude_query;
\r
112 unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
\r
113 Xapian::QueryParser::FLAG_PHRASE |
\r
114 @@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
115 mail_query, string_query);
\r
118 - final_query = _notmuch_exclude_tags (query, final_query);
\r
119 + exclude_query = _notmuch_exclude_tags (query, final_query);
\r
121 + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
122 + final_query, exclude_query);
\r
124 enquire.set_weighting_scheme (Xapian::BoolWeight());
\r
126 @@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
127 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
128 _find_prefix ("type"),
\r
130 - Xapian::Query string_query, final_query;
\r
131 + Xapian::Query string_query, final_query, exclude_query;
\r
133 unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
\r
134 Xapian::QueryParser::FLAG_PHRASE |
\r
135 @@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
136 mail_query, string_query);
\r
139 - final_query = _notmuch_exclude_tags (query, final_query);
\r
140 + exclude_query = _notmuch_exclude_tags (query, final_query);
\r
142 + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
143 + final_query, exclude_query);
\r
145 enquire.set_weighting_scheme(Xapian::BoolWeight());
\r
146 enquire.set_docid_order(Xapian::Enquire::ASCENDING);
\r