]> granicus.if.org Git - neomutt/commitdiff
count messages for mutt progress bar
authorKarel Zak <kzak@redhat.com>
Thu, 6 Sep 2012 07:31:54 +0000 (09:31 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:06 +0000 (16:30 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
mutt_notmuch.c

index c84157a0480b18aaf7fc876b71a1cb2433ed214c..9ede705dd96a2c8dff274e78ff5550b14cb76652 100644 (file)
@@ -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: