mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
config: test whether an item is stored in the database by name
QUERY_STRING was only used in two places, both to test whether a variable should be stored in (or retrieved from) the database. Since other configuration variables might be stored in the database in the future, consolidate that test into a single function. We also document that these configuration options should not be placed in the config file.
This commit is contained in:
parent
4dfcc8c9b2
commit
886c0b1666
2 changed files with 16 additions and 4 deletions
|
@ -15,7 +15,11 @@ DESCRIPTION
|
||||||
===========
|
===========
|
||||||
|
|
||||||
The **config** command can be used to get or set settings in the notmuch
|
The **config** command can be used to get or set settings in the notmuch
|
||||||
configuration file.
|
configuration file and corresponding database.
|
||||||
|
|
||||||
|
Items marked **[STORED IN DATABASE]** are only in the database. They
|
||||||
|
should not be placed in the configuration file, and should be accessed
|
||||||
|
programmatically as described in the SYNOPSIS above.
|
||||||
|
|
||||||
**get**
|
**get**
|
||||||
The value of the specified configuration item is printed to
|
The value of the specified configuration item is printed to
|
||||||
|
@ -142,6 +146,7 @@ The available configuration items are described below.
|
||||||
|
|
||||||
**query.<name>**
|
**query.<name>**
|
||||||
|
|
||||||
|
**[STORED IN DATABASE]**
|
||||||
Expansion for named query called <name>. See
|
Expansion for named query called <name>. See
|
||||||
**notmuch-search-terms(7)** for more information about named
|
**notmuch-search-terms(7)** for more information about named
|
||||||
queries.
|
queries.
|
||||||
|
|
|
@ -808,7 +808,14 @@ _item_split (char *item, char **group, char **key)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUILT_WITH_PREFIX "built_with."
|
#define BUILT_WITH_PREFIX "built_with."
|
||||||
#define QUERY_PREFIX "query."
|
|
||||||
|
static bool
|
||||||
|
_stored_in_db (const char *item)
|
||||||
|
{
|
||||||
|
if (STRNCMP_LITERAL (item, "query.") == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_print_db_config(notmuch_config_t *config, const char *name)
|
_print_db_config(notmuch_config_t *config, const char *name)
|
||||||
|
@ -857,7 +864,7 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
|
||||||
} else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
|
} else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
|
||||||
printf ("%s\n",
|
printf ("%s\n",
|
||||||
notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
|
notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
|
||||||
} else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
|
} else if (_stored_in_db (item)) {
|
||||||
return _print_db_config (config, item);
|
return _print_db_config (config, item);
|
||||||
} else {
|
} else {
|
||||||
char **value;
|
char **value;
|
||||||
|
@ -928,7 +935,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
|
if (_stored_in_db (item)) {
|
||||||
return _set_db_config (config, item, argc, argv);
|
return _set_db_config (config, item, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue