The new.scan option is a list of URLs that can be "scanned". The fact that the database maildir is scanned "automagically" is a little weird, but it doesn't do any harm unless you decide to put mail there that you really don't want indexed. Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com> --- I added text here to respond to Mark Walters's confusion regarding how I implemented scanning. notmuch-client.h | 9 +++++++++ notmuch-config.c | 33 ++++++++++++++++++++++++++++++++- notmuch-new.c | 18 ++++++++++++++++++ test/config | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/notmuch-client.h b/notmuch-client.h index 0c17b79..20349b2 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -257,6 +257,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, const char *new_ignore[], size_t length); +const char ** +notmuch_config_get_new_scan (notmuch_config_t *config, + size_t *length); + +void +notmuch_config_set_new_scan (notmuch_config_t *config, + const char *new_scan[], + size_t length); + notmuch_bool_t notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config); diff --git a/notmuch-config.c b/notmuch-config.c index 3e37a2d..387f855 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -50,7 +50,13 @@ static const char new_config_comment[] = "\t that will not be searched for messages by \"notmuch new\".\n" "\n" "\t NOTE: *Every* file/directory that goes by one of those names will\n" - "\t be ignored, independent of its depth/location in the mail store.\n"; + "\t be ignored, independent of its depth/location in the mail store.\n" + "\n" + "\tscan A list (separated by ';') of mail URLs to scan.\n" + "\t Each URL denotes a \"root\" which will be searched for mail files.\n" + "\t How this search is performed depends on the scheme of the URL (the\n" + "\t part before the first colon).\n" + "\t The maildir located at database.path, above, will automatically be added.\n"; static const char user_config_comment[] = " User configuration\n" @@ -113,6 +119,8 @@ struct _notmuch_config { size_t new_tags_length; const char **new_ignore; size_t new_ignore_length; + const char **new_scan; + size_t new_scan_length; notmuch_bool_t maildir_synchronize_flags; const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -274,6 +282,8 @@ notmuch_config_open (void *ctx, config->new_tags_length = 0; config->new_ignore = NULL; config->new_ignore_length = 0; + config->new_scan = NULL; + config->new_scan_length = 0; config->maildir_synchronize_flags = TRUE; config->search_exclude_tags = NULL; config->search_exclude_tags_length = 0; @@ -375,6 +385,10 @@ notmuch_config_open (void *ctx, notmuch_config_set_new_ignore (config, NULL, 0); } + if (notmuch_config_get_new_scan (config, &tmp) == NULL) { + notmuch_config_set_new_scan (config, NULL, 0); + } + if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) { if (is_new) { const char *tags[] = { "deleted", "spam" }; @@ -631,6 +645,14 @@ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length) &(config->new_ignore_length), length); } +const char ** +notmuch_config_get_new_scan (notmuch_config_t *config, size_t *length) +{ + return _config_get_list (config, "new", "scan", + &(config->new_scan), + &(config->new_scan_length), length); +} + void notmuch_config_set_user_other_email (notmuch_config_t *config, const char *list[], @@ -658,6 +680,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, &(config->new_ignore)); } +void +notmuch_config_set_new_scan (notmuch_config_t *config, + const char *list[], + size_t length) +{ + _config_set_list (config, "new", "scan", list, length, + &(config->new_scan)); +} + const char ** notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length) { diff --git a/notmuch-new.c b/notmuch-new.c index 938ae29..8377750 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -607,6 +607,16 @@ add_files (notmuch_database_t *notmuch, return ret; } +/* Call out to the appropriate add_files function, based on the URI. */ +static notmuch_status_t +add_files_uri (unused(notmuch_database_t *notmuch), + unused(const char *uri), + unused(add_files_state_t *state)) +{ + /* Stub for now */ + return NOTMUCH_STATUS_SUCCESS; +} + static void setup_progress_printing_timer (void) { @@ -832,6 +842,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) int ret = 0; struct stat st; const char *db_path; + const char **new_scan; + size_t new_scan_length, new_scan_i; char *dot_notmuch_path; struct sigaction action; _filename_node_t *f; @@ -930,6 +942,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) timer_is_active = TRUE; } + new_scan = notmuch_config_get_new_scan (config, &new_scan_length); + + for (new_scan_i = 0; new_scan_i < new_scan_length; new_scan_i++) { + add_files_uri (notmuch, new_scan[new_scan_i], &add_files_state); + } + ret = add_files (notmuch, db_path, &add_files_state); if (ret) goto DONE; diff --git a/test/config b/test/config index 93ecb13..b0ad0c1 100755 --- a/test/config +++ b/test/config @@ -52,6 +52,7 @@ user.primary_email=test_suite@notmuchmail.org user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org new.tags=unread;inbox; new.ignore= +new.scan= search.exclude_tags= maildir.synchronize_flags=true foo.string=this is another string value -- 1.7.9.5