v3 of libconfig / single argument date / named query patches

David Bremner david at tethera.net
Sat Apr 30 18:24:28 PDT 2016


The main difference here is responding to Tomi's comments about
"options" and rebasing against master. Rebasing was surprisingly
messy, so I might have botched something up.

One thing to discuss is the dump/restore format. dkg has discussed
attaching some non-tag metadata to messages, so we may want to make
sure the changes are general enough to handle that.  If desired we
could add more "pseudo-comments" with #x where x is not @ to introduce
that metadata. I'm not sure how valuable this upward compatibility is;
I guess it would mainly allow us not maintain a third dump format.

The first 3 patches are usable on their own.

Interdiff follows.

diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index c3470a8..5a517eb 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -132,9 +132,9 @@ The available configuration items are described below.
     
         Default: ``gpg``.
 
-    **options.<name>**
+    **built_with.<name>**
 
-	Compile time option <name>. Current possibilities include
+	Compile time feature <name>. Current possibilities include
 	"compact" (see **notmuch-compact(1)**)
 	and "field_processor" (see **notmuch-search-terms(7)**).
 
diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst
index 7474f53..223031b 100644
--- a/doc/man7/notmuch-search-terms.rst
+++ b/doc/man7/notmuch-search-terms.rst
@@ -387,7 +387,7 @@ notmuch was built against a sufficiently recent version of Xapian by running
 
 ::
 
-  % notmuch config get options.field_processor
+  % notmuch config get built_with.field_processor
 
 Currently the following features require field processor support:
 
diff --git a/lib/Makefile.local b/lib/Makefile.local
index fab1242..35caa3e 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -39,7 +39,7 @@ libnotmuch_c_srcs =		\
 	$(dir)/message-file.c	\
 	$(dir)/messages.c	\
 	$(dir)/sha1.c		\
-	$(dir)/options.c	\
+	$(dir)/built-with.c	\
 	$(dir)/tags.c
 
 libnotmuch_cxx_srcs =		\
diff --git a/lib/options.c b/lib/built-with.c
similarity index 69%
rename from lib/options.c
rename to lib/built-with.c
index 4e15d92..b619bed 100644
--- a/lib/options.c
+++ b/lib/built-with.c
@@ -22,28 +22,11 @@
 #include "notmuch-private.h"
 
 notmuch_bool_t
-notmuch_options_present (notmuch_option_t mask)
-{
-    notmuch_option_t present = 0;
-
-#if HAVE_XAPIAN_COMPACT
-    present |= NOTMUCH_OPTION_COMPACT;
-#endif
-
-#if HAVE_XAPIAN_COMPACT
-    present |= NOTMUCH_OPTION_FIELD_PROCESSOR;
-#endif
-
-    return (mask & present) != 0;
-
-}
-
-notmuch_bool_t
-notmuch_options_get (const char *name) {
+notmuch_built_with (const char *name) {
     if (STRNCMP_LITERAL (name, "compact") == 0) {
-	return notmuch_options_present (NOTMUCH_OPTION_COMPACT);
+	return HAVE_XAPIAN_COMPACT;
     } else if (STRNCMP_LITERAL (name, "field_processor") == 0) {
-	return notmuch_options_present (NOTMUCH_OPTION_FIELD_PROCESSOR);
+	return HAVE_XAPIAN_FIELD_PROCESSOR;
     } else {
 	return FALSE;
     }
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 2278822..bd977c3 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1902,16 +1902,11 @@ notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
 void
 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
 
-typedef enum {
-    NOTMUCH_OPTION_COMPACT = 1,
-    NOTMUCH_OPTION_FIELD_PROCESSOR = 2
-} notmuch_option_t;
-
-notmuch_bool_t
-notmuch_options_present (notmuch_option_t mask);
-
+/**
+ * interrogate the library for compile time features
+ */
 notmuch_bool_t
-notmuch_options_get (const char *name);
+notmuch_built_with (const char *name);
 /* @} */
 
 NOTMUCH_END_DECLS
diff --git a/notmuch-config.c b/notmuch-config.c
index 121fec6..e4f47e4 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -750,7 +750,7 @@ _item_split (char *item, char **group, char **key)
     return 0;
 }
 
-#define OPTION_PREFIX "options."
+#define BUILT_WITH_PREFIX "built_with."
 #define QUERY_PREFIX "query."
 
 static int
@@ -797,9 +797,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
 	tags = notmuch_config_get_new_tags (config, &length);
 	for (i = 0; i < length; i++)
 	    printf ("%s\n", tags[i]);
-    } else if (STRNCMP_LITERAL (item, OPTION_PREFIX) == 0) {
+    } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
 	printf ("%s\n",
-	       notmuch_options_get (item + strlen (OPTION_PREFIX)) ? "true" : "false");
+		notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
     } else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
 	return _print_db_config (config, item);
     } else {
@@ -866,7 +866,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
 {
     char *group, *key;
 
-    if (STRNCMP_LITERAL (item, OPTION_PREFIX) == 0) {
+    if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
 	fprintf (stderr, "Error: read only option: %s\n", item);
 	return 1;
     }
@@ -904,10 +904,12 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
 static
 void
 _notmuch_config_list_options () {
-    printf("options.compact=%s\n",
-	   notmuch_options_present(NOTMUCH_OPTION_COMPACT) ? "true" : "false");
-    printf("options.field_processor=%s\n",
-	   notmuch_options_present(NOTMUCH_OPTION_FIELD_PROCESSOR) ? "true" : "false");
+    printf("%scompact=%s\n",
+	   BUILT_WITH_PREFIX,
+	   notmuch_built_with ("compact") ? "true" : "false");
+    printf("%sfield_processor=%s\n",
+	   BUILT_WITH_PREFIX,
+	   notmuch_built_with ("field_processor") ? "true" : "false");
 }
 
 static int
diff --git a/test/T030-config.sh b/test/T030-config.sh
index 39ee885..b8d5a86 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -57,8 +57,8 @@ maildir.synchronize_flags=true
 crypto.gpg_path=gpg
 foo.string=this is another string value
 foo.list=this;is another;list value;
-options.compact=something
-options.field_processor=something
+built_with.compact=something
+built_with.field_processor=something
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 5db03a6..be2f0db 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -19,7 +19,7 @@ another.suite at example.com
 foo bar
 baz
 EOF
-output=$(notmuch --config=new-notmuch-config config list | notmuch_options_sanitize)
+output=$(notmuch --config=new-notmuch-config config list | notmuch_built_with_sanitize)
 test_expect_equal "$output" "\
 database.path=/path/to/maildir
 user.name=Test Suite
@@ -30,7 +30,7 @@ new.ignore=
 search.exclude_tags=baz;
 maildir.synchronize_flags=true
 crypto.gpg_path=gpg
-options.compact=something
-options.field_processor=something"
+built_with.compact=something
+built_with.field_processor=something"
 
 test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index b5a1941..e96c184 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -740,9 +740,9 @@ notmuch_uuid_sanitize ()
     sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'
 }
 
-notmuch_options_sanitize ()
+notmuch_built_with_sanitize ()
 {
-    sed 's/^options[.]\(.*\)=.*$/options.\1=something/'
+    sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
 notmuch_config_sanitize ()


More information about the notmuch mailing list