From 6d873d376040628040220efd3e66be31fed88e7f Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 6 Mar 2017 22:07:57 +0100
Subject: [PATCH] startup: add option 'nopauses' to disable pausing after a
 warning

This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
---
 doc/nano.texi        | 4 ++++
 doc/nanorc.5         | 4 ++++
 doc/sample.nanorc.in | 4 ++++
 src/nano.h           | 3 ++-
 src/rcfile.c         | 3 ++-
 src/winio.c          | 4 ++--
 syntax/nanorc.nanorc | 2 +-
 7 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/doc/nano.texi b/doc/nano.texi
index 6159bd33..d66e65a7 100644
--- a/doc/nano.texi
+++ b/doc/nano.texi
@@ -743,6 +743,10 @@ Don't convert files from DOS/Mac format.
 @item set nohelp
 Don't display the help lists at the bottom of the screen.
 
+@item set nopauses
+Don't pause between warnings at startup.  This means that only
+the last one will be visible (when there are multiple ones).
+
 @item set nonewlines
 Don't add newlines to the ends of files.
 
diff --git a/doc/nanorc.5 b/doc/nanorc.5
index 1dd50ca8..ece4e190 100644
--- a/doc/nanorc.5
+++ b/doc/nanorc.5
@@ -151,6 +151,10 @@ Don't display the two help lines at the bottom of the screen.
 .B set nonewlines
 Don't automatically add a newline to the ends of files.
 .TP
+.B set nopauses
+Don't pause between warnings at startup.  This means that only
+the last one will be visible (when there are multiple ones).
+.TP
 .B set nowrap
 Don't hard-wrap text at all.
 .TP
diff --git a/doc/sample.nanorc.in b/doc/sample.nanorc.in
index c8970b4b..b2e9fe72 100644
--- a/doc/sample.nanorc.in
+++ b/doc/sample.nanorc.in
@@ -95,6 +95,10 @@
 ## Don't display the helpful shortcut lists at the bottom of the screen.
 # set nohelp
 
+## Don't pause between warnings at startup.  Which means that only the
+## last one will be readable (when there are multiple ones).
+# set nopauses
+
 ## Don't add newlines to the ends of files.
 # set nonewlines
 
diff --git a/src/nano.h b/src/nano.h
index eba20ace..60fc8c6b 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -509,7 +509,8 @@ enum
     MAKE_IT_UNIX,
     JUSTIFY_TRIM,
     SHOW_CURSOR,
-    LINE_NUMBERS
+    LINE_NUMBERS,
+    NO_PAUSES
 };
 
 /* Flags for the menus in which a given function should be present. */
diff --git a/src/rcfile.c b/src/rcfile.c
index 5c0c9439..3ede61f6 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -62,6 +62,7 @@ static const rcoption rcopts[] = {
 #endif
     {"nohelp", NO_HELP},
     {"nonewlines", NO_NEWLINES},
+    {"nopauses", NO_PAUSES},
 #ifndef DISABLE_WRAPPING
     {"nowrap", NO_WRAP},
 #endif
@@ -1292,7 +1293,7 @@ void do_rcfiles(void)
 
     free(nanorc);
 
-    if (errors && !ISSET(QUIET)) {
+    if (errors && !ISSET(QUIET) && !ISSET(NO_PAUSES)) {
 	errors = FALSE;
 	fprintf(stderr, _("\nPress Enter to continue starting nano.\n"));
 	while (getchar() != '\n')
diff --git a/src/winio.c b/src/winio.c
index 1e6cc298..8f99fa8e 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2111,11 +2111,11 @@ void statusline(message_type importance, const char *msg, ...)
 
     /* Shortly pause after each of the first three alert messages,
      * to give the user time to read them. */
-    if (lastmessage == ALERT && alerts < 4)
+    if (lastmessage == ALERT && alerts < 4 && !ISSET(NO_PAUSES))
 	napms(1200);
 
     if (importance == ALERT) {
-	if (++alerts > 3)
+	if (++alerts > 3 && !ISSET(NO_PAUSES))
 	    msg = _("Further warnings were suppressed");
 	beep();
     }
diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc
index b5aacaab..121cdc84 100644
--- a/syntax/nanorc.nanorc
+++ b/syntax/nanorc.nanorc
@@ -7,7 +7,7 @@ comment "#"
 icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
 
 # Keywords
-icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
+icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
 icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" "[[:space:]]+[[:digit:]]+$"
 icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
 icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
-- 
GitLab