Initially support selection of query syntax in two subcommands to
enable testing.
---
notmuch-search.c | 16 +++++++++++++++-
test/T080-search.sh | 5 +++++
test/T095-address.sh | 5 +++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/notmuch-search.c b/notmuch-search.c
index 244817a9..fd25a414 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -43,6 +43,11 @@ typedef enum {
DEDUP_ADDRESS,
} dedup_t;
+typedef enum {
+ QUERY_SYNTAX_XAPIAN,
+ QUERY_SYNTAX_SEXP
+} query_syntax_t;
+
typedef enum {
NOTMUCH_FORMAT_JSON,
NOTMUCH_FORMAT_TEXT,
@@ -56,6 +61,7 @@ typedef struct {
int format_sel;
sprinter_t *format;
int exclude;
+ int query_syntax;
notmuch_query_t *query;
int sort;
int output;
@@ -721,7 +727,10 @@ _notmuch_search_prepare (search_context_t *ctx, int argc, char *argv[])
return EXIT_FAILURE;
}
- ctx->query = notmuch_query_create (ctx->notmuch, query_str);
+ if (ctx->query_syntax == QUERY_SYNTAX_SEXP)
+ ctx->query = notmuch_query_create_sexpr (ctx->notmuch, query_str);
+ else
+ ctx->query = notmuch_query_create (ctx->notmuch, query_str);
if (ctx->query == NULL) {
fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE;
@@ -771,6 +780,7 @@ static search_context_t search_context = {
.format_sel = NOTMUCH_FORMAT_TEXT,
.exclude = NOTMUCH_EXCLUDE_TRUE,
.sort = NOTMUCH_SORT_NEWEST_FIRST,
+ .query_syntax = QUERY_SYNTAX_XAPIAN,
.output = 0,
.offset = 0,
.limit = -1, /* unlimited */
@@ -789,6 +799,10 @@ static const notmuch_opt_desc_t common_options[] = {
{ "text", NOTMUCH_FORMAT_TEXT },
{ "text0", NOTMUCH_FORMAT_TEXT0 },
{ 0, 0 } } },
+ { .opt_keyword = &search_context.query_syntax, .name = "query-syntax", .keywords =
+ (notmuch_keyword_t []){ { "xapian", QUERY_SYNTAX_XAPIAN },
+ { "sexp", QUERY_SYNTAX_SEXP },
+ { 0, 0 } } },
{ .opt_int = ¬much_format_version, .name = "format-version" },
{ }
};
diff --git a/test/T080-search.sh b/test/T080-search.sh
index a3f0dead..966e772a 100755
--- a/test/T080-search.sh
+++ b/test/T080-search.sh
@@ -189,4 +189,9 @@ test_begin_subtest "parts do not have adjacent term positions"
output=$(notmuch search id:termpos and '"c x"')
test_expect_equal "$output" ""
+test_begin_subtest "sexpr query: all messages"
+notmuch search '*' > EXPECTED
+notmuch search --query-syntax=sexp '()' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
test_done
diff --git a/test/T095-address.sh b/test/T095-address.sh
index 817be538..adf0b307 100755
--- a/test/T095-address.sh
+++ b/test/T095-address.sh
@@ -325,4 +325,9 @@ cat <<EOF >EXPECTED
EOF
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "sexpr query: all messages"
+notmuch address '*' > EXPECTED
+notmuch address --query-syntax=sexp '()' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
test_done
--
2.30.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org