--- /dev/null
+Return-Path: <dme@dme.org>\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 2F8AA429E35\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:30 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]\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 LlRI0j5+cJ+R for <notmuch@notmuchmail.org>;\r
+ Fri, 24 Oct 2014 01:48:22 -0700 (PDT)\r
+Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com\r
+ [74.125.82.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 79AD7431FD8 for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:14 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f50.google.com with SMTP id a1so586860wgh.21\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:13 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:user-agent:from:to:subject:date:message-id\r
+ :in-reply-to:references;\r
+ bh=WOabpojA0ZyiQ3501Wf2/8Oh2cBz/sxCFHVCk7aVLrg=;\r
+ b=LeHlT5cXPz6UPlMcge30eqU3xtBv+fRVMbLXsTmr0tN5UhZEvv/4iq2nSLEUdHZUgY\r
+ +F2TxGdD0C3stdFFDWU4IsZDPigZlQWFQWj7uaLHHT6o6XoQpjK54qqI1SqGce678w4y\r
+ orQMl6feVtXanQhdhW/X8g8jOly251e2fwzf5MGLgTDflt9Be/h6iZxfA7ASCsmM1Nfv\r
+ o774eB/kLYkxlnBna8yv6rhDU072KZM/KwLJ6fLcnT7KGnp3p9lb7GzunjThiqWD/AbL\r
+ zcfx9TC99zTINO4J1DngrL35IjnG24Ii8iwbBHTLrmkmHWS3aJnKu9DhM+iDfbDhbmAk\r
+ 5Sew==\r
+X-Gm-Message-State:\r
+ ALoCoQnYdm/N7iBEL6wWpB69pXli1iq22Qya4Hf53V5tU7mpWVpHAIoIv7sjvBJJGYlp+62tFu6S\r
+X-Received: by 10.180.79.228 with SMTP id m4mr2631132wix.26.1414140491848;\r
+ Fri, 24 Oct 2014 01:48:11 -0700 (PDT)\r
+Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net.\r
+ [81.149.164.25])\r
+ by mx.google.com with ESMTPSA id wt3sm4840424wjb.40.2014.10.24.01.48.11\r
+ for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 24 Oct 2014 01:48:11 -0700 (PDT)\r
+Received: from localhost (30000@localhost [local]);\r
+ by localhost (OpenSMTPD) with ESMTPA id ff3c1fde;\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 08:48:08 +0000 (UTC)\r
+User-Agent: OpenSMTPD enqueuer (Demoostik)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v1 1/3] search: Seperately report matching and non-matching\r
+ authors.\r
+Date: Fri, 24 Oct 2014 09:48:06 +0100\r
+Message-Id: <1414140488-29978-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.1.1\r
+In-Reply-To: <1414140488-29978-1-git-send-email-dme@dme.org>\r
+References: <1414140488-29978-1-git-send-email-dme@dme.org>\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, 24 Oct 2014 08:48:30 -0000\r
+\r
+In addition to the :authors attribute of each search result, include\r
+:authors_matched and :authors_non_matched attributes. Both attributes\r
+are always included. If there are no non-matching authors, the\r
+:authors_non_matched attribute is set to the empty string.\r
+---\r
+ lib/notmuch.h | 34 ++++++++++++++++++++++++++++++++\r
+ lib/thread.cc | 60 +++++++++++++++++++++++++++++++++++++++-----------------\r
+ notmuch-search.c | 6 ++++++\r
+ 3 files changed, 82 insertions(+), 18 deletions(-)\r
+\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index dae0416..30ce6c3 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -993,6 +993,40 @@ const char *\r
+ notmuch_thread_get_authors (notmuch_thread_t *thread);\r
+ \r
+ /**\r
++ * Get the matched authors of 'thread' as a UTF-8 string.\r
++ *\r
++ * The returned string is a comma-separated list of the names of the\r
++ * authors of mail messages in the query results that belong to this\r
++ * thread.\r
++ *\r
++ * Authors are ordered by date.\r
++ *\r
++ * The returned string belongs to 'thread' and as such, should not be\r
++ * modified by the caller and will only be valid for as long as the\r
++ * thread is valid, (which is until notmuch_thread_destroy or until\r
++ * the query from which it derived is destroyed).\r
++ */\r
++const char *\r
++notmuch_thread_get_authors_matched (notmuch_thread_t *thread);\r
++\r
++/**\r
++ * Get the non-matched authors of 'thread' as a UTF-8 string.\r
++ *\r
++ * The returned string is a comma-separated list of the names of the\r
++ * authors of mail messages in the query results that belong to this\r
++ * thread.\r
++ *\r
++ * Authors are ordered by date.\r
++ *\r
++ * The returned string belongs to 'thread' and as such, should not be\r
++ * modified by the caller and will only be valid for as long as the\r
++ * thread is valid, (which is until notmuch_thread_destroy or until\r
++ * the query from which it derived is destroyed).\r
++ */\r
++const char *\r
++notmuch_thread_get_authors_non_matched (notmuch_thread_t *thread);\r
++\r
++/**\r
+ * Get the subject of 'thread' as a UTF-8 string.\r
+ *\r
+ * The subject is taken from the first message (according to the query\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 8922403..b344875 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -33,6 +33,8 @@ struct visible _notmuch_thread {\r
+ GHashTable *matched_authors_hash;\r
+ GPtrArray *matched_authors_array;\r
+ char *authors;\r
++ char *authors_matched;\r
++ char *authors_non_matched;\r
+ GHashTable *tags;\r
+ \r
+ /* All messages, oldest first. */\r
+@@ -112,10 +114,11 @@ _thread_add_matched_author (notmuch_thread_t *thread,\r
+ g_ptr_array_add (thread->matched_authors_array, author_copy);\r
+ }\r
+ \r
+-/* Construct an authors string from matched_authors_array and\r
+- * authors_array. The string contains matched authors first, then\r
+- * non-matched authors (with the two groups separated by '|'). Within\r
+- * each group, authors are listed in date order. */\r
++/* Construct the authors_matched, authors_non_matched and authors\r
++ * strings from matched_authors_array and authors_array. The authors\r
++ * string contains matched authors first, then non-matched authors\r
++ * (with the two groups separated by '|'). Within each group, authors\r
++ * are listed in date order. */\r
+ static void\r
+ _resolve_thread_authors_string (notmuch_thread_t *thread)\r
+ {\r
+@@ -123,36 +126,43 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)\r
+ char *author;\r
+ int first_non_matched_author = 1;\r
+ \r
+- /* First, list all matched authors in date order. */\r
++ /* List all matched authors in date order. */\r
+ for (i = 0; i < thread->matched_authors_array->len; i++) {\r
+ author = (char *) g_ptr_array_index (thread->matched_authors_array, i);\r
+- if (thread->authors)\r
+- thread->authors = talloc_asprintf (thread, "%s, %s",\r
+- thread->authors,\r
+- author);\r
+- else\r
+- thread->authors = author;\r
++ if (thread->authors_matched) {\r
++ thread->authors_matched = talloc_asprintf (thread, "%s, %s",\r
++ thread->authors_matched,\r
++ author);\r
++ } else {\r
++ thread->authors_matched = author;\r
++ }\r
+ }\r
+ \r
+- /* Next, append any non-matched authors that haven't already appeared. */\r
++ /* List any non-matched authors that haven't already appeared. */\r
+ for (i = 0; i < thread->authors_array->len; i++) {\r
+ author = (char *) g_ptr_array_index (thread->authors_array, i);\r
+ if (g_hash_table_lookup_extended (thread->matched_authors_hash,\r
+ author, NULL, NULL))\r
+ continue;\r
+ if (first_non_matched_author) {\r
+- thread->authors = talloc_asprintf (thread, "%s| %s",\r
+- thread->authors,\r
+- author);\r
++ thread->authors_non_matched = author;\r
+ } else {\r
+- thread->authors = talloc_asprintf (thread, "%s, %s",\r
+- thread->authors,\r
+- author);\r
++ thread->authors_non_matched = talloc_asprintf (thread, "%s, %s",\r
++ thread->authors_non_matched,\r
++ author);\r
+ }\r
+ \r
+ first_non_matched_author = 0;\r
+ }\r
+ \r
++ /* List both matched and any non-matched authors. */\r
++ if (thread->authors_non_matched)\r
++ thread->authors = talloc_asprintf (thread, "%s| %s",\r
++ thread->authors_matched,\r
++ thread->authors_non_matched);\r
++ else\r
++ thread->authors = thread->authors_matched;\r
++\r
+ g_ptr_array_free (thread->authors_array, TRUE);\r
+ thread->authors_array = NULL;\r
+ g_ptr_array_free (thread->matched_authors_array, TRUE);\r
+@@ -473,6 +483,8 @@ _notmuch_thread_create (void *ctx,\r
+ NULL, NULL);\r
+ thread->matched_authors_array = g_ptr_array_new ();\r
+ thread->authors = NULL;\r
++ thread->authors_matched = NULL;\r
++ thread->authors_non_matched = NULL;\r
+ thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,\r
+ free, NULL);\r
+ \r
+@@ -568,6 +580,18 @@ notmuch_thread_get_authors (notmuch_thread_t *thread)\r
+ }\r
+ \r
+ const char *\r
++notmuch_thread_get_authors_matched (notmuch_thread_t *thread)\r
++{\r
++ return thread->authors_matched;\r
++}\r
++\r
++const char *\r
++notmuch_thread_get_authors_non_matched (notmuch_thread_t *thread)\r
++{\r
++ return thread->authors_non_matched;\r
++}\r
++\r
++const char *\r
+ notmuch_thread_get_subject (notmuch_thread_t *thread)\r
+ {\r
+ return thread->subject;\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index bc9be45..f1b096d 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -114,6 +114,8 @@ do_search_threads (sprinter_t *format,\r
+ } else { /* output == OUTPUT_SUMMARY */\r
+ void *ctx_quote = talloc_new (thread);\r
+ const char *authors = notmuch_thread_get_authors (thread);\r
++ const char *authors_matched = notmuch_thread_get_authors_matched (thread);\r
++ const char *authors_non_matched = notmuch_thread_get_authors_non_matched (thread);\r
+ const char *subject = notmuch_thread_get_subject (thread);\r
+ const char *thread_id = notmuch_thread_get_thread_id (thread);\r
+ int matched = notmuch_thread_get_matched_messages (thread);\r
+@@ -152,6 +154,10 @@ do_search_threads (sprinter_t *format,\r
+ format->integer (format, total);\r
+ format->map_key (format, "authors");\r
+ format->string (format, authors);\r
++ format->map_key (format, "authors_matched");\r
++ format->string (format, authors_matched);\r
++ format->map_key (format, "authors_non_matched");\r
++ format->string (format, authors_non_matched);\r
+ format->map_key (format, "subject");\r
+ format->string (format, subject);\r
+ if (notmuch_format_version >= 2) {\r
+-- \r
+2.1.1\r
+\r