X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-config.c;h=e9456d794456c080e81abbd6a00efcb6b123c3c4;hp=e5b4db45fdf53dcb4254bec0b321e1dfcbcf719e;hb=HEAD;hpb=686230712f3865ac0d0250084113d6d859cc2519 diff --git a/notmuch-config.c b/notmuch-config.c index e5b4db45..8123e438 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -32,7 +32,7 @@ static const char toplevel_config_comment[] = "\n" " For more information about notmuch, see https://notmuchmail.org"; -struct config_group { +static const struct config_group { const char *group_name; const char *comment; } group_comment_table [] = { @@ -278,18 +278,24 @@ notmuch_conffile_open (notmuch_database_t *notmuch, return NULL; } - if (config->is_new) - g_key_file_set_comment (config->key_file, NULL, NULL, - toplevel_config_comment, NULL); - for (size_t i = 0; i < ARRAY_SIZE (group_comment_table); i++) { const char *name = group_comment_table[i].group_name; if (! g_key_file_has_group (config->key_file, name)) { /* Force group to exist before adding comment */ g_key_file_set_value (config->key_file, name, "dummy_key", "dummy_val"); g_key_file_remove_key (config->key_file, name, "dummy_key", NULL); - g_key_file_set_comment (config->key_file, name, NULL, - group_comment_table[i].comment, NULL); + if (config->is_new && (i == 0) ) { + const char *comment; + + comment = talloc_asprintf (config, "%s\n%s", + toplevel_config_comment, + group_comment_table[i].comment); + g_key_file_set_comment (config->key_file, name, NULL, comment, + NULL); + } else { + g_key_file_set_comment (config->key_file, name, NULL, + group_comment_table[i].comment, NULL); + } } } return config; @@ -383,7 +389,10 @@ _config_set_list (notmuch_conffile_t *config, const char *list[], size_t length) { - g_key_file_set_string_list (config->key_file, group, key, list, length); + if (length > 1) + g_key_file_set_string_list (config->key_file, group, key, list, length); + else + g_key_file_set_string (config->key_file, group, key, list[0]); } void @@ -512,14 +521,15 @@ typedef struct config_key { bool (*validate)(const char *); } config_key_info_t; -static struct config_key +static const struct config_key config_key_table[] = { { "index.decrypt", false, NULL }, { "index.header.", true, validate_field_name }, { "query.", true, NULL }, + { "squery.", true, validate_field_name }, }; -static config_key_info_t * +static const config_key_info_t * _config_key_info (const char *item) { for (size_t i = 0; i < ARRAY_SIZE (config_key_table); i++) { @@ -590,7 +600,7 @@ notmuch_config_command_set (notmuch_database_t *notmuch, int argc, char *argv[]) { char *group, *key; - config_key_info_t *key_info; + const config_key_info_t *key_info; notmuch_conffile_t *config; bool update_database = false; int opt_index, ret; @@ -679,6 +689,9 @@ _notmuch_config_list_built_with () printf ("%sretry_lock=%s\n", BUILT_WITH_PREFIX, notmuch_built_with ("retry_lock") ? "true" : "false"); + printf ("%ssexp_queries=%s\n", + BUILT_WITH_PREFIX, + notmuch_built_with ("sexp_queries") ? "true" : "false"); } static int @@ -708,10 +721,6 @@ notmuch_config_command (notmuch_database_t *notmuch, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; - if (notmuch_requested_db_uuid) - fprintf (stderr, "Warning: ignoring --uuid=%s\n", - notmuch_requested_db_uuid); - /* skip at least subcommand argument */ argc -= opt_index; argv += opt_index;