aboutsummaryrefslogtreecommitdiff
path: root/notmuch-search.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-24 08:17:14 -0700
committerDavid Bremner <david@tethera.net>2021-09-04 17:07:19 -0700
commite3b1a0a6a59691f6be9fd0cb3b0d01bb9a7fe2b7 (patch)
treef612542d279065e94f0e2c53173c51acc78feec1 /notmuch-search.c
parentc4f2f33a50643b41e6dbf0519c563ae7db48beab (diff)
CLI/search+address: support sexpr queries
Initially support selection of query syntax in two subcommands to enable testing.
Diffstat (limited to 'notmuch-search.c')
-rw-r--r--notmuch-search.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/notmuch-search.c b/notmuch-search.c
index 375a247d..39d55bfe 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -56,6 +56,7 @@ typedef struct {
int format_sel;
sprinter_t *format;
int exclude;
+ int query_syntax;
notmuch_query_t *query;
int sort;
int output;
@@ -719,11 +720,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 == NULL) {
- fprintf (stderr, "Out of memory\n");
+ if (print_status_database ("notmuch search", ctx->notmuch,
+ notmuch_query_create_with_syntax (ctx->notmuch, query_str,
+ ctx->query_syntax, &ctx->query)))
return EXIT_FAILURE;
- }
notmuch_query_set_sort (ctx->query, ctx->sort);
@@ -769,6 +769,7 @@ static search_context_t search_context = {
.format_sel = NOTMUCH_FORMAT_TEXT,
.exclude = NOTMUCH_EXCLUDE_TRUE,
.sort = NOTMUCH_SORT_NEWEST_FIRST,
+ .query_syntax = NOTMUCH_QUERY_SYNTAX_XAPIAN,
.output = 0,
.offset = 0,
.limit = -1, /* unlimited */
@@ -787,6 +788,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", .keywords =
+ (notmuch_keyword_t []){ { "infix", NOTMUCH_QUERY_SYNTAX_XAPIAN },
+ { "sexp", NOTMUCH_QUERY_SYNTAX_SEXP },
+ { 0, 0 } } },
{ .opt_int = &notmuch_format_version, .name = "format-version" },
{ }
};