[notmuch] [PATCH 2/3] have _notmuch_thread_create mark which messages matched the...
authorBart Trojanowski <bart@jukie.net>
Wed, 25 Nov 2009 04:54:34 +0000 (23:54 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:42 +0000 (09:35 -0800)
84/a70154e2970e5990f9aa4c6811e1cc91ab2e78 [new file with mode: 0644]

diff --git a/84/a70154e2970e5990f9aa4c6811e1cc91ab2e78 b/84/a70154e2970e5990f9aa4c6811e1cc91ab2e78
new file mode 100644 (file)
index 0000000..855007f
--- /dev/null
@@ -0,0 +1,94 @@
+Return-Path: <bart@jukie.net>\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 0D0DB431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:55:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 WsPasMks4Yon for <notmuch@notmuchmail.org>;\r
+       Tue, 24 Nov 2009 20:55:19 -0800 (PST)\r
+Received: from tau.jukie.net (tau.jukie.net [216.239.93.128])\r
+       by olra.theworths.org (Postfix) with ESMTP id 69F66431FBF\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:55:18 -0800 (PST)\r
+Received: from localhost.localdomain (oxygen.jukie.net [10.10.10.8])\r
+       by tau.jukie.net (Postfix) with ESMTP id E1721C00F85;\r
+       Tue, 24 Nov 2009 23:55:17 -0500 (EST)\r
+From: Bart Trojanowski <bart@jukie.net>\r
+To: notmuch@notmuchmail.org\r
+Date: Tue, 24 Nov 2009 23:54:34 -0500\r
+Message-Id: <1259124875-28212-3-git-send-email-bart@jukie.net>\r
+X-Mailer: git-send-email 1.6.4.4.2.gc2f148\r
+In-Reply-To: <1259124875-28212-2-git-send-email-bart@jukie.net>\r
+References: <1259124875-28212-1-git-send-email-bart@jukie.net>\r
+       <1259124875-28212-2-git-send-email-bart@jukie.net>\r
+Cc: Bart Trojanowski <bart@jukie.net>\r
+Subject: [notmuch] [PATCH 2/3] have _notmuch_thread_create mark which\r
+       messages matched the query\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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, 25 Nov 2009 04:55:20 -0000\r
+\r
+When _notmuch_thread_create() is given a query string, it can return more\r
+messages than just those matching the query.  To distinguish those that\r
+matched the query expression, the MATCHING_SEARCH flag is set\r
+appropriately.\r
+\r
+Signed-off-by: Bart Trojanowski <bart@jukie.net>\r
+---\r
+ lib/notmuch.h |    1 +\r
+ lib/thread.cc |    8 ++++++++\r
+ 2 files changed, 9 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index c232c58..3974820 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -686,6 +686,7 @@ notmuch_message_get_filename (notmuch_message_t *message);\r
\r
+ /* Message flags */\r
+ typedef enum _notmuch_message_flag {\r
++    NOTMUCH_MSG_FLAG_MATCHING_SEARCH,\r
+ } notmuch_message_flag_t;\r
\r
+ /* Get a value of a flag for the email corresponding to 'message'. */\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 58d88c2..9e4cb5c 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -132,6 +132,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+                            notmuch_message_t *message)\r
+ {\r
+     time_t date;\r
++    notmuch_message_t *hashed_message;\r
\r
+     date = notmuch_message_get_date (message);\r
\r
+@@ -142,6 +143,13 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+       thread->newest = date;\r
\r
+     thread->matched_messages++;\r
++\r
++    if (g_hash_table_lookup_extended (thread->message_hash,\r
++                          notmuch_message_get_message_id (message), NULL,\r
++                          (void **) &hashed_message)) {\r
++      notmuch_message_set_flag (hashed_message,\r
++                      NOTMUCH_MSG_FLAG_MATCHING_SEARCH, 1);\r
++    }\r
+ }\r
\r
+ static void\r
+-- \r
+1.6.4.4.2.gc2f148\r
+\r