1 Return-Path: <novalazy@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 CF655431FD0
\r
6 for <notmuch@notmuchmail.org>; Wed, 20 Jun 2012 06:29:32 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id dX8TI7kwreSU for <notmuch@notmuchmail.org>;
\r
17 Wed, 20 Jun 2012 06:29:31 -0700 (PDT)
\r
18 Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com
\r
19 [209.85.210.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id CB180431FCB
\r
22 for <notmuch@notmuchmail.org>; Wed, 20 Jun 2012 06:29:30 -0700 (PDT)
\r
23 Received: by dadg9 with SMTP id g9so12291942dad.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 20 Jun 2012 06:29:30 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=wbM92hLqFqJT+Doctyy/ZeCmh2XnikQt41iBi9d6lBg=;
\r
28 b=kpN3/LeSxXUJrqPe5AXb1SjDtTOrDxnyrOl5K/seSysIfHTgUANmeSlAF61BaoET99
\r
29 4mJilMuWbTu3r0/tFoZDoDoKcXKAkdGPSObr+97AuAnGpXnIRJAPTXr2QYoyp7IVWgRa
\r
30 3c7Eh5X/jZICgjzPdBBfDspHlOZw4bEIxfBKwcSLskXAx5kJ2Un7bnIDdzbZJnIAurOD
\r
31 s0PL2PvLQyzKRtUtek+HPpCdnrLB+aHe9ba07ltRIoagUNULvIyygBWSv15x7bV/RTsK
\r
32 /6v7NWr0UwmoNt2AT7dU/VTW4yE8O5y5mZOY/yIy/llDduj+cvgC4eCElSneafghGXFg
\r
34 Received: by 10.68.197.70 with SMTP id is6mr57963960pbc.64.1340198970092;
\r
35 Wed, 20 Jun 2012 06:29:30 -0700 (PDT)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id ok6sm31955999pbb.29.2012.06.20.06.29.26
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Wed, 20 Jun 2012 06:29:29 -0700 (PDT)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 1/8] lib: add --exclude=all option
\r
44 Date: Wed, 20 Jun 2012 23:29:00 +1000
\r
45 Message-Id: <1340198947-29370-2-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.4.4
\r
47 In-Reply-To: <1340198947-29370-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1340198947-29370-1-git-send-email-novalazy@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Wed, 20 Jun 2012 13:29:33 -0000
\r
63 From: Mark Walters <markwalters1009@gmail.com>
\r
65 Adds a exclude all option to the lib which means that excluded
\r
66 messages are completely ignored (as if they had actually been
\r
69 lib/notmuch-private.h | 1 +
\r
70 lib/notmuch.h | 22 +++++++++++++++-------
\r
71 lib/query.cc | 10 ++++++----
\r
72 lib/thread.cc | 41 ++++++++++++++++++++++++++++++-----------
\r
73 4 files changed, 52 insertions(+), 22 deletions(-)
\r
75 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
76 index bfb4111..aa799b4 100644
\r
77 --- a/lib/notmuch-private.h
\r
78 +++ b/lib/notmuch-private.h
\r
79 @@ -232,6 +232,7 @@ _notmuch_thread_create (void *ctx,
\r
80 unsigned int seed_doc_id,
\r
81 notmuch_doc_id_set_t *match_set,
\r
82 notmuch_string_list_t *excluded_terms,
\r
83 + notmuch_exclude_t omit_exclude,
\r
84 notmuch_sort_t sort);
\r
87 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
88 index 3633bed..1280afd 100644
\r
91 @@ -500,14 +500,22 @@ typedef enum {
\r
93 notmuch_query_get_query_string (notmuch_query_t *query);
\r
95 +/* Exclude values for notmuch_query_set_omit_excluded */
\r
97 + NOTMUCH_EXCLUDE_FALSE,
\r
98 + NOTMUCH_EXCLUDE_TRUE,
\r
99 + NOTMUCH_EXCLUDE_ALL
\r
100 +} notmuch_exclude_t;
\r
102 /* Specify whether to omit excluded results or simply flag them. By
\r
103 * default, this is set to TRUE.
\r
105 - * If this is TRUE, notmuch_query_search_messages will omit excluded
\r
106 - * messages from the results. notmuch_query_search_threads will omit
\r
107 - * threads that match only in excluded messages, but will include all
\r
108 - * messages in threads that match in at least one non-excluded
\r
110 + * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
\r
111 + * messages from the results, and notmuch_query_search_threads will omit
\r
112 + * threads that match only in excluded messages. If set to TRUE,
\r
113 + * notmuch_query_search_threads will include all messages in threads that
\r
114 + * match in at least one non-excluded message. Otherwise, if set to ALL,
\r
115 + * notmuch_query_search_threads will omit excluded messages from all threads.
\r
117 * The performance difference when calling
\r
118 * notmuch_query_search_messages should be relatively small (and both
\r
119 @@ -516,9 +524,9 @@ notmuch_query_get_query_string (notmuch_query_t *query);
\r
120 * excluded messages as it does not need to construct the threads that
\r
121 * only match in excluded messages.
\r
125 -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded);
\r
126 +notmuch_query_set_omit_excluded (notmuch_query_t *query,
\r
127 + notmuch_exclude_t omit_excluded);
\r
129 /* Specify the sorting desired for this query. */
\r
131 diff --git a/lib/query.cc b/lib/query.cc
\r
132 index e9c1a2d..f752452 100644
\r
135 @@ -28,7 +28,7 @@ struct _notmuch_query {
\r
136 const char *query_string;
\r
137 notmuch_sort_t sort;
\r
138 notmuch_string_list_t *exclude_terms;
\r
139 - notmuch_bool_t omit_excluded;
\r
140 + notmuch_exclude_t omit_excluded;
\r
143 typedef struct _notmuch_mset_messages {
\r
144 @@ -92,7 +92,7 @@ notmuch_query_create (notmuch_database_t *notmuch,
\r
146 query->exclude_terms = _notmuch_string_list_create (query);
\r
148 - query->omit_excluded = TRUE;
\r
149 + query->omit_excluded = NOTMUCH_EXCLUDE_TRUE;
\r
153 @@ -104,7 +104,8 @@ notmuch_query_get_query_string (notmuch_query_t *query)
\r
157 -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded)
\r
158 +notmuch_query_set_omit_excluded (notmuch_query_t *query,
\r
159 + notmuch_exclude_t omit_excluded)
\r
161 query->omit_excluded = omit_excluded;
\r
163 @@ -220,7 +221,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
164 if (query->exclude_terms) {
\r
165 exclude_query = _notmuch_exclude_tags (query, final_query);
\r
167 - if (query->omit_excluded)
\r
168 + if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE)
\r
169 final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
\r
170 final_query, exclude_query);
\r
172 @@ -486,6 +487,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
\r
174 &threads->match_set,
\r
175 threads->query->exclude_terms,
\r
176 + threads->query->omit_excluded,
\r
177 threads->query->sort);
\r
180 diff --git a/lib/thread.cc b/lib/thread.cc
\r
181 index e976d64..4cb0896 100644
\r
182 --- a/lib/thread.cc
\r
183 +++ b/lib/thread.cc
\r
184 @@ -215,7 +215,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
\r
186 _thread_add_message (notmuch_thread_t *thread,
\r
187 notmuch_message_t *message,
\r
188 - notmuch_string_list_t *exclude_terms)
\r
189 + notmuch_string_list_t *exclude_terms,
\r
190 + notmuch_exclude_t omit_exclude)
\r
192 notmuch_tags_t *tags;
\r
194 @@ -223,6 +224,28 @@ _thread_add_message (notmuch_thread_t *thread,
\r
195 InternetAddress *address;
\r
196 const char *from, *author;
\r
197 char *clean_author;
\r
198 + notmuch_bool_t message_excluded = FALSE;
\r
200 + for (tags = notmuch_message_get_tags (message);
\r
201 + notmuch_tags_valid (tags);
\r
202 + notmuch_tags_move_to_next (tags))
\r
204 + tag = notmuch_tags_get (tags);
\r
205 + /* Is message excluded? */
\r
206 + for (notmuch_string_node_t *term = exclude_terms->head;
\r
208 + term = term->next)
\r
210 + /* We ignore initial 'K'. */
\r
211 + if (strcmp(tag, (term->string + 1)) == 0) {
\r
212 + message_excluded = TRUE;
\r
218 + if (message_excluded && omit_exclude == NOTMUCH_EXCLUDE_ALL)
\r
221 _notmuch_message_list_add_message (thread->message_list,
\r
222 talloc_steal (thread, message));
\r
223 @@ -263,17 +286,12 @@ _thread_add_message (notmuch_thread_t *thread,
\r
224 notmuch_tags_move_to_next (tags))
\r
226 tag = notmuch_tags_get (tags);
\r
227 - /* Mark excluded messages. */
\r
228 - for (notmuch_string_node_t *term = exclude_terms->head; term;
\r
229 - term = term->next) {
\r
230 - /* We ignore initial 'K'. */
\r
231 - if (strcmp(tag, (term->string + 1)) == 0) {
\r
232 - notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
\r
236 g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
\r
239 + /* Mark excluded messages. */
\r
240 + if (message_excluded)
\r
241 + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
\r
245 @@ -404,6 +422,7 @@ _notmuch_thread_create (void *ctx,
\r
246 unsigned int seed_doc_id,
\r
247 notmuch_doc_id_set_t *match_set,
\r
248 notmuch_string_list_t *exclude_terms,
\r
249 + notmuch_exclude_t omit_excluded,
\r
250 notmuch_sort_t sort)
\r
252 notmuch_thread_t *thread;
\r
253 @@ -479,7 +498,7 @@ _notmuch_thread_create (void *ctx,
\r
254 if (doc_id == seed_doc_id)
\r
255 message = seed_message;
\r
257 - _thread_add_message (thread, message, exclude_terms);
\r
258 + _thread_add_message (thread, message, exclude_terms, omit_excluded);
\r
260 if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
\r
261 _notmuch_doc_id_set_remove (match_set, doc_id);
\r