From: Kirill A. Shutemov Date: Fri, 11 Oct 2013 18:34:57 +0000 (-0700) Subject: apply NotmuchExcludeTags to count queries X-Git-Tag: neomutt-20160317~5^2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f40d09ab53ba4507de1c6dcbc8ff761adb4246b3;p=neomutt apply NotmuchExcludeTags to count queries We have support of tag excluding, but it doesn't cover count queries. Let's fix this. Signed-off-by: Kirill A. Shutemov --- diff --git a/mutt_notmuch.c b/mutt_notmuch.c index a9a11edad..bca3f3967 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -568,25 +568,8 @@ static int get_database_mtime(struct nm_ctxdata *data, time_t *mtime) return 0; } -static notmuch_query_t *get_query(struct nm_ctxdata *data, int writable) +static void apply_exclude_tags(notmuch_query_t *query) { - notmuch_database_t *db = NULL; - notmuch_query_t *q = NULL; - const char *str; - - if (!data) - return NULL; - - db = get_db(data, writable); - str = get_query_string(data); - - if (!db || !str) - goto err; - - q = notmuch_query_create(db, str); - if (!q) - goto err; - if (NotmuchExcludeTags) { char *buf = safe_strdup(NotmuchExcludeTags); char *p, *tag = NULL, *end = NULL; @@ -607,12 +590,33 @@ static notmuch_query_t *get_query(struct nm_ctxdata *data, int writable) *end = '\0'; dprint(2, (debugfile, "nm: query explude tag '%s'\n", tag)); - notmuch_query_add_tag_exclude(q, tag); + notmuch_query_add_tag_exclude(query, tag); end = tag = NULL; } FREE(&buf); - } +} + +static notmuch_query_t *get_query(struct nm_ctxdata *data, int writable) +{ + notmuch_database_t *db = NULL; + notmuch_query_t *q = NULL; + const char *str; + + if (!data) + return NULL; + + db = get_db(data, writable); + str = get_query_string(data); + + if (!db || !str) + goto err; + + q = notmuch_query_create(db, str); + if (!q) + goto err; + + apply_exclude_tags(q); notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST); dprint(2, (debugfile, "nm: query successfully initialized\n")); return q; @@ -1562,6 +1566,7 @@ static unsigned count_query(notmuch_database_t *db, const char *qstr) notmuch_query_t *q = notmuch_query_create(db, qstr); if (q) { + apply_exclude_tags(q); res = notmuch_query_count_messages(q); notmuch_query_destroy(q); dprint(1, (debugfile, "nm: count '%s', result=%d\n", qstr, res));