]> granicus.if.org Git - neomutt/commitdiff
error: Don't pause after duplicate messages
authorRichard Russon <rich@flatcap.org>
Thu, 22 Mar 2018 15:02:23 +0000 (15:02 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 22 Mar 2018 15:59:11 +0000 (15:59 +0000)
Fixes #1100

curs_lib.c
globals.h
main.c
menu.c
mutt_logging.c

index 3ad927fa297399d8cfac082bd9bf17155fc8c6a2..9c1695efa3c0669444242f7097e3bf3d5b3d5270 100644 (file)
@@ -737,7 +737,7 @@ void mutt_window_getyx(struct MuttWindow *win, int *y, int *x)
 
 void mutt_show_error(void)
 {
-  if (OPT_KEEP_QUIET)
+  if (OPT_KEEP_QUIET || !ErrorBufMessage)
     return;
 
   SETCOLOR(OPT_MSG_ERR ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
index e8e2cdf01434e29d0ab604f36b0ded9518b3cd28..ba1792a926d5751d6f2b5d9c303f6a7dc05f6a72 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -37,6 +37,7 @@
 
 WHERE struct Context *Context;
 
+WHERE bool ErrorBufMessage;
 WHERE char ErrorBuf[STRING];
 WHERE char AttachmentMarker[STRING];
 
diff --git a/main.c b/main.c
index b37c4728ffd727a3319ed1e9f38d2d6b2da8879f..52a8d79655ff3531c597d720ad627d1d9a567fbd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -877,7 +877,7 @@ int main(int argc, char **argv, char **env)
     rv = ci_send_message(sendflags, msg, bodyfile, NULL, NULL);
     /* We WANT the "Mail sent." and any possible, later error */
     log_queue_empty();
-    if (ErrorBuf[0])
+    if (ErrorBufMessage)
       mutt_message("%s", ErrorBuf);
 
     if (edit_infile)
@@ -1046,7 +1046,7 @@ main_curses:
   log_queue_flush(log_disp_terminal);
   mutt_log_stop();
   /* Repeat the last message to the user */
-  if (repeat_error && ErrorBuf[0])
+  if (repeat_error && ErrorBufMessage)
     puts(ErrorBuf);
 main_exit:
   return rc;
diff --git a/menu.c b/menu.c
index 05d77f135bb70816a21b390525c551e70194a811..7918e674fe7cea919f6f619eb6626692dc295e78 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -479,7 +479,7 @@ static void menu_redraw_prompt(struct Menu *menu)
       OPT_MSG_ERR = false;
     }
 
-    if (*ErrorBuf)
+    if (ErrorBufMessage)
       mutt_clear_error();
 
     mutt_window_mvaddstr(menu->messagewin, 0, 0, menu->prompt);
index 6c568cdaa6de7cf81e3dffbf0222681a19457747..d81c61a565137250cc2b02f3636d99475497adce 100644 (file)
@@ -140,7 +140,7 @@ void mutt_clear_error(void)
   if (OPT_MSG_ERR)
     error_pause();
 
-  ErrorBuf[0] = 0;
+  ErrorBufMessage = false;
   if (!OPT_NO_CURSES)
     mutt_window_clearline(MuttMessageWindow, 0);
 }
@@ -180,20 +180,26 @@ int log_disp_curses(time_t stamp, const char *file, int line,
     ret += snprintf(buf2, len, ": %s (errno = %d)", p, errno);
   }
 
-  log_disp_file(stamp, file, line, function, level, "%s", buf);
-  if (stamp == 0)
-    log_disp_queue(stamp, file, line, function, level, "%s", buf);
+  bool dupe = (strcmp(buf, ErrorBuf) == 0);
+  if (!dupe)
+  {
+    /* Only log unique messages */
+    log_disp_file(stamp, file, line, function, level, "%s", buf);
+    if (stamp == 0)
+      log_disp_queue(stamp, file, line, function, level, "%s", buf);
+  }
 
   /* Don't display debugging message on screen */
   if (level > LL_MESSAGE)
     return 0;
 
   /* Only pause if this is a message following an error */
-  if ((level > LL_ERROR) && OPT_MSG_ERR)
+  if ((level > LL_ERROR) && OPT_MSG_ERR && !dupe)
     error_pause();
 
   mutt_simple_format(ErrorBuf, sizeof(ErrorBuf), 0, MuttMessageWindow->cols,
                      FMT_LEFT, 0, buf, sizeof(buf), 0);
+  ErrorBufMessage = true;
 
   if (!OPT_KEEP_QUIET)
   {
@@ -206,7 +212,7 @@ int log_disp_curses(time_t stamp, const char *file, int line,
     mutt_refresh();
   }
 
-  if (level <= LL_ERROR)
+  if ((level <= LL_ERROR) && !dupe)
   {
     OPT_MSG_ERR = true;
     if (gettimeofday(&LastError, NULL) < 0)