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 9C2CF431FDE
\r
6 for <notmuch@notmuchmail.org>; Thu, 1 Mar 2012 14:29:47 -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 sgKWmm+OpHX2 for <notmuch@notmuchmail.org>;
\r
18 Thu, 1 Mar 2012 14:29:45 -0800 (PST)
\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com
\r
20 [209.85.212.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 A796E429E29
\r
23 for <notmuch@notmuchmail.org>; Thu, 1 Mar 2012 14:29:31 -0800 (PST)
\r
24 Received: by mail-wi0-f181.google.com with SMTP id o1so305757wic.26
\r
25 for <notmuch@notmuchmail.org>; Thu, 01 Mar 2012 14:29:31 -0800 (PST)
\r
26 Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates
\r
27 10.180.107.99 as permitted sender) client-ip=10.180.107.99;
\r
28 Authentication-Results: mr.google.com; spf=pass (google.com: domain of
\r
29 markwalters1009@gmail.com designates 10.180.107.99 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.107.99])
\r
33 by 10.180.107.99 with SMTP id hb3mr15031246wib.5.1330640971521
\r
34 (num_hops = 1); Thu, 01 Mar 2012 14:29:31 -0800 (PST)
\r
35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
36 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
37 bh=BsaS5Zpnoh6DatNKWnhrJrtCDw2ujgE0cyPqM93aJfM=;
\r
38 b=CEreg372lEs2PAzL+R9mmKQ3RusNRyaXS/8qqB6//fWzlv+esozfzP5IgeE0VRyet/
\r
39 hJqAvle8iBfc+z4i3NPAdU8Cizy5t1sRDXNeo/bksGNH1pILkYDcWULKL+lKnM2ngxXe
\r
40 QsUVvNyYUiDSCjdPSESdRViFM3p1L8PnWm5YjeJOoh5oJnLk3UXEJIrfsTFnmPYA+gJK
\r
41 VMpJ+IDOsRXtCCvzNTj9DCFD3V6zrHsZhJm8mqbggh4tKl+JofsEKTdcvrQY7siGeiP8
\r
42 9ZE6wtuOoWfoWrzF2BfmGZVrabu4NVPXTP2ut3aPMzikLn+1TuA31Yt9wX3CypPGlBFP
\r
44 Received: by 10.180.107.99 with SMTP id hb3mr12083013wib.5.1330640971468;
\r
45 Thu, 01 Mar 2012 14:29:31 -0800 (PST)
\r
46 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
47 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
48 hn8sm10961838wib.11.2012.03.01.14.29.27 (version=TLSv1/SSLv3 cipher=OTHER);
\r
49 Thu, 01 Mar 2012 14:29:30 -0800 (PST)
\r
50 From: Mark Walters <markwalters1009@gmail.com>
\r
51 To: notmuch@notmuchmail.org
\r
52 Subject: [Patch v7 06/13] lib: Add the exclude flag to
\r
53 notmuch_query_search_threads
\r
54 Date: Thu, 1 Mar 2012 22:30:38 +0000
\r
55 Message-Id: <1330641045-27416-7-git-send-email-markwalters1009@gmail.com>
\r
56 X-Mailer: git-send-email 1.7.2.3
\r
57 In-Reply-To: <1330641045-27416-1-git-send-email-markwalters1009@gmail.com>
\r
58 References: <1330641045-27416-1-git-send-email-markwalters1009@gmail.com>
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Thu, 01 Mar 2012 22:29:48 -0000
\r
73 Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
\r
74 notmuch_query_search_threads. Implemented by inspecting the tags
\r
75 directly in _notmuch_thread_create/_thread_add_message rather than as
\r
76 a Xapian query for speed reasons.
\r
78 Note notmuch_thread_get_matched_messages now returns the number of
\r
79 non-excluded matching messages. This API is not totally desirable but
\r
80 fixing it means breaking binary compatibility so we delay that.
\r
82 lib/notmuch-private.h | 7 +++++--
\r
83 lib/notmuch.h | 6 ++++--
\r
85 lib/thread.cc | 18 +++++++++++++++---
\r
86 4 files changed, 25 insertions(+), 7 deletions(-)
\r
88 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
89 index e791bb0..ea836f7 100644
\r
90 --- a/lib/notmuch-private.h
\r
91 +++ b/lib/notmuch-private.h
\r
92 @@ -148,6 +148,8 @@ typedef enum _notmuch_private_status {
\r
94 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
\r
96 +typedef struct _notmuch_string_list notmuch_string_list_t;
\r
100 /* Lookup a prefix value by name.
\r
101 @@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx,
\r
102 notmuch_database_t *notmuch,
\r
103 unsigned int seed_doc_id,
\r
104 notmuch_doc_id_set_t *match_set,
\r
105 + notmuch_string_list_t *excluded_terms,
\r
106 notmuch_sort_t sort);
\r
109 @@ -459,11 +462,11 @@ typedef struct _notmuch_string_node {
\r
110 struct _notmuch_string_node *next;
\r
111 } notmuch_string_node_t;
\r
113 -typedef struct visible _notmuch_string_list {
\r
114 +struct visible _notmuch_string_list {
\r
116 notmuch_string_node_t *head;
\r
117 notmuch_string_node_t **tail;
\r
118 -} notmuch_string_list_t;
\r
121 notmuch_string_list_t *
\r
122 _notmuch_string_list_create (const void *ctx);
\r
123 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
124 index f75afae..babd208 100644
\r
125 --- a/lib/notmuch.h
\r
126 +++ b/lib/notmuch.h
\r
127 @@ -672,8 +672,10 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
\r
128 /* Get the number of messages in 'thread' that matched the search.
\r
130 * This count includes only the messages in this thread that were
\r
131 - * matched by the search from which the thread was created. Contrast
\r
132 - * with notmuch_thread_get_total_messages() .
\r
133 + * matched by the search from which the thread was created and were
\r
134 + * not excluded by any exclude tags passed in with the query (see
\r
135 + * notmuch_query_add_tag_exclude). Contrast with
\r
136 + * notmuch_thread_get_total_messages() .
\r
139 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
\r
140 diff --git a/lib/query.cc b/lib/query.cc
\r
141 index ef2a11f..ab18fbc 100644
\r
144 @@ -475,6 +475,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
\r
145 threads->query->notmuch,
\r
147 &threads->match_set,
\r
148 + threads->query->exclude_terms,
\r
149 threads->query->sort);
\r
152 diff --git a/lib/thread.cc b/lib/thread.cc
\r
153 index 0435ee6..e976d64 100644
\r
154 --- a/lib/thread.cc
\r
155 +++ b/lib/thread.cc
\r
156 @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
\r
159 _thread_add_message (notmuch_thread_t *thread,
\r
160 - notmuch_message_t *message)
\r
161 + notmuch_message_t *message,
\r
162 + notmuch_string_list_t *exclude_terms)
\r
164 notmuch_tags_t *tags;
\r
166 @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
\r
167 notmuch_tags_move_to_next (tags))
\r
169 tag = notmuch_tags_get (tags);
\r
170 + /* Mark excluded messages. */
\r
171 + for (notmuch_string_node_t *term = exclude_terms->head; term;
\r
172 + term = term->next) {
\r
173 + /* We ignore initial 'K'. */
\r
174 + if (strcmp(tag, (term->string + 1)) == 0) {
\r
175 + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
\r
179 g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
\r
182 @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
\r
183 _thread_set_subject_from_message (thread, message);
\r
186 - thread->matched_messages++;
\r
187 + if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
\r
188 + thread->matched_messages++;
\r
190 if (g_hash_table_lookup_extended (thread->message_hash,
\r
191 notmuch_message_get_message_id (message), NULL,
\r
192 @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
\r
193 notmuch_database_t *notmuch,
\r
194 unsigned int seed_doc_id,
\r
195 notmuch_doc_id_set_t *match_set,
\r
196 + notmuch_string_list_t *exclude_terms,
\r
197 notmuch_sort_t sort)
\r
199 notmuch_thread_t *thread;
\r
200 @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
\r
201 if (doc_id == seed_doc_id)
\r
202 message = seed_message;
\r
204 - _thread_add_message (thread, message);
\r
205 + _thread_add_message (thread, message, exclude_terms);
\r
207 if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
\r
208 _notmuch_doc_id_set_remove (match_set, doc_id);
\r