From: Mark Walters Date: Sat, 3 Mar 2012 13:05:16 +0000 (+0000) Subject: [PATCH 3/5] cli: move search to the new --with-excluded naming scheme. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=551983913aff0f9a05206134bd81d0355a0ffcf0;p=notmuch-archives.git [PATCH 3/5] cli: move search to the new --with-excluded naming scheme. --- diff --git a/3f/4683e44d0aacdc9464cacd8925b0f0be0f6ecb b/3f/4683e44d0aacdc9464cacd8925b0f0be0f6ecb new file mode 100644 index 000000000..8bf54010c --- /dev/null +++ b/3f/4683e44d0aacdc9464cacd8925b0f0be0f6ecb @@ -0,0 +1,211 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A07E0431FC4 + for ; Sat, 3 Mar 2012 05:04:18 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id YvGvANPoTskB for ; + Sat, 3 Mar 2012 05:04:16 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 84912431FD7 + for ; Sat, 3 Mar 2012 05:04:16 -0800 (PST) +Received: by wico1 with SMTP id o1so697883wic.26 + for ; Sat, 03 Mar 2012 05:04:15 -0800 (PST) +Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates + 10.216.131.78 as permitted sender) client-ip=10.216.131.78; +Authentication-Results: mr.google.com; spf=pass (google.com: domain of + markwalters1009@gmail.com designates 10.216.131.78 as permitted + sender) smtp.mail=markwalters1009@gmail.com; + dkim=pass header.i=markwalters1009@gmail.com +Received: from mr.google.com ([10.216.131.78]) + by 10.216.131.78 with SMTP id l56mr1102683wei.94.1330779855449 + (num_hops = 1); Sat, 03 Mar 2012 05:04:15 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=VWN20Q6vv7qze+E1bITNO3I0EUFnZyPea5Qvg80VzYc=; + b=IXwwhJNTzKIxHzZFdCUMLNp8efhzBaAe+qzYlUZesxFKAsY3GCGaTckJK1IFLOmyfu + ai9HpNhQQuBf+YqOt8Dvyniq0X+7CVmGPulJN0DxGeS42uXQBofJrplyMr2KB0qo4SDQ + 7370cHkxZUWZYTHhoQUcd9/Bca5STnA8gFLD2AJAvxFsEbkz8/5L7X2UhUwfqkuc0vt7 + sirz6o5GoJHmRUKqMeQqifOdiSdiwoiBcnufMTkXn2SVEuPtQ06MJKE6fWgJ78DsYbXf + ZONoDYGqDY3JLCwqh4W0kd5nm3ZBTGAq7QU+TB2zmoryzU+csAHucQNzPAvzJST/4ptr + aeDw== +Received: by 10.216.131.78 with SMTP id l56mr904323wei.94.1330779855388; + Sat, 03 Mar 2012 05:04:15 -0800 (PST) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + h19sm9355204wiw.9.2012.03.03.05.04.14 (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 03 Mar 2012 05:04:14 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 3/5] cli: move search to the new --with-excluded naming + scheme. +Date: Sat, 3 Mar 2012 13:05:16 +0000 +Message-Id: <1330779918-28024-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com> +References: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 03 Mar 2012 13:04:18 -0000 + +This commit replaces the --no-exclude option with a --with-excluded +option. The output is identical in all cases except output-summary. In +this case they output exactly the same thread lines. They differ in +that with the new option the match count (i.e., the x in [x/n] in the +output) is the number of matching non-excluded messages rather than +the number of matching messages. + +It also change the behaviour when the --with-excluded option is not +set (for output=summary): it no longer returns threads only matching +in excluded messages. This is neccesary to keep the cli output +uncluttered and for speed reasons. +--- + man/man1/notmuch-search.1 | 6 ++++-- + notmuch-search.c | 20 +++++++++++--------- + test/search | 9 ++++----- + 3 files changed, 19 insertions(+), 16 deletions(-) + +diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 +index 8426aa3..e46ae68 100644 +--- a/man/man1/notmuch-search.1 ++++ b/man/man1/notmuch-search.1 +@@ -114,9 +114,11 @@ Limit the number of displayed results to N. + + .RS 4 + .TP 4 +-.BR \-\-no\-exclude ++.BR \-\-with\-excluded + +-Do not exclude the messages matching search.exclude_tags in the config file. ++Include messages matching search.exclude_tags from the config file in ++the output. Note that, in this case, the summary output shows the ++number of matching non-excluded messages for each thread. + .RE + + .SH SEE ALSO +diff --git a/notmuch-search.c b/notmuch-search.c +index f6061e4..4af19b5 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -210,9 +210,6 @@ do_search_threads (const search_format_t *format, + int first_thread = 1; + int i; + +- if (output == OUTPUT_THREADS) +- notmuch_query_set_omit_excluded_messages (query, TRUE); +- + if (offset < 0) { + offset += notmuch_query_count_threads (query); + if (offset < 0) +@@ -303,8 +300,6 @@ do_search_messages (const search_format_t *format, + int first_message = 1; + int i; + +- notmuch_query_set_omit_excluded_messages (query, TRUE); +- + if (offset < 0) { + offset += notmuch_query_count_messages (query); + if (offset < 0) +@@ -376,7 +371,6 @@ do_search_tags (notmuch_database_t *notmuch, + const char *tag; + int first_tag = 1; + +- notmuch_query_set_omit_excluded_messages (query, TRUE); + /* should the following only special case if no excluded terms + * specified? */ + +@@ -435,7 +429,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + output_t output = OUTPUT_SUMMARY; + int offset = 0; + int limit = -1; /* unlimited */ +- notmuch_bool_t no_exclude = FALSE; ++ notmuch_bool_t with_excluded = FALSE; + unsigned int i; + + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } +@@ -457,7 +451,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + { "files", OUTPUT_FILES }, + { "tags", OUTPUT_TAGS }, + { 0, 0 } } }, +- { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, ++ { NOTMUCH_OPT_BOOLEAN, &with_excluded, "with-excluded", 'd', 0 }, + { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, + { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, + { 0, 0, 0, 0, 0 } +@@ -505,7 +499,13 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + + notmuch_query_set_sort (query, sort); + +- if (!no_exclude) { ++ /* If we have --with-excluded we could use ++ * notmuch_query_set_with_excluded, but it is simpler not to set ++ * the exclude tags in the first place. The one exception is the ++ * summary output where we do need to use ++ * notmuch_query_set_with_excluded as we do want the counts to ++ * reflect the excludes. */ ++ if (!with_excluded || output == OUTPUT_SUMMARY) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + +@@ -513,6 +513,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + (config, &search_exclude_tags_length); + for (i = 0; i < search_exclude_tags_length; i++) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ if (output == OUTPUT_SUMMARY && with_excluded) ++ notmuch_query_set_with_excluded_messages (query, TRUE); + } + + switch (output) { +diff --git a/test/search b/test/search +index 081f60c..6d26f56 100755 +--- a/test/search ++++ b/test/search +@@ -136,8 +136,7 @@ generate_message '[subject]="Deleted"' + notmuch new > /dev/null + notmuch tag +deleted id:$gen_msg_id + output=$(notmuch search subject:deleted | notmuch_search_sanitize) +-test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +-thread:XXX 2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox unread)" ++test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)" + + test_begin_subtest "Exclude \"deleted\" messages from search, overridden" + output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize) +@@ -149,10 +148,10 @@ output=$(notmuch search subject:deleted | notmuch_search_sanitize) + test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) + thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" + +-test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude specified" +-output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize) ++test_begin_subtest "Don't exclude \"deleted\" messages when --with-excluded specified" ++output=$(notmuch search --with-excluded subject:deleted | notmuch_search_sanitize) + test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +-thread:XXX 2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)" ++thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" + + test_begin_subtest "Don't exclude \"deleted\" messages from search if not configured" + notmuch config set search.exclude_tags +-- +1.7.2.3 +