[PATCH 4/8] lib: extend private string map API with iterators
[notmuch-archives.git] / 36 / ae1820d161cd2573688560f3c3676b418d965e
1 Return-Path: <amdragon@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 58BC8431FB6\r
6         for <notmuch@notmuchmail.org>; Sat, 11 Dec 2010 22:41:20 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.798\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.798 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7]\r
14         autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id kwFQWFOED6bU for <notmuch@notmuchmail.org>;\r
18         Sat, 11 Dec 2010 22:41:18 -0800 (PST)\r
19 Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com\r
20         [209.85.216.53])\r
21         by olra.theworths.org (Postfix) with ESMTP id DBC59431FB5\r
22         for <notmuch@notmuchmail.org>; Sat, 11 Dec 2010 22:41:17 -0800 (PST)\r
23 Received: by qwe5 with SMTP id 5so5614323qwe.26\r
24         for <notmuch@notmuchmail.org>; Sat, 11 Dec 2010 22:41:16 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:mime-version:received:received:in-reply-to\r
27         :references:date:message-id:subject:from:to:cc:content-type;\r
28         bh=llB8BCqwR/r5jhLhdb2Q6t7G6dKIXiNFXmrv3naNLkk=;\r
29         b=m82jRWVNMKoO8lr85WEWPUrzMqpFS0MpQyJeheFnoKzDmRERT+fMHVoHtjwNkF3iWl\r
30         +4W3I5bgH4CJhDUWEn/NhFXwjtgTbPCXLF1fMB9sZJlF0C59LJwRgG5p3AwG/2FFTkm9\r
31         2faC7QpS9HUSr9o5lRQF+EIDXZ2PReWysGGmQ=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
34         :cc:content-type;\r
35         b=WW84QZgBosom94dpMRGIPKavmXRKKiax4MbXMgeQNcWaNNyeF+5bn2RO/rrjvpxn2e\r
36         4BD1GHdwW9UuWHNRr9yGLCMMuvZNwcIbz7T8J8iH8Ti/5eaBBbIVyXWRbd1AdT4EaGwH\r
37         vtcM0E8Wag/97GeVaDGaKEBwV4CiO6ZkwGhb0=\r
38 MIME-Version: 1.0\r
39 Received: by 10.229.235.4 with SMTP id ke4mr2483152qcb.201.1292136074473; Sat,\r
40         11 Dec 2010 22:41:14 -0800 (PST)\r
41 Received: by 10.229.224.202 with HTTP; Sat, 11 Dec 2010 22:41:14 -0800 (PST)\r
42 In-Reply-To:\r
43  <1291235635-16523-1-git-send-email-joel.borggren.franck@gmail.com>\r
44 References: <1291235635-16523-1-git-send-email-joel.borggren.franck@gmail.com>\r
45 Date: Sun, 12 Dec 2010 01:41:14 -0500\r
46 Message-ID: <AANLkTinX_07ZucHbf6kVAsy-quauY+N9hMhJwKjMt1Dk@mail.gmail.com>\r
47 Subject: Re: [PATCH] add headers cc: bcc: and to: (as exactto:) to search\r
48  index\r
49 From: Austin Clements <amdragon@gmail.com>\r
50 To: =?ISO-8859-1?Q?Joel_Borggr=E9n=2DFranck?= <joel.borggren.franck@gmail.com>\r
51 Content-Type: multipart/alternative; boundary=0016e6465148b87303049730dfea\r
52 Cc: notmuch@notmuchmail.org\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Sun, 12 Dec 2010 06:41:21 -0000\r
66 \r
67 --0016e6465148b87303049730dfea\r
68 Content-Type: text/plain; charset=ISO-8859-1\r
69 Content-Transfer-Encoding: quoted-printable\r
70 \r
71 Short of full header indexing, wouldn't a better way to achieve this be to\r
72 store only the "to" header as "XTO", the "cc" header "XCC", and the "bcc"\r
73 header as "XBCC" and use Xapian's multi-prefix support to map the "to:"\r
74 query prefix to "XTO", "XCC", and "XBCC"?  That way you're not storing twic=\r
75 e\r
76 as many copies of  every address.\r
77 \r
78 On Wed, Dec 1, 2010 at 3:33 PM, Joel Borggr=E9n-Franck <\r
79 joel.borggren.franck@gmail.com> wrote:\r
80 \r
81 > From: Joel Borggr=E9n-Franck <jbf@codehouse.se>\r
82 >\r
83 > Add headers cc: bcc: and to: to index. Real header to: is searched as\r
84 > "exactto:foo@bar.baz" and search term "to:" is kept as a union of cc:,\r
85 > bcc: and to: for backward compatibility. Use search term "cc:" resp.\r
86 > "bcc:" to search those headers respectively.\r
87 > ---\r
88 >  lib/database.cc |   11 +++++++----\r
89 >  lib/index.cc    |    9 +++++++++\r
90 >  2 files changed, 16 insertions(+), 4 deletions(-)\r
91 >\r
92 > diff --git a/lib/database.cc b/lib/database.cc\r
93 > index 7a00917..68910f3 100644\r
94 > --- a/lib/database.cc\r
95 > +++ b/lib/database.cc\r
96 > @@ -88,9 +88,9 @@ typedef struct {\r
97 >  *     MESSAGE_ID:     The unique ID of the mail mess (see "id" above)\r
98 >  *\r
99 >  * In addition, terms from the content of the message are added with\r
100 > - * "from", "to", "attachment", and "subject" prefixes for use by the\r
101 > - * user in searching. But the database doesn't really care itself\r
102 > - * about any of these.\r
103 > + * "from", "to", "exactto", "cc", "bbc", "attachment" and "subject"\r
104 > + * prefixes for use by the user in searching. But the database doesn't\r
105 > + * really care itself about any of these.\r
106 >  *\r
107 >  * The data portion of a mail document is empty.\r
108 >  *\r
109 > @@ -204,7 +204,10 @@ static prefix_t PROBABILISTIC_PREFIX[]=3D {\r
110 >     { "from",                  "XFROM" },\r
111 >     { "to",                    "XTO" },\r
112 >     { "attachment",            "XATTACHMENT" },\r
113 > -    { "subject",               "XSUBJECT"}\r
114 > +    { "subject",               "XSUBJECT"},\r
115 > +    { "exactto",                "XEXACTTO"},\r
116 > +    { "cc",                     "XCC"},\r
117 > +    { "bcc",                    "XBCC"},\r
118 >  };\r
119 >\r
120 >  int\r
121 > diff --git a/lib/index.cc b/lib/index.cc\r
122 > index 00478f8..d59c255 100644\r
123 > --- a/lib/index.cc\r
124 > +++ b/lib/index.cc\r
125 > @@ -455,6 +455,15 @@ _notmuch_message_index_file (notmuch_message_t\r
126 > *message,\r
127 >\r
128 >     _index_address_list (message, "from", addresses);\r
129 >\r
130 > +    addresses =3D g_mime_message_get_recipients (mime_message,\r
131 > GMIME_RECIPIENT_TYPE_TO);\r
132 > +    _index_address_list (message, "exactto", addresses);\r
133 > +\r
134 > +    addresses =3D g_mime_message_get_recipients (mime_message,\r
135 > GMIME_RECIPIENT_TYPE_CC);\r
136 > +    _index_address_list (message, "cc", addresses);\r
137 > +\r
138 > +    addresses =3D g_mime_message_get_recipients (mime_message,\r
139 > GMIME_RECIPIENT_TYPE_BCC);\r
140 > +    _index_address_list (message, "bcc", addresses);\r
141 > +\r
142 >     addresses =3D g_mime_message_get_all_recipients (mime_message);\r
143 >     _index_address_list (message, "to", addresses);\r
144 >\r
145 > --\r
146 > 1.7.3.2\r
147 >\r
148 > _______________________________________________\r
149 > notmuch mailing list\r
150 > notmuch@notmuchmail.org\r
151 > http://notmuchmail.org/mailman/listinfo/notmuch\r
152 >\r
153 \r
154 --0016e6465148b87303049730dfea\r
155 Content-Type: text/html; charset=ISO-8859-1\r
156 Content-Transfer-Encoding: quoted-printable\r
157 \r
158 Short of full header indexing, wouldn&#39;t a better way to achieve this be=\r
159  to store only the &quot;to&quot; header as &quot;XTO&quot;, the &quot;cc&q=\r
160 uot; header &quot;XCC&quot;, and the &quot;bcc&quot; header as &quot;XBCC&q=\r
161 uot; and use Xapian&#39;s multi-prefix support to map the &quot;to:&quot; q=\r
162 uery prefix to &quot;XTO&quot;, &quot;XCC&quot;, and &quot;XBCC&quot;? =A0T=\r
163 hat way you&#39;re not storing twice as many copies of =A0every address.<br=\r
164 >\r
165 <br><div class=3D"gmail_quote">On Wed, Dec 1, 2010 at 3:33 PM, Joel Borggr=\r
166 =E9n-Franck <span dir=3D"ltr">&lt;<a href=3D"mailto:joel.borggren.franck@gm=\r
167 ail.com">joel.borggren.franck@gmail.com</a>&gt;</span> wrote:<br><blockquot=\r
168 e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=\r
169 id;padding-left:1ex;">\r
170 From: Joel Borggr=E9n-Franck &lt;<a href=3D"mailto:jbf@codehouse.se">jbf@co=\r
171 dehouse.se</a>&gt;<br>\r
172 <br>\r
173 Add headers cc: bcc: and to: to index. Real header to: is searched as<br>\r
174 &quot;exactto:foo@bar.baz&quot; and search term &quot;to:&quot; is kept as =\r
175 a union of cc:,<br>\r
176 bcc: and to: for backward compatibility. Use search term &quot;cc:&quot; re=\r
177 sp.<br>\r
178 &quot;bcc:&quot; to search those headers respectively.<br>\r
179 ---<br>\r
180 =A0lib/database.cc | =A0 11 +++++++----<br>\r
181 =A0lib/index.cc =A0 =A0| =A0 =A09 +++++++++<br>\r
182 =A02 files changed, 16 insertions(+), 4 deletions(-)<br>\r
183 <br>\r
184 diff --git a/lib/database.cc b/lib/database.cc<br>\r
185 index 7a00917..68910f3 100644<br>\r
186 --- a/lib/database.cc<br>\r
187 +++ b/lib/database.cc<br>\r
188 @@ -88,9 +88,9 @@ typedef struct {<br>\r
189  =A0* =A0 =A0 MESSAGE_ID: =A0 =A0 The unique ID of the mail mess (see &quot=\r
190 ;id&quot; above)<br>\r
191  =A0*<br>\r
192  =A0* In addition, terms from the content of the message are added with<br>\r
193 - * &quot;from&quot;, &quot;to&quot;, &quot;attachment&quot;, and &quot;sub=\r
194 ject&quot; prefixes for use by the<br>\r
195 - * user in searching. But the database doesn&#39;t really care itself<br>\r
196 - * about any of these.<br>\r
197 + * &quot;from&quot;, &quot;to&quot;, &quot;exactto&quot;, &quot;cc&quot;, =\r
198 &quot;bbc&quot;, &quot;attachment&quot; and &quot;subject&quot;<br>\r
199 + * prefixes for use by the user in searching. But the database doesn&#39;t=\r
200 <br>\r
201 + * really care itself about any of these.<br>\r
202  =A0*<br>\r
203  =A0* The data portion of a mail document is empty.<br>\r
204  =A0*<br>\r
205 @@ -204,7 +204,10 @@ static prefix_t PROBABILISTIC_PREFIX[]=3D {<br>\r
206  =A0 =A0 { &quot;from&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&quot;XFROM=\r
207 &quot; },<br>\r
208  =A0 =A0 { &quot;to&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&quot;XTO=\r
209 &quot; },<br>\r
210  =A0 =A0 { &quot;attachment&quot;, =A0 =A0 =A0 =A0 =A0 =A0&quot;XATTACHMENT=\r
211 &quot; },<br>\r
212 - =A0 =A0{ &quot;subject&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 &quot;XSUBJECT&=\r
213 quot;}<br>\r
214 + =A0 =A0{ &quot;subject&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 &quot;XSUBJECT&=\r
215 quot;},<br>\r
216 + =A0 =A0{ &quot;exactto&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&quot;XEXACT=\r
217 TO&quot;},<br>\r
218 + =A0 =A0{ &quot;cc&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &quot;XC=\r
219 C&quot;},<br>\r
220 + =A0 =A0{ &quot;bcc&quot;, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&quot;XB=\r
221 CC&quot;},<br>\r
222 =A0};<br>\r
223 <br>\r
224 =A0int<br>\r
225 diff --git a/lib/index.cc b/lib/index.cc<br>\r
226 index 00478f8..d59c255 100644<br>\r
227 --- a/lib/index.cc<br>\r
228 +++ b/lib/index.cc<br>\r
229 @@ -455,6 +455,15 @@ _notmuch_message_index_file (notmuch_message_t *messag=\r
230 e,<br>\r
231 <br>\r
232  =A0 =A0 _index_address_list (message, &quot;from&quot;, addresses);<br>\r
233 <br>\r
234 + =A0 =A0addresses =3D g_mime_message_get_recipients (mime_message, GMIME_R=\r
235 ECIPIENT_TYPE_TO);<br>\r
236 + =A0 =A0_index_address_list (message, &quot;exactto&quot;, addresses);<br>\r
237 +<br>\r
238 + =A0 =A0addresses =3D g_mime_message_get_recipients (mime_message, GMIME_R=\r
239 ECIPIENT_TYPE_CC);<br>\r
240 + =A0 =A0_index_address_list (message, &quot;cc&quot;, addresses);<br>\r
241 +<br>\r
242 + =A0 =A0addresses =3D g_mime_message_get_recipients (mime_message, GMIME_R=\r
243 ECIPIENT_TYPE_BCC);<br>\r
244 + =A0 =A0_index_address_list (message, &quot;bcc&quot;, addresses);<br>\r
245 +<br>\r
246  =A0 =A0 addresses =3D g_mime_message_get_all_recipients (mime_message);<br=\r
247 >\r
248  =A0 =A0 _index_address_list (message, &quot;to&quot;, addresses);<br>\r
249 <font color=3D"#888888"><br>\r
250 --<br>\r
251 1.7.3.2<br>\r
252 <br>\r
253 _______________________________________________<br>\r
254 notmuch mailing list<br>\r
255 <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a><br>\r
256 <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch" target=3D"_blan=\r
257 k">http://notmuchmail.org/mailman/listinfo/notmuch</a><br>\r
258 </font></blockquote></div><br>\r
259 \r
260 --0016e6465148b87303049730dfea--\r