--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 1F78F429E27\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 02:24:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 kvvmoqQOr3gJ for <notmuch@notmuchmail.org>;\r
+ Fri, 24 Oct 2014 02:24:20 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id D0C4D431FD8\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 02:24:19 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Xhb6B-00034K-EB; Fri, 24 Oct 2014 10:24:15 +0100\r
+Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Xhb6A-0003ml-Mn; Fri, 24 Oct 2014 10:23:55 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v1 1/3] search: Seperately report matching and\r
+ non-matching authors.\r
+In-Reply-To: <1414140488-29978-2-git-send-email-dme@dme.org>\r
+References: <1414140488-29978-1-git-send-email-dme@dme.org>\r
+ <1414140488-29978-2-git-send-email-dme@dme.org>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Fri, 24 Oct 2014 10:23:53 +0100\r
+Message-ID: <87y4s5vn12.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 87.81.223.162\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: fea76dc32e0ad6a59ad4b1f29aed2695 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.1\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -0.1 points.\r
+ Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.1 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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 09:24:28 -0000\r
+\r
+\r
+Hi\r
+\r
+I definitely like the idea: some comments below.\r
+\r
+On Fri, 24 Oct 2014, David Edmondson <dme@dme.org> wrote:\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
+What about having both authors_matched and authors_not_matched as lists\r
+of authors (ie one string for each author)? Then emacs, for example,\r
+wouldn't try and parse the string back into authors before\r
+splitting. And authors_non_matched could be an empty list when\r
+appropriate which seems more natural than the empty string.\r
+\r
+All the above is based on what a client might want in the output rather\r
+than what is easy or sensible to implement in the C code.\r
+\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
+I think I would prefer to make this look like the matched case and drop\r
+the first_non_matched_author stuff.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r