--- /dev/null
+Return-Path: <pieter@praet.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 16F3441ED96\r
+ for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 06:28:06 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id bu+UwR2P-gSo for <notmuch@notmuchmail.org>;\r
+ Wed, 1 Feb 2012 06:28:05 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 6A2D641ED91 for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 06:28:05 -0800\r
+ (PST)\r
+Received: by wgbdt12 with SMTP id dt12so1185375wgb.2\r
+ for <notmuch@notmuchmail.org>; Wed, 01 Feb 2012 06:28:04 -0800 (PST)\r
+Received: by 10.180.101.161 with SMTP id fh1mr41904353wib.0.1328106479221;\r
+ Wed, 01 Feb 2012 06:27:59 -0800 (PST)\r
+Received: from localhost ([109.131.39.11])\r
+ by mx.google.com with ESMTPS id fw1sm4860980wib.0.2012.02.01.06.27.57\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 01 Feb 2012 06:27:58 -0800 (PST)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] added support for user-specified files & directories to\r
+ ignore\r
+In-Reply-To: <20120131-new-ignore-1-git-send-email-too@iki.fi>\r
+References: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>\r
+ <20120131-new-ignore-1-git-send-email-too@iki.fi>\r
+User-Agent: Notmuch/0.11+132~ga81001f (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+Date: Wed, 01 Feb 2012 15:25:57 +0100\r
+Message-ID: <87r4ye6362.fsf@praet.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 01 Feb 2012 14:28:08 -0000\r
+\r
+On Tue, 31 Jan 2012 18:28:04 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+> A new configuration key 'new.ignore' is used to determine which\r
+> files and directories user wants not to be scanned as new mails.\r
+> \r
+> This work merges my previous attempts and Andreas Amann's work\r
+> in id:"ylp7hi23mw8.fsf@tyndall.ie"\r
+> \r
+> See notes in id:"20120131-new-ignore-1-git-send-email-too@iki.fi"\r
+> ---\r
+\r
+Great work Tomi!\r
+\r
+LGTM (though keep in mind, I'm no C coder).\r
+\r
+> Notes\r
+> \r
+> 1) Currently there is comment for new.ignore in newly created configuration\r
+> file but as the list is initially empty there will be not tag in place.\r
+> \r
+> 2) Whenever some already existing directory is added to the exclude list\r
+> and the parent directory timestamp has not changed, notmuch new will not\r
+> notice the directory has gone (as it still is there), user needs to 'touch'\r
+> the parent directory before next 'notmuch new' no make notmuch notice.\r
+> \r
+> 2012-01-26: could notmuch track mtime of the configuration file and if\r
+> that changes, ignore mail directory timestamps ?\r
+> \r
+> \r
+> 3) in id:"1327572718-13411-2-git-send-email-tomi.ollila@iki.fi" dropped...\r
+> \r
+> notmuch-client.h | 8 ++++++++\r
+> notmuch-config.c | 35 +++++++++++++++++++++++++++++++++--\r
+> notmuch-new.c | 45 +++++++++++++++++++++++++++++++++------------\r
+> 3 files changed, 74 insertions(+), 14 deletions(-)\r
+> \r
+> diff --git a/notmuch-client.h b/notmuch-client.h\r
+> index e0eb594..c62ce78 100644\r
+> --- a/notmuch-client.h\r
+> +++ b/notmuch-client.h\r
+> @@ -250,6 +250,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+> const char *new_tags[],\r
+> size_t length);\r
+> \r
+> +const char **\r
+> +notmuch_config_get_new_ignore (notmuch_config_t *config,\r
+> + size_t *length);\r
+> +void\r
+> +notmuch_config_set_new_ignore (notmuch_config_t *config,\r
+> + const char *new_ignore[],\r
+> + size_t length);\r
+> +\r
+> notmuch_bool_t\r
+> notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);\r
+> \r
+> diff --git a/notmuch-config.c b/notmuch-config.c\r
+> index a124e34..f1cc5c2 100644\r
+> --- a/notmuch-config.c\r
+> +++ b/notmuch-config.c\r
+> @@ -44,7 +44,10 @@ static const char new_config_comment[] =\r
+> " The following options are supported here:\n"\r
+> "\n"\r
+> "\ttags A list (separated by ';') of the tags that will be\n"\r
+> - "\t added to all messages incorporated by \"notmuch new\".\n";\r
+> + "\t added to all messages incorporated by \"notmuch new\".\n"\r
+> + "\n"\r
+> + "\tignore A list (separated by ';') of files and directories that"\r
+> + "\t will not be searched for messages by \"notmuch new\".\n";\r
+> \r
+> static const char user_config_comment[] =\r
+> " User configuration\n"\r
+> @@ -105,6 +108,8 @@ struct _notmuch_config {\r
+> size_t user_other_email_length;\r
+> const char **new_tags;\r
+> size_t new_tags_length;\r
+> + const char **new_ignore;\r
+> + size_t new_ignore_length;\r
+> notmuch_bool_t maildir_synchronize_flags;\r
+> const char **search_exclude_tags;\r
+> size_t search_exclude_tags_length;\r
+> @@ -264,6 +269,8 @@ notmuch_config_open (void *ctx,\r
+> config->user_other_email_length = 0;\r
+> config->new_tags = NULL;\r
+> config->new_tags_length = 0;\r
+> + config->new_ignore = NULL;\r
+> + config->new_ignore_length = 0;\r
+> config->maildir_synchronize_flags = TRUE;\r
+> config->search_exclude_tags = NULL;\r
+> config->search_exclude_tags_length = 0;\r
+> @@ -360,7 +367,11 @@ notmuch_config_open (void *ctx,\r
+> const char *tags[] = { "unread", "inbox" };\r
+> notmuch_config_set_new_tags (config, tags, 2);\r
+> }\r
+> -\r
+> +#if 0 /* No point setting empty list -- it's not written */\r
+> + if (notmuch_config_get_new_ignore (config, &tmp) == NULL) {\r
+> + notmuch_config_set_new_ignore (config, NULL, 0);\r
+> + }\r
+> +#endif\r
+> if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {\r
+> if (is_new) {\r
+> const char *tags[] = { "deleted", "spam" };\r
+> @@ -609,6 +620,15 @@ notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)\r
+> &(config->new_tags_length), length);\r
+> }\r
+> \r
+> +const char **\r
+> +notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)\r
+> +{\r
+> + return _config_get_list (config, "new", "ignore",\r
+> + &(config->new_ignore),\r
+> + &(config->new_ignore_length), length);\r
+> +}\r
+> +\r
+> +\r
+> void\r
+> notmuch_config_set_user_other_email (notmuch_config_t *config,\r
+> const char *list[],\r
+> @@ -627,6 +647,17 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+> &(config->new_tags));\r
+> }\r
+> \r
+> +#if 0 /* UNNEEDED SO FAR */\r
+> +void\r
+> +notmuch_config_set_new_ignore (notmuch_config_t *config,\r
+> + const char *list[],\r
+> + size_t length)\r
+> +{\r
+> + _config_set_list (config, "new", "ignore", list, length,\r
+> + &(config->new_ignore));\r
+> +}\r
+> +#endif\r
+> +\r
+\r
+Is this really discarded during compilation ?!?\r
+\r
+The results of my test [1] suggest otherwise...\r
+\r
+\r
+> const char **\r
+> notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)\r
+> {\r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index a569a54..36d5c5d 100644\r
+> --- a/notmuch-new.c\r
+> +++ b/notmuch-new.c\r
+> @@ -39,6 +39,8 @@ typedef struct {\r
+> int verbose;\r
+> const char **new_tags;\r
+> size_t new_tags_length;\r
+> + const char **new_ignore;\r
+> + size_t new_ignore_length;\r
+> \r
+> int total_files;\r
+> int processed_files;\r
+> @@ -181,6 +183,20 @@ _entries_resemble_maildir (struct dirent **entries, int count)\r
+> return 0;\r
+> }\r
+> \r
+> +/* Check if user asked to ignore these files/directories */\r
+> +\r
+> +static int\r
+> +_entry_in_ignore_list (const char *entry, add_files_state_t *state)\r
+> +{\r
+> + size_t i, ignore_length = state->new_ignore_length;\r
+> +\r
+> + for (i = 0; i < ignore_length; i++)\r
+> + if (strcmp (entry, state->new_ignore[i]) == 0)\r
+> + return 1;\r
+> +\r
+> + return 0;\r
+> +}\r
+> +\r
+> /* Examine 'path' recursively as follows:\r
+> *\r
+> * o Ask the filesystem for the mtime of 'path' (fs_mtime)\r
+> @@ -320,15 +336,15 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+> }\r
+> \r
+> /* Ignore special directories to avoid infinite recursion.\r
+> - * Also ignore the .notmuch directory and any "tmp" directory\r
+> - * that appears within a maildir.\r
+> + * Also ignore the .notmuch directory, any "tmp" directory\r
+> + * that appears within a maildir and files/directories\r
+> + * user have configured to be ignored.\r
+> */\r
+> - /* XXX: Eventually we'll want more sophistication to let the\r
+> - * user specify files to be ignored. */\r
+> if (strcmp (entry->d_name, ".") == 0 ||\r
+> strcmp (entry->d_name, "..") == 0 ||\r
+> (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||\r
+> - strcmp (entry->d_name, ".notmuch") ==0)\r
+> + strcmp (entry->d_name, ".notmuch") == 0 ||\r
+> + _entry_in_ignore_list (entry->d_name, state))\r
+> {\r
+> continue;\r
+> }\r
+> @@ -369,6 +385,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+> \r
+> entry = fs_entries[i];\r
+> \r
+> + /* Ignore files & directories user has configured to be ignored */\r
+> + if (_entry_in_ignore_list (entry->d_name, state))\r
+> + continue;\r
+> +\r
+> /* Check if we've walked past any names in db_files or\r
+> * db_subdirs. If so, these have been deleted. */\r
+> while (notmuch_filenames_valid (db_files) &&\r
+> @@ -648,7 +668,7 @@ add_files (notmuch_database_t *notmuch,\r
+> * initialized to zero by the top-level caller before calling\r
+> * count_files). */\r
+> static void\r
+> -count_files (const char *path, int *count)\r
+> +count_files (const char *path, int *count, add_files_state_t *state)\r
+> {\r
+> struct dirent *entry = NULL;\r
+> char *next;\r
+> @@ -670,13 +690,13 @@ count_files (const char *path, int *count)\r
+> entry = fs_entries[i++];\r
+> \r
+> /* Ignore special directories to avoid infinite recursion.\r
+> - * Also ignore the .notmuch directory.\r
+> + * Also ignore the .notmuch directory and files/directories\r
+> + * user have configured to be ignored.\r
+> */\r
+> - /* XXX: Eventually we'll want more sophistication to let the\r
+> - * user specify files to be ignored. */\r
+> if (strcmp (entry->d_name, ".") == 0 ||\r
+> strcmp (entry->d_name, "..") == 0 ||\r
+> - strcmp (entry->d_name, ".notmuch") == 0)\r
+> + strcmp (entry->d_name, ".notmuch") == 0 ||\r
+> + _entry_in_ignore_list (entry->d_name, state))\r
+> {\r
+> continue;\r
+> }\r
+> @@ -697,7 +717,7 @@ count_files (const char *path, int *count)\r
+> fflush (stdout);\r
+> }\r
+> } else if (S_ISDIR (st.st_mode)) {\r
+> - count_files (next, count);\r
+> + count_files (next, count, state);\r
+> }\r
+> \r
+> free (next);\r
+> @@ -837,6 +857,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+> return 1;\r
+> \r
+> add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);\r
+> + add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);\r
+> add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
+> db_path = notmuch_config_get_database_path (config);\r
+> \r
+> @@ -852,7 +873,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+> int count;\r
+> \r
+> count = 0;\r
+> - count_files (db_path, &count);\r
+> + count_files (db_path, &count, &add_files_state);\r
+> if (interrupted)\r
+> return 1;\r
+> \r
+> -- \r
+> 1.7.6.5\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+\r
+Peace\r
+\r
+-- \r
+Pieter\r
+\r
+[1] id:"1328105573-4626-1-git-send-email-pieter@praet.org"\r