--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 2FAE0431FB6\r
+ for <notmuch@notmuchmail.org>; Fri, 21 Jun 2013 04:00:15 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\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 ANE+3NO6YFQh for <notmuch@notmuchmail.org>;\r
+ Fri, 21 Jun 2013 04:00:08 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 845CE431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 21 Jun 2013 04:00:08 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 4FB66100033;\r
+ Fri, 21 Jun 2013 13:59:57 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3 7/8] lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t\r
+In-Reply-To: <87fvwdx19x.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> <87fvwdx19x.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.15.2+181~gfb53171 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Fri, 21 Jun 2013 13:59:57 +0300\r
+Message-ID: <m2txkrk9ua.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Fri, 21 Jun 2013 11:00:15 -0000\r
+\r
+On Thu, Jun 20 2013, Mark Walters <markwalters1009@gmail.com> wrote:\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
+So, the choice here is to choose between\r
+\r
+id:"1368454815-1854-1-git-send-email-novalazy@gmail.com"\r
+and\r
+id:"87bo8edif8.fsf@qmul.ac.uk" \r
+\r
+(might be hard to catch from this thread -- was easier to take from\r
+http://nmbug.tethera.net/status/ )\r
+\r
+Both apply cleanly to current master ( d0bd88f )\r
+\r
+While Peter's version surely looks simpler (and may work, didn't test atm)\r
+the comments Mark presents makes sense (especially the "subtlety" thing ;)\r
+\r
+IMHO Mark's version makes future development "safer" and therefore my\r
+vote (or million of those) goes to id:"87bo8edif8.fsf@qmul.ac.uk"\r
+\r
+> Best wishes\r
+>\r
+> Mark\r
+\r
+Tomi\r
+\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r