--- /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 3495441ED88\r
+ for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 01:03:21 -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 Z9AV2aQQFUdO for <notmuch@notmuchmail.org>;\r
+ Wed, 15 Feb 2012 01:03:19 -0800 (PST)\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 C9FEC431E82\r
+ for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 01:03:18 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id p13so603332wer.26\r
+ for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 01:03:18 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=W5gWFpKFDk0cYcvFsue3qkq4xkV12E+Ahl6I/T4aQRk=;\r
+ b=HmL5g3pKdziCFkbNMDO7r69bsXcWi0oz2r2CBfkTqyES5tAakJ/ie8f7szGK2xxtNU\r
+ ho05mbQbC7eXTEQpzUcVL/SgA9KIUIRWCXz8ricjhqRJpnMlnBxNloMdSD5OgslBL8MK\r
+ u9KCXtRvgDOPLxubxm/6t0lYgmGVw0OGkpgRk=\r
+Received: by 10.180.82.39 with SMTP id f7mr33843586wiy.19.1329296598586;\r
+ Wed, 15 Feb 2012 01:03:18 -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
+ s8sm32092059wiz.8.2012.02.15.01.03.17 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 15 Feb 2012 01:03:17 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH v5 10/11] cli: omit excluded messages in results where\r
+ appropriate.\r
+Date: Wed, 15 Feb 2012 09:03:38 +0000\r
+Message-Id: <1329296619-7463-11-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1329296619-7463-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1329296619-7463-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: Wed, 15 Feb 2012 09:03:21 -0000\r
+\r
+In all cases of notmuch count/search/show where the results returned\r
+cannot reflect the exclude flag return just the matched not-excluded\r
+results. If the caller wishes to have all the matched results (i.e.,\r
+including the excluded ones) they should call with the\r
+--no-exclude option.\r
+\r
+The relevant cases are\r
+ count: both threads and messages\r
+ search: all cases except the summary view\r
+ show: mbox format\r
+---\r
+ notmuch-count.c | 2 ++\r
+ notmuch-search.c | 9 +++++++++\r
+ notmuch-show.c | 6 ++++++\r
+ 3 files changed, 17 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 5364507..46b76ae 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -88,6 +88,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+ notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
+ }\r
+ \r
++ notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+ switch (output) {\r
+ case OUTPUT_MESSAGES:\r
+ printf ("%u\n", notmuch_query_count_messages (query));\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 43ec90b..d2b2488 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -207,6 +207,9 @@ 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
+@@ -297,6 +300,8 @@ 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
+@@ -368,6 +373,10 @@ 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
+ /* Special-case query of "*" for better performance. */\r
+ if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {\r
+ tags = notmuch_database_get_all_tags (notmuch);\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 2a634e9..17a4ec6 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1080,6 +1080,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");\r
+ return 1;\r
+ }\r
++\r
+ format = &format_mbox;\r
+ break;\r
+ case NOTMUCH_FORMAT_RAW:\r
+@@ -1137,6 +1138,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ return 1;\r
+ }\r
+ \r
++ /* if format=mbox then we can not output excluded messages as\r
++ * there is no way to make the exclude flag available */\r
++ if (format_sel == NOTMUCH_FORMAT_MBOX)\r
++ notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+ /* If a single message is requested we do not use search_excludes. */\r
+ if (params.part >= 0)\r
+ ret = do_show_single (ctx, query, format, ¶ms);\r
+-- \r
+1.7.2.3\r
+\r