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 3CCB1429E36
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:09 -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 QhXMmpuqQ-19 for <notmuch@notmuchmail.org>;
\r
18 Thu, 2 Feb 2012 09:43:08 -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 6F821431FBD
\r
23 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:07 -0800 (PST)
\r
24 Received: by mail-we0-f181.google.com with SMTP id b10so2324200wer.26
\r
25 for <notmuch@notmuchmail.org>; Thu, 02 Feb 2012 09:43:07 -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=eAUX78p88IX+cG4hVJxkEo2EBDwpTAL60rWPZ7/6HBQ=;
\r
29 b=mmTSMU4Bp0T0IO812Ul4GzEwjPS2z+2PmMTXUQk/0pSRDljR/xDIwqTU//ufqXFMgv
\r
30 na6ijTX2froXmJ9ZDgW9rhScSxzflsl1CJACpiG2UPamwse4AaMAf1tprENKURZG8d4b
\r
31 DHK+RYu1vkTPhmKI+4LVLu0ek0/aVJvwaxsCw=
\r
32 Received: by 10.216.138.102 with SMTP id z80mr4277872wei.38.1328204587111;
\r
33 Thu, 02 Feb 2012 09:43:07 -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 hc10sm1119723wib.8.2012.02.02.09.43.05 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Thu, 02 Feb 2012 09:43:06 -0800 (PST)
\r
38 From: Mark Walters <markwalters1009@gmail.com>
\r
39 To: notmuch@notmuchmail.org,
\r
41 Subject: [PATCH v4 06/11] lib: Add the exclude flag to
\r
42 notmuch_query_search_threads
\r
43 Date: Thu, 2 Feb 2012 17:43:34 +0000
\r
44 Message-Id: <1328204619-25046-6-git-send-email-markwalters1009@gmail.com>
\r
45 X-Mailer: git-send-email 1.7.2.3
\r
46 In-Reply-To: <874nv9rv79.fsf@qmul.ac.uk>
\r
47 References: <874nv9rv79.fsf@qmul.ac.uk>
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Thu, 02 Feb 2012 17:43:10 -0000
\r
62 Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
\r
63 notmuch_query_search_threads. Implemented by inspecting the tags
\r
64 directly in _notmuch_thread_create/_thread_add_message rather than as
\r
65 a Xapian query for speed reasons.
\r
67 lib/notmuch-private.h | 7 +++++--
\r
69 lib/thread.cc | 18 +++++++++++++++---
\r
70 3 files changed, 21 insertions(+), 5 deletions(-)
\r
72 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
73 index e791bb0..ea836f7 100644
\r
74 --- a/lib/notmuch-private.h
\r
75 +++ b/lib/notmuch-private.h
\r
76 @@ -148,6 +148,8 @@ typedef enum _notmuch_private_status {
\r
78 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
\r
80 +typedef struct _notmuch_string_list notmuch_string_list_t;
\r
84 /* Lookup a prefix value by name.
\r
85 @@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx,
\r
86 notmuch_database_t *notmuch,
\r
87 unsigned int seed_doc_id,
\r
88 notmuch_doc_id_set_t *match_set,
\r
89 + notmuch_string_list_t *excluded_terms,
\r
90 notmuch_sort_t sort);
\r
93 @@ -459,11 +462,11 @@ typedef struct _notmuch_string_node {
\r
94 struct _notmuch_string_node *next;
\r
95 } notmuch_string_node_t;
\r
97 -typedef struct visible _notmuch_string_list {
\r
98 +struct visible _notmuch_string_list {
\r
100 notmuch_string_node_t *head;
\r
101 notmuch_string_node_t **tail;
\r
102 -} notmuch_string_list_t;
\r
105 notmuch_string_list_t *
\r
106 _notmuch_string_list_create (const void *ctx);
\r
107 diff --git a/lib/query.cc b/lib/query.cc
\r
108 index 90a71a1..e1c3977 100644
\r
111 @@ -472,6 +472,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
\r
112 threads->query->notmuch,
\r
114 &threads->match_set,
\r
115 + threads->query->exclude_terms,
\r
116 threads->query->sort);
\r
119 diff --git a/lib/thread.cc b/lib/thread.cc
\r
120 index 0435ee6..e976d64 100644
\r
121 --- a/lib/thread.cc
\r
122 +++ b/lib/thread.cc
\r
123 @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
\r
126 _thread_add_message (notmuch_thread_t *thread,
\r
127 - notmuch_message_t *message)
\r
128 + notmuch_message_t *message,
\r
129 + notmuch_string_list_t *exclude_terms)
\r
131 notmuch_tags_t *tags;
\r
133 @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
\r
134 notmuch_tags_move_to_next (tags))
\r
136 tag = notmuch_tags_get (tags);
\r
137 + /* Mark excluded messages. */
\r
138 + for (notmuch_string_node_t *term = exclude_terms->head; term;
\r
139 + term = term->next) {
\r
140 + /* We ignore initial 'K'. */
\r
141 + if (strcmp(tag, (term->string + 1)) == 0) {
\r
142 + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
\r
146 g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
\r
149 @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
\r
150 _thread_set_subject_from_message (thread, message);
\r
153 - thread->matched_messages++;
\r
154 + if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
\r
155 + thread->matched_messages++;
\r
157 if (g_hash_table_lookup_extended (thread->message_hash,
\r
158 notmuch_message_get_message_id (message), NULL,
\r
159 @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
\r
160 notmuch_database_t *notmuch,
\r
161 unsigned int seed_doc_id,
\r
162 notmuch_doc_id_set_t *match_set,
\r
163 + notmuch_string_list_t *exclude_terms,
\r
164 notmuch_sort_t sort)
\r
166 notmuch_thread_t *thread;
\r
167 @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
\r
168 if (doc_id == seed_doc_id)
\r
169 message = seed_message;
\r
171 - _thread_add_message (thread, message);
\r
172 + _thread_add_message (thread, message, exclude_terms);
\r
174 if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
\r
175 _notmuch_doc_id_set_remove (match_set, doc_id);
\r