[RFC PATCH 3/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag
authorMark Walters <markwalters1009@gmail.com>
Tue, 24 Jan 2012 01:18:42 +0000 (01:18 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:05 +0000 (09:43 -0800)
4c/ae2f22e775917f3832e177780d400e72b65248 [new file with mode: 0644]

diff --git a/4c/ae2f22e775917f3832e177780d400e72b65248 b/4c/ae2f22e775917f3832e177780d400e72b65248
new file mode 100644 (file)
index 0000000..f228fe8
--- /dev/null
@@ -0,0 +1,201 @@
+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 0F314429E5B\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:18:05 -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 7W1WURL22POg for <notmuch@notmuchmail.org>;\r
+       Mon, 23 Jan 2012 17:18:04 -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 16865429E21\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:18:03 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id b10so3021166wer.26\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:18:03 -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=b5Y71ehYOoKb21r8nlMS0pwVs0cFF3DGqhex70sZZTc=;\r
+       b=syj9InI3ddjkpN7H+btzohd/NvenxlWsK+hek0eW8VDYSDGtQmp1ZZIBwTjLAJ1j1w\r
+       LsmI3SKbub4kYMegHQDInn4fjZU3qgie4VY5jJWSZqoD8HzYbHAh/CPT/nQq48soMVV/\r
+       5Etf5AhCXk/ghP+sgdPkjX0JeadT6TQbtE/i0=\r
+Received: by 10.216.138.101 with SMTP id z79mr31918wei.7.1327367883800;\r
+       Mon, 23 Jan 2012 17:18:03 -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
+ hc10sm12828949wib.8.2012.01.23.17.18.02       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 23 Jan 2012 17:18:02 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+       Austin Clements <amdragon@MIT.EDU>\r
+Subject: [RFC PATCH 3/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag\r
+Date: Tue, 24 Jan 2012 01:18:42 +0000\r
+Message-Id: <1327367923-18228-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <20120124011609.GX16740@mit.edu>\r
+References: <20120124011609.GX16740@mit.edu>\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: Tue, 24 Jan 2012 01:18:05 -0000\r
+\r
+Add the actual NOTMUCH_MESSAGE_FLAG_EXCLUDED flag.\r
+\r
+---\r
+ lib/notmuch-private.h |    1 +\r
+ lib/notmuch.h         |    3 ++-\r
+ lib/query.cc          |   11 +++++++----\r
+ lib/thread.cc         |   14 ++++++++++----\r
+ 4 files changed, 20 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index e791bb0..cb3eca6 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -216,6 +216,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_doc_id_set_t *excluded_doc_ids,\r
+                       notmuch_sort_t sort);\r
\r
+ /* message.cc */\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 7929fe7..cf0d45d 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -895,7 +895,8 @@ notmuch_message_get_filenames (notmuch_message_t *message);\r
\r
+ /* Message flags */\r
+ typedef enum _notmuch_message_flag {\r
+-    NOTMUCH_MESSAGE_FLAG_MATCH\r
++    NOTMUCH_MESSAGE_FLAG_MATCH,\r
++    NOTMUCH_MESSAGE_FLAG_EXCLUDED\r
+ } notmuch_message_flag_t;\r
\r
+ /* Get a value of a flag for the email corresponding to 'message'. */\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 92fa834..69e32bd 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -55,6 +55,7 @@ struct visible _notmuch_threads {\r
+     /* The set of matched docid's that have not been assigned to a\r
+      * thread. Initially, this contains every docid in doc_ids. */\r
+     notmuch_doc_id_set_t match_set;\r
++    notmuch_doc_id_set_t *excluded_doc_ids;\r
+ };\r
\r
+ static notmuch_bool_t\r
+@@ -302,6 +303,9 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages)\r
+       INTERNAL_ERROR ("a messages iterator contains a non-existent document ID.\n");\r
+     }\r
\r
++    if (_notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id))\r
++      notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
++\r
+     return message;\r
+ }\r
\r
+@@ -314,10 +318,6 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages)\r
\r
+     mset_messages->iterator++;\r
\r
+-    while ((mset_messages->iterator != mset_messages->iterator_end) &&\r
+-         (_notmuch_doc_id_set_contains (messages->excluded_doc_ids,\r
+-                                        *mset_messages->iterator)))\r
+-      mset_messages->iterator++;\r
+ }\r
\r
+ static notmuch_bool_t\r
+@@ -403,6 +403,8 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
+       notmuch_messages_move_to_next (messages);\r
+     }\r
+     threads->doc_id_pos = 0;\r
++    /* the excluded messages are in query context so this should be ok */\r
++    threads->excluded_doc_ids = messages->excluded_doc_ids;\r
\r
+     talloc_free (messages);\r
\r
+@@ -452,6 +454,7 @@ notmuch_threads_get (notmuch_threads_t *threads)\r
+                                  threads->query->notmuch,\r
+                                  doc_id,\r
+                                  &threads->match_set,\r
++                                 threads->excluded_doc_ids,\r
+                                  threads->query->sort);\r
+ }\r
\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 0435ee6..6ea2a44 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -302,7 +302,8 @@ _thread_set_subject_from_message (notmuch_thread_t *thread,\r
+ static void\r
+ _thread_add_matched_message (notmuch_thread_t *thread,\r
+                            notmuch_message_t *message,\r
+-                           notmuch_sort_t sort)\r
++                           notmuch_sort_t sort,\r
++                           notmuch_bool_t excluded)\r
+ {\r
+     time_t date;\r
+     notmuch_message_t *hashed_message;\r
+@@ -321,7 +322,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 (!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 +394,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_doc_id_set_t *excluded_doc_ids,\r
+                       notmuch_sort_t sort)\r
+ {\r
+     notmuch_thread_t *thread;\r
+@@ -456,7 +459,9 @@ _notmuch_thread_create (void *ctx,\r
+      * oldest or newest subject is desired. */\r
+     notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);\r
\r
+-    for (messages = notmuch_query_search_messages (thread_id_query);\r
++    messages = notmuch_query_search_messages (thread_id_query);\r
++    messages->excluded_doc_ids = excluded_doc_ids;\r
++    for (;\r
+        notmuch_messages_valid (messages);\r
+        notmuch_messages_move_to_next (messages))\r
+     {\r
+@@ -471,7 +476,8 @@ _notmuch_thread_create (void *ctx,\r
\r
+       if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {\r
+           _notmuch_doc_id_set_remove (match_set, doc_id);\r
+-          _thread_add_matched_message (thread, message, sort);\r
++          _thread_add_matched_message (thread, message, sort,\r
++                                       _notmuch_doc_id_set_contains (excluded_doc_ids, doc_id));\r
+       }\r
\r
+       _notmuch_message_close (message);\r
+-- \r
+1.7.2.3\r
+\r