1 Return-Path: <amthrax@drake.mit.edu>
\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 5F08F431FB6
\r
6 for <notmuch@notmuchmail.org>; Tue, 10 Jan 2012 21:03:49 -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 MAgIF3lSdmcS for <notmuch@notmuchmail.org>;
\r
16 Tue, 10 Jan 2012 21:03:46 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id AC79E429E37
\r
20 for <notmuch@notmuchmail.org>; Tue, 10 Jan 2012 21:03:41 -0800 (PST)
\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-d8-4f0d182de6f0
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 30.EF.02234.D281D0F4; Wed, 11 Jan 2012 00:03:41 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q0B53ejJ027482;
\r
27 Wed, 11 Jan 2012 00:03:40 -0500
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0B53cZU017227
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Wed, 11 Jan 2012 00:03:40 -0500 (EST)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1RkqLa-0005dl-GB; Wed, 11 Jan 2012 00:03:38 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 3/3] search: Support automatic tag exclusions
\r
41 Date: Wed, 11 Jan 2012 00:02:53 -0500
\r
42 Message-Id: <1326258173-21163-4-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.7.3
\r
44 In-Reply-To: <1326258173-21163-1-git-send-email-amdragon@mit.edu>
\r
45 References: <20120109043101.GH20796@mit.edu>
\r
46 <1326258173-21163-1-git-send-email-amdragon@mit.edu>
\r
48 Content-Type: text/plain; charset=UTF-8
\r
49 Content-Transfer-Encoding: 8bit
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsUixCmqrKsrwetvsKNF0uL6zZnMDowez1bd
\r
52 Yg5gjOKySUnNySxLLdK3S+DK+HRsLVtBo13F7fZG9gbGGUZdjJwcEgImEuvvzWaBsMUkLtxb
\r
53 z9bFyMUhJLCPUWJFWz8jSEJIYAOjxO4uFojEfSaJr2/2MkM48xklrn1qYgOpYhPQkNi2fzlY
\r
54 h4iAtMTOu7NZuxg5OJgFRCTezWQCCQsLREucPnIVrIRFQFWi/9VTZhCbV8BBYv3dLawQVyhI
\r
55 nFt9jh3E5hRwlLizazMTxBHJEu39K6DqBSVOznzCAjFeXWL9PCGQMLOAvETz1tnMExiFZiGp
\r
56 moVQNQtJ1QJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6Rnq5mSV6qSmlmxjBASzJu4Px3UGl
\r
57 Q4wCHIxKPLwGqTz+QqyJZcWVuYcYJTmYlER5+8R4/YX4kvJTKjMSizPii0pzUosPMUpwMCuJ
\r
58 8CpmAZXzpiRWVqUW5cOkpDlYlMR5VbXe+QkJpCeWpGanphakFsFkZTg4lCR494oDDRUsSk1P
\r
59 rUjLzClBSDNxcIIM5wEavgukhre4IDG3ODMdIn+KUVFKnLcXJCEAksgozYPrhSWYV4ziQK8I
\r
60 8x4AqeIBJie47ldAg5mABm9ZB3J1cUkiQkqqgbH+UUdjySfm875XHj3kWp5WquWernqrTvbH
\r
61 367Wy3fjv7JcjleIZnmrmNEbqv+rdtdB43r/M23J6TkJnxdtuFny3K7u2zuZa+dMTMXZrgcE
\r
62 ztuoH6ca6v++zlls68v5W04sT9ukI31yZlpD2AWz+TPqXWon/Y77supLMcO8rtbzSevf/roS
\r
63 /ECJpTgj0VCLuag4EQAhqjIqCwMAAA==
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Wed, 11 Jan 2012 05:03:49 -0000
\r
78 This adds a "search" section to the config file and an
\r
79 "auto_tag_exclusions" setting in that section. The search and count
\r
80 commands pass tag tags from the configuration to the library.
\r
82 notmuch-client.h | 8 ++++++++
\r
83 notmuch-config.c | 42 ++++++++++++++++++++++++++++++++++++++++++
\r
84 notmuch-count.c | 8 ++++++++
\r
85 notmuch-search.c | 8 ++++++++
\r
86 test/search | 18 ++++++++++++++++++
\r
87 5 files changed, 84 insertions(+), 0 deletions(-)
\r
89 diff --git a/notmuch-client.h b/notmuch-client.h
\r
90 index 517c010..62ede28 100644
\r
91 --- a/notmuch-client.h
\r
92 +++ b/notmuch-client.h
\r
93 @@ -235,6 +235,14 @@ void
\r
94 notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
\r
95 notmuch_bool_t synchronize_flags);
\r
98 +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *length);
\r
101 +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,
\r
102 + const char *list[],
\r
106 notmuch_run_hook (const char *db_path, const char *hook);
\r
108 diff --git a/notmuch-config.c b/notmuch-config.c
\r
109 index d697138..6c3123b 100644
\r
110 --- a/notmuch-config.c
\r
111 +++ b/notmuch-config.c
\r
112 @@ -84,6 +84,15 @@ static const char maildir_config_comment[] =
\r
113 "\tand update tags, while the \"notmuch tag\" and \"notmuch restore\"\n"
\r
114 "\tcommands will notice tag changes and update flags in filenames\n";
\r
116 +static const char search_config_comment[] =
\r
117 + " Search configuration\n"
\r
119 + " The following option is supported here:\n"
\r
121 + "\tauto_exclude_tags A ;-separated list of tags that will be\n"
\r
122 + "\t excluded from queries by default. This can be overridden by including\n"
\r
123 + "\t these tags in a query.\n";
\r
125 struct _notmuch_config {
\r
127 GKeyFile *key_file;
\r
128 @@ -96,6 +105,8 @@ struct _notmuch_config {
\r
129 const char **new_tags;
\r
130 size_t new_tags_length;
\r
131 notmuch_bool_t maildir_synchronize_flags;
\r
132 + const char **auto_exclude_tags;
\r
133 + size_t auto_exclude_tags_length;
\r
137 @@ -221,6 +232,7 @@ notmuch_config_open (void *ctx,
\r
138 int file_had_new_group;
\r
139 int file_had_user_group;
\r
140 int file_had_maildir_group;
\r
141 + int file_had_search_group;
\r
145 @@ -252,6 +264,8 @@ notmuch_config_open (void *ctx,
\r
146 config->new_tags = NULL;
\r
147 config->new_tags_length = 0;
\r
148 config->maildir_synchronize_flags = TRUE;
\r
149 + config->auto_exclude_tags = NULL;
\r
150 + config->auto_exclude_tags_length = 0;
\r
152 if (! g_key_file_load_from_file (config->key_file,
\r
154 @@ -295,6 +309,7 @@ notmuch_config_open (void *ctx,
\r
155 file_had_new_group = g_key_file_has_group (config->key_file, "new");
\r
156 file_had_user_group = g_key_file_has_group (config->key_file, "user");
\r
157 file_had_maildir_group = g_key_file_has_group (config->key_file, "maildir");
\r
158 + file_had_search_group = g_key_file_has_group (config->key_file, "search");
\r
161 if (notmuch_config_get_database_path (config) == NULL) {
\r
162 @@ -345,6 +360,11 @@ notmuch_config_open (void *ctx,
\r
163 notmuch_config_set_new_tags (config, tags, 2);
\r
166 + if (notmuch_config_get_auto_exclude_tags (config, &tmp) == NULL) {
\r
167 + const char *tags[] = { "deleted", "spam" };
\r
168 + notmuch_config_set_auto_exclude_tags (config, tags, 2);
\r
172 config->maildir_synchronize_flags =
\r
173 g_key_file_get_boolean (config->key_file,
\r
174 @@ -387,6 +407,11 @@ notmuch_config_open (void *ctx,
\r
175 maildir_config_comment, NULL);
\r
178 + if (! file_had_search_group) {
\r
179 + g_key_file_set_comment (config->key_file, "search", NULL,
\r
180 + search_config_comment, NULL);
\r
184 *is_new_ret = is_new;
\r
186 @@ -597,6 +622,23 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
\r
187 &(config->new_tags));
\r
191 +notmuch_config_get_auto_exclude_tags (notmuch_config_t *config, size_t *length)
\r
193 + return _config_get_list (config, "search", "auto_exclude_tags",
\r
194 + &(config->auto_exclude_tags),
\r
195 + &(config->auto_exclude_tags_length), length);
\r
199 +notmuch_config_set_auto_exclude_tags (notmuch_config_t *config,
\r
200 + const char *list[],
\r
203 + _config_set_list (config, "search", "auto_exclude_tags", list, length,
\r
204 + &(config->auto_exclude_tags));
\r
207 /* Given a configuration item of the form <group>.<key> return the
\r
208 * component group and key. If any error occurs, print a message on
\r
209 * stderr and return 1. Otherwise, return 0.
\r
210 diff --git a/notmuch-count.c b/notmuch-count.c
\r
211 index fb7401b..494619f 100644
\r
212 --- a/notmuch-count.c
\r
213 +++ b/notmuch-count.c
\r
214 @@ -35,6 +35,9 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
217 output_t output = OUTPUT_MESSAGES;
\r
218 + const char **auto_exclude_tags;
\r
219 + size_t auto_exclude_tags_length;
\r
222 notmuch_opt_desc_t options[] = {
\r
223 { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
\r
224 @@ -75,6 +78,11 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
228 + auto_exclude_tags = notmuch_config_get_auto_exclude_tags
\r
229 + (config, &auto_exclude_tags_length);
\r
230 + for (i = 0; i < auto_exclude_tags_length; i++)
\r
231 + notmuch_query_add_tag_exclude (query, auto_exclude_tags[i]);
\r
234 case OUTPUT_MESSAGES:
\r
235 printf ("%u\n", notmuch_query_count_messages (query));
\r
236 diff --git a/notmuch-search.c b/notmuch-search.c
\r
237 index 4baab56..8867aab 100644
\r
238 --- a/notmuch-search.c
\r
239 +++ b/notmuch-search.c
\r
240 @@ -423,6 +423,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
241 output_t output = OUTPUT_SUMMARY;
\r
243 int limit = -1; /* unlimited */
\r
244 + const char **auto_exclude_tags;
\r
245 + size_t auto_exclude_tags_length;
\r
248 enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
\r
249 format_sel = NOTMUCH_FORMAT_TEXT;
\r
250 @@ -490,6 +493,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
252 notmuch_query_set_sort (query, sort);
\r
254 + auto_exclude_tags = notmuch_config_get_auto_exclude_tags
\r
255 + (config, &auto_exclude_tags_length);
\r
256 + for (i = 0; i < auto_exclude_tags_length; i++)
\r
257 + notmuch_query_add_tag_exclude (query, auto_exclude_tags[i]);
\r
261 case OUTPUT_SUMMARY:
\r
262 diff --git a/test/search b/test/search
\r
263 index a7a0b18..f421ae3 100755
\r
266 @@ -129,4 +129,22 @@ add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12
\r
267 output=$(notmuch search "bödý" | notmuch_search_sanitize)
\r
268 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
\r
270 +test_begin_subtest "Search hides deleted"
\r
271 +generate_message '[subject]="Not deleted"'
\r
272 +generate_message '[subject]="Deleted"'
\r
273 +notmuch new > /dev/null
\r
274 +notmuch tag +deleted id:$gen_msg_id
\r
275 +output=$(notmuch search subject:deleted | notmuch_search_sanitize)
\r
276 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)"
\r
278 +test_begin_subtest "Search shows deleted if requested"
\r
279 +output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize)
\r
280 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Deleted (deleted inbox unread)"
\r
282 +test_begin_subtest "Search hides deleted in threads"
\r
283 +add_message '[subject]="Not deleted reply"' '[in-reply-to]="<$gen_msg_id>"'
\r
284 +output=$(notmuch search subject:deleted | notmuch_search_sanitize)
\r
285 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)
\r
286 +thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)"
\r