{
notmuch_database_t *db;
- char *db_filename; /**< Filename of the NotMuch database */
- char *db_query; /**< Previous query */
- int db_limit; /**< Maximum number of results to return */
- int query_type; /**< Messages or Threads */
+ char *db_filename; /**< Filename of the NotMuch database */
+ char *db_query; /**< Previous query */
+ int db_limit; /**< Maximum number of results to return */
+ enum NmQueryType query_type; /**< Messages or Threads */
struct UriTag *query_items;
return NULL;
}
-static int string_to_query_type(const char *str)
+static enum NmQueryType string_to_query_type(const char *str)
{
- if (!str)
- str = NmQueryType; /* user's default */
- if (!str)
- return NM_QUERY_TYPE_MESGS; /* hardcoded default */
-
- if (strcmp(str, "threads") == 0)
+ if (mutt_strcmp(str, "threads") == 0)
return NM_QUERY_TYPE_THREADS;
- else if (strcmp(str, "messages") == 0)
+ else if (mutt_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 *query_type_to_string(enum NmQueryType query_type)
+{
+ if (query_type == NM_QUERY_TYPE_THREADS)
+ return "threads";
+ else
+ return "messages";
+}
+
/**
* query_window_check_timebase - Checks if a given timebase string is valid
* @param[in] timebase: string containing a time base
if (data->db_query)
return data->db_query;
+ data->query_type = string_to_query_type(NmQueryType); /* user's default */
+
for (item = data->query_items; item; item = item->next)
{
if (!item->value || !item->name)
if (!data->db_query)
return NULL;
- if (!data->query_type)
- data->query_type = string_to_query_type(NULL);
-
if (window)
{
char buf[LONG_STRING];
return data ? data->db_limit : 0;
}
-static int get_query_type(struct NmCtxData *data)
-{
- return (data && data->query_type) ? data->query_type : string_to_query_type(NULL);
-}
-
static const char *get_db_filename(struct NmCtxData *data)
{
char *db_filename = NULL;
int added;
if (data)
- added = snprintf(uri, sizeof(uri), "notmuch://%s?query=", get_db_filename(data));
+ added = snprintf(uri, sizeof(uri),
+ "notmuch://%s?type=%s&query=", get_db_filename(data),
+ query_type_to_string(data->query_type));
else if (NmDefaultUri)
- added = snprintf(uri, sizeof(uri), "%s?query=", NmDefaultUri);
+ added = snprintf(uri, sizeof(uri), "%s?type=%s&query=", NmDefaultUri,
+ query_type_to_string(data->query_type));
else if (Folder)
- added = snprintf(uri, sizeof(uri), "notmuch://%s?query=", Folder);
+ added = snprintf(uri, sizeof(uri), "notmuch://%s?type=%s&query=", Folder,
+ query_type_to_string(data->query_type));
else
return NULL;
q = notmuch_query_create(db, new_str);
- switch (get_query_type(data))
+ switch (data->query_type)
{
case NM_QUERY_TYPE_MESGS:
{
if (q)
{
rc = 0;
- switch (get_query_type(data))
+ switch (data->query_type)
{
case NM_QUERY_TYPE_MESGS:
if (!read_mesgs_query(ctx, q, 0))