--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 0CE1F431FB6\r
+ for <notmuch@notmuchmail.org>; Wed, 19 Jun 2013 14:02:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.401\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.401 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ FREEMAIL_REPLY=2.499, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3]\r
+ 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 KLLfK6sD0wdB for <notmuch@notmuchmail.org>;\r
+ Wed, 19 Jun 2013 14:02:11 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id EAE59431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 19 Jun 2013 14:02:10 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1UpPW1-0002BS-GG; Wed, 19 Jun 2013 22:02:06 +0100\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1UpPW0-0002J9-MC; Wed, 19 Jun 2013 22:02:05 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3 7/8] lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t\r
+In-Reply-To: <87bo8edif8.fsf@qmul.ac.uk>\r
+References: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com>\r
+ <1368301809-12532-8-git-send-email-markwalters1009@gmail.com>\r
+ <87bo8edif8.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.15.2+171~ge2f30a2 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Wed, 19 Jun 2013 22:02:02 +0100\r
+Message-ID: <87fvwdx19x.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 1b03f602faee308225184f651c57fe55 (of first 20000 bytes)\r
+X-SpamAssassin-Score: 0.6\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored 0.6 points. Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * 1.0 FREEMAIL_REPLY From and body contain different freemails\r
+ * -0.4 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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, 19 Jun 2013 21:02:19 -0000\r
+\r
+\r
+I think we should decide before 0.16 whether to go with this patch and\r
+patch 8/8 or for Peter's suggestion at\r
+id:1368454815-1854-1-git-send-email-novalazy@gmail.com\r
+\r
+Now we have an enum for the NOTMUCH_EXCLUDE possibilities (rather than a\r
+bool) I think it makes sense to implement NOTMUCH_EXCLUDE_FALSE properly\r
+but I am happy with either choice.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+On Mon, 13 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can\r
+> cover all four values of search --exclude in the cli.\r
+>\r
+> Previously the way to avoid any message being marked excluded was to\r
+> pass in an empty list of excluded tags: since we now have an explicit\r
+> option we might as well honour it.\r
+>\r
+> The enum is in a slightly strange order as the existing FALSE/TRUE\r
+> options correspond to the new\r
+> NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do\r
+> not need to bump the version number.\r
+>\r
+> Indeed, an example of this is that the cli count and show still use\r
+> FALSE/TRUE and still work.\r
+> ---\r
+>\r
+> This is a new version of this single patch. In Peter's version\r
+> NOTMUCH_EXCLUDE_FLAG and NOTMUCH_EXCLUDE_FALSE were treated as synonyms:\r
+> this makes them behave in the obvious way and documents them.\r
+>\r
+> I think the only subtlety is the enum order mentioned in the commit\r
+> message. Additionally it would be good to update cli count and show and,\r
+> at for the latter, it would be good to add an option exclude=all too (so\r
+> excluded messages are completely omitted). Those should both be simple\r
+> but we need to decide whether to allow all four options\r
+> (false/flag/true/all) always or not. Always allowing all 4 is nicely\r
+> consistent but sometimes redundant. Additionally we would need some\r
+> tests.\r
+>\r
+> I think this patch should go in with the main series as I think it is\r
+> worth reserving the NOTMUCH_EXCLUDE_FALSE #define/value so that we don't\r
+> break code in future if we do wish to add it.\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+>\r
+> \r
+> lib/notmuch.h | 18 ++++++++++++++++--\r
+> lib/query.cc | 8 +++++---\r
+> lib/thread.cc | 28 +++++++++++++++-------------\r
+> notmuch-search.c | 2 +-\r
+> 4 files changed, 37 insertions(+), 19 deletions(-)\r
+>\r
+> diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> index 27b43ff..73c85a4 100644\r
+> --- a/lib/notmuch.h\r
+> +++ b/lib/notmuch.h\r
+> @@ -500,10 +500,15 @@ typedef enum {\r
+> const char *\r
+> notmuch_query_get_query_string (notmuch_query_t *query);\r
+> \r
+> -/* Exclude values for notmuch_query_set_omit_excluded */\r
+> +/* Exclude values for notmuch_query_set_omit_excluded. The strange\r
+> + * order is to maintain backward compatibility: the old FALSE/TRUE\r
+> + * options correspond to the new\r
+> + * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.\r
+> + */\r
+> typedef enum {\r
+> - NOTMUCH_EXCLUDE_FALSE,\r
+> + NOTMUCH_EXCLUDE_FLAG,\r
+> NOTMUCH_EXCLUDE_TRUE,\r
+> + NOTMUCH_EXCLUDE_FALSE,\r
+> NOTMUCH_EXCLUDE_ALL\r
+> } notmuch_exclude_t;\r
+> \r
+> @@ -517,6 +522,15 @@ typedef enum {\r
+> * match in at least one non-excluded message. Otherwise, if set to ALL,\r
+> * notmuch_query_search_threads will omit excluded messages from all threads.\r
+> *\r
+> + * If set to FALSE or FLAG then both notmuch_query_search_messages and\r
+> + * notmuch_query_search_threads will return all matching\r
+> + * messages/threads regardless of exclude status. If set to FLAG then\r
+> + * the exclude flag will be set for any excluded message that is\r
+> + * returned by notmuch_query_search_messages, and the thread counts\r
+> + * for threads returned by notmuch_query_search_threads will be the\r
+> + * number of non-excluded messages/matches. Otherwise, if set to\r
+> + * FALSE, then the exclude status is completely ignored.\r
+> + *\r
+> * The performance difference when calling\r
+> * notmuch_query_search_messages should be relatively small (and both\r
+> * should be very fast). However, in some cases,\r
+> diff --git a/lib/query.cc b/lib/query.cc\r
+> index 1cc768f..69668a4 100644\r
+> --- a/lib/query.cc\r
+> +++ b/lib/query.cc\r
+> @@ -218,13 +218,15 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
+> }\r
+> messages->base.excluded_doc_ids = NULL;\r
+> \r
+> - if (query->exclude_terms) {\r
+> + if ((query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) && (query->exclude_terms)) {\r
+> exclude_query = _notmuch_exclude_tags (query, final_query);\r
+> \r
+> - if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE)\r
+> + if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE ||\r
+> + query->omit_excluded == NOTMUCH_EXCLUDE_ALL)\r
+> + {\r
+> final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
+> final_query, exclude_query);\r
+> - else {\r
+> + } else { /* NOTMUCH_EXCLUDE_FLAG */\r
+> exclude_query = Xapian::Query (Xapian::Query::OP_AND,\r
+> exclude_query, final_query);\r
+> \r
+> diff --git a/lib/thread.cc b/lib/thread.cc\r
+> index bc07877..4dcf705 100644\r
+> --- a/lib/thread.cc\r
+> +++ b/lib/thread.cc\r
+> @@ -238,20 +238,22 @@ _thread_add_message (notmuch_thread_t *thread,\r
+> char *clean_author;\r
+> notmuch_bool_t message_excluded = FALSE;\r
+> \r
+> - for (tags = notmuch_message_get_tags (message);\r
+> - notmuch_tags_valid (tags);\r
+> - notmuch_tags_move_to_next (tags))\r
+> - {\r
+> - tag = notmuch_tags_get (tags);\r
+> - /* Is message excluded? */\r
+> - for (notmuch_string_node_t *term = exclude_terms->head;\r
+> - term != NULL;\r
+> - term = term->next)\r
+> + if (omit_exclude != NOTMUCH_EXCLUDE_FALSE) {\r
+> + for (tags = notmuch_message_get_tags (message);\r
+> + notmuch_tags_valid (tags);\r
+> + notmuch_tags_move_to_next (tags))\r
+> {\r
+> - /* We ignore initial 'K'. */\r
+> - if (strcmp(tag, (term->string + 1)) == 0) {\r
+> - message_excluded = TRUE;\r
+> - break;\r
+> + tag = notmuch_tags_get (tags);\r
+> + /* Is message excluded? */\r
+> + for (notmuch_string_node_t *term = exclude_terms->head;\r
+> + term != NULL;\r
+> + term = term->next)\r
+> + {\r
+> + /* We ignore initial 'K'. */\r
+> + if (strcmp(tag, (term->string + 1)) == 0) {\r
+> + message_excluded = TRUE;\r
+> + break;\r
+> + }\r
+> }\r
+> }\r
+> }\r
+> diff --git a/notmuch-search.c b/notmuch-search.c\r
+> index 4323201..a20791a 100644\r
+> --- a/notmuch-search.c\r
+> +++ b/notmuch-search.c\r
+> @@ -411,7 +411,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\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 (query, NOTMUCH_EXCLUDE_FALSE);\r
+> + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG);\r
+> if (exclude == EXCLUDE_ALL)\r
+> notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);\r
+> }\r
+> -- \r
+> 1.7.9.1\r