--- /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 2EC7F429E28\r
+ for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:31 -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 1XIOvgC1VpWy for <notmuch@notmuchmail.org>;\r
+ Sat, 28 Jan 2012 16:03:30 -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 37A63431FCF\r
+ for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:30 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id b10so2751672wer.26\r
+ for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 16:03:30 -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=nBzJtZ4zSaimCeB5V32DXI2qT7WcwbQ1JgB/R51C2Fc=;\r
+ b=DLgtkGwT2D2GK5OKOzvFDHUIIrauWarx+CjJqplROdrjZ8C8OTjno1fcny8Z0cVcxC\r
+ ZihHhRC3vuCVrGqYUhsLVpvny7VLS4cyPyjqM7p4CHzeFeaejLLZgeLPlR+Ib2tGvdob\r
+ jm/lbyEBR+bWXYQORCZIZ1+vtzlUnZhPJlT74=\r
+Received: by 10.216.135.15 with SMTP id t15mr5026561wei.3.1327795409956;\r
+ Sat, 28 Jan 2012 16:03:29 -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
+ l6sm20810344wiv.11.2012.01.28.16.03.28 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 28 Jan 2012 16:03:29 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ amdragon@MIT.EDU\r
+Subject: [PATCH 3/4] Add exclude flag\r
+Date: Sun, 29 Jan 2012 00:04:03 +0000\r
+Message-Id: <1327795444-18745-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <8739azqt2j.fsf@qmul.ac.uk>\r
+References: <8739azqt2j.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: Sun, 29 Jan 2012 00:03:31 -0000\r
+\r
+Add the exclude flag to notmuch_query_search_threads\r
+\r
+---\r
+ lib/notmuch-private.h | 17 +++++++++++------\r
+ lib/query.cc | 1 +\r
+ lib/thread.cc | 18 +++++++++++++++---\r
+ 3 files changed, 27 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index 7bf153e..56b87c6 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -211,12 +211,8 @@ _notmuch_directory_get_document_id (notmuch_directory_t *directory);\r
+ \r
+ /* thread.cc */\r
+ \r
+-notmuch_thread_t *\r
+-_notmuch_thread_create (void *ctx,\r
+- notmuch_database_t *notmuch,\r
+- unsigned int seed_doc_id,\r
+- notmuch_doc_id_set_t *match_set,\r
+- notmuch_sort_t sort);\r
++/* Definition of _notmuch_thread_create moved later since now uses\r
++ * string_list_t */\r
+ \r
+ /* message.cc */\r
+ \r
+@@ -401,6 +397,7 @@ typedef struct _notmuch_message_list {\r
+ */\r
+ struct visible _notmuch_messages {\r
+ notmuch_bool_t is_of_list_type;\r
++ notmuch_doc_id_set_t *excluded_doc_ids;\r
+ notmuch_message_node_t *iterator;\r
+ };\r
+ \r
+@@ -491,6 +488,14 @@ notmuch_filenames_t *\r
+ _notmuch_filenames_create (const void *ctx,\r
+ notmuch_string_list_t *list);\r
+ \r
++notmuch_thread_t *\r
++_notmuch_thread_create (void *ctx,\r
++ notmuch_database_t *notmuch,\r
++ unsigned int seed_doc_id,\r
++ notmuch_doc_id_set_t *match_set,\r
++ notmuch_string_list_t *excluded_terms,\r
++ notmuch_sort_t sort);\r
++\r
+ #pragma GCC visibility pop\r
+ \r
+ NOTMUCH_END_DECLS\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 8ffafe5..de95745 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -456,6 +456,7 @@ notmuch_threads_get (notmuch_threads_t *threads)\r
+ threads->query->notmuch,\r
+ doc_id,\r
+ &threads->match_set,\r
++ threads->query->exclude_terms,\r
+ threads->query->sort);\r
+ }\r
+ \r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 0435ee6..6d65d52 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,\r
+ */\r
+ static void\r
+ _thread_add_message (notmuch_thread_t *thread,\r
+- notmuch_message_t *message)\r
++ notmuch_message_t *message,\r
++ notmuch_string_list_t *exclude_terms)\r
+ {\r
+ notmuch_tags_t *tags;\r
+ const char *tag;\r
+@@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,\r
+ notmuch_tags_move_to_next (tags))\r
+ {\r
+ tag = notmuch_tags_get (tags);\r
++ /* mark excluded messages */\r
++ for (notmuch_string_node_t *term = exclude_terms->head; term;\r
++ term = term->next) {\r
++ /* we ignore initial 'K' */\r
++ if (strcmp(tag, (term->string + 1)) == 0) {\r
++ notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
++ break;\r
++ }\r
++ }\r
+ g_hash_table_insert (thread->tags, xstrdup (tag), NULL);\r
+ }\r
+ }\r
+@@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+ _thread_set_subject_from_message (thread, message);\r
+ }\r
+ \r
+- thread->matched_messages++;\r
++ if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))\r
++ thread->matched_messages++;\r
+ \r
+ if (g_hash_table_lookup_extended (thread->message_hash,\r
+ notmuch_message_get_message_id (message), NULL,\r
+@@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,\r
+ notmuch_database_t *notmuch,\r
+ unsigned int seed_doc_id,\r
+ notmuch_doc_id_set_t *match_set,\r
++ notmuch_string_list_t *exclude_terms,\r
+ notmuch_sort_t sort)\r
+ {\r
+ notmuch_thread_t *thread;\r
+@@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,\r
+ if (doc_id == seed_doc_id)\r
+ message = seed_message;\r
+ \r
+- _thread_add_message (thread, message);\r
++ _thread_add_message (thread, message, exclude_terms);\r
+ \r
+ if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {\r
+ _notmuch_doc_id_set_remove (match_set, doc_id);\r
+-- \r
+1.7.2.3\r
+\r