unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH 05/12] config: test whether an item is stored in the database by name
Date: Fri, 20 Oct 2017 22:25:42 -0400	[thread overview]
Message-ID: <20171021022549.2724-6-dkg@fifthhorseman.net> (raw)
In-Reply-To: <20171021022549.2724-1-dkg@fifthhorseman.net>

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.
---
 doc/man1/notmuch-config.rst |  7 ++++++-
 notmuch-config.c            | 13 ++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index 71294554..539199c2 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -15,7 +15,11 @@ DESCRIPTION
 ===========
 
 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**
         The value of the specified configuration item is printed to
@@ -142,6 +146,7 @@ The available configuration items are described below.
 
     **query.<name>**
 
+        **[STORED IN DATABASE]**
         Expansion for named query called <name>. See
         **notmuch-search-terms(7)** for more information about named
         queries.
diff --git a/notmuch-config.c b/notmuch-config.c
index 8fb59f96..74668718 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -808,7 +808,14 @@ _item_split (char *item, char **group, char **key)
 }
 
 #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
 _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) {
 	printf ("%s\n",
 		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);
     } else {
 	char **value;
@@ -928,7 +935,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
 	return 1;
     }
 
-    if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
+    if (_stored_in_db (item)) {
 	return _set_db_config (config, item, argc, argv);
     }
 
-- 
2.14.2

  parent reply	other threads:[~2017-10-21  2:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-21  2:25 cleartext indexing, revision 7 Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 01/12] index: implement notmuch_indexopts_t with try_decrypt Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 02/12] doc: add notmuch-properties(7) Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 03/12] reindex: drop all properties named with prefix "index." Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 04/12] crypto: index encrypted parts when indexopts try_decrypt is set Daniel Kahn Gillmor
2017-10-21  2:25 ` Daniel Kahn Gillmor [this message]
2017-10-21  2:25 ` [PATCH 06/12] config: define new option index.try_decrypt Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 07/12] cli: set up shared command-line arguments for indexing Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 08/12] tests: emacs_fcc_message: allow passing --arguments to notmuch new Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 09/12] cli/new: add --try-decrypt=(true|false) Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 10/12] cli/insert: " Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 11/12] cli/reindex: " Daniel Kahn Gillmor
2017-10-21  2:25 ` [PATCH 12/12] python: add try_decrypt argument to Database.index_file() Daniel Kahn Gillmor
2017-10-25  5:47   ` Daniel Kahn Gillmor
2017-10-22  0:02 ` cleartext indexing, revision 7 David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171021022549.2724-6-dkg@fifthhorseman.net \
    --to=dkg@fifthhorseman.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).