--- /dev/null
+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 25345431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:21 -0700 (PDT)\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 BJ1UZ2NHUiRu for <notmuch@notmuchmail.org>;\r
+ Thu, 15 Mar 2012 11:42:18 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A2AA9431E62\r
+ for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:16 -0700 (PDT)\r
+Received: by mail-we0-f181.google.com with SMTP id m13so3528469wer.26\r
+ for <notmuch@notmuchmail.org>; Thu, 15 Mar 2012 11:42:16 -0700 (PDT)\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=hT1hrr94WGX1539QJetu5XO8XpS8WNqFx8L+w0uwasc=;\r
+ b=KJM07sj5lIAH2npw1d44yqF0VZPB27xZOhsBbcOnm0rUnOFFmjtwZHg4ofF6epxIvv\r
+ XdW1wodCgJ1fJQ/k65udInAgyN+FV+A4cSMDSNu1TU283w8a6gkRiReEnxPlEP9QzNTV\r
+ n+5THlxrCMYeMaVsE9UpJg+aS0/fGXRpCL0OKI3ovLyvK05kU4zdp6mzyUGqJ74R+Z6C\r
+ KfyDdOpmvN5kSLzhVDVFsocSvMSu6ceHb53SKM9AQXMiLqSghDiBpUXgwiNEJX5KgH/b\r
+ 6NiU9FkiwGJ5IIMSSimoA6lcM7uEgxp827kcVxZmVntvYkWkwWliPiDQdr0UtEGagrd3\r
+ cVsQ==\r
+Received: by 10.216.134.2 with SMTP id r2mr4737610wei.31.1331836936311;\r
+ Thu, 15 Mar 2012 11:42:16 -0700 (PDT)\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
+ fw5sm7088634wib.0.2012.03.15.11.42.15 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Thu, 15 Mar 2012 11:42:15 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/5] cli: move search to the new --exclude= naming scheme.\r
+Date: Thu, 15 Mar 2012 18:42:03 +0000\r
+Message-Id: <1331836925-31437-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1331836925-31437-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1331836925-31437-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: Thu, 15 Mar 2012 18:42:21 -0000\r
+\r
+This commit replaces the --no-exclude option with a\r
+--exclude=(true|false|flag) option. The default is to omit the\r
+excluded messages.\r
+\r
+The flag option only makes sense if output=summary (as otherwise there\r
+is nowhere to print the flag). In summary output exclude=false and\r
+exclude=flag give almost identical output:\r
+they differ in that with the exclude=flag option the match count\r
+(i.e., the x in [x/n] in the output) is the number of matching\r
+non-excluded messages rather than the number of matching messages.\r
+\r
+Note this changes the default for output=summary when no --exclude=\r
+option is given: it used to default to flag and now defaults to true\r
+(i.e. omit excluded messages). This is neccesary to keep the cli\r
+output uncluttered and for speed reasons.\r
+---\r
+ man/man1/notmuch-search.1 | 12 +++++++++---\r
+ notmuch-search.c | 32 +++++++++++++++++++++++---------\r
+ test/search | 13 ++++++-------\r
+ 3 files changed, 38 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1\r
+index 8426aa3..49fbd0d 100644\r
+--- a/man/man1/notmuch-search.1\r
++++ b/man/man1/notmuch-search.1\r
+@@ -114,9 +114,15 @@ Limit the number of displayed results to N.\r
+ \r
+ .RS 4\r
+ .TP 4\r
+-.BR \-\-no\-exclude\r
+-\r
+-Do not exclude the messages matching search.exclude_tags in the config file.\r
++.BR \-\-exclude=(true|false|flag)\r
++\r
++Specify whether to omit messages matching search.tag_exclude from the\r
++search results (the default) or not. The extra option\r
++.B flag\r
++only has an effect when\r
++.B --output=summary\r
++In this case all matching threads are returned but the "match count"\r
++is the number of matching non-excluded messages in the thread.\r
+ .RE\r
+ \r
+ .SH SEE ALSO\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index f6061e4..fe18a93 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
+@@ -422,6 +416,12 @@ do_search_tags (notmuch_database_t *notmuch,\r
+ return 0;\r
+ }\r
+ \r
++enum {\r
++ EXCLUDE_TRUE,\r
++ EXCLUDE_FALSE,\r
++ EXCLUDE_FLAG,\r
++};\r
++\r
+ int\r
+ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ {\r
+@@ -435,7 +435,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
++ int exclude = EXCLUDE_TRUE;\r
+ unsigned int i;\r
+ \r
+ enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
+@@ -457,7 +457,11 @@ 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_KEYWORD, &exclude, "exclude", 'x',\r
++ (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
++ { "false", EXCLUDE_FALSE },\r
++ { "flag", EXCLUDE_FLAG },\r
++ { 0, 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 +509,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ \r
+ notmuch_query_set_sort (query, sort);\r
+ \r
+- if (!no_exclude) {\r
++ if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) {\r
++ /* if we are not doing summary output there is no where to\r
++ * print the excluded flag so fall back on including the\r
++ * excluded messages */\r
++ fprintf (stderr, "Cannot flag excluded messages with this output: fall back on just including them\n");\r
++ exclude = EXCLUDE_FALSE;\r
++ }\r
++\r
++ if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) {\r
+ const char **search_exclude_tags;\r
+ size_t search_exclude_tags_length;\r
+ \r
+@@ -513,6 +525,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 (exclude == EXCLUDE_FLAG)\r
++ notmuch_query_set_omit_excluded_messages (query, FALSE);\r
+ }\r
+ \r
+ switch (output) {\r
+diff --git a/test/search b/test/search\r
+index 17af6a2..318fdb8 100755\r
+--- a/test/search\r
++++ b/test/search\r
+@@ -138,15 +138,14 @@ notmuch new > /dev/null\r
+ notmuch tag +deleted id:$gen_msg_id\r
+ 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 message search"\r
+ output=$(notmuch search --output=messages subject:deleted | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "id:$not_deleted_id"\r
+ \r
+-test_begin_subtest "Exclude \"deleted\" messages from message search (no-exclude)"\r
+-output=$(notmuch search --no-exclude --output=messages subject:deleted | notmuch_search_sanitize)\r
++test_begin_subtest "Exclude \"deleted\" messages from message search --exclude=false"\r
++output=$(notmuch search --exclude=false --output=messages subject:deleted | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "id:$not_deleted_id\r
+ id:$deleted_id"\r
+ \r
+@@ -166,10 +165,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 --exclude=flag specified"\r
++output=$(notmuch search --exclude=flag 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.9.1\r
+\r