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 25345431FAE
\r
6 for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:21 -0700 (PDT)
\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 BJ1UZ2NHUiRu for <notmuch@notmuchmail.org>;
\r
18 Thu, 15 Mar 2012 11:42:18 -0700 (PDT)
\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 A2AA9431E62
\r
23 for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:16 -0700 (PDT)
\r
24 Received: by mail-we0-f181.google.com with SMTP id m13so3528469wer.26
\r
25 for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:16 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=hT1hrr94WGX1539QJetu5XO8XpS8WNqFx8L+w0uwasc=;
\r
29 b=KJM07sj5lIAH2npw1d44yqF0VZPB27xZOhsBbcOnm0rUnOFFmjtwZHg4ofF6epxIvv
\r
30 XdW1wodCgJ1fJQ/k65udInAgyN+FV+A4cSMDSNu1TU283w8a6gkRiReEnxPlEP9QzNTV
\r
31 n+5THlxrCMYeMaVsE9UpJg+aS0/fGXRpCL0OKI3ovLyvK05kU4zdp6mzyUGqJ74R+Z6C
\r
32 KfyDdOpmvN5kSLzhVDVFsocSvMSu6ceHb53SKM9AQXMiLqSghDiBpUXgwiNEJX5KgH/b
\r
33 6NiU9FkiwGJ5IIMSSimoA6lcM7uEgxp827kcVxZmVntvYkWkwWliPiDQdr0UtEGagrd3
\r
35 Received: by 10.216.134.2 with SMTP id r2mr4737610wei.31.1331836936311;
\r
36 Thu, 15 Mar 2012 11:42:16 -0700 (PDT)
\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
38 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
39 fw5sm7088634wib.0.2012.03.15.11.42.15 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Thu, 15 Mar 2012 11:42:15 -0700 (PDT)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 3/5] cli: move search to the new --exclude= naming scheme.
\r
44 Date: Thu, 15 Mar 2012 18:42:03 +0000
\r
45 Message-Id: <1331836925-31437-4-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1331836925-31437-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1331836925-31437-1-git-send-email-markwalters1009@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: Thu, 15 Mar 2012 18:42:21 -0000
\r
63 This commit replaces the --no-exclude option with a
\r
64 --exclude=(true|false|flag) option. The default is to omit the
\r
67 The flag option only makes sense if output=summary (as otherwise there
\r
68 is nowhere to print the flag). In summary output exclude=false and
\r
69 exclude=flag give almost identical output:
\r
70 they differ in that with the exclude=flag option the match count
\r
71 (i.e., the x in [x/n] in the output) is the number of matching
\r
72 non-excluded messages rather than the number of matching messages.
\r
74 Note this changes the default for output=summary when no --exclude=
\r
75 option is given: it used to default to flag and now defaults to true
\r
76 (i.e. omit excluded messages). This is neccesary to keep the cli
\r
77 output uncluttered and for speed reasons.
\r
79 man/man1/notmuch-search.1 | 12 +++++++++---
\r
80 notmuch-search.c | 32 +++++++++++++++++++++++---------
\r
81 test/search | 13 ++++++-------
\r
82 3 files changed, 38 insertions(+), 19 deletions(-)
\r
84 diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1
\r
85 index 8426aa3..49fbd0d 100644
\r
86 --- a/man/man1/notmuch-search.1
\r
87 +++ b/man/man1/notmuch-search.1
\r
88 @@ -114,9 +114,15 @@ Limit the number of displayed results to N.
\r
92 -.BR \-\-no\-exclude
\r
94 -Do not exclude the messages matching search.exclude_tags in the config file.
\r
95 +.BR \-\-exclude=(true|false|flag)
\r
97 +Specify whether to omit messages matching search.tag_exclude from the
\r
98 +search results (the default) or not. The extra option
\r
100 +only has an effect when
\r
101 +.B --output=summary
\r
102 +In this case all matching threads are returned but the "match count"
\r
103 +is the number of matching non-excluded messages in the thread.
\r
107 diff --git a/notmuch-search.c b/notmuch-search.c
\r
108 index f6061e4..fe18a93 100644
\r
109 --- a/notmuch-search.c
\r
110 +++ b/notmuch-search.c
\r
111 @@ -210,9 +210,6 @@ do_search_threads (const search_format_t *format,
\r
112 int first_thread = 1;
\r
115 - if (output == OUTPUT_THREADS)
\r
116 - notmuch_query_set_omit_excluded_messages (query, TRUE);
\r
119 offset += notmuch_query_count_threads (query);
\r
121 @@ -303,8 +300,6 @@ do_search_messages (const search_format_t *format,
\r
122 int first_message = 1;
\r
125 - notmuch_query_set_omit_excluded_messages (query, TRUE);
\r
128 offset += notmuch_query_count_messages (query);
\r
130 @@ -376,7 +371,6 @@ do_search_tags (notmuch_database_t *notmuch,
\r
134 - notmuch_query_set_omit_excluded_messages (query, TRUE);
\r
135 /* should the following only special case if no excluded terms
\r
138 @@ -422,6 +416,12 @@ do_search_tags (notmuch_database_t *notmuch,
\r
149 notmuch_search_command (void *ctx, int argc, char *argv[])
\r
151 @@ -435,7 +435,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
152 output_t output = OUTPUT_SUMMARY;
\r
154 int limit = -1; /* unlimited */
\r
155 - notmuch_bool_t no_exclude = FALSE;
\r
156 + int exclude = EXCLUDE_TRUE;
\r
159 enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
\r
160 @@ -457,7 +457,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
161 { "files", OUTPUT_FILES },
\r
162 { "tags", OUTPUT_TAGS },
\r
164 - { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
\r
165 + { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
\r
166 + (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
\r
167 + { "false", EXCLUDE_FALSE },
\r
168 + { "flag", EXCLUDE_FLAG },
\r
170 { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
\r
171 { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 },
\r
173 @@ -505,7 +509,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
175 notmuch_query_set_sort (query, sort);
\r
177 - if (!no_exclude) {
\r
178 + if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) {
\r
179 + /* if we are not doing summary output there is no where to
\r
180 + * print the excluded flag so fall back on including the
\r
181 + * excluded messages */
\r
182 + fprintf (stderr, "Cannot flag excluded messages with this output: fall back on just including them\n");
\r
183 + exclude = EXCLUDE_FALSE;
\r
186 + if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) {
\r
187 const char **search_exclude_tags;
\r
188 size_t search_exclude_tags_length;
\r
190 @@ -513,6 +525,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
191 (config, &search_exclude_tags_length);
\r
192 for (i = 0; i < search_exclude_tags_length; i++)
\r
193 notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
\r
194 + if (exclude == EXCLUDE_FLAG)
\r
195 + notmuch_query_set_omit_excluded_messages (query, FALSE);
\r
199 diff --git a/test/search b/test/search
\r
200 index 17af6a2..318fdb8 100755
\r
203 @@ -138,15 +138,14 @@ notmuch new > /dev/null
\r
204 notmuch tag +deleted id:$gen_msg_id
\r
205 deleted_id=$gen_msg_id
\r
206 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
\r
207 -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)
\r
208 -thread:XXX 2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox unread)"
\r
209 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)"
\r
211 test_begin_subtest "Exclude \"deleted\" messages from message search"
\r
212 output=$(notmuch search --output=messages subject:deleted | notmuch_search_sanitize)
\r
213 test_expect_equal "$output" "id:$not_deleted_id"
\r
215 -test_begin_subtest "Exclude \"deleted\" messages from message search (no-exclude)"
\r
216 -output=$(notmuch search --no-exclude --output=messages subject:deleted | notmuch_search_sanitize)
\r
217 +test_begin_subtest "Exclude \"deleted\" messages from message search --exclude=false"
\r
218 +output=$(notmuch search --exclude=false --output=messages subject:deleted | notmuch_search_sanitize)
\r
219 test_expect_equal "$output" "id:$not_deleted_id
\r
222 @@ -166,10 +165,10 @@ output=$(notmuch search subject:deleted | notmuch_search_sanitize)
\r
223 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)
\r
224 thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)"
\r
226 -test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude specified"
\r
227 -output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize)
\r
228 +test_begin_subtest "Don't exclude \"deleted\" messages when --exclude=flag specified"
\r
229 +output=$(notmuch search --exclude=flag subject:deleted | notmuch_search_sanitize)
\r
230 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)
\r
231 -thread:XXX 2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)"
\r
232 +thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)"
\r
234 test_begin_subtest "Don't exclude \"deleted\" messages from search if not configured"
\r
235 notmuch config set search.exclude_tags
\r