From: Kevin McCarthy <kevin@8t8.us>
Date: Sat, 8 Apr 2017 21:18:26 +0000 (-0700)
Subject: Silence imap progress messages for pipe-message. (see #3929)
X-Git-Tag: neomutt-20170414~11^2~1
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b88fe3b41f2829c1036c37b41d624eba1d74d0f4;p=neomutt

Silence imap progress messages for pipe-message. (see #3929)

_mutt_pipe_message() calls endwin(), and then calls pipe_msg().  If an
imap message body hasn't already been downloaded, this can end up
calling imap_fetch_message().

The progress messages in imap_fetch_message() were restoring curses,
just after extract_url was running.  This was leading to a condition
where mutt curses didn't think the screen had changed after
extract_url exited.

There was already a check for isendwin() inside imap_fetch_message(),
but it wasn't wrapped around the progressbar creation/usage.  Add a
check for those places too.
---

diff --git a/imap/message.c b/imap/message.c
index 9d628e678..1f5150bc5 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -712,6 +712,7 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
   /* Sam's weird courier server returns an OK response even when FETCH
    * fails. Thanks Sam. */
   short fetched = 0;
+  int output_progress;
 
   idata = ctx->data;
   h = ctx->hdrs[msgno];
@@ -742,7 +743,10 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
     }
   }
 
-  if (!isendwin())
+  /* This function is called in a few places after endwin()
+   * e.g. _mutt_pipe_message(). */
+  output_progress = !isendwin ();
+  if (output_progress)
     mutt_message (_("Fetching message..."));
 
   if (!(msg->fp = msg_cache_put (idata, h)))
@@ -800,9 +804,13 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
 	    imap_error ("imap_fetch_message()", buf);
 	    goto bail;
 	  }
-	  mutt_progress_init (&progressbar, _("Fetching message..."),
-			      MUTT_PROGRESS_SIZE, NetInc, bytes);
-	  if (imap_read_literal (msg->fp, idata, bytes, &progressbar) < 0)
+          if (output_progress)
+          {
+            mutt_progress_init (&progressbar, _("Fetching message..."),
+                                MUTT_PROGRESS_SIZE, NetInc, bytes);
+          }
+	  if (imap_read_literal (msg->fp, idata, bytes,
+                                 output_progress ? &progressbar : NULL) < 0)
 	    goto bail;
 	  /* pick up trailing line */
 	  if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)