--- /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 38B4F431FDB\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:38 -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 FRR3kzRwo01z for <notmuch@notmuchmail.org>;\r
+ Thu, 2 Feb 2012 09:43:37 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ C4B65429E29 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:18 -0800\r
+ (PST)\r
+Received: by mail-ww0-f45.google.com with SMTP id dt12so2522817wgb.2\r
+ for <notmuch@notmuchmail.org>; Thu, 02 Feb 2012 09:43: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=O97wCa0n7XsK6R6wcr4EphxC/rgAff6CB3dulJaU7Ns=;\r
+ b=PNUpNBzjfIDsUCqOOsagne/SDF5xz27y9zTFg0emwlSHRwmagg9JTyMqbJVlFzwG14\r
+ nOeesn5hqWKK3J3q6ZxjF50JyBUOsXrQCwtu1Ugyh4dQ385KSrHaBSBPdOwFnDuoM72F\r
+ SHNRCRVRGlL4TUPC8bF15awpG8LY9cWo7XdrU=\r
+Received: by 10.180.100.228 with SMTP id fb4mr6263865wib.1.1328204598461;\r
+ Thu, 02 Feb 2012 09:43: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
+ q2sm1127404wiy.7.2012.02.02.09.43.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu,\r
+ 02 Feb 2012 09:43:17 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ amdragon@MIT.EDU\r
+Subject: [PATCH v4 10/11] cli: omit excluded messages in results where\r
+ appropriate.\r
+Date: Thu, 2 Feb 2012 17:43:38 +0000\r
+Message-Id: <1328204619-25046-10-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <874nv9rv79.fsf@qmul.ac.uk>\r
+References: <874nv9rv79.fsf@qmul.ac.uk>\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, 02 Feb 2012 17:43:38 -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 | 5 +++++\r
+ 3 files changed, 16 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 108f13b..924e7ea 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1166,6 +1166,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 (mbox)\r
++ notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+ /* if part was requested and format was not specified, use format=raw */\r
+ if (params.part >= 0 && !format_specified)\r
+ format = &format_raw;\r
+-- \r
+1.7.2.3\r
+\r