From: Karel Zak Date: Thu, 6 Sep 2012 07:31:54 +0000 (+0200) Subject: count messages for mutt progress bar X-Git-Tag: neomutt-20160404~13^2~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65ff2214b0f274b6af1c0686c59d27408eafa835;p=neomutt count messages for mutt progress bar Signed-off-by: Karel Zak --- diff --git a/mutt_notmuch.c b/mutt_notmuch.c index c84157a04..9ede705dd 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -879,8 +879,6 @@ int nm_read_query(CONTEXT *ctx) notmuch_query_t *q; struct nm_ctxdata *data; int rc = -1; - char msgbuf[STRING]; - progress_t progress; if (init_context(ctx) != 0) return -1; @@ -889,18 +887,24 @@ int nm_read_query(CONTEXT *ctx) if (!data) return -1; - data->progress = &progress; - dprint(1, (debugfile, "nm: reading messages...[current count=%d]\n", ctx->msgcount)); - if (!ctx->quiet) { - snprintf (msgbuf, sizeof (msgbuf), _("Reading %s..."), ctx->path); - mutt_progress_init (data->progress, msgbuf, M_PROGRESS_MSG, ReadInc, 0); - } q = get_query(data, FALSE); if (q) { int type = get_query_type(data); + char msgbuf[STRING]; + progress_t progress; + + if (!ctx->quiet) { + unsigned ct = notmuch_query_count_messages(q); + + data->progress = &progress; + snprintf (msgbuf, sizeof(msgbuf), + _("Reading %s..."), ctx->path); + mutt_progress_init(data->progress, msgbuf, + M_PROGRESS_MSG, ReadInc, ct); + } switch(type) { case NM_QUERY_TYPE_MESGS: