--- /dev/null
+Return-Path: <jani@nikula.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 03602431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 17 Oct 2013 07:17:17 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 KYd1PwNmmAC1 for <notmuch@notmuchmail.org>;\r
+ Thu, 17 Oct 2013 07:17:04 -0700 (PDT)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 5B6F8431FAE for <notmuch@notmuchmail.org>; Thu, 17 Oct 2013 07:17:04 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f53.google.com with SMTP id t10so1084212eei.26\r
+ for <notmuch@notmuchmail.org>; Thu, 17 Oct 2013 07:17:03 -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:from:to:cc:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=WKr5XBJedjXYyxITlEMnrox6FTKqHUBfGmPY/ius0OM=;\r
+ b=lKqoaDn55h0+l05N7t32zkdCYEYan9g3DTnrptEIxvM8lpZmXsiB0fYB6zAMuABXWp\r
+ a7VdYxZSmM7eZ4g9fPGvrNczbOkIBJQCGE9GKaT3X5g+v0+w55tVvFfAb4EPK/2/uzIa\r
+ OWBwJ08VUmBpVZD3KOLUzfICYCj/TEHwpR/0ZunPUPY2015DLkdv2uwLnK2ps6B/uFjR\r
+ 5V2eYnsEX6ynFLOTGtHomKHGdO0EzXxi1/PUfg4Z3wGhPRyJtn2w/hQv6BzBoqwGJaQh\r
+ VljZufdOTLnLrPXgxRD1HFou4Xn5tagdnGY03nUKhXpQron0FgzqR3erbClrA6N8Z6yD\r
+ dQcw==\r
+X-Gm-Message-State:\r
+ ALoCoQmHKhgz5k2OUiZtYNy7G8mOlni60+Cs4qtil87c0SoDsqSxkMQwBxfL6pBQ6H6KJ2mEEhzd\r
+X-Received: by 10.15.98.9 with SMTP id bi9mr3986193eeb.67.1382019423188;\r
+ Thu, 17 Oct 2013 07:17:03 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id a1sm193403452eem.1.1969.12.31.16.00.00\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Thu, 17 Oct 2013 07:17:01 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: "Alexey I. Froloff" <raorn@raorn.name>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] lib: Add a new prefix "list" to the search-terms syntax\r
+In-Reply-To: <1365549369-12776-1-git-send-email-raorn@raorn.name>\r
+References: <20130409083010.GA27675@raorn.name>\r
+ <1365549369-12776-1-git-send-email-raorn@raorn.name>\r
+User-Agent: Notmuch/0.16+97~g6878b0b (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 17 Oct 2013 17:17:00 +0300\r
+Message-ID: <87bo2ougmb.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: "Alexey I. Froloff" <raorn@raorn.name>\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: Thu, 17 Oct 2013 14:17:17 -0000\r
+\r
+On Wed, 10 Apr 2013, "Alexey I. Froloff" <raorn@raorn.name> wrote:\r
+> From: "Alexey I. Froloff" <raorn@raorn.name>\r
+>\r
+> Add support for indexing and searching the message's List-Id header.\r
+> This is useful when matching all the messages belonging to a particular\r
+> mailing list.\r
+\r
+There's an issue with our duplicate message-id handling that is likely\r
+to cause confusion with List-Id: searches. If you receive several\r
+duplicates of the same message (judged by the message-id), only the\r
+first one of them gets indexed, and the rest are ignored. This means\r
+that for messages you receive both directly and through a list, it will\r
+be arbitrary whether the List-Id: gets indexed or not. Therefore a list:\r
+search might not return all the messages you'd expect.\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+> Rework of the patch by Pablo Oliveira <pablo@sifflez.org>\r
+>\r
+> Differences from original patch:\r
+>\r
+> The whole list ID indexed as boolean term, not split by words.\r
+> List description is not indexed at all.\r
+>\r
+> Thanks to ojwb and amdragon from irc://irc.freenode.net/notmuch\r
+>\r
+> Signed-off-by: Alexey I. Froloff <raorn@raorn.name>\r
+> ---\r
+> lib/database.cc | 1 +\r
+> lib/index.cc | 45 ++++++++++++++++++++++++++++++++++++++++-\r
+> man/man7/notmuch-search-terms.7 | 8 ++++++++\r
+> 3 files changed, 53 insertions(+), 1 deletion(-)\r
+>\r
+> diff --git a/lib/database.cc b/lib/database.cc\r
+> index 91d4329..6313913 100644\r
+> --- a/lib/database.cc\r
+> +++ b/lib/database.cc\r
+> @@ -203,6 +203,7 @@ static prefix_t BOOLEAN_PREFIX_INTERNAL[] = {\r
+> };\r
+> \r
+> static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {\r
+> + { "list", "XLIST"},\r
+> { "thread", "G" },\r
+> { "tag", "K" },\r
+> { "is", "K" },\r
+> diff --git a/lib/index.cc b/lib/index.cc\r
+> index a2edd6d..8b97ec3 100644\r
+> --- a/lib/index.cc\r
+> +++ b/lib/index.cc\r
+> @@ -304,6 +304,46 @@ _index_address_list (notmuch_message_t *message,\r
+> }\r
+> }\r
+> \r
+> +static void\r
+> +_index_list_id (notmuch_message_t *message,\r
+> + const char *list_id_header)\r
+> +{\r
+> + const char *begin_list_id, *end_list_id;\r
+> +\r
+> + if (list_id_header == NULL)\r
+> + return;\r
+> +\r
+> + /* RFC2919 says that the list-id is found at the end of the header\r
+> + * and enclosed between angle brackets. If we cannot find a\r
+> + * matching pair of brackets containing at least one character,\r
+> + * we ignore the list id header. */\r
+> + begin_list_id = strrchr (list_id_header, '<');\r
+> + if (!begin_list_id) {\r
+> + fprintf (stderr, "Warning: Not indexing mailformed List-Id tag.\n");\r
+> + return;\r
+> + }\r
+> +\r
+> + end_list_id = strrchr(begin_list_id, '>');\r
+> + if (!end_list_id || (end_list_id - begin_list_id < 2)) {\r
+> + fprintf (stderr, "Warning: Not indexing mailformed List-Id tag.\n");\r
+> + return;\r
+> + }\r
+> +\r
+> + void *local = talloc_new (message);\r
+> +\r
+> + /* We extract the list id between the angle brackets */\r
+> + const char *list_id = talloc_strndup (local, begin_list_id + 1,\r
+> + end_list_id - begin_list_id - 1);\r
+> +\r
+> + /* _notmuch_message_add_term() may return\r
+> + * NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG here. We can't fix it, but\r
+> + * this is not a reason to exit with error... */\r
+> + if (_notmuch_message_add_term (message, "list", list_id))\r
+> + fprintf (stderr, "Warning: Not indexing List-Id: <%s>\n", list_id);\r
+> +\r
+> + talloc_free (local);\r
+> +}\r
+> +\r
+> /* Callback to generate terms for each mime part of a message. */\r
+> static void\r
+> _index_mime_part (notmuch_message_t *message,\r
+> @@ -432,7 +472,7 @@ _notmuch_message_index_file (notmuch_message_t *message,\r
+> GMimeMessage *mime_message = NULL;\r
+> InternetAddressList *addresses;\r
+> FILE *file = NULL;\r
+> - const char *from, *subject;\r
+> + const char *from, *subject, *list_id;\r
+> notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;\r
+> static int initialized = 0;\r
+> char from_buf[5];\r
+> @@ -500,6 +540,9 @@ mboxes is deprecated and may be removed in the future.\n", filename);\r
+> subject = g_mime_message_get_subject (mime_message);\r
+> _notmuch_message_gen_terms (message, "subject", subject);\r
+> \r
+> + list_id = g_mime_object_get_header (GMIME_OBJECT (mime_message), "List-Id");\r
+> + _index_list_id (message, list_id);\r
+> +\r
+> _index_mime_part (message, g_mime_message_get_mime_part (mime_message));\r
+> \r
+> DONE:\r
+> diff --git a/man/man7/notmuch-search-terms.7 b/man/man7/notmuch-search-terms.7\r
+> index eb417ba..9cae107 100644\r
+> --- a/man/man7/notmuch-search-terms.7\r
+> +++ b/man/man7/notmuch-search-terms.7\r
+> @@ -52,6 +52,8 @@ terms to match against specific portions of an email, (where\r
+> \r
+> thread:<thread-id>\r
+> \r
+> + list:<list-id>\r
+> +\r
+> folder:<directory-path>\r
+> \r
+> date:<since>..<until>\r
+> @@ -100,6 +102,12 @@ thread ID values can be seen in the first column of output from\r
+> .B "notmuch search"\r
+> \r
+> The\r
+> +.BR list: ,\r
+> +is used to match mailing list ID of an email message \- contents of the\r
+> +List\-Id: header without the '<', '>' delimiters or decoded list\r
+> +description.\r
+> +\r
+> +The\r
+> .B folder:\r
+> prefix can be used to search for email message files that are\r
+> contained within particular directories within the mail store. Only\r
+> -- \r
+> 1.8.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r