[PATCH 1/5] emacs: compile and load notmuch-pick.el if present.
[notmuch-archives.git] / 2f / fe3367e71c7a55b035c4b11e11626385894a16
1 Return-Path: <jani@nikula.org>\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 5E6AF429E21\r
6         for <notmuch@notmuchmail.org>; Wed, 11 Jan 2012 11:28:00 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id kqCOtOIto7h8 for <notmuch@notmuchmail.org>;\r
16         Wed, 11 Jan 2012 11:27:59 -0800 (PST)\r
17 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
18  [74.125.83.53])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  291FC431FB6    for <notmuch@notmuchmail.org>; Wed, 11 Jan 2012 11:27:59 -0800\r
21  (PST)\r
22 Received: by eeke51 with SMTP id e51so644885eek.26\r
23         for <notmuch@notmuchmail.org>; Wed, 11 Jan 2012 11:27:58 -0800 (PST)\r
24 Received: by 10.14.32.20 with SMTP id n20mr208666eea.42.1326310077866;\r
25         Wed, 11 Jan 2012 11:27:57 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
27         [80.220.92.23])\r
28         by mx.google.com with ESMTPS id b49sm9358011eec.9.2012.01.11.11.27.54\r
29         (version=SSLv3 cipher=OTHER); Wed, 11 Jan 2012 11:27:55 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH 3/3] search: Support automatic tag exclusions\r
33 In-Reply-To: <1326258173-21163-4-git-send-email-amdragon@mit.edu>\r
34 References: <20120109043101.GH20796@mit.edu>\r
35         <1326258173-21163-1-git-send-email-amdragon@mit.edu>\r
36         <1326258173-21163-4-git-send-email-amdragon@mit.edu>\r
37 User-Agent: Notmuch/0.10.2+193~ga73a411 (http://notmuchmail.org) Emacs/23.3.1\r
38         (i686-pc-linux-gnu)\r
39 Date: Wed, 11 Jan 2012 21:27:52 +0200\r
40 Message-ID: <87ty42ca4n.fsf@nikula.org>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=utf-8\r
43 Content-Transfer-Encoding: quoted-printable\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\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: Wed, 11 Jan 2012 19:28:00 -0000\r
57 \r
58 On Wed, 11 Jan 2012 00:02:53 -0500, Austin Clements <amdragon@MIT.EDU> wrot=\r
59 e:\r
60 > This adds a "search" section to the config file and an\r
61 > "auto_tag_exclusions" setting in that section.  The search and count\r
62 > commands pass tag tags from the configuration to the library.\r
63 \r
64 Looks good.\r
65 \r
66 Perhaps a few subtests like this in test/count on a corpus with some\r
67 "deleted" or "spam" tags would be in order:\r
68 \r
69 test_begin_subtest "message count with --output=3Dmessages"\r
70 test_expect_equal \\r
71     "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \\r
72     "`notmuch count --output=3Dmessages ${SEARCH}`"\r
73 \r
74 test_begin_subtest "thread count with --output=3Dthreads"\r
75 test_expect_equal \\r
76     "`notmuch search --output=3Dthreads ${SEARCH} | wc -l`" \\r
77     "`notmuch count --output=3Dthreads ${SEARCH}`"\r
78 \r
79 That's copy-paste from test/count; doing the same after some exclude\r
80 tagging (and making sure it actually affects count) should be enough.\r
81 \r
82 \r
83 BR,\r
84 Jani.\r
85 \r
86 \r
87 \r
88 \r
89 > ---\r
90 >  notmuch-client.h |    8 ++++++++\r
91 >  notmuch-config.c |   42 ++++++++++++++++++++++++++++++++++++++++++\r
92 >  notmuch-count.c  |    8 ++++++++\r
93 >  notmuch-search.c |    8 ++++++++\r
94 >  test/search      |   18 ++++++++++++++++++\r
95 >  5 files changed, 84 insertions(+), 0 deletions(-)\r
96 >=20\r
97 > diff --git a/notmuch-client.h b/notmuch-client.h\r
98 > index 517c010..62ede28 100644\r
99 > --- a/notmuch-client.h\r
100 > +++ b/notmuch-client.h\r
101 > @@ -235,6 +235,14 @@ void\r
102 >  notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,\r
103 >                                             notmuch_bool_t synchronize_flags);\r
104 >=20=20\r
105 > +const char **\r
106 > +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *=\r
107 length);\r
108 > +\r
109 > +void\r
110 > +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,\r
111 > +                                   const char *list[],\r
112 > +                                   size_t length);\r
113 > +\r
114 >  int\r
115 >  notmuch_run_hook (const char *db_path, const char *hook);\r
116 >=20=20\r
117 > diff --git a/notmuch-config.c b/notmuch-config.c\r
118 > index d697138..6c3123b 100644\r
119 > --- a/notmuch-config.c\r
120 > +++ b/notmuch-config.c\r
121 > @@ -84,6 +84,15 @@ static const char maildir_config_comment[] =3D\r
122 >      "\tand update tags, while the \"notmuch tag\" and \"notmuch restore\=\r
123 "\n"\r
124 >      "\tcommands will notice tag changes and update flags in filenames\n";\r
125 >=20=20\r
126 > +static const char search_config_comment[] =3D\r
127 > +    " Search configuration\n"\r
128 > +    "\n"\r
129 > +    " The following option is supported here:\n"\r
130 > +    "\n"\r
131 > +    "\tauto_exclude_tags      A ;-separated list of tags that will be\n"\r
132 > +    "\t excluded from queries by default.  This can be overridden by inc=\r
133 luding\n"\r
134 > +    "\t these tags in a query.\n";\r
135 > +\r
136 >  struct _notmuch_config {\r
137 >      char *filename;\r
138 >      GKeyFile *key_file;\r
139 > @@ -96,6 +105,8 @@ struct _notmuch_config {\r
140 >      const char **new_tags;\r
141 >      size_t new_tags_length;\r
142 >      notmuch_bool_t maildir_synchronize_flags;\r
143 > +    const char **auto_exclude_tags;\r
144 > +    size_t auto_exclude_tags_length;\r
145 >  };\r
146 >=20=20\r
147 >  static int\r
148 > @@ -221,6 +232,7 @@ notmuch_config_open (void *ctx,\r
149 >      int file_had_new_group;\r
150 >      int file_had_user_group;\r
151 >      int file_had_maildir_group;\r
152 > +    int file_had_search_group;\r
153 >=20=20\r
154 >      if (is_new_ret)\r
155 >       *is_new_ret =3D 0;\r
156 > @@ -252,6 +264,8 @@ notmuch_config_open (void *ctx,\r
157 >      config->new_tags =3D NULL;\r
158 >      config->new_tags_length =3D 0;\r
159 >      config->maildir_synchronize_flags =3D TRUE;\r
160 > +    config->auto_exclude_tags =3D NULL;\r
161 > +    config->auto_exclude_tags_length =3D 0;\r
162 >=20=20\r
163 >      if (! g_key_file_load_from_file (config->key_file,\r
164 >                                    config->filename,\r
165 > @@ -295,6 +309,7 @@ notmuch_config_open (void *ctx,\r
166 >      file_had_new_group =3D g_key_file_has_group (config->key_file, "new"=\r
167 );\r
168 >      file_had_user_group =3D g_key_file_has_group (config->key_file, "use=\r
169 r");\r
170 >      file_had_maildir_group =3D g_key_file_has_group (config->key_file, "=\r
171 maildir");\r
172 > +    file_had_search_group =3D g_key_file_has_group (config->key_file, "s=\r
173 earch");\r
174 >=20=20\r
175 >=20=20\r
176 >      if (notmuch_config_get_database_path (config) =3D=3D NULL) {\r
177 > @@ -345,6 +360,11 @@ notmuch_config_open (void *ctx,\r
178 >       notmuch_config_set_new_tags (config, tags, 2);\r
179 >      }\r
180 >=20=20\r
181 > +    if (notmuch_config_get_auto_exclude_tags (config, &tmp) =3D=3D NULL)=\r
182  {\r
183 > +     const char *tags[] =3D { "deleted", "spam" };\r
184 > +     notmuch_config_set_auto_exclude_tags (config, tags, 2);\r
185 > +    }\r
186 > +\r
187 >      error =3D NULL;\r
188 >      config->maildir_synchronize_flags =3D\r
189 >       g_key_file_get_boolean (config->key_file,\r
190 > @@ -387,6 +407,11 @@ notmuch_config_open (void *ctx,\r
191 >                               maildir_config_comment, NULL);\r
192 >      }\r
193 >=20=20\r
194 > +    if (! file_had_search_group) {\r
195 > +     g_key_file_set_comment (config->key_file, "search", NULL,\r
196 > +                             search_config_comment, NULL);\r
197 > +    }\r
198 > +\r
199 >      if (is_new_ret)\r
200 >       *is_new_ret =3D is_new;\r
201 >=20=20\r
202 > @@ -597,6 +622,23 @@ notmuch_config_set_new_tags (notmuch_config_t *confi=\r
203 g,\r
204 >                    &(config->new_tags));\r
205 >  }\r
206 >=20=20\r
207 > +const char **\r
208 > +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *=\r
209 length)\r
210 > +{\r
211 > +    return _config_get_list (config, "search", "auto_exclude_tags",\r
212 > +                          &(config->auto_exclude_tags),\r
213 > +                          &(config->auto_exclude_tags_length), length);\r
214 > +}\r
215 > +\r
216 > +void\r
217 > +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,\r
218 > +                                   const char *list[],\r
219 > +                                   size_t length)\r
220 > +{\r
221 > +    _config_set_list (config, "search", "auto_exclude_tags", list, lengt=\r
222 h,\r
223 > +                   &(config->auto_exclude_tags));\r
224 > +}\r
225 > +\r
226 >  /* Given a configuration item of the form <group>.<key> return the\r
227 >   * component group and key. If any error occurs, print a message on\r
228 >   * stderr and return 1. Otherwise, return 0.\r
229 > diff --git a/notmuch-count.c b/notmuch-count.c\r
230 > index fb7401b..494619f 100644\r
231 > --- a/notmuch-count.c\r
232 > +++ b/notmuch-count.c\r
233 > @@ -35,6 +35,9 @@ notmuch_count_command (void *ctx, int argc, char *argv[=\r
234 ])\r
235 >      char *query_str;\r
236 >      int opt_index;\r
237 >      output_t output =3D OUTPUT_MESSAGES;\r
238 > +    const char **auto_exclude_tags;\r
239 > +    size_t auto_exclude_tags_length;\r
240 > +    unsigned int i;\r
241 >=20=20\r
242 >      notmuch_opt_desc_t options[] =3D {\r
243 >       { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
244 > @@ -75,6 +78,11 @@ notmuch_count_command (void *ctx, int argc, char *argv=\r
245 [])\r
246 >       return 1;\r
247 >      }\r
248 >=20=20\r
249 > +    auto_exclude_tags =3D notmuch_config_get_auto_exclude_tags\r
250 > +     (config, &auto_exclude_tags_length);\r
251 > +    for (i =3D 0; i < auto_exclude_tags_length; i++)\r
252 > +     notmuch_query_add_tag_exclude (query, auto_exclude_tags[i]);\r
253 > +\r
254 >      switch (output) {\r
255 >      case OUTPUT_MESSAGES:\r
256 >       printf ("%u\n", notmuch_query_count_messages (query));\r
257 > diff --git a/notmuch-search.c b/notmuch-search.c\r
258 > index 4baab56..8867aab 100644\r
259 > --- a/notmuch-search.c\r
260 > +++ b/notmuch-search.c\r
261 > @@ -423,6 +423,9 @@ notmuch_search_command (void *ctx, int argc, char *ar=\r
262 gv[])\r
263 >      output_t output =3D OUTPUT_SUMMARY;\r
264 >      int offset =3D 0;\r
265 >      int limit =3D -1; /* unlimited */\r
266 > +    const char **auto_exclude_tags;\r
267 > +    size_t auto_exclude_tags_length;\r
268 > +    unsigned int i;\r
269 >=20=20\r
270 >      enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
271 >       format_sel =3D NOTMUCH_FORMAT_TEXT;\r
272 > @@ -490,6 +493,11 @@ notmuch_search_command (void *ctx, int argc, char *a=\r
273 rgv[])\r
274 >=20=20\r
275 >      notmuch_query_set_sort (query, sort);\r
276 >=20=20\r
277 > +    auto_exclude_tags =3D notmuch_config_get_auto_exclude_tags\r
278 > +     (config, &auto_exclude_tags_length);\r
279 > +    for (i =3D 0; i < auto_exclude_tags_length; i++)\r
280 > +     notmuch_query_add_tag_exclude (query, auto_exclude_tags[i]);\r
281 > +\r
282 >      switch (output) {\r
283 >      default:\r
284 >      case OUTPUT_SUMMARY:\r
285 > diff --git a/test/search b/test/search\r
286 > index a7a0b18..f421ae3 100755\r
287 > --- a/test/search\r
288 > +++ b/test/search\r
289 > @@ -129,4 +129,22 @@ add_message '[subject]=3D"utf8-message-body-subject"=\r
290 ' '[date]=3D"Sat, 01 Jan 2000 12\r
291 >  output=3D$(notmuch search "b=C3=B6d=C3=BD" | notmuch_search_sanitize)\r
292 >  test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test =\r
293 Suite; utf8-message-body-subject (inbox unread)"\r
294 >=20=20\r
295 > +test_begin_subtest "Search hides deleted"\r
296 > +generate_message '[subject]=3D"Not deleted"'\r
297 > +generate_message '[subject]=3D"Deleted"'\r
298 > +notmuch new > /dev/null\r
299 > +notmuch tag +deleted id:$gen_msg_id\r
300 > +output=3D$(notmuch search subject:deleted | notmuch_search_sanitize)\r
301 > +test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test =\r
302 Suite; Not deleted (inbox unread)"\r
303 > +\r
304 > +test_begin_subtest "Search shows deleted if requested"\r
305 > +output=3D$(notmuch search subject:deleted and tag:deleted | notmuch_sear=\r
306 ch_sanitize)\r
307 > +test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test =\r
308 Suite; Deleted (deleted inbox unread)"\r
309 > +\r
310 > +test_begin_subtest "Search hides deleted in threads"\r
311 > +add_message '[subject]=3D"Not deleted reply"' '[in-reply-to]=3D"<$gen_ms=\r
312 g_id>"'\r
313 > +output=3D$(notmuch search subject:deleted | notmuch_search_sanitize)\r
314 > +test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test =\r
315 Suite; Not deleted (inbox unread)\r
316 > +thread:XXX   2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (del=\r
317 eted inbox unread)"\r
318 > +\r
319 >  test_done\r
320 > --=20\r
321 > 1.7.7.3\r
322 >=20\r
323 > _______________________________________________\r
324 > notmuch mailing list\r
325 > notmuch@notmuchmail.org\r
326 > http://notmuchmail.org/mailman/listinfo/notmuch\r