type=<threads|messages>
- 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:
Default is unlimited.
+ nm_query_type = <threads|messages>
+
+ This variable specifies notmuch query type, supported types: 'threads' and
+ 'messages'.
+
+ Default is 'messages'.
+
vfolder_format = <string>
This variable allows you to customize the file browser display for virtual
** .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" },
/*
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;
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;