]> granicus.if.org Git - neomutt/commitdiff
add: log warnings
authorRichard Russon <rich@flatcap.org>
Wed, 2 Oct 2019 14:20:32 +0000 (15:20 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 4 Oct 2019 23:36:40 +0000 (00:36 +0100)
Distinguish between errors and warnings in the log and displayed on screen.

  color warning brightyellow default

color.c
color.h
commands.c
contrib/sample.neomuttrc
init.c
mutt_logging.c
pager.c

diff --git a/color.c b/color.c
index fc60fbaabf8f7c4ce28c7984002cf8ddb88a4220..2f2a55be7c0d2c3c5df1daf2396a4bd1ca28c169 100644 (file)
--- a/color.c
+++ b/color.c
@@ -154,6 +154,7 @@ static const struct Mapping Fields[] = {
   { "tilde", MT_COLOR_TILDE },
   { "tree", MT_COLOR_TREE },
   { "underline", MT_COLOR_UNDERLINE },
+  { "warning", MT_COLOR_WARNING },
   { NULL, 0 },
 };
 
diff --git a/color.h b/color.h
index 97ff26c3f6d61ddbad138a2fef18aeb715cf13d7..7a30322ad3ab215bfed1488628a4d13dac71ffb4 100644 (file)
--- a/color.h
+++ b/color.h
@@ -84,6 +84,7 @@ enum ColorId
   MT_COLOR_SB_SPOOLFILE,             ///< $spoolfile (Spool mailbox)
 #endif
   MT_COLOR_MESSAGE_LOG,              ///< Menu showing log messages
+  MT_COLOR_WARNING,                  ///< Warning messages
   /* please no non-MT_COLOR_INDEX objects after this point */
   MT_COLOR_INDEX,                    ///< Index: default colour (takes a pattern)
   MT_COLOR_INDEX_AUTHOR,             ///< Index: author field (takes a pattern)
index 3cc114876202055390eb883a63b3c90fb03d04d4..7beaae07d487fb869bb4cea3f339aec3697ca1fc 100644 (file)
@@ -868,8 +868,10 @@ void mutt_enter_command(void)
     {
       if (rc == MUTT_CMD_SUCCESS) /* command succeeded with message */
         mutt_message("%s", err.data);
-      else /* error executing command */
+      else if (rc == MUTT_CMD_ERROR)
         mutt_error("%s", err.data);
+      else if (rc == MUTT_CMD_WARNING)
+        mutt_warning("%s", err.data);
     }
   }
   /* else successful command */
index a7fa21d2f18690c9c5c1d456c39f1b3535b5f765..98a364b34e1e201568dff476ae98c8f0e1df23b0 100644 (file)
@@ -141,6 +141,7 @@ color message brightcyan default
 color markers brightcyan default
 color attachment brightmagenta default
 color search default green     # how to hilite search patterns in the pager
+color warning brightyellow default
 
 color header brightred default ^(From|Subject):
 color body magenta default "(ftp|http|https)://[^ ]+"  # point out URLs
diff --git a/init.c b/init.c
index 0e49a753a61be40bb1a9b2bba0f0e259c7b32fcf..bcac0a9d80a5659f25df2af3e73afb4264a84ed6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -288,12 +288,17 @@ static int execute_commands(struct ListHead *p)
   struct ListNode *np = NULL;
   STAILQ_FOREACH(np, p, entries)
   {
-    if (mutt_parse_rc_line(np->data, token, err) == MUTT_CMD_ERROR)
-    {
+    enum CommandResult rc2 = mutt_parse_rc_line(np->data, token, err);
+    if (rc2 == MUTT_CMD_ERROR)
       mutt_error(_("Error in command line: %s"), mutt_b2s(err));
+
+    if ((rc2 == MUTT_CMD_ERROR) || (rc2 == MUTT_CMD_WARNING))
+      mutt_warning(_("Warning in command line: %s"), mutt_b2s(err));
+
+    if ((rc2 == MUTT_CMD_ERROR) || (rc2 == MUTT_CMD_WARNING))
+    {
       mutt_buffer_pool_release(&token);
       mutt_buffer_pool_release(&err);
-
       return -1;
     }
   }
index 84a0533271791464ba679bb1031429bd907ccd23..add812f5ceea5ef13a228ddb398124aed4e51f72 100644 (file)
@@ -170,9 +170,20 @@ int log_disp_curses(time_t stamp, const char *file, int line,
 
   if (!OptKeepQuiet)
   {
-    if (level == LL_ERROR)
-      mutt_beep(false);
-    mutt_curses_set_color((level == LL_ERROR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
+    switch (level)
+    {
+      case LL_ERROR:
+        mutt_beep(false);
+        mutt_curses_set_color(MT_COLOR_ERROR);
+        break;
+      case LL_WARNING:
+        mutt_curses_set_color(MT_COLOR_WARNING);
+        break;
+      default:
+        mutt_curses_set_color(MT_COLOR_MESSAGE);
+        break;
+    }
+
     mutt_window_mvaddstr(MuttMessageWindow, 0, 0, ErrorBuf);
     mutt_curses_set_color(MT_COLOR_NORMAL);
     mutt_window_clrtoeol(MuttMessageWindow);
diff --git a/pager.c b/pager.c
index fd9770731aac44550174a686b36db940e8c059ff..22476b8c3c81ac189ca0e3529e85a3db476463b3 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1682,6 +1682,8 @@ static int display_line(FILE *fp, LOFF_T *last_pos, struct Line **line_info,
     (*line_info)[n].type = MT_COLOR_MESSAGE_LOG;
     if (buf[11] == 'M')
       (*line_info)[n].syntax[0].color = MT_COLOR_MESSAGE;
+    else if (buf[11] == 'W')
+      (*line_info)[n].syntax[0].color = MT_COLOR_WARNING;
     else if (buf[11] == 'E')
       (*line_info)[n].syntax[0].color = MT_COLOR_ERROR;
     else