From: Karel Zak Date: Fri, 7 Sep 2012 07:31:54 +0000 (+0200) Subject: add nm_query_type config file option X-Git-Tag: neomutt-20160404~13^2~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d713a4bb5a633a0cb34a6963a6e8d4206238a0cb;p=neomutt add nm_query_type config file option Signed-off-by: Karel Zak --- diff --git a/README.notmuch b/README.notmuch index 77f133d80..a38fdeb19 100644 --- a/README.notmuch +++ b/README.notmuch @@ -69,7 +69,8 @@ notmuch support for mutt type= - Reads all matching messages or whole-threads. The defauls is 'messages'. + Reads all matching messages or whole-threads. The defauls is 'messages' + or nm_query_type. * commands: @@ -158,6 +159,13 @@ notmuch support for mutt Default is unlimited. + nm_query_type = + + This variable specifies notmuch query type, supported types: 'threads' and + 'messages'. + + Default is 'messages'. + vfolder_format = This variable allows you to customize the file browser display for virtual diff --git a/globals.h b/globals.h index bf27e1c9b..e0bf286e4 100644 --- a/globals.h +++ b/globals.h @@ -288,6 +288,7 @@ WHERE char *NotmuchUnreadTag; WHERE char *NotmuchHiddenTags; WHERE char *VirtFolderFormat; WHERE int NotmuchDBLimit; +WHERE char *NotmuchQueryType; #endif diff --git a/init.h b/init.h index 6f3b346ca..f7e7353ad 100644 --- a/init.h +++ b/init.h @@ -1701,6 +1701,11 @@ struct option_t MuttVars[] = { ** .pp ** This variable specifies the default limit used in notmuch queries. */ + { "nm_query_type", DT_STR, R_NONE, UL &NotmuchQueryType, 0 }, + /* + ** .pp + ** This variable specifies the default query type (threads or messages) used in notmuch queries. + */ #endif { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" }, /* diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 28ad8b470..5b190d344 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -309,6 +309,22 @@ static struct nm_ctxdata *get_ctxdata(CONTEXT *ctx) return NULL; } +static int string_to_guery_type(const char *str) +{ + if (!str) + str = NotmuchQueryType; /* user's default */ + if (!str) + return NM_QUERY_TYPE_MESGS; /* hardcoded default */ + + if (strcmp(str, "threads") == 0) + return NM_QUERY_TYPE_THREADS; + else if (strcmp(str, "messages") == 0) + return NM_QUERY_TYPE_MESGS; + + mutt_error (_("failed to parse notmuch query type: %s"), str); + return NM_QUERY_TYPE_MESGS; +} + static char *get_query_string(struct nm_ctxdata *data) { struct uri_tag *item; @@ -326,18 +342,16 @@ static char *get_query_string(struct nm_ctxdata *data) if (mutt_atoi(item->value, &data->db_limit)) mutt_error (_("failed to parse notmuch limit: %s"), item->value); - } else if (strcmp(item->name, "type") == 0) { - if (strcmp(item->value, "threads") == 0) - data->query_type = NM_QUERY_TYPE_THREADS; - else if (strcmp(item->value, "messages") == 0) - data->query_type = NM_QUERY_TYPE_MESGS; - else - mutt_error (_("failed to parse notmuch query type: %s"), item->value); + } else if (strcmp(item->name, "type") == 0) + data->query_type = string_to_guery_type(item->value); - } else if (strcmp(item->name, "query") == 0) + else if (strcmp(item->name, "query") == 0) data->db_query = safe_strdup(item->value); } + if (!data->query_type) + data->query_type = string_to_guery_type(NULL); + dprint(2, (debugfile, "nm: query '%s'\n", data->db_query)); return data->db_query;