X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-search.c;h=39d55bfeb25e33add37d2d017f36551d5ec2f842;hb=036734252d07d8568937073d4f2d366bcb06bc4e;hp=aba22799cb285af087553f9ebffa9dbf0c619486;hpb=d613d10ddd5948b4fa5a186fc54752047b25023d;p=notmuch diff --git a/notmuch-search.c b/notmuch-search.c index aba22799..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; @@ -709,8 +710,6 @@ _notmuch_search_prepare (search_context_t *ctx, int argc, char *argv[]) notmuch_exit_if_unsupported_format (); - notmuch_exit_if_unmatched_db_uuid (ctx->notmuch); - query_str = query_string_from_args (ctx->notmuch, argc, argv); if (query_str == NULL) { fprintf (stderr, "Out of memory.\n"); @@ -721,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); @@ -771,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 */ @@ -789,12 +788,16 @@ 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 = ¬much_format_version, .name = "format-version" }, { } }; int -notmuch_search_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[]) +notmuch_search_command (notmuch_database_t *notmuch, int argc, char *argv[]) { search_context_t *ctx = &search_context; int opt_index, ret; @@ -827,11 +830,12 @@ notmuch_search_command (unused(notmuch_config_t *config), notmuch_database_t *no if (opt_index < 0) return EXIT_FAILURE; - notmuch_process_shared_options (argv[0]); + notmuch_process_shared_options (notmuch, argv[0]); if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && ctx->dupe != -1) { - fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); + fprintf (stderr, + "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); return EXIT_FAILURE; } @@ -860,7 +864,7 @@ notmuch_search_command (unused(notmuch_config_t *config), notmuch_database_t *no } int -notmuch_address_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[]) +notmuch_address_command (notmuch_database_t *notmuch, int argc, char *argv[]) { search_context_t *ctx = &search_context; int opt_index, ret; @@ -892,7 +896,7 @@ notmuch_address_command (unused(notmuch_config_t *config), notmuch_database_t *n if (opt_index < 0) return EXIT_FAILURE; - notmuch_process_shared_options (argv[0]); + notmuch_process_shared_options (notmuch, argv[0]); if (! (ctx->output & (OUTPUT_SENDER | OUTPUT_RECIPIENTS))) ctx->output |= OUTPUT_SENDER;