[PATCH 2/2] added support for user-specified directories to exclude

2012-01-28 Thread Fabio Zanini
On Fri, Jan 27, 2012 at 12:41:18PM +0200, Tomi Ollila wrote:
> It's easy to combine works together, but more difficult is to choose best 
> terminology: database.exclude vs. new.ignore (or something in between or 
> totally different). Ideas anyone?

I would opt for including two mechanisms for ignoring dirs:
- explicit mention in the config file (e.g. under new.ignore);
- check for presence of a file in the dir (e.g. .notmuchignore), much
  like mu [1].

The second mechanism is useful in case of a large number of folders to
be ignored, as one can simply copy .notmuchignore in all those folders
with a for cycle; listing all of them in the config file would be
cumbersome - and make the config file itself horribly bloated.

Cheers,
Fabio

[1] http://code.google.com/p/mu0/


Re: [PATCH 2/2] added support for user-specified directories to exclude

2012-01-28 Thread Fabio Zanini
On Fri, Jan 27, 2012 at 12:41:18PM +0200, Tomi Ollila wrote:
> It's easy to combine works together, but more difficult is to choose best 
> terminology: database.exclude vs. new.ignore (or something in between or 
> totally different). Ideas anyone?

I would opt for including two mechanisms for ignoring dirs:
- explicit mention in the config file (e.g. under new.ignore);
- check for presence of a file in the dir (e.g. .notmuchignore), much
  like mu [1].

The second mechanism is useful in case of a large number of folders to
be ignored, as one can simply copy .notmuchignore in all those folders
with a for cycle; listing all of them in the config file would be
cumbersome - and make the config file itself horribly bloated.

Cheers,
Fabio

[1] http://code.google.com/p/mu0/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Austin Clements
Quoth Tomi Ollila on Jan 26 at 12:11 pm:
> A new configuration key 'database.exclude' is used to determine
> which directories user wants not to be scanned for new mails.

Not just directories.

> ---
> 
> Notes (from 2011-09-13):
> 
> 1) Currently the comments for newly created configuration file are not
> updated, so for not this is 'undocumented feature'. Should there be an
> empty configuration line as a placeholder ... ?

This is unfortunate and hard to do anything about with the current
config file design.  For precisely this reason, I think option
documentation should be in per-option comments instead of per-section
comments, but this would be a large change to the config structure.
For now, it should definitely be added to the section comment so that
newly generated config files get it.  If you want to be fancy, you can
check for the old section comment (or perhaps just its hash) and
automatically upgrade it.

> 2) Whenever some already existing directory is added to the exclude list
> and the parent directory timestamp has not changed, notmuch new will not
> notice the directory has gone (as it still is there), user needs to 'touch'
> the parent directory before next 'notmuch new' no make notmuch notice.
> 
> 2012-01-26: could notmuch track mtime of the configuration file and if
> that changes, ignore mail directory timestamps ?

notmuch actively descends into every subdirectory of your Maildir (it
has to, since mtime changes don't propagate up), which seems like the
perfect opportunity to check if an ignored directory is present in the
database.  This is harder for ignored files and probably not worth
solving since people are probably ignoring files that aren't mail
anyway (whereas I know people want to ignore directories that contain
mail).

> 3) count_files() function is not touched. The functionality there has fallen
> behind of add_files_recursive (maildir+tmp check and following symlinks).
> The question there should it be updated, or attempted to merge with
> add_files (as the comment says). count_files() is only called at the beginning
> when database is not yet initialised.

Given that count_files is already broken, it's probably best to leave
it as is for now and maybe fix it thoroughly later.  I wouldn't be too
worried about this though, since a new database is likely to also have
no configured ignores.

> ---
>  notmuch-client.h |3 +++
>  notmuch-config.c |   13 +
>  notmuch-new.c|   22 --
>  3 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-client.h b/notmuch-client.h
> index e0eb594..78460fc 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -219,6 +219,9 @@ void
>  notmuch_config_set_database_path (notmuch_config_t *config,
> const char *database_path);
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length);

As I mentioned in another email, I would prefer to see this in the
'new' section (though I could probably be persuaded otherwise).  Also,
I think "ignore" would be more typical terminology (think .gitignore,
etc).

Also, every other getter has a corresponding setter.

>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config);
>  
> diff --git a/notmuch-config.c b/notmuch-config.c
> index a124e34..e236114 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -99,6 +99,8 @@ struct _notmuch_config {
>  GKeyFile *key_file;
>  
>  char *database_path;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  char *user_name;
>  char *user_primary_email;
>  const char **user_other_email;
> @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
>  config->key_file = g_key_file_new ();
>  
>  config->database_path = NULL;
> +config->database_exclude = NULL;
> +config->database_exclude_length = 0;
>  config->user_name = NULL;
>  config->user_primary_email = NULL;
>  config->user_other_email = NULL;
> @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t 
> *config,
>  config->database_path = NULL;
>  }
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length)
> +{
> +return _config_get_list (config, "database", "exclude",
> +  &(config->database_exclude),
> +  &(config->database_exclude_length), length);
> +}
> +

All of the other options are fetched by notmuch_config_open and set if
they don't exist.  This has the effect that they will get added to the
configuration file if it is written out, which won't happen to this
option.

>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config)
>  {
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..d607f5b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -39,6 +39,8 @@ typedef

[PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Austin Clements
Quoth Tomi Ollila on Jan 27 at 12:41 pm:
> On Thu, 26 Jan 2012 13:11:36 +, Jani Nikula  wrote:
> > On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  
> > wrote:
> > > A new configuration key 'database.exclude' is used to determine
> > > which directories user wants not to be scanned for new mails.
> > > 
> > > ---
> > > 
> > > Notes (from 2011-09-13):
> > > 
> > > 1) Currently the comments for newly created configuration file are not
> > > updated, so for not this is 'undocumented feature'. Should there be an
> > > empty configuration line as a placeholder ... ?
> > > 
> > > 2) Whenever some already existing directory is added to the exclude list
> > > and the parent directory timestamp has not changed, notmuch new will not
> > > notice the directory has gone (as it still is there), user needs to 
> > > 'touch'
> > > the parent directory before next 'notmuch new' no make notmuch notice.
> > > 
> > > 2012-01-26: could notmuch track mtime of the configuration file and if
> > > that changes, ignore mail directory timestamps ?
> > > 
> > > 3) count_files() function is not touched. The functionality there has 
> > > fallen
> > > behind of add_files_recursive (maildir+tmp check and following symlinks).
> > > The question there should it be updated, or attempted to merge with
> > > add_files (as the comment says). count_files() is only called at the 
> > > beginning
> > > when database is not yet initialised.
> > > ---
> 
> [ ... ]
> 
> > > + /* Ignore user-specified directories */
> > > + for (j = 0; j < state->database_exclude_length; j++)
> > > + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> > > + break;
> > > + if (j < state->database_exclude_length)
> > > + continue;
> > 
> > How about wrapping that in a function you can use here and below?
> > 
> > if (user_wants_this_excluded (...))
> > continue;
> 
> Good point
> 
> > Please also have a look at id:"87pqecylon.fsf at nikula.org" and the
> > patches Austin posted. "Auto ignore"?
> 
> I personally don't mind auto ignore -- I even like the system yells about
> those 3 files I forgot to add to ignore list every now and then (when the
> mtime of the directory those are located changes). This is also something
> different -- I can start keeping my drafts and spam directories alongside
> other mail directories (or folders is you want to use that term).

The allure of auto ignore is that you don't have to do anything to use
it, but it's much less powerful than explicit ignores.  I think having
both mechanisms would be overkill and I would use explicit ignores in
preference to auto ignore.

> Thanks for that id: it refers thread starting from id:"ylp7hi23mw8.fsf at 
> tyndall.ie" 
> ( http://notmuchmail.org/pipermail/notmuch/2010/003145.html )
> 
> and the patch there is somewhat more complete (although old rebase-wise). 
> It's easy to combine works together, but more difficult is to choose best 
> terminology: database.exclude vs. new.ignore (or something in between or 
> totally different). Ideas anyone?

I would weigh in on the side of new.ignore, or at least something
under [new].  This option fits better with the existing option in
[new] than it does with the existing option in [database].


Re: [PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Austin Clements
Quoth Tomi Ollila on Jan 26 at 12:11 pm:
> A new configuration key 'database.exclude' is used to determine
> which directories user wants not to be scanned for new mails.

Not just directories.

> ---
> 
> Notes (from 2011-09-13):
> 
> 1) Currently the comments for newly created configuration file are not
> updated, so for not this is 'undocumented feature'. Should there be an
> empty configuration line as a placeholder ... ?

This is unfortunate and hard to do anything about with the current
config file design.  For precisely this reason, I think option
documentation should be in per-option comments instead of per-section
comments, but this would be a large change to the config structure.
For now, it should definitely be added to the section comment so that
newly generated config files get it.  If you want to be fancy, you can
check for the old section comment (or perhaps just its hash) and
automatically upgrade it.

> 2) Whenever some already existing directory is added to the exclude list
> and the parent directory timestamp has not changed, notmuch new will not
> notice the directory has gone (as it still is there), user needs to 'touch'
> the parent directory before next 'notmuch new' no make notmuch notice.
> 
> 2012-01-26: could notmuch track mtime of the configuration file and if
> that changes, ignore mail directory timestamps ?

notmuch actively descends into every subdirectory of your Maildir (it
has to, since mtime changes don't propagate up), which seems like the
perfect opportunity to check if an ignored directory is present in the
database.  This is harder for ignored files and probably not worth
solving since people are probably ignoring files that aren't mail
anyway (whereas I know people want to ignore directories that contain
mail).

> 3) count_files() function is not touched. The functionality there has fallen
> behind of add_files_recursive (maildir+tmp check and following symlinks).
> The question there should it be updated, or attempted to merge with
> add_files (as the comment says). count_files() is only called at the beginning
> when database is not yet initialised.

Given that count_files is already broken, it's probably best to leave
it as is for now and maybe fix it thoroughly later.  I wouldn't be too
worried about this though, since a new database is likely to also have
no configured ignores.

> ---
>  notmuch-client.h |3 +++
>  notmuch-config.c |   13 +
>  notmuch-new.c|   22 --
>  3 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-client.h b/notmuch-client.h
> index e0eb594..78460fc 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -219,6 +219,9 @@ void
>  notmuch_config_set_database_path (notmuch_config_t *config,
> const char *database_path);
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length);

As I mentioned in another email, I would prefer to see this in the
'new' section (though I could probably be persuaded otherwise).  Also,
I think "ignore" would be more typical terminology (think .gitignore,
etc).

Also, every other getter has a corresponding setter.

>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config);
>  
> diff --git a/notmuch-config.c b/notmuch-config.c
> index a124e34..e236114 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -99,6 +99,8 @@ struct _notmuch_config {
>  GKeyFile *key_file;
>  
>  char *database_path;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  char *user_name;
>  char *user_primary_email;
>  const char **user_other_email;
> @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
>  config->key_file = g_key_file_new ();
>  
>  config->database_path = NULL;
> +config->database_exclude = NULL;
> +config->database_exclude_length = 0;
>  config->user_name = NULL;
>  config->user_primary_email = NULL;
>  config->user_other_email = NULL;
> @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t 
> *config,
>  config->database_path = NULL;
>  }
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length)
> +{
> +return _config_get_list (config, "database", "exclude",
> +  &(config->database_exclude),
> +  &(config->database_exclude_length), length);
> +}
> +

All of the other options are fetched by notmuch_config_open and set if
they don't exist.  This has the effect that they will get added to the
configuration file if it is written out, which won't happen to this
option.

>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config)
>  {
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..d607f5b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -39,6 +39,8 @@ typedef

Re: [PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Austin Clements
Quoth Tomi Ollila on Jan 27 at 12:41 pm:
> On Thu, 26 Jan 2012 13:11:36 +, Jani Nikula  wrote:
> > On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  wrote:
> > > A new configuration key 'database.exclude' is used to determine
> > > which directories user wants not to be scanned for new mails.
> > > 
> > > ---
> > > 
> > > Notes (from 2011-09-13):
> > > 
> > > 1) Currently the comments for newly created configuration file are not
> > > updated, so for not this is 'undocumented feature'. Should there be an
> > > empty configuration line as a placeholder ... ?
> > > 
> > > 2) Whenever some already existing directory is added to the exclude list
> > > and the parent directory timestamp has not changed, notmuch new will not
> > > notice the directory has gone (as it still is there), user needs to 
> > > 'touch'
> > > the parent directory before next 'notmuch new' no make notmuch notice.
> > > 
> > > 2012-01-26: could notmuch track mtime of the configuration file and if
> > > that changes, ignore mail directory timestamps ?
> > > 
> > > 3) count_files() function is not touched. The functionality there has 
> > > fallen
> > > behind of add_files_recursive (maildir+tmp check and following symlinks).
> > > The question there should it be updated, or attempted to merge with
> > > add_files (as the comment says). count_files() is only called at the 
> > > beginning
> > > when database is not yet initialised.
> > > ---
> 
> [ ... ]
> 
> > > + /* Ignore user-specified directories */
> > > + for (j = 0; j < state->database_exclude_length; j++)
> > > + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> > > + break;
> > > + if (j < state->database_exclude_length)
> > > + continue;
> > 
> > How about wrapping that in a function you can use here and below?
> > 
> > if (user_wants_this_excluded (...))
> > continue;
> 
> Good point
> 
> > Please also have a look at id:"87pqecylon@nikula.org" and the
> > patches Austin posted. "Auto ignore"?
> 
> I personally don't mind auto ignore -- I even like the system yells about
> those 3 files I forgot to add to ignore list every now and then (when the
> mtime of the directory those are located changes). This is also something
> different -- I can start keeping my drafts and spam directories alongside
> other mail directories (or folders is you want to use that term).

The allure of auto ignore is that you don't have to do anything to use
it, but it's much less powerful than explicit ignores.  I think having
both mechanisms would be overkill and I would use explicit ignores in
preference to auto ignore.

> Thanks for that id: it refers thread starting from 
> id:"ylp7hi23mw8@tyndall.ie" 
> ( http://notmuchmail.org/pipermail/notmuch/2010/003145.html )
> 
> and the patch there is somewhat more complete (although old rebase-wise). 
> It's easy to combine works together, but more difficult is to choose best 
> terminology: database.exclude vs. new.ignore (or something in between or 
> totally different). Ideas anyone?

I would weigh in on the side of new.ignore, or at least something
under [new].  This option fits better with the existing option in
[new] than it does with the existing option in [database].
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Tomi Ollila
On Thu, 26 Jan 2012 13:11:36 +, Jani Nikula  wrote:
> On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  wrote:
> > A new configuration key 'database.exclude' is used to determine
> > which directories user wants not to be scanned for new mails.
> > 
> > ---
> > 
> > Notes (from 2011-09-13):
> > 
> > 1) Currently the comments for newly created configuration file are not
> > updated, so for not this is 'undocumented feature'. Should there be an
> > empty configuration line as a placeholder ... ?
> > 
> > 2) Whenever some already existing directory is added to the exclude list
> > and the parent directory timestamp has not changed, notmuch new will not
> > notice the directory has gone (as it still is there), user needs to 'touch'
> > the parent directory before next 'notmuch new' no make notmuch notice.
> > 
> > 2012-01-26: could notmuch track mtime of the configuration file and if
> > that changes, ignore mail directory timestamps ?
> > 
> > 3) count_files() function is not touched. The functionality there has fallen
> > behind of add_files_recursive (maildir+tmp check and following symlinks).
> > The question there should it be updated, or attempted to merge with
> > add_files (as the comment says). count_files() is only called at the 
> > beginning
> > when database is not yet initialised.
> > ---

[ ... ]

> > +   /* Ignore user-specified directories */
> > +   for (j = 0; j < state->database_exclude_length; j++)
> > +   if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> > +   break;
> > +   if (j < state->database_exclude_length)
> > +   continue;
> 
> How about wrapping that in a function you can use here and below?
> 
>   if (user_wants_this_excluded (...))
>   continue;

Good point

> Please also have a look at id:"87pqecylon.fsf at nikula.org" and the
> patches Austin posted. "Auto ignore"?

I personally don't mind auto ignore -- I even like the system yells about
those 3 files I forgot to add to ignore list every now and then (when the
mtime of the directory those are located changes). This is also something
different -- I can start keeping my drafts and spam directories alongside
other mail directories (or folders is you want to use that term).

Thanks for that id: it refers thread starting from id:"ylp7hi23mw8.fsf at 
tyndall.ie" 
( http://notmuchmail.org/pipermail/notmuch/2010/003145.html )

and the patch there is somewhat more complete (although old rebase-wise). 
It's easy to combine works together, but more difficult is to choose best 
terminology: database.exclude vs. new.ignore (or something in between or 
totally different). Ideas anyone?

Tomi


Re: [PATCH 2/2] added support for user-specified directories to exclude

2012-01-27 Thread Tomi Ollila
On Thu, 26 Jan 2012 13:11:36 +, Jani Nikula  wrote:
> On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  wrote:
> > A new configuration key 'database.exclude' is used to determine
> > which directories user wants not to be scanned for new mails.
> > 
> > ---
> > 
> > Notes (from 2011-09-13):
> > 
> > 1) Currently the comments for newly created configuration file are not
> > updated, so for not this is 'undocumented feature'. Should there be an
> > empty configuration line as a placeholder ... ?
> > 
> > 2) Whenever some already existing directory is added to the exclude list
> > and the parent directory timestamp has not changed, notmuch new will not
> > notice the directory has gone (as it still is there), user needs to 'touch'
> > the parent directory before next 'notmuch new' no make notmuch notice.
> > 
> > 2012-01-26: could notmuch track mtime of the configuration file and if
> > that changes, ignore mail directory timestamps ?
> > 
> > 3) count_files() function is not touched. The functionality there has fallen
> > behind of add_files_recursive (maildir+tmp check and following symlinks).
> > The question there should it be updated, or attempted to merge with
> > add_files (as the comment says). count_files() is only called at the 
> > beginning
> > when database is not yet initialised.
> > ---

[ ... ]

> > +   /* Ignore user-specified directories */
> > +   for (j = 0; j < state->database_exclude_length; j++)
> > +   if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> > +   break;
> > +   if (j < state->database_exclude_length)
> > +   continue;
> 
> How about wrapping that in a function you can use here and below?
> 
>   if (user_wants_this_excluded (...))
>   continue;

Good point

> Please also have a look at id:"87pqecylon@nikula.org" and the
> patches Austin posted. "Auto ignore"?

I personally don't mind auto ignore -- I even like the system yells about
those 3 files I forgot to add to ignore list every now and then (when the
mtime of the directory those are located changes). This is also something
different -- I can start keeping my drafts and spam directories alongside
other mail directories (or folders is you want to use that term).

Thanks for that id: it refers thread starting from 
id:"ylp7hi23mw8@tyndall.ie" 
( http://notmuchmail.org/pipermail/notmuch/2010/003145.html )

and the patch there is somewhat more complete (although old rebase-wise). 
It's easy to combine works together, but more difficult is to choose best 
terminology: database.exclude vs. new.ignore (or something in between or 
totally different). Ideas anyone?

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] added support for user-specified directories to exclude

2012-01-26 Thread Jani Nikula
On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  wrote:
> A new configuration key 'database.exclude' is used to determine
> which directories user wants not to be scanned for new mails.
> 
> ---
> 
> Notes (from 2011-09-13):
> 
> 1) Currently the comments for newly created configuration file are not
> updated, so for not this is 'undocumented feature'. Should there be an
> empty configuration line as a placeholder ... ?
> 
> 2) Whenever some already existing directory is added to the exclude list
> and the parent directory timestamp has not changed, notmuch new will not
> notice the directory has gone (as it still is there), user needs to 'touch'
> the parent directory before next 'notmuch new' no make notmuch notice.
> 
> 2012-01-26: could notmuch track mtime of the configuration file and if
> that changes, ignore mail directory timestamps ?
> 
> 3) count_files() function is not touched. The functionality there has fallen
> behind of add_files_recursive (maildir+tmp check and following symlinks).
> The question there should it be updated, or attempted to merge with
> add_files (as the comment says). count_files() is only called at the beginning
> when database is not yet initialised.
> ---
>  notmuch-client.h |3 +++
>  notmuch-config.c |   13 +
>  notmuch-new.c|   22 --
>  3 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-client.h b/notmuch-client.h
> index e0eb594..78460fc 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -219,6 +219,9 @@ void
>  notmuch_config_set_database_path (notmuch_config_t *config,
> const char *database_path);
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length);
>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config);
>  
> diff --git a/notmuch-config.c b/notmuch-config.c
> index a124e34..e236114 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -99,6 +99,8 @@ struct _notmuch_config {
>  GKeyFile *key_file;
>  
>  char *database_path;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  char *user_name;
>  char *user_primary_email;
>  const char **user_other_email;
> @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
>  config->key_file = g_key_file_new ();
>  
>  config->database_path = NULL;
> +config->database_exclude = NULL;
> +config->database_exclude_length = 0;
>  config->user_name = NULL;
>  config->user_primary_email = NULL;
>  config->user_other_email = NULL;
> @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t 
> *config,
>  config->database_path = NULL;
>  }
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length)
> +{
> +return _config_get_list (config, "database", "exclude",
> +  &(config->database_exclude),
> +  &(config->database_exclude_length), length);
> +}
> +
>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config)
>  {
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..d607f5b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -39,6 +39,8 @@ typedef struct {
>  int verbose;
>  const char **new_tags;
>  size_t new_tags_length;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  
>  int total_files;
>  int processed_files;
> @@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
>  is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
>  
>  for (i = 0; i < num_fs_entries; i++) {
> + size_t j;
> +
>   if (interrupted)
>   break;
>  
> @@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
>* Also ignore the .notmuch directory and any "tmp" directory
>* that appears within a maildir.
>*/
> - /* XXX: Eventually we'll want more sophistication to let the
> -  * user specify files to be ignored. */
>   if (strcmp (entry->d_name, ".") == 0 ||
>   strcmp (entry->d_name, "..") == 0 ||
>   (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
> @@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
>   {
>   continue;
>   }
> + /* Ignore user-specified directories */
> + for (j = 0; j < state->database_exclude_length; j++)
> + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> + break;
> + if (j < state->database_exclude_length)
> + continue;

How about wrapping that in a function you can use here and below?

if (user_wants_this_excluded (...))
continue;

Please also have a look at id:"87pqecylon.fsf at nikula.org" and the
patches Austin posted. "Auto ignore"?

BR,
Jani.

>  
>   next = talloc_asprintf (n

[PATCH 2/2] added support for user-specified directories to exclude

2012-01-26 Thread Tomi Ollila
A new configuration key 'database.exclude' is used to determine
which directories user wants not to be scanned for new mails.

---

Notes (from 2011-09-13):

1) Currently the comments for newly created configuration file are not
updated, so for not this is 'undocumented feature'. Should there be an
empty configuration line as a placeholder ... ?

2) Whenever some already existing directory is added to the exclude list
and the parent directory timestamp has not changed, notmuch new will not
notice the directory has gone (as it still is there), user needs to 'touch'
the parent directory before next 'notmuch new' no make notmuch notice.

2012-01-26: could notmuch track mtime of the configuration file and if
that changes, ignore mail directory timestamps ?

3) count_files() function is not touched. The functionality there has fallen
behind of add_files_recursive (maildir+tmp check and following symlinks).
The question there should it be updated, or attempted to merge with
add_files (as the comment says). count_files() is only called at the beginning
when database is not yet initialised.
---
 notmuch-client.h |3 +++
 notmuch-config.c |   13 +
 notmuch-new.c|   22 --
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index e0eb594..78460fc 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -219,6 +219,9 @@ void
 notmuch_config_set_database_path (notmuch_config_t *config,
  const char *database_path);

+const char **
+notmuch_config_get_database_exclude (notmuch_config_t *config,
+size_t *length);
 const char *
 notmuch_config_get_user_name (notmuch_config_t *config);

diff --git a/notmuch-config.c b/notmuch-config.c
index a124e34..e236114 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -99,6 +99,8 @@ struct _notmuch_config {
 GKeyFile *key_file;

 char *database_path;
+const char **database_exclude;
+size_t database_exclude_length;
 char *user_name;
 char *user_primary_email;
 const char **user_other_email;
@@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
 config->key_file = g_key_file_new ();

 config->database_path = NULL;
+config->database_exclude = NULL;
+config->database_exclude_length = 0;
 config->user_name = NULL;
 config->user_primary_email = NULL;
 config->user_other_email = NULL;
@@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t *config,
 config->database_path = NULL;
 }

+const char **
+notmuch_config_get_database_exclude (notmuch_config_t *config,
+size_t *length)
+{
+return _config_get_list (config, "database", "exclude",
+&(config->database_exclude),
+&(config->database_exclude_length), length);
+}
+
 const char *
 notmuch_config_get_user_name (notmuch_config_t *config)
 {
diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..d607f5b 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -39,6 +39,8 @@ typedef struct {
 int verbose;
 const char **new_tags;
 size_t new_tags_length;
+const char **database_exclude;
+size_t database_exclude_length;

 int total_files;
 int processed_files;
@@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);

 for (i = 0; i < num_fs_entries; i++) {
+   size_t j;
+
if (interrupted)
break;

@@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
 * Also ignore the .notmuch directory and any "tmp" directory
 * that appears within a maildir.
 */
-   /* XXX: Eventually we'll want more sophistication to let the
-* user specify files to be ignored. */
if (strcmp (entry->d_name, ".") == 0 ||
strcmp (entry->d_name, "..") == 0 ||
(is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
@@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
{
continue;
}
+   /* Ignore user-specified directories */
+   for (j = 0; j < state->database_exclude_length; j++)
+   if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
+   break;
+   if (j < state->database_exclude_length)
+   continue;

next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
status = add_files_recursive (notmuch, next, state);
@@ -364,11 +372,20 @@ add_files_recursive (notmuch_database_t *notmuch,
 /* Pass 2: Scan for new files, removed files, and removed directories. */
 for (i = 0; i < num_fs_entries; i++)
 {
+   size_t j;
+
if (interrupted)
break;

 entry = fs_entries[i];

+   /* Ignore user-specified files & directories */
+   for (j = 0; j < state->database_exclude_length; j++)
+

Re: [PATCH 2/2] added support for user-specified directories to exclude

2012-01-26 Thread Jani Nikula
On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila  wrote:
> A new configuration key 'database.exclude' is used to determine
> which directories user wants not to be scanned for new mails.
> 
> ---
> 
> Notes (from 2011-09-13):
> 
> 1) Currently the comments for newly created configuration file are not
> updated, so for not this is 'undocumented feature'. Should there be an
> empty configuration line as a placeholder ... ?
> 
> 2) Whenever some already existing directory is added to the exclude list
> and the parent directory timestamp has not changed, notmuch new will not
> notice the directory has gone (as it still is there), user needs to 'touch'
> the parent directory before next 'notmuch new' no make notmuch notice.
> 
> 2012-01-26: could notmuch track mtime of the configuration file and if
> that changes, ignore mail directory timestamps ?
> 
> 3) count_files() function is not touched. The functionality there has fallen
> behind of add_files_recursive (maildir+tmp check and following symlinks).
> The question there should it be updated, or attempted to merge with
> add_files (as the comment says). count_files() is only called at the beginning
> when database is not yet initialised.
> ---
>  notmuch-client.h |3 +++
>  notmuch-config.c |   13 +
>  notmuch-new.c|   22 --
>  3 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-client.h b/notmuch-client.h
> index e0eb594..78460fc 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -219,6 +219,9 @@ void
>  notmuch_config_set_database_path (notmuch_config_t *config,
> const char *database_path);
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length);
>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config);
>  
> diff --git a/notmuch-config.c b/notmuch-config.c
> index a124e34..e236114 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -99,6 +99,8 @@ struct _notmuch_config {
>  GKeyFile *key_file;
>  
>  char *database_path;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  char *user_name;
>  char *user_primary_email;
>  const char **user_other_email;
> @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
>  config->key_file = g_key_file_new ();
>  
>  config->database_path = NULL;
> +config->database_exclude = NULL;
> +config->database_exclude_length = 0;
>  config->user_name = NULL;
>  config->user_primary_email = NULL;
>  config->user_other_email = NULL;
> @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t 
> *config,
>  config->database_path = NULL;
>  }
>  
> +const char **
> +notmuch_config_get_database_exclude (notmuch_config_t *config,
> +  size_t *length)
> +{
> +return _config_get_list (config, "database", "exclude",
> +  &(config->database_exclude),
> +  &(config->database_exclude_length), length);
> +}
> +
>  const char *
>  notmuch_config_get_user_name (notmuch_config_t *config)
>  {
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..d607f5b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -39,6 +39,8 @@ typedef struct {
>  int verbose;
>  const char **new_tags;
>  size_t new_tags_length;
> +const char **database_exclude;
> +size_t database_exclude_length;
>  
>  int total_files;
>  int processed_files;
> @@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
>  is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
>  
>  for (i = 0; i < num_fs_entries; i++) {
> + size_t j;
> +
>   if (interrupted)
>   break;
>  
> @@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
>* Also ignore the .notmuch directory and any "tmp" directory
>* that appears within a maildir.
>*/
> - /* XXX: Eventually we'll want more sophistication to let the
> -  * user specify files to be ignored. */
>   if (strcmp (entry->d_name, ".") == 0 ||
>   strcmp (entry->d_name, "..") == 0 ||
>   (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
> @@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
>   {
>   continue;
>   }
> + /* Ignore user-specified directories */
> + for (j = 0; j < state->database_exclude_length; j++)
> + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
> + break;
> + if (j < state->database_exclude_length)
> + continue;

How about wrapping that in a function you can use here and below?

if (user_wants_this_excluded (...))
continue;

Please also have a look at id:"87pqecylon@nikula.org" and the
patches Austin posted. "Auto ignore"?

BR,
Jani.

>  
>   next = talloc_asprintf (notm

[PATCH 2/2] added support for user-specified directories to exclude

2012-01-26 Thread Tomi Ollila
A new configuration key 'database.exclude' is used to determine
which directories user wants not to be scanned for new mails.

---

Notes (from 2011-09-13):

1) Currently the comments for newly created configuration file are not
updated, so for not this is 'undocumented feature'. Should there be an
empty configuration line as a placeholder ... ?

2) Whenever some already existing directory is added to the exclude list
and the parent directory timestamp has not changed, notmuch new will not
notice the directory has gone (as it still is there), user needs to 'touch'
the parent directory before next 'notmuch new' no make notmuch notice.

2012-01-26: could notmuch track mtime of the configuration file and if
that changes, ignore mail directory timestamps ?

3) count_files() function is not touched. The functionality there has fallen
behind of add_files_recursive (maildir+tmp check and following symlinks).
The question there should it be updated, or attempted to merge with
add_files (as the comment says). count_files() is only called at the beginning
when database is not yet initialised.
---
 notmuch-client.h |3 +++
 notmuch-config.c |   13 +
 notmuch-new.c|   22 --
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index e0eb594..78460fc 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -219,6 +219,9 @@ void
 notmuch_config_set_database_path (notmuch_config_t *config,
  const char *database_path);
 
+const char **
+notmuch_config_get_database_exclude (notmuch_config_t *config,
+size_t *length);
 const char *
 notmuch_config_get_user_name (notmuch_config_t *config);
 
diff --git a/notmuch-config.c b/notmuch-config.c
index a124e34..e236114 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -99,6 +99,8 @@ struct _notmuch_config {
 GKeyFile *key_file;
 
 char *database_path;
+const char **database_exclude;
+size_t database_exclude_length;
 char *user_name;
 char *user_primary_email;
 const char **user_other_email;
@@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
 config->key_file = g_key_file_new ();
 
 config->database_path = NULL;
+config->database_exclude = NULL;
+config->database_exclude_length = 0;
 config->user_name = NULL;
 config->user_primary_email = NULL;
 config->user_other_email = NULL;
@@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t *config,
 config->database_path = NULL;
 }
 
+const char **
+notmuch_config_get_database_exclude (notmuch_config_t *config,
+size_t *length)
+{
+return _config_get_list (config, "database", "exclude",
+&(config->database_exclude),
+&(config->database_exclude_length), length);
+}
+
 const char *
 notmuch_config_get_user_name (notmuch_config_t *config)
 {
diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..d607f5b 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -39,6 +39,8 @@ typedef struct {
 int verbose;
 const char **new_tags;
 size_t new_tags_length;
+const char **database_exclude;
+size_t database_exclude_length;
 
 int total_files;
 int processed_files;
@@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
 
 for (i = 0; i < num_fs_entries; i++) {
+   size_t j;
+
if (interrupted)
break;
 
@@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
 * Also ignore the .notmuch directory and any "tmp" directory
 * that appears within a maildir.
 */
-   /* XXX: Eventually we'll want more sophistication to let the
-* user specify files to be ignored. */
if (strcmp (entry->d_name, ".") == 0 ||
strcmp (entry->d_name, "..") == 0 ||
(is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
@@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
{
continue;
}
+   /* Ignore user-specified directories */
+   for (j = 0; j < state->database_exclude_length; j++)
+   if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
+   break;
+   if (j < state->database_exclude_length)
+   continue;
 
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
status = add_files_recursive (notmuch, next, state);
@@ -364,11 +372,20 @@ add_files_recursive (notmuch_database_t *notmuch,
 /* Pass 2: Scan for new files, removed files, and removed directories. */
 for (i = 0; i < num_fs_entries; i++)
 {
+   size_t j;
+
if (interrupted)
break;
 
 entry = fs_entries[i];
 
+   /* Ignore user-specified files & directories */
+   for (j = 0; j < state->database_exclude_length; j++