notmuch tests issue on solaris
[notmuch-archives.git] / ab / edc63b5d98b7f141afc8f2ef503c2a99a17050
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
40 MIME-Version: 1.0\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
46 Precedence: list\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
57 \r
58 \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
61 mailing list.\r
62 \r
63 Signed-off-by: Pablo Oliveira <pablo@sifflez.org>\r
64 ---\r
65  lib/database.cc |    3 ++-\r
66  lib/index.cc    |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-\r
67  notmuch.1       |    2 ++\r
68  notmuch.c       |    1 +\r
69  4 files changed, 53 insertions(+), 2 deletions(-)\r
70 \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
77      { "to", "XTO" },\r
78      { "attachment", "XATTACHMENT" },\r
79 -    { "subject", "XSUBJECT"}\r
80 +    { "subject", "XSUBJECT"},\r
81 +    { "listid", "XLISTID"}\r
82  };\r
83  \r
84  int\r
85 diff --git a/lib/index.cc b/lib/index.cc\r
86 index 125fa6c..b27a1dc 100644\r
87 --- a/lib/index.cc\r
88 +++ b/lib/index.cc\r
89 @@ -254,6 +254,50 @@ _index_mime_part (notmuch_message_t *message,\r
90      free (body);\r
91  }\r
92  \r
93 +static void\r
94 +_index_listid (notmuch_message_t *message,\r
95 +               const char *list_id_header)\r
96 +{\r
97 +    const char *begin_list_id, *end_list_id;\r
98 +\r
99 +    if (list_id_header == NULL)\r
100 +       return;\r
101 +\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
106 +\r
107 +    begin_list_id = strrchr (list_id_header, '<');\r
108 +    if (!begin_list_id)\r
109 +       return;\r
110 +\r
111 +    end_list_id = strrchr(begin_list_id, '>');\r
112 +    if (!end_list_id || (end_list_id - begin_list_id < 2))\r
113 +       return;\r
114 +\r
115 +    void *local = talloc_new (NULL);\r
116 +\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
120 +\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
124 +\r
125 +    /* Description may be RFC2047 encoded */\r
126 +    char *decoded_desc = g_mime_utils_header_decode_phrase(description);\r
127 +\r
128 +    _notmuch_message_gen_terms(message, "listid", list_id);\r
129 +\r
130 +    if (decoded_desc)\r
131 +       _notmuch_message_gen_terms(message, "listid", decoded_desc);\r
132 +\r
133 +    free(decoded_desc);\r
134 +    talloc_free (local);\r
135 +}\r
136 +\r
137  notmuch_status_t\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
143      FILE *file = NULL;\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
148  \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
152  \r
153 +    listid = g_mime_object_get_header (GMIME_OBJECT(mime_message), "List-Id");\r
154 +    _index_listid (message, listid);\r
155 +\r
156      _index_mime_part (message, g_mime_message_get_mime_part (mime_message));\r
157  \r
158    DONE:\r
159 diff --git a/notmuch.1 b/notmuch.1\r
160 index 369ecba..2be7056 100644\r
161 --- a/notmuch.1\r
162 +++ b/notmuch.1\r
163 @@ -362,6 +362,8 @@ terms to match against specific portions of an email, (where\r
164  \r
165         thread:<thread-id>\r
166  \r
167 +       listid:<list-id>\r
168 +\r
169  The\r
170  .B from:\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
174 --- a/notmuch.c\r
175 +++ b/notmuch.c\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
181      "\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
184 -- \r
185 1.6.3.3\r
186 \r
187 \r