--- /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 91972429E32\r
+ for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:05:30 -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 NJM1TvCOaKfN for <notmuch@notmuchmail.org>;\r
+ Sat, 25 Feb 2012 19:05:27 -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
+ E7FE1414FAA for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:45:55 -0800\r
+ (PST)\r
+Received: by wgbdt12 with SMTP id dt12so2776876wgb.2\r
+ for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:45:54 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
+ 10.180.24.202 as permitted sender) client-ip=10.180.24.202; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+ markwalters1009@gmail.com designates 10.180.24.202 as permitted\r
+ sender) smtp.mail=markwalters1009@gmail.com;\r
+ dkim=pass header.i=markwalters1009@gmail.com\r
+Received: from mr.google.com ([10.180.24.202])\r
+ by 10.180.24.202 with SMTP id w10mr16925309wif.9.1330224354651\r
+ (num_hops = 1); Sat, 25 Feb 2012 18:45:54 -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;\r
+ bh=GyxPT6pttOhARConHN6ybITkA2WDBdn86+5vr+/jcYM=;\r
+ b=kRGgYc/65j4Vg1u7zzNtgEv/s4WzGW9NFUbbKICZ0QtWdzPxpx6dzDmqQAgF6nzHuv\r
+ gdGtOZ/cPgbnwc7eDAJTgOCRPM3efv2sqXy8NKBzx1dAz/APNRMX8OOtswu/2KDaQFPF\r
+ CPjHpgEZwfT+pUIiVrxmAkiU/a4HDYPmS6IIU=\r
+Received: by 10.180.24.202 with SMTP id w10mr9232867wif.9.1330157124526;\r
+ Sat, 25 Feb 2012 00:05:24 -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
+ s4sm13024346wiy.5.2012.02.25.00.05.22 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 25 Feb 2012 00:05:23 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ Austin Clements <amdragon@MIT.EDU>\r
+Subject: [Patch v6 00/13] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag\r
+Date: Sat, 25 Feb 2012 08:06:31 +0000\r
+Message-Id: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\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: Sun, 26 Feb 2012 03:05:30 -0000\r
+\r
+\r
+Here is the latest version of the series. It fixes all of Austin's\r
+review comments. I don't think there are any significant outstanding\r
+issues.\r
+\r
+Having asked whether excluded messages should still be marked excluded\r
+when the tag is explicitly mentioned in the query I realised that they\r
+must not be marked. If they are then the front end cannot distinguish\r
+messages that are excluded because they match the tag the user has\r
+said they do not care about (eg tag:deleted), or excluded because they\r
+match some other excluded tag (eg tag:spam).\r
+\r
+I have also updated the test for search since the matching only in an\r
+excluded message thread is now returned but the "match count" is zero\r
+so the frontend cannot ignore it if it wishes.\r
+\r
+Finally, I updated notmuch.el so that it throws away threads with zero\r
+matches. As mentioned in the commit comment there are better\r
+possibilities but this is a minimal change (it is a 1 line patch\r
+except for indentation).\r
+\r
+The total changes from v5 are:\r
+ \r
+ Three changes of search_exclude_tags to search.exclude_tags in the\r
+ man pages. (one in each of count/show and search).\r
+\r
+ Changed the talloc context of the excluded messages to message\r
+ rather than query.\r
+\r
+ Corrected an indentation error (8 spaces instead of a tab)\r
+ \r
+ Moved a test patch earlier in the series (next to its\r
+ corresponding change); no change overall.\r
+\r
+ Fixed the search test.\r
+ \r
+ Remove exclude tags that occur in the query from the list of\r
+ exclude tags so that the messages do not get marked excluded.\r
+\r
+ Make notmuch.el drop results with no matching non-excluded\r
+ messages.\r
+\r
+The diff from v5 is at the end of this cover letter.\r
+\r
+Best wishes \r
+\r
+Mark\r
+\r
+\r
+Mark Walters (13):\r
+ cli: add --no-exclude option to count and search.\r
+ cli: Add --no-exclude to the man pages for search and count\r
+ test: add tests for new cli --no-exclude option\r
+ lib: Rearrange the exclude code in query.cc\r
+ lib: Make notmuch_query_search_messages set the exclude flag\r
+ lib: Add the exclude flag to notmuch_query_search_threads\r
+ test: update search test to reflect exclude flag\r
+ cli: Make notmuch-show respect excludes.\r
+ test: update tests to reflect the exclude flag\r
+ man: update manpage for notmuch-show --no-exclude option\r
+ cli: omit excluded messages in results where appropriate.\r
+ emacs: show: recognize the exclude flag.\r
+ emacs: notmuch.el ignore excluded matches\r
+\r
+ emacs/notmuch-show.el | 19 ++++++++++-\r
+ emacs/notmuch.el | 22 +++++++------\r
+ lib/notmuch-private.h | 8 +++-\r
+ lib/notmuch.h | 16 +++++++--\r
+ lib/query.cc | 77 +++++++++++++++++++++++++++++++++++++++------\r
+ lib/thread.cc | 18 +++++++++--\r
+ man/man1/notmuch-count.1 | 7 ++++\r
+ man/man1/notmuch-search.1 | 7 ++++\r
+ man/man1/notmuch-show.1 | 7 ++++\r
+ notmuch-count.c | 19 +++++++---\r
+ notmuch-search.c | 26 ++++++++++++---\r
+ notmuch-show.c | 31 ++++++++++++++++--\r
+ test/count | 21 ++++++++++++\r
+ test/crypto | 9 +++++-\r
+ test/encoding | 2 +-\r
+ test/json | 6 ++--\r
+ test/maildir-sync | 1 +\r
+ test/multipart | 4 +-\r
+ test/search | 8 ++++-\r
+ test/thread-naming | 16 +++++-----\r
+ 20 files changed, 263 insertions(+), 61 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 5b4f1c5..8b209cd 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -865,16 +865,18 @@ non-authors is found, assume that all of the authors match."\r
+ (goto-char (point-max))\r
+ (if (/= (match-beginning 1) line)\r
+ (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n")))\r
+- (let ((beg (point)))\r
+- (notmuch-search-show-result date count authors\r
+- (notmuch-prettify-subject subject) tags)\r
+- (notmuch-search-color-line beg (point) tag-list)\r
+- (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
+- (put-text-property beg (point) 'notmuch-search-authors authors)\r
+- (put-text-property beg (point) 'notmuch-search-subject subject)\r
+- (when (string= thread-id notmuch-search-target-thread)\r
+- (set 'found-target beg)\r
+- (set 'notmuch-search-target-thread "found")))\r
++ ;; We currently just throw away excluded matches.\r
++ (unless (eq (aref count 1) ?0)\r
++ (let ((beg (point)))\r
++ (notmuch-search-show-result date count authors\r
++ (notmuch-prettify-subject subject) tags)\r
++ (notmuch-search-color-line beg (point) tag-list)\r
++ (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
++ (put-text-property beg (point) 'notmuch-search-authors authors)\r
++ (put-text-property beg (point) 'notmuch-search-subject subject)\r
++ (when (string= thread-id notmuch-search-target-thread)\r
++ (set 'found-target beg)\r
++ (set 'notmuch-search-target-thread "found"))))\r
+ (set 'line (match-end 0)))\r
+ (set 'more nil)\r
+ (while (and (< line (length string)) (= (elt string line) ?\n))\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index e1c3977..ab18fbc 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -139,8 +139,9 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages)\r
+ \r
+ /* Return a query that matches messages with the excluded tags\r
+ * registered with query. Any tags that explicitly appear in xquery\r
+- * will not be excluded. The caller of this function has to combine\r
+- * the returned query appropriately.*/\r
++ * will not be excluded, and will be removed from the list of exclude\r
++ * tags. The caller of this function has to combine the returned\r
++ * query appropriately.*/\r
+ static Xapian::Query\r
+ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
+ {\r
+@@ -157,6 +158,8 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
+ if (it == end)\r
+ exclude_query = Xapian::Query (Xapian::Query::OP_OR,\r
+ exclude_query, Xapian::Query (term->string));\r
++ else\r
++ term->string = talloc_strdup (query, "");\r
+ }\r
+ return exclude_query;\r
+ }\r
+@@ -228,7 +231,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
+ unsigned int doc_id = *iterator;\r
+ g_array_append_val (excluded_doc_ids, doc_id);\r
+ }\r
+- messages->base.excluded_doc_ids = talloc (query, _notmuch_doc_id_set);\r
++ messages->base.excluded_doc_ids = talloc (messages, _notmuch_doc_id_set);\r
+ _notmuch_doc_id_set_init (query, messages->base.excluded_doc_ids,\r
+ excluded_doc_ids);\r
+ g_array_unref (excluded_doc_ids);\r
+diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1\r
+index 413b405..97972a7 100644\r
+--- a/man/man1/notmuch-count.1\r
++++ b/man/man1/notmuch-count.1\r
+@@ -43,7 +43,7 @@ Output the number of matching threads.\r
+ .TP 4\r
+ .BR \-\-no\-exclude\r
+ \r
+-Do not exclude the messages matching search_exclude_tags in the config file.\r
++Do not exclude the messages matching search.exclude_tags in the config file.\r
+ .RE\r
+ .RE\r
+ .RE\r
+diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1\r
+index bc54b4d..f2e5a38 100644\r
+--- a/man/man1/notmuch-search.1\r
++++ b/man/man1/notmuch-search.1\r
+@@ -116,7 +116,7 @@ Limit the number of displayed results to N.\r
+ .TP 4\r
+ .BR \-\-no\-exclude\r
+ \r
+-Do not exclude the messages matching search_exclude_tags in the config file.\r
++Do not exclude the messages matching search.exclude_tags in the config file.\r
+ .RE\r
+ \r
+ .SH SEE ALSO\r
+diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1\r
+index f743a53..8383a05 100644\r
+--- a/man/man1/notmuch-show.1\r
++++ b/man/man1/notmuch-show.1\r
+@@ -132,7 +132,7 @@ content.\r
+ .TP 4\r
+ .B \-\-no-exclude\r
+ \r
+-Do not exclude the messages matching search_exclude_tags in the config file.\r
++Do not exclude the messages matching search.exclude_tags in the config file.\r
+ .RE\r
+ \r
+ A common use of\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index d2b2488..61c65e5 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -454,7 +454,7 @@ 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_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
+ { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+ { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+diff --git a/test/search b/test/search\r
+index 3da5d17..081f60c 100755\r
+--- a/test/search\r
++++ b/test/search\r
+@@ -136,7 +136,8 @@ generate_message '[subject]="Deleted"'\r
+ notmuch new > /dev/null\r
+ notmuch tag +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
++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
+ \r
+ test_begin_subtest "Exclude \"deleted\" messages from search, overridden"\r
+ output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize)\r