1 Return-Path: <pieter@praet.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 16F3441ED96
\r
6 for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 06:28:06 -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 bu+UwR2P-gSo for <notmuch@notmuchmail.org>;
\r
16 Wed, 1 Feb 2012 06:28:05 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) (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 6A2D641ED91 for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 06:28:05 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so1185375wgb.2
\r
23 for <notmuch@notmuchmail.org>; Wed, 01 Feb 2012 06:28:04 -0800 (PST)
\r
24 Received: by 10.180.101.161 with SMTP id fh1mr41904353wib.0.1328106479221;
\r
25 Wed, 01 Feb 2012 06:27:59 -0800 (PST)
\r
26 Received: from localhost ([109.131.39.11])
\r
27 by mx.google.com with ESMTPS id fw1sm4860980wib.0.2012.02.01.06.27.57
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Wed, 01 Feb 2012 06:27:58 -0800 (PST)
\r
30 From: Pieter Praet <pieter@praet.org>
\r
31 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
32 Subject: Re: [PATCH] added support for user-specified files & directories to
\r
34 In-Reply-To: <20120131-new-ignore-1-git-send-email-too@iki.fi>
\r
35 References: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>
\r
36 <20120131-new-ignore-1-git-send-email-too@iki.fi>
\r
37 User-Agent: Notmuch/0.11+132~ga81001f (http://notmuchmail.org) Emacs/23.3.1
\r
38 (x86_64-unknown-linux-gnu)
\r
39 Date: Wed, 01 Feb 2012 15:25:57 +0100
\r
40 Message-ID: <87r4ye6362.fsf@praet.org>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\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, 01 Feb 2012 14:28:08 -0000
\r
58 On Tue, 31 Jan 2012 18:28:04 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
59 > A new configuration key 'new.ignore' is used to determine which
\r
60 > files and directories user wants not to be scanned as new mails.
\r
62 > This work merges my previous attempts and Andreas Amann's work
\r
63 > in id:"ylp7hi23mw8.fsf@tyndall.ie"
\r
65 > See notes in id:"20120131-new-ignore-1-git-send-email-too@iki.fi"
\r
70 LGTM (though keep in mind, I'm no C coder).
\r
74 > 1) Currently there is comment for new.ignore in newly created configuration
\r
75 > file but as the list is initially empty there will be not tag in place.
\r
77 > 2) Whenever some already existing directory is added to the exclude list
\r
78 > and the parent directory timestamp has not changed, notmuch new will not
\r
79 > notice the directory has gone (as it still is there), user needs to 'touch'
\r
80 > the parent directory before next 'notmuch new' no make notmuch notice.
\r
82 > 2012-01-26: could notmuch track mtime of the configuration file and if
\r
83 > that changes, ignore mail directory timestamps ?
\r
86 > 3) in id:"1327572718-13411-2-git-send-email-tomi.ollila@iki.fi" dropped...
\r
88 > notmuch-client.h | 8 ++++++++
\r
89 > notmuch-config.c | 35 +++++++++++++++++++++++++++++++++--
\r
90 > notmuch-new.c | 45 +++++++++++++++++++++++++++++++++------------
\r
91 > 3 files changed, 74 insertions(+), 14 deletions(-)
\r
93 > diff --git a/notmuch-client.h b/notmuch-client.h
\r
94 > index e0eb594..c62ce78 100644
\r
95 > --- a/notmuch-client.h
\r
96 > +++ b/notmuch-client.h
\r
97 > @@ -250,6 +250,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
\r
98 > const char *new_tags[],
\r
102 > +notmuch_config_get_new_ignore (notmuch_config_t *config,
\r
103 > + size_t *length);
\r
105 > +notmuch_config_set_new_ignore (notmuch_config_t *config,
\r
106 > + const char *new_ignore[],
\r
107 > + size_t length);
\r
110 > notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
\r
112 > diff --git a/notmuch-config.c b/notmuch-config.c
\r
113 > index a124e34..f1cc5c2 100644
\r
114 > --- a/notmuch-config.c
\r
115 > +++ b/notmuch-config.c
\r
116 > @@ -44,7 +44,10 @@ static const char new_config_comment[] =
\r
117 > " The following options are supported here:\n"
\r
119 > "\ttags A list (separated by ';') of the tags that will be\n"
\r
120 > - "\t added to all messages incorporated by \"notmuch new\".\n";
\r
121 > + "\t added to all messages incorporated by \"notmuch new\".\n"
\r
123 > + "\tignore A list (separated by ';') of files and directories that"
\r
124 > + "\t will not be searched for messages by \"notmuch new\".\n";
\r
126 > static const char user_config_comment[] =
\r
127 > " User configuration\n"
\r
128 > @@ -105,6 +108,8 @@ struct _notmuch_config {
\r
129 > size_t user_other_email_length;
\r
130 > const char **new_tags;
\r
131 > size_t new_tags_length;
\r
132 > + const char **new_ignore;
\r
133 > + size_t new_ignore_length;
\r
134 > notmuch_bool_t maildir_synchronize_flags;
\r
135 > const char **search_exclude_tags;
\r
136 > size_t search_exclude_tags_length;
\r
137 > @@ -264,6 +269,8 @@ notmuch_config_open (void *ctx,
\r
138 > config->user_other_email_length = 0;
\r
139 > config->new_tags = NULL;
\r
140 > config->new_tags_length = 0;
\r
141 > + config->new_ignore = NULL;
\r
142 > + config->new_ignore_length = 0;
\r
143 > config->maildir_synchronize_flags = TRUE;
\r
144 > config->search_exclude_tags = NULL;
\r
145 > config->search_exclude_tags_length = 0;
\r
146 > @@ -360,7 +367,11 @@ notmuch_config_open (void *ctx,
\r
147 > const char *tags[] = { "unread", "inbox" };
\r
148 > notmuch_config_set_new_tags (config, tags, 2);
\r
151 > +#if 0 /* No point setting empty list -- it's not written */
\r
152 > + if (notmuch_config_get_new_ignore (config, &tmp) == NULL) {
\r
153 > + notmuch_config_set_new_ignore (config, NULL, 0);
\r
156 > if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {
\r
158 > const char *tags[] = { "deleted", "spam" };
\r
159 > @@ -609,6 +620,15 @@ notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)
\r
160 > &(config->new_tags_length), length);
\r
164 > +notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)
\r
166 > + return _config_get_list (config, "new", "ignore",
\r
167 > + &(config->new_ignore),
\r
168 > + &(config->new_ignore_length), length);
\r
173 > notmuch_config_set_user_other_email (notmuch_config_t *config,
\r
174 > const char *list[],
\r
175 > @@ -627,6 +647,17 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
\r
176 > &(config->new_tags));
\r
179 > +#if 0 /* UNNEEDED SO FAR */
\r
181 > +notmuch_config_set_new_ignore (notmuch_config_t *config,
\r
182 > + const char *list[],
\r
185 > + _config_set_list (config, "new", "ignore", list, length,
\r
186 > + &(config->new_ignore));
\r
191 Is this really discarded during compilation ?!?
\r
193 The results of my test [1] suggest otherwise...
\r
197 > notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)
\r
199 > diff --git a/notmuch-new.c b/notmuch-new.c
\r
200 > index a569a54..36d5c5d 100644
\r
201 > --- a/notmuch-new.c
\r
202 > +++ b/notmuch-new.c
\r
203 > @@ -39,6 +39,8 @@ typedef struct {
\r
205 > const char **new_tags;
\r
206 > size_t new_tags_length;
\r
207 > + const char **new_ignore;
\r
208 > + size_t new_ignore_length;
\r
211 > int processed_files;
\r
212 > @@ -181,6 +183,20 @@ _entries_resemble_maildir (struct dirent **entries, int count)
\r
216 > +/* Check if user asked to ignore these files/directories */
\r
219 > +_entry_in_ignore_list (const char *entry, add_files_state_t *state)
\r
221 > + size_t i, ignore_length = state->new_ignore_length;
\r
223 > + for (i = 0; i < ignore_length; i++)
\r
224 > + if (strcmp (entry, state->new_ignore[i]) == 0)
\r
230 > /* Examine 'path' recursively as follows:
\r
232 > * o Ask the filesystem for the mtime of 'path' (fs_mtime)
\r
233 > @@ -320,15 +336,15 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
236 > /* Ignore special directories to avoid infinite recursion.
\r
237 > - * Also ignore the .notmuch directory and any "tmp" directory
\r
238 > - * that appears within a maildir.
\r
239 > + * Also ignore the .notmuch directory, any "tmp" directory
\r
240 > + * that appears within a maildir and files/directories
\r
241 > + * user have configured to be ignored.
\r
243 > - /* XXX: Eventually we'll want more sophistication to let the
\r
244 > - * user specify files to be ignored. */
\r
245 > if (strcmp (entry->d_name, ".") == 0 ||
\r
246 > strcmp (entry->d_name, "..") == 0 ||
\r
247 > (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r
248 > - strcmp (entry->d_name, ".notmuch") ==0)
\r
249 > + strcmp (entry->d_name, ".notmuch") == 0 ||
\r
250 > + _entry_in_ignore_list (entry->d_name, state))
\r
254 > @@ -369,6 +385,10 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
256 > entry = fs_entries[i];
\r
258 > + /* Ignore files & directories user has configured to be ignored */
\r
259 > + if (_entry_in_ignore_list (entry->d_name, state))
\r
262 > /* Check if we've walked past any names in db_files or
\r
263 > * db_subdirs. If so, these have been deleted. */
\r
264 > while (notmuch_filenames_valid (db_files) &&
\r
265 > @@ -648,7 +668,7 @@ add_files (notmuch_database_t *notmuch,
\r
266 > * initialized to zero by the top-level caller before calling
\r
267 > * count_files). */
\r
269 > -count_files (const char *path, int *count)
\r
270 > +count_files (const char *path, int *count, add_files_state_t *state)
\r
272 > struct dirent *entry = NULL;
\r
274 > @@ -670,13 +690,13 @@ count_files (const char *path, int *count)
\r
275 > entry = fs_entries[i++];
\r
277 > /* Ignore special directories to avoid infinite recursion.
\r
278 > - * Also ignore the .notmuch directory.
\r
279 > + * Also ignore the .notmuch directory and files/directories
\r
280 > + * user have configured to be ignored.
\r
282 > - /* XXX: Eventually we'll want more sophistication to let the
\r
283 > - * user specify files to be ignored. */
\r
284 > if (strcmp (entry->d_name, ".") == 0 ||
\r
285 > strcmp (entry->d_name, "..") == 0 ||
\r
286 > - strcmp (entry->d_name, ".notmuch") == 0)
\r
287 > + strcmp (entry->d_name, ".notmuch") == 0 ||
\r
288 > + _entry_in_ignore_list (entry->d_name, state))
\r
292 > @@ -697,7 +717,7 @@ count_files (const char *path, int *count)
\r
295 > } else if (S_ISDIR (st.st_mode)) {
\r
296 > - count_files (next, count);
\r
297 > + count_files (next, count, state);
\r
301 > @@ -837,6 +857,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
304 > add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
305 > + add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);
\r
306 > add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
307 > db_path = notmuch_config_get_database_path (config);
\r
309 > @@ -852,7 +873,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
313 > - count_files (db_path, &count);
\r
314 > + count_files (db_path, &count, &add_files_state);
\r
321 > _______________________________________________
\r
322 > notmuch mailing list
\r
323 > notmuch@notmuchmail.org
\r
324 > http://notmuchmail.org/mailman/listinfo/notmuch
\r
332 [1] id:"1328105573-4626-1-git-send-email-pieter@praet.org"
\r