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
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
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
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
39 Date: Wed, 11 Jan 2012 21:27:52 +0200
\r
40 Message-ID: <87ty42ca4n.fsf@nikula.org>
\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
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
58 On Wed, 11 Jan 2012 00:02:53 -0500, Austin Clements <amdragon@MIT.EDU> wrot=
\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
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
69 test_begin_subtest "message count with --output=3Dmessages"
\r
71 "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \
\r
72 "`notmuch count --output=3Dmessages ${SEARCH}`"
\r
74 test_begin_subtest "thread count with --output=3Dthreads"
\r
76 "`notmuch search --output=3Dthreads ${SEARCH} | wc -l`" \
\r
77 "`notmuch count --output=3Dthreads ${SEARCH}`"
\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
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
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
106 > +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *=
\r
110 > +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,
\r
111 > + const char *list[],
\r
112 > + size_t length);
\r
115 > notmuch_run_hook (const char *db_path, const char *hook);
\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
124 > "\tcommands will notice tag changes and update flags in filenames\n";
\r
126 > +static const char search_config_comment[] =3D
\r
127 > + " Search configuration\n"
\r
129 > + " The following option is supported here:\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
134 > + "\t these tags in a query.\n";
\r
136 > struct _notmuch_config {
\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
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
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
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
168 > file_had_user_group =3D g_key_file_has_group (config->key_file, "use=
\r
170 > file_had_maildir_group =3D g_key_file_has_group (config->key_file, "=
\r
172 > + file_had_search_group =3D g_key_file_has_group (config->key_file, "s=
\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
181 > + if (notmuch_config_get_auto_exclude_tags (config, &tmp) =3D=3D NULL)=
\r
183 > + const char *tags[] =3D { "deleted", "spam" };
\r
184 > + notmuch_config_set_auto_exclude_tags (config, tags, 2);
\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
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
200 > *is_new_ret =3D is_new;
\r
202 > @@ -597,6 +622,23 @@ notmuch_config_set_new_tags (notmuch_config_t *confi=
\r
204 > &(config->new_tags));
\r
208 > +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *=
\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
217 > +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,
\r
218 > + const char *list[],
\r
221 > + _config_set_list (config, "search", "auto_exclude_tags", list, lengt=
\r
223 > + &(config->auto_exclude_tags));
\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
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
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
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
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
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
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
275 > notmuch_query_set_sort (query, sort);
\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
282 > switch (output) {
\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
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
304 > +test_begin_subtest "Search shows deleted if requested"
\r
305 > +output=3D$(notmuch search subject:deleted and tag:deleted | notmuch_sear=
\r
307 > +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test =
\r
308 Suite; Deleted (deleted inbox unread)"
\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
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
323 > _______________________________________________
\r
324 > notmuch mailing list
\r
325 > notmuch@notmuchmail.org
\r
326 > http://notmuchmail.org/mailman/listinfo/notmuch
\r