[PATCH 3/5] cli: move search to the new --with-excluded naming scheme.
authorMark Walters <markwalters1009@gmail.com>
Sat, 3 Mar 2012 13:05:16 +0000 (13:05 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:12 +0000 (09:45 -0800)
3f/4683e44d0aacdc9464cacd8925b0f0be0f6ecb [new file with mode: 0644]

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