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 A8B62431FBF
\r
6 for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:26:01 -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 n84t0+KgD835 for <notmuch@notmuchmail.org>;
\r
18 Sat, 25 Feb 2012 19:26:00 -0800 (PST)
\r
19 Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com
\r
20 [74.125.82.41]) (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 80140431FAE for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:26:00 -0800
\r
24 Received: by wgbds1 with SMTP id ds1so238785wgb.2
\r
25 for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:25:59 -0800 (PST)
\r
26 Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates
\r
27 10.180.102.132 as permitted sender) client-ip=10.180.102.132;
\r
28 Authentication-Results: mr.google.com; spf=pass (google.com: domain of
\r
29 markwalters1009@gmail.com designates 10.180.102.132 as
\r
30 permitted sender) smtp.mail=markwalters1009@gmail.com;
\r
31 dkim=pass header.i=markwalters1009@gmail.com
\r
32 Received: from mr.google.com ([10.180.102.132])
\r
33 by 10.180.102.132 with SMTP id fo4mr7814576wib.6.1330226759530
\r
34 (num_hops = 1); Sat, 25 Feb 2012 19:25:59 -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=BsaS5Zpnoh6DatNKWnhrJrtCDw2ujgE0cyPqM93aJfM=;
\r
38 b=ks77y3BzRfJSIo2cI5QH1IMrKEmQKlrqm4QSmkENfz2c30s5RESjdR9IuD5kpdGioi
\r
39 uEmO8E6wZq/FS4L4AoLlPcsUD0+yH9O9lG+Yge6kRv7Aa1RxCW/ehmk0ahNdsJnvuQd8
\r
40 m7HKXJ+D8vDKIb045U/pEl/qs9vSI0jhiO5Ek=
\r
41 Received: by 10.180.102.132 with SMTP id fo4mr1766457wib.6.1330157139391;
\r
42 Sat, 25 Feb 2012 00:05:39 -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 dr5sm20713170wib.0.2012.02.25.00.05.38 (version=TLSv1/SSLv3 cipher=OTHER);
\r
46 Sat, 25 Feb 2012 00:05:38 -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 06/13] lib: Add the exclude flag to
\r
51 notmuch_query_search_threads
\r
52 Date: Sat, 25 Feb 2012 08:06:37 +0000
\r
53 Message-Id: <1330157204-26094-7-git-send-email-markwalters1009@gmail.com>
\r
54 X-Mailer: git-send-email 1.7.2.3
\r
55 In-Reply-To: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>
\r
56 References: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sun, 26 Feb 2012 03:26:04 -0000
\r
71 Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
\r
72 notmuch_query_search_threads. Implemented by inspecting the tags
\r
73 directly in _notmuch_thread_create/_thread_add_message rather than as
\r
74 a Xapian query for speed reasons.
\r
76 Note notmuch_thread_get_matched_messages now returns the number of
\r
77 non-excluded matching messages. This API is not totally desirable but
\r
78 fixing it means breaking binary compatibility so we delay that.
\r
80 lib/notmuch-private.h | 7 +++++--
\r
81 lib/notmuch.h | 6 ++++--
\r
83 lib/thread.cc | 18 +++++++++++++++---
\r
84 4 files changed, 25 insertions(+), 7 deletions(-)
\r
86 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
87 index e791bb0..ea836f7 100644
\r
88 --- a/lib/notmuch-private.h
\r
89 +++ b/lib/notmuch-private.h
\r
90 @@ -148,6 +148,8 @@ typedef enum _notmuch_private_status {
\r
92 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
\r
94 +typedef struct _notmuch_string_list notmuch_string_list_t;
\r
98 /* Lookup a prefix value by name.
\r
99 @@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx,
\r
100 notmuch_database_t *notmuch,
\r
101 unsigned int seed_doc_id,
\r
102 notmuch_doc_id_set_t *match_set,
\r
103 + notmuch_string_list_t *excluded_terms,
\r
104 notmuch_sort_t sort);
\r
107 @@ -459,11 +462,11 @@ typedef struct _notmuch_string_node {
\r
108 struct _notmuch_string_node *next;
\r
109 } notmuch_string_node_t;
\r
111 -typedef struct visible _notmuch_string_list {
\r
112 +struct visible _notmuch_string_list {
\r
114 notmuch_string_node_t *head;
\r
115 notmuch_string_node_t **tail;
\r
116 -} notmuch_string_list_t;
\r
119 notmuch_string_list_t *
\r
120 _notmuch_string_list_create (const void *ctx);
\r
121 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
122 index f75afae..babd208 100644
\r
123 --- a/lib/notmuch.h
\r
124 +++ b/lib/notmuch.h
\r
125 @@ -672,8 +672,10 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
\r
126 /* Get the number of messages in 'thread' that matched the search.
\r
128 * This count includes only the messages in this thread that were
\r
129 - * matched by the search from which the thread was created. Contrast
\r
130 - * with notmuch_thread_get_total_messages() .
\r
131 + * matched by the search from which the thread was created and were
\r
132 + * not excluded by any exclude tags passed in with the query (see
\r
133 + * notmuch_query_add_tag_exclude). Contrast with
\r
134 + * notmuch_thread_get_total_messages() .
\r
137 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
\r
138 diff --git a/lib/query.cc b/lib/query.cc
\r
139 index ef2a11f..ab18fbc 100644
\r
142 @@ -475,6 +475,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
\r
143 threads->query->notmuch,
\r
145 &threads->match_set,
\r
146 + threads->query->exclude_terms,
\r
147 threads->query->sort);
\r
150 diff --git a/lib/thread.cc b/lib/thread.cc
\r
151 index 0435ee6..e976d64 100644
\r
152 --- a/lib/thread.cc
\r
153 +++ b/lib/thread.cc
\r
154 @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
\r
157 _thread_add_message (notmuch_thread_t *thread,
\r
158 - notmuch_message_t *message)
\r
159 + notmuch_message_t *message,
\r
160 + notmuch_string_list_t *exclude_terms)
\r
162 notmuch_tags_t *tags;
\r
164 @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
\r
165 notmuch_tags_move_to_next (tags))
\r
167 tag = notmuch_tags_get (tags);
\r
168 + /* Mark excluded messages. */
\r
169 + for (notmuch_string_node_t *term = exclude_terms->head; term;
\r
170 + term = term->next) {
\r
171 + /* We ignore initial 'K'. */
\r
172 + if (strcmp(tag, (term->string + 1)) == 0) {
\r
173 + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
\r
177 g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
\r
180 @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
\r
181 _thread_set_subject_from_message (thread, message);
\r
184 - thread->matched_messages++;
\r
185 + if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
\r
186 + thread->matched_messages++;
\r
188 if (g_hash_table_lookup_extended (thread->message_hash,
\r
189 notmuch_message_get_message_id (message), NULL,
\r
190 @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
\r
191 notmuch_database_t *notmuch,
\r
192 unsigned int seed_doc_id,
\r
193 notmuch_doc_id_set_t *match_set,
\r
194 + notmuch_string_list_t *exclude_terms,
\r
195 notmuch_sort_t sort)
\r
197 notmuch_thread_t *thread;
\r
198 @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
\r
199 if (doc_id == seed_doc_id)
\r
200 message = seed_message;
\r
202 - _thread_add_message (thread, message);
\r
203 + _thread_add_message (thread, message, exclude_terms);
\r
205 if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
\r
206 _notmuch_doc_id_set_remove (match_set, doc_id);
\r