1 Return-Path: <pablo.oliveira@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 54C3B431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 26 Dec 2009 18:06:45 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id 67-2HzCtVahI for <notmuch@notmuchmail.org>;
\r
11 Sat, 26 Dec 2009 18:06:44 -0800 (PST)
\r
12 Received: from ey-out-1920.google.com (ey-out-1920.google.com [74.125.78.148])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 2FC75431FAE
\r
14 for <notmuch@notmuchmail.org>; Sat, 26 Dec 2009 18:06:44 -0800 (PST)
\r
15 Received: by ey-out-1920.google.com with SMTP id 3so2896446eyh.6
\r
16 for <notmuch@notmuchmail.org>; Sat, 26 Dec 2009 18:06:43 -0800 (PST)
\r
17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
18 h=domainkey-signature:received:received:sender:from:to:subject:date
\r
19 :message-id:mime-version:content-type;
\r
20 bh=h9mmZSc14flcTatym49RRjEy0s/KcdI7YnTElViS+BQ=;
\r
21 b=tIbvvJrVwsCogH0n/fvzqjfcgMla0aGgPQLWGeogzg+DqQXT2KUEATOMaKQRTt+dvT
\r
22 aPIPNye0KPFBR9n2/1kvPUpunfHsUoSaFdlDTTgJFqQ51gr8ZkhfzSsVGMXXpybhFRYc
\r
23 78K4mRQ9tFa49Ar90uWDpe5LJUArurZeIPGg4=
\r
24 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
25 h=sender:from:to:subject:date:message-id:mime-version:content-type;
\r
26 b=LY23gJuEFLWWA0DDThmS+BEkWbx2X22QfmLhGujTOs2bJu4h6m9K+jPR+6CuvT4Rsv
\r
27 4R6gan82TWB5+gqWLNPKj22QCuMAzPmkuWlxhu+IQbHeIBgb+u/aU1QbA7GL2EXHkId0
\r
28 8p/enI3htpTNaS8a6nmbZPSV6psXD2NXD3rQc=
\r
29 Received: by 10.213.102.66 with SMTP id f2mr4559047ebo.12.1261879603088;
\r
30 Sat, 26 Dec 2009 18:06:43 -0800 (PST)
\r
31 Received: from ecaz (80.174.89.24.dyn.user.ono.com [80.174.89.24])
\r
32 by mx.google.com with ESMTPS id 15sm7270537ewy.12.2009.12.26.18.06.40
\r
33 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
34 Sat, 26 Dec 2009 18:06:42 -0800 (PST)
\r
35 Sender: Pablo Oliveira <pablo.oliveira@gmail.com>
\r
36 From: Pablo Oliveira <pablo@sifflez.org>
\r
37 To: notmuch@notmuchmail.org
\r
38 Date: Sun, 27 Dec 2009 03:06:37 +0100
\r
39 Message-ID: <87ws09i30y.fsf@sifflez.org>
\r
41 Content-Type: text/plain; charset=us-ascii
\r
42 Subject: [notmuch] [PATCH] lib: Add a new prefix "listid" to the
\r
43 search-terms syntax.
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.12
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Sun, 27 Dec 2009 02:06:45 -0000
\r
59 Add support for indexing and searching the message's List-ID header.
\r
60 This is useful when matching all the messages belonging to a particular
\r
63 Signed-off-by: Pablo Oliveira <pablo@sifflez.org>
\r
65 lib/database.cc | 3 ++-
\r
66 lib/index.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
\r
69 4 files changed, 53 insertions(+), 2 deletions(-)
\r
71 diff --git a/lib/database.cc b/lib/database.cc
\r
72 index b6c4d07..f5d695c 100644
\r
73 --- a/lib/database.cc
\r
74 +++ b/lib/database.cc
\r
75 @@ -124,7 +124,8 @@ prefix_t PROBABILISTIC_PREFIX[]= {
\r
76 { "from", "XFROM" },
\r
78 { "attachment", "XATTACHMENT" },
\r
79 - { "subject", "XSUBJECT"}
\r
80 + { "subject", "XSUBJECT"},
\r
81 + { "listid", "XLISTID"}
\r
85 diff --git a/lib/index.cc b/lib/index.cc
\r
86 index 125fa6c..b27a1dc 100644
\r
89 @@ -254,6 +254,50 @@ _index_mime_part (notmuch_message_t *message,
\r
94 +_index_listid (notmuch_message_t *message,
\r
95 + const char *list_id_header)
\r
97 + const char *begin_list_id, *end_list_id;
\r
99 + if (list_id_header == NULL)
\r
102 + /* RFC2919 says that the list-id is found at the end of the header
\r
103 + * and enclosed between angle brackets. If we cannot find a
\r
104 + * matching pair of brackets containing at least one character,
\r
105 + * we ignore the list id header. */
\r
107 + begin_list_id = strrchr (list_id_header, '<');
\r
108 + if (!begin_list_id)
\r
111 + end_list_id = strrchr(begin_list_id, '>');
\r
112 + if (!end_list_id || (end_list_id - begin_list_id < 2))
\r
115 + void *local = talloc_new (NULL);
\r
117 + /* We extract the list id between the angle brackets */
\r
118 + const char *list_id = talloc_strndup(local, begin_list_id + 1,
\r
119 + end_list_id - begin_list_id - 1);
\r
121 + /* All the text before is the description of the list */
\r
122 + const char *description = talloc_strndup(local, list_id_header,
\r
123 + begin_list_id - list_id_header);
\r
125 + /* Description may be RFC2047 encoded */
\r
126 + char *decoded_desc = g_mime_utils_header_decode_phrase(description);
\r
128 + _notmuch_message_gen_terms(message, "listid", list_id);
\r
130 + if (decoded_desc)
\r
131 + _notmuch_message_gen_terms(message, "listid", decoded_desc);
\r
133 + free(decoded_desc);
\r
134 + talloc_free (local);
\r
138 _notmuch_message_index_file (notmuch_message_t *message,
\r
139 const char *filename)
\r
140 @@ -263,7 +307,7 @@ _notmuch_message_index_file (notmuch_message_t *message,
\r
141 GMimeMessage *mime_message = NULL;
\r
142 InternetAddressList *addresses;
\r
144 - const char *from, *subject;
\r
145 + const char *from, *subject, *listid;
\r
146 notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
\r
147 static int initialized = 0;
\r
149 @@ -298,6 +342,9 @@ _notmuch_message_index_file (notmuch_message_t *message,
\r
150 subject = skip_re_in_subject (subject);
\r
151 _notmuch_message_gen_terms (message, "subject", subject);
\r
153 + listid = g_mime_object_get_header (GMIME_OBJECT(mime_message), "List-Id");
\r
154 + _index_listid (message, listid);
\r
156 _index_mime_part (message, g_mime_message_get_mime_part (mime_message));
\r
159 diff --git a/notmuch.1 b/notmuch.1
\r
160 index 369ecba..2be7056 100644
\r
163 @@ -362,6 +362,8 @@ terms to match against specific portions of an email, (where
\r
171 prefix is used to match the name or address of the sender of an email
\r
172 diff --git a/notmuch.c b/notmuch.c
\r
173 index 2ac8a59..cc9233b 100644
\r
176 @@ -55,6 +55,7 @@ static const char search_terms_help[] =
\r
177 "\t\t\ttag:<tag>\n"
\r
178 "\t\t\tid:<message-id>\n"
\r
179 "\t\t\tthread:<thread-id>\n"
\r
180 + "\t\t\tlistid:<list-id>\n"
\r
182 "\t\tThe from: prefix is used to match the name or address of\n"
\r
183 "\t\tthe sender of an email message.\n"
\r