From 0b43c8da111ffb046f7413a227762d8aace40456 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 14 May 2024 16:29:35 +0200 Subject: [PATCH 01/30] docs: extend the FAQ item about urxvt modified keys, with M-Home/M-End --- doc/faq.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/faq.html b/doc/faq.html index 79f605dc..4b8422ce 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -208,6 +208,9 @@ URxvt.keysym.M-Right: \033[1;3C URxvt.keysym.M-Left: \033[1;3D + URxvt.keysym.M-Home: \033[1;3H + URxvt.keysym.M-End: \033[1;3F + URxvt.keysym.M-Insert: \033[2;3~ URxvt.keysym.M-Delete: \033[3;3~ From 803a16cbcd2d1a770dc5d8f5aa7051f5dcf2b398 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 14 May 2024 16:32:25 +0200 Subject: [PATCH 02/30] input: drop recognition of the urxvt escape sequences for M-Home/M-End Nano does not recognize the urxvt escape sequences for other combinations either. And with the previous two commits, the urxvt user can now "help themselves". This reverts commit 363a4378 from three days ago. --- src/winio.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/winio.c b/src/winio.c index 9a9d282a..54cffd9a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -829,8 +829,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY else if (length > 1 && seq[1] == '@') return shiftcontrolhome; - else if (length > 1 && seq[1] == 0xFE) - return ALT_HOME; #endif break; case '8': /* Esc [ 8 ~ == End on Eterm/rxvt; @@ -846,8 +844,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY else if (length > 1 && seq[1] == '@') return shiftcontrolend; - else if (length > 1 && seq[1] == 0xFE) - return ALT_END; #endif break; case '9': /* Esc [ 9 == Delete on Mach console. */ @@ -1060,12 +1056,6 @@ int parse_kbinput(WINDOW *frame) #endif else if (keycode < 0x20 && !last_escape_was_alone) meta_key = TRUE; -#ifndef NANO_TINY - else if (keycode == KEY_HOME) - return ALT_HOME; - else if (keycode == KEY_END) - return ALT_END; -#endif } else if (waiting_codes == 0 || nextcodes[0] == ESC_CODE || (keycode != 'O' && keycode != '[')) { if (!shifted_metas) From 54c8cb8c811b9fd202266f43798d77d2120d015e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 10 May 2024 10:44:28 +0200 Subject: [PATCH 03/30] files: when a filename with a colon and digits exists, open that file When the user specifies, on the command line, a filename that ends with a colon plus digits, and that filename exists in the file system, then open that file, instead of interpreting the digits as a line number. Also, if the filename stripped of the colon plus digits does not exist, then do not interpret the digits as a line number either but treat them as part of the file name. Before this change, the user would have to escape the colon whenever they wanted to open a file whose name ended with a colon plus digits. Now the user needs to escape the colon only when 'foo' exists and they want to create, say, 'foo:24'. Problem-was-reported-by: Ralph Corderoy https://lists.gnu.org/archive/html/nano-devel/2024-05/msg00001.html Mitigation-was-suggested-by: Mike Scalora https://lists.gnu.org/archive/html/nano-devel/2024-05/msg00008.html --- src/nano.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index 973054f0..0467504f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2495,19 +2495,24 @@ int main(int argc, char **argv) { char *filename = argv[optind++]; char *colon = filename + (*filename ? 1 : 0); + struct stat fileinfo; /* Search the filename for a colon. If the colon is preceded by * a backslash, elide the backslash and skip the colon. If there * is a valid number after the colon, chop colon and number off. * The number is later used to place the cursor on that line. */ + if (strchr(filename, ':') && stat(filename, &fileinfo) < 0) { while ((colon = strchr(colon, ':'))) { if (*(colon - 1) == '\\') memmove(colon - 1, colon, strlen(colon) + 1); - else if (parse_line_column(colon + 1, &givenline, &givencol)) + else if (parse_line_column(colon + 1, &givenline, &givencol)) { *colon = '\0'; - else + if (stat(filename, &fileinfo) < 0) + *colon++ = ':'; + } else ++colon; } + } if (!open_buffer(filename, TRUE)) continue; From d64235eb6e7129a8a6c94076e2c7e2b30fa77db1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 10 May 2024 11:23:42 +0200 Subject: [PATCH 04/30] tweaks: reshuffle a declaration, adjust a comment, normalize indentation --- src/nano.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/nano.c b/src/nano.c index 0467504f..0821dfaf 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2494,24 +2494,26 @@ int main(int argc, char **argv) #endif { char *filename = argv[optind++]; - char *colon = filename + (*filename ? 1 : 0); struct stat fileinfo; - /* Search the filename for a colon. If the colon is preceded by - * a backslash, elide the backslash and skip the colon. If there - * is a valid number after the colon, chop colon and number off. + /* If the filename contains a colon and this file does not exist, + * then check if the filename ends with a number (while skipping + * any colon preceded by a backslash and eliding the backslash). + * If there is a valid trailing number, chop colon and number off. * The number is later used to place the cursor on that line. */ if (strchr(filename, ':') && stat(filename, &fileinfo) < 0) { - while ((colon = strchr(colon, ':'))) { - if (*(colon - 1) == '\\') - memmove(colon - 1, colon, strlen(colon) + 1); - else if (parse_line_column(colon + 1, &givenline, &givencol)) { - *colon = '\0'; - if (stat(filename, &fileinfo) < 0) - *colon++ = ':'; - } else - ++colon; - } + char *colon = filename + (*filename ? 1 : 0); + + while ((colon = strchr(colon, ':'))) { + if (*(colon - 1) == '\\') + memmove(colon - 1, colon, strlen(colon) + 1); + else if (parse_line_column(colon + 1, &givenline, &givencol)) { + *colon = '\0'; + if (stat(filename, &fileinfo) < 0) + *colon++ = ':'; + } else + ++colon; + } } if (!open_buffer(filename, TRUE)) From 2445e775355f2571f41a7c32e8674df3510fcbf8 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 10 May 2024 11:27:08 +0200 Subject: [PATCH 05/30] files: avoid mistakenly setting the column number to a given line number When the file 'foo:24' exists (but not 'foo') and the user wants to use the colon notation to place the cursor on a certain line, then nano would first interpret the given line number as a column number, before noticing that 'foo' does not exist and then skipping the first colon. So, when such a misinterpretation occurs, the column number needs to be reset to zero. --- src/nano.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nano.c b/src/nano.c index 0821dfaf..b1fe2bec 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2509,8 +2509,10 @@ int main(int argc, char **argv) memmove(colon - 1, colon, strlen(colon) + 1); else if (parse_line_column(colon + 1, &givenline, &givencol)) { *colon = '\0'; - if (stat(filename, &fileinfo) < 0) + if (stat(filename, &fileinfo) < 0) { *colon++ = ':'; + givencol = 0; + } } else ++colon; } From 259a3c70e3522c78b36f95026eed88f3ddd02e23 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 20 May 2024 16:08:29 +0200 Subject: [PATCH 06/30] general: disable the type-ahead checking that ncurses normally does While updating the screen, ncurses by default polls the input source now and then to see if there is new input, and if so, stops updating the screen and waits for the next call of doupdate() or refresh(). https://lists.gnu.org/archive/html/bug-ncurses/2024-05/msg00077.html Disable this polling, as it is just a waste of time, and there *might* be situations where the intruding keystroke does not actually trigger a new update, which could result in a half-updated screen. --- src/nano.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nano.c b/src/nano.c index b1fe2bec..123af18d 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2437,6 +2437,9 @@ int main(int argc, char **argv) mousefocusin = get_keycode("kxIN", FOCUS_IN); mousefocusout = get_keycode("kxOUT", FOCUS_OUT); + /* Disable the type-ahead checking that ncurses normally does. */ + typeahead(-1); + #ifdef HAVE_SET_ESCDELAY /* Tell ncurses to pass the Esc key quickly. */ set_escdelay(50); From add945e717f6c2392622f665390b8d586bf183e4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 25 May 2024 12:02:33 +0200 Subject: [PATCH 07/30] files: look for digits and colons starting from the end of the filename Starting from the end of the provided filename avoids needlessly looking at colons that are somewhere in the middle of the path or the filename. It also avoids inconsistenly interpreting a specified line number as a column number when the filename itself ends with a colon plus digits and the filename without the colon plus digits exists too. This also removes the eliding of a backslash before a colon, which would mangle the filename if the name actually contained a backslash followed by a colon. Negative line and column numbers are no longer allowed when using the colon notation. This fixes https://savannah.gnu.org/bugs/?65781, and fixes https://savannah.gnu.org/bugs/?65782. Problems existed since version 8.0, since colon parsing was introduced. --- src/nano.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/nano.c b/src/nano.c index 123af18d..5707bd96 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2500,24 +2500,24 @@ int main(int argc, char **argv) struct stat fileinfo; /* If the filename contains a colon and this file does not exist, - * then check if the filename ends with a number (while skipping - * any colon preceded by a backslash and eliding the backslash). - * If there is a valid trailing number, chop colon and number off. + * then check if the filename ends with digits preceded by a colon + * (possibly preceded by more digits and a colon). If there is or + * are such trailing numbers, chop the colons plus numbers off. * The number is later used to place the cursor on that line. */ if (strchr(filename, ':') && stat(filename, &fileinfo) < 0) { - char *colon = filename + (*filename ? 1 : 0); - - while ((colon = strchr(colon, ':'))) { - if (*(colon - 1) == '\\') - memmove(colon - 1, colon, strlen(colon) + 1); - else if (parse_line_column(colon + 1, &givenline, &givencol)) { - *colon = '\0'; - if (stat(filename, &fileinfo) < 0) { - *colon++ = ':'; - givencol = 0; - } - } else - ++colon; + char *coda = filename + strlen(filename); + maybe_two: + while (--coda > filename + 1 && ('0' <= *coda && *coda <= '9')) + ; + if (*coda == ':' && ('0' <= *(coda + 1) && *(coda +1) <= '9')) { + *coda = '\0'; + if (stat(filename, &fileinfo) < 0) { + *coda = ':'; + /* If this was the first colon, look for a second one. */ + if (!strchr(coda + 1, ':')) + goto maybe_two; + } else if (!parse_line_column(coda + 1, &givenline, &givencol)) + die(_("Invalid number\n")); } } From 02dd0b4ed5fbf9766c98397ea2b350aad633db2f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 25 May 2024 14:50:37 +0200 Subject: [PATCH 08/30] options: require --colonparsing/-@ to parse colon+number after a filename Stop doing colon parsing by default, to avoid surprises and frustration for users that have filenames that end in a colon plus digits. The equivalent rcfile option is, of course, 'set colonparsing'. Using +1, or similar, before the filename disables any colon parsing and the filename is taken as is. --- src/definitions.h | 1 + src/nano.c | 10 ++++++++-- src/rcfile.c | 1 + syntax/nanorc.nanorc | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/definitions.h b/src/definitions.h index 55d8235d..706a0c07 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -373,6 +373,7 @@ enum { EMPTY_LINE, INDICATOR, BOOKSTYLE, + COLON_PARSING, STATEFLAGS, USE_MAGIC, MINIBAR, diff --git a/src/nano.c b/src/nano.c index 5707bd96..e99a0fab 100644 --- a/src/nano.c +++ b/src/nano.c @@ -646,6 +646,7 @@ void usage(void) print_opt("-!", "--magic", N_("Also try magic to determine syntax")); #endif #ifndef NANO_TINY + print_opt("-@", "--colonparsing", N_("Accept 'filename:linenumber' notation")); print_opt("-%", "--stateflags", N_("Show some states on the title bar")); print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom")); print_opt("-0", "--zero", N_("Hide all bars, use whole terminal")); @@ -1799,6 +1800,7 @@ int main(int argc, char **argv) {"indicator", 0, NULL, 'q'}, {"unix", 0, NULL, 'u'}, {"afterends", 0, NULL, 'y'}, + {"colonparsing", 0, NULL, '@'}, {"stateflags", 0, NULL, '%'}, {"minibar", 0, NULL, '_'}, {"zero", 0, NULL, '0'}, @@ -1850,7 +1852,7 @@ int main(int argc, char **argv) SET(MODERN_BINDINGS); while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RS$T:UVWX:Y:Z" - "abcdef:ghijklmno:pqr:s:tuvwxy!%_0/", long_options, NULL)) != -1) { + "abcdef:ghijklmno:pqr:s:tuvwxy!@%_0/", long_options, NULL)) != -1) { switch (optchr) { #ifndef NANO_TINY case 'A': @@ -2089,6 +2091,9 @@ int main(int argc, char **argv) break; #endif #ifndef NANO_TINY + case '@': + SET(COLON_PARSING); + break; case '%': SET(STATEFLAGS); break; @@ -2504,7 +2509,8 @@ int main(int argc, char **argv) * (possibly preceded by more digits and a colon). If there is or * are such trailing numbers, chop the colons plus numbers off. * The number is later used to place the cursor on that line. */ - if (strchr(filename, ':') && stat(filename, &fileinfo) < 0) { + if (ISSET(COLON_PARSING) && !givenline && strchr(filename, ':') && + !givencol && stat(filename, &fileinfo) < 0) { char *coda = filename + strlen(filename); maybe_two: while (--coda > filename + 1 && ('0' <= *coda && *coda <= '9')) diff --git a/src/rcfile.c b/src/rcfile.c index 943d6888..95271a7e 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -98,6 +98,7 @@ static const rcoption rcopts[] = { {"backup", MAKE_BACKUP}, {"backupdir", 0}, {"bookstyle", BOOKSTYLE}, + {"colonparsing", COLON_PARSING}, {"cutfromcursor", CUT_FROM_CURSOR}, {"emptyline", EMPTY_LINE}, {"guidestripe", 0}, diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc index 6b81075e..5af71c4d 100644 --- a/syntax/nanorc.nanorc +++ b/syntax/nanorc.nanorc @@ -14,7 +14,7 @@ color bold,purple "^[[:blank:]]*include[[:blank:]][^"]*([[:blank:]]|$)" color lime "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*" # The arguments of commands -color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|tabstospaces|trimblanks|unix|wordbounds|zap|zero)\>" +color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|colonparsing|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|tabstospaces|trimblanks|unix|wordbounds|zap|zero)\>" color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+" color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>" color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|execute|browser|whereisfile|gotodir|spell|linter|all)\>" From 4930fbbba726e90bd2f080c0484e726415719397 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 26 May 2024 17:01:53 +0200 Subject: [PATCH 09/30] docs: explain the details of --colonparsing / -@ / 'set colonparsing' Also, remove the earlier explanation, when colon parsing was still done by default. --- doc/nano.1 | 13 ++++++++++--- doc/nano.texi | 24 +++++++++++++++++++++--- doc/nanorc.5 | 10 ++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index 8ca854a5..cc2eab80 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -58,9 +58,6 @@ When giving a filename on the command line, the cursor can be put on a specific line by adding the line number with a plus sign (\fB+\fR) before the filename, and even in a specific column by adding it with a comma. Negative numbers count from the end of the file or line. -The line and column numbers may also be specified by gluing them with colons -after the filename. (When a filename contains a colon followed by digits, -escape the colon by preceding it with a triple backslash.) .sp The cursor can be put on the first or last occurrence of a specific string by specifying that string after \fB+/\fR or \fB+?\fR before the filename. @@ -354,6 +351,16 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings. When neither the file's name nor its first line give a clue, try using libmagic to determine the applicable syntax. .TP +.BR \-@ ", " \-\-colonparsing +When a filename given on the command line ends in a colon plus digits +and this filename does not exist, then snip the colon plus digits and +understand the digits as a line number. If the trimmed filename does +not exist either, then repeat the process and understand the obtained +two numbers as line and column number. But if the doubly trimmed +filename does not exist either, then forget the trimming and accept +the original filename as is. To disable this colon parsing, use +something like \fB+1\fR before the filename. +.TP .BR \-% ", " \-\-stateflags Use the top-right corner of the screen for showing some state flags: \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when diff --git a/doc/nano.texi b/doc/nano.texi index 35ad7484..dbdc2ff8 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -156,9 +156,6 @@ The cursor can be put on a specific line of a file by adding the line number with a plus sign before the filename, and even in a specific column by adding it with a comma. Negative numbers count from the end of the file or line. -The line and column numbers may also be specified by gluing them with colons -after the filename. (When a filename contains a colon followed by digits, -escape the colon by preceding it with a triple backslash.) The cursor can be put on the first or last occurrence of a specific string by specifying that string after @code{+/} or @code{+?} before the filename. @@ -720,6 +717,17 @@ instead of beginnings. When neither the file's name nor its first line give a clue, try using libmagic to determine the applicable syntax. +@item -@ +@itemx --colonparsing +When a filename given on the command line ends in a colon plus digits +and this filename does not exist, then snip the colon plus digits and +understand the digits as a line number. If the trimmed filename does +not exist either, then repeat the process and understand the obtained +two numbers as line and column number. But if the doubly trimmed +filename does not exist either, then forget the trimming and accept +the original filename as is. To disable this colon parsing, use +something like @code{+1} before the filename. + @item -% @itemx --stateflags Use the top-right corner of the screen for showing some state flags: @@ -929,6 +937,16 @@ Automatically hard-wrap the current line when it becomes overlong. @item set casesensitive Do case-sensitive searches by default. +@item set colonparsing +When a filename given on the command line ends in a colon plus digits +and this filename does not exist, then snip the colon plus digits and +understand the digits as a line number. If the trimmed filename does +not exist either, then repeat the process and understand the obtained +two numbers as line and column number. But if the doubly trimmed +filename does not exist either, then forget the trimming and accept +the original filename as is. To disable this colon parsing, use +something like @code{+1} before the filename. + @item set constantshow Constantly display the cursor position on the status bar. Note that this overrides @option{quickblank}. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 672f6e16..5f8a9cd6 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -121,6 +121,16 @@ Automatically hard-wrap the current line when it becomes overlong. .B set casesensitive Do case-sensitive searches by default. .TP +.B set colonparsing +When a filename given on the command line ends in a colon plus digits +and this filename does not exist, then snip the colon plus digits and +understand the digits as a line number. If the trimmed filename does +not exist either, then repeat the process and understand the obtained +two numbers as line and column number. But if the doubly trimmed +filename does not exist either, then forget the trimming and accept +the original filename as is. To disable this colon parsing, use +something like \fB+1\fR before the filename. +.TP .B set constantshow Constantly display the cursor position in the status bar. This overrides the option \fBquickblank\fR. From b408147f485b11625ca34c6e3a7e91c95fedb18d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 28 May 2024 16:31:07 +0200 Subject: [PATCH 10/30] tweaks: exclude the colon-parsing code from the tiny version The option --colonparsing is not available in the tiny version, so there is no need for the code either. --- src/nano.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nano.c b/src/nano.c index e99a0fab..40175c78 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2502,6 +2502,7 @@ int main(int argc, char **argv) #endif { char *filename = argv[optind++]; +#ifndef NANO_TINY struct stat fileinfo; /* If the filename contains a colon and this file does not exist, @@ -2526,7 +2527,7 @@ int main(int argc, char **argv) die(_("Invalid number\n")); } } - +#endif if (!open_buffer(filename, TRUE)) continue; } From 49c2f5dea98bb0876c0f126f0029530ec2ab7838 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 25 May 2024 09:22:11 +0200 Subject: [PATCH 11/30] new feature: option -z lists the names of available syntaxes When one has installed additional syntaxes, one tends to forget what exactly is there. So it's nice to be able to list them. The syntaxes are listed in the reverse order in which they were read: the most recent first. The long form of the option is, of course, --listsyntaxes, which can be abbreviated to --list. This fulfills https://savannah.gnu.org/bugs/?65779. The feature was suggested by `davidhcefx`. --- src/nano.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/nano.c b/src/nano.c index 40175c78..2dd08289 100644 --- a/src/nano.c +++ b/src/nano.c @@ -642,6 +642,9 @@ void usage(void) #ifndef NANO_TINY print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends")); #endif +#ifdef ENABLE_COLOR + print_opt("-z", "--listsyntaxes", N_("List the names of available syntaxes")); +#endif #ifdef HAVE_LIBMAGIC print_opt("-!", "--magic", N_("Also try magic to determine syntax")); #endif @@ -796,6 +799,27 @@ void version(void) printf("\n"); } +#ifdef ENABLE_COLOR +/* List the names of the available syntaxes. */ +void list_syntax_names(void) +{ + int width = 0; + + printf(_("Available syntaxes:\n")); + + for (syntaxtype *sntx = syntaxes; sntx != NULL; sntx = sntx->next) { + if (width > 45) { + printf("\n"); + width = 0; + } + printf(" %s", sntx->name); + width += wideness(sntx->name, 45 * 4); + } + + printf("\n"); +} +#endif + /* Register that Ctrl+C was pressed during some system call. */ void make_a_note(int signal) { @@ -1773,6 +1797,9 @@ int main(int argc, char **argv) {"nowrap", 0, NULL, 'w'}, #endif {"nohelp", 0, NULL, 'x'}, +#ifdef ENABLE_COLOR + {"listsyntaxes", 0, NULL, 'z'}, +#endif {"modernbindings", 0, NULL, '/'}, #ifndef NANO_TINY {"smarthome", 0, NULL, 'A'}, @@ -1852,7 +1879,7 @@ int main(int argc, char **argv) SET(MODERN_BINDINGS); while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RS$T:UVWX:Y:Z" - "abcdef:ghijklmno:pqr:s:tuvwxy!@%_0/", long_options, NULL)) != -1) { + "abcdef:ghijklmno:pqr:s:tuvwxyz!@%_0/", long_options, NULL)) > 0) { switch (optchr) { #ifndef NANO_TINY case 'A': @@ -2085,6 +2112,14 @@ int main(int argc, char **argv) SET(AFTER_ENDS); break; #endif +#ifdef ENABLE_COLOR + case 'z': + if (!ignore_rcfiles) + do_rcfiles(); + if (syntaxes) + list_syntax_names(); + exit(0); +#endif #ifdef HAVE_LIBMAGIC case '!': SET(USE_MAGIC); From a590645cde905c325b39ef0dbdf748871fad5567 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 26 May 2024 16:41:41 +0200 Subject: [PATCH 12/30] docs: document the new --listsyntaxes (-z) option --- doc/nano.1 | 3 +++ doc/nano.texi | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/doc/nano.1 b/doc/nano.1 index cc2eab80..5e0b66be 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -347,6 +347,9 @@ Don't show the two help lines at the bottom of the screen. .BR \-y ", " \-\-afterends Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings. .TP +.BR \-z ", " \-\-listsyntaxes +List the names of the available syntaxes and exit. +.TP .BR \-! ", " \-\-magic When neither the file's name nor its first line give a clue, try using libmagic to determine the applicable syntax. diff --git a/doc/nano.texi b/doc/nano.texi index dbdc2ff8..25ecb0ac 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -712,6 +712,10 @@ disabled to display the help-system navigation keys. Make @kbd{Ctrl+Right} and @kbd{Ctrl+Delete} stop at word ends instead of beginnings. +@item -z +@itemx --listsyntaxes +List the names of the available syntaxes and exit. + @item -! @itemx --magic When neither the file's name nor its first line give a clue, From c26f901ba94f0a37265aaa13e06873fdf882ae66 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 31 May 2024 12:45:18 +0200 Subject: [PATCH 13/30] options: remove the deprecated synonym -$ of -S/--softwrap The old short option -$ has been deprecated for four years, since version 5.0, commit 7d3aad40. --- doc/nano.1 | 1 - doc/nano.texi | 1 - src/nano.c | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index 5e0b66be..c372c894 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -201,7 +201,6 @@ with any name beginning with 'r' (e.g. "rnano"). Display over multiple screen rows lines that exceed the screen's width. (You can make this soft-wrapping occur at whitespace instead of rudely at the screen's edge, by using also \fB\-\-atblanks\fR.) -(The old short option, \fB\-$\fR, is deprecated.) .TP .BR \-T\ \fInumber ", " \-\-tabsize= \fInumber Set the size (width) of a tab to \fInumber\fP columns. The value of diff --git a/doc/nano.texi b/doc/nano.texi index 25ecb0ac..7c6bd1b7 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -518,7 +518,6 @@ any name beginning with @code{r} (e.g.@: @command{rnano}). Display over multiple screen rows lines that exceed the screen's width. (You can make this soft-wrapping occur at whitespace instead of rudely at the screen's edge, by using also @code{--atblanks}.) -(The old short option, @code{-$}, is deprecated.) @item -T @var{number} @itemx --tabsize=@var{number} diff --git a/src/nano.c b/src/nano.c index 2dd08289..ab2cb810 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1878,7 +1878,7 @@ int main(int argc, char **argv) else if (*(tail(argv[0])) == 'e') SET(MODERN_BINDINGS); - while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RS$T:UVWX:Y:Z" + while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z" "abcdef:ghijklmno:pqr:s:tuvwxyz!@%_0/", long_options, NULL)) > 0) { switch (optchr) { #ifndef NANO_TINY @@ -1965,7 +1965,6 @@ int main(int argc, char **argv) break; #ifndef NANO_TINY case 'S': - case '$': /* Deprecated; remove in 2024. */ SET(SOFTWRAP); break; case 'T': From b92cbf5f09b1b260250f31d980e6aba11ced47ed Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 31 May 2024 12:49:38 +0200 Subject: [PATCH 14/30] rcfile: remove old bindable function 'nowrap', alias of 'breaklonglines' The bindable function 'nowrap' has been deprecated for three years, since version 5.5, commit e14127b8. (The obsolete options --nowrap and 'set nowrap' continue to exist.) --- doc/nano.texi | 1 - doc/nanorc.5 | 1 - src/rcfile.c | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/nano.texi b/doc/nano.texi index 7c6bd1b7..f925d529 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -1855,7 +1855,6 @@ position to the end of the line. @item breaklonglines Toggles whether long lines will be hard-wrapped to the next line. -(The old name of this function, 'nowrap', is deprecated.) @item tabstospaces Toggles whether typed tabs will be converted to spaces. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 5f8a9cd6..dab6701d 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -1005,7 +1005,6 @@ position to the end of the line. .TP .B breaklonglines Toggles whether long lines will be hard-wrapped to the next line. -(The old name of this function, 'nowrap', is deprecated.) .TP .B tabstospaces Toggles whether typed tabs will be converted to spaces. diff --git a/src/rcfile.c b/src/rcfile.c index 95271a7e..557a6962 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -470,8 +470,7 @@ keystruct *strtosc(const char *input) else if (!strcmp(input, "cutfromcursor")) s->toggle = CUT_FROM_CURSOR; #ifdef ENABLE_WRAPPING - else if (!strcmp(input, "breaklonglines") || - !strcmp(input, "nowrap")) /* Deprecated; remove in 2024. */ + else if (!strcmp(input, "breaklonglines")) s->toggle = BREAK_LONG_LINES; #endif else if (!strcmp(input, "tabstospaces")) From 5bc6d0ef2e7a79078ce24606a4bc13b23c481c76 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 31 May 2024 16:41:46 +0200 Subject: [PATCH 15/30] tweaks: extend the deprecation period of 'set nowrap' and prefix 'bright' --- src/rcfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rcfile.c b/src/rcfile.c index 557a6962..9e80c1da 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -69,7 +69,7 @@ static const rcoption rcopts[] = { {"nohelp", NO_HELP}, {"nonewlines", NO_NEWLINES}, #ifdef ENABLE_WRAPPING - {"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */ + {"nowrap", NO_WRAP}, /* Deprecated; remove in 2027. */ #endif #ifdef ENABLE_OPERATINGDIR {"operatingdir", 0}, @@ -1048,7 +1048,7 @@ short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE, short color_to_short(const char *colorname, bool *vivid, bool *thick) { if (strncmp(colorname, "bright", 6) == 0 && colorname[6] != '\0') { - /* Prefix "bright" is deprecated; remove in 2024. */ + /* Prefix "bright" is deprecated; remove in 2027. */ *vivid = TRUE; *thick = TRUE; colorname += 6; From b3780aab33d5ee1f4918591971f3c013f1d67054 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 31 May 2024 16:45:05 +0200 Subject: [PATCH 16/30] docs: remove the 'filename:linenumber' format from the synopsis (This should have been part of commit 4930fbbb from five days ago.) --- doc/nano.1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index c372c894..4e0f618f 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -25,9 +25,6 @@ nano \- Nano's ANOther text editor, inspired by Pico .B nano .RI [ options "] [[\fB+" line [\fB, column "]] " file ]... .sp -.B nano -.RI [ options "] [" file [\fB: line [\fB: column "]]]..." -.sp .BR nano " [" \fIoptions "] [[" + [ crCR ]{ / | ? } \fIstring "] " \fIfile ]... .SH NOTICE From 5251ce1b20e7e2b6d886136ef0bce164b8788fc7 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 1 Jun 2024 09:30:44 +0200 Subject: [PATCH 17/30] tweaks: simplify a condition, to match the same condition five lines back --- src/winio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 54cffd9a..e5a61546 100644 --- a/src/winio.c +++ b/src/winio.c @@ -409,7 +409,7 @@ int get_input(WINDOW *frame) else if (frame) read_keys_from(frame); - if (waiting_codes > 0) { + if (waiting_codes) { waiting_codes--; #ifdef ENABLE_NANORC if (*nextcodes == MORE_PLANTS) { From ea07eb6aa3320001665faf9913728ddb66a43196 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 1 Jun 2024 10:52:15 +0200 Subject: [PATCH 18/30] help: show option -Y/--syntax in --help output also in restricted mode Since version 3.2, commit 5ca444e5, nano reads the nanorc files also in restricted mode (when not also --ignorercfiles is given), meaning that syntaxes are available and that a specific syntax can be selected on the command line. So, the --help output in restricted mode should list the relevant option: -Y / --syntax=. (This should have been part of commit b81995af from six years ago.) --- src/nano.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index ab2cb810..cc894fdf 100644 --- a/src/nano.c +++ b/src/nano.c @@ -574,8 +574,7 @@ void usage(void) N_("Which other characters are word parts")); #endif #ifdef ENABLE_COLOR - if (!ISSET(RESTRICTED)) - print_opt(_("-Y "), _("--syntax="), + print_opt(_("-Y "), _("--syntax="), N_("Syntax definition to use for coloring")); #endif #ifndef NANO_TINY From 689748843cef6bd39175c95a836f0d626ccb18ff Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 1 Jun 2024 11:08:48 +0200 Subject: [PATCH 19/30] files: with --rectrict, prevent invoking the browser and toggling backups Prevent also the toggling of Append and Prepend. All four functions should not be available in restricted mode, and are absent from the WriteOut menu in that mode, but using {browser}, {backup}, {append} or {prepend} in a string bind allowed to bypass the menu checks. This fixes https://savannah.gnu.org/bugs/?65819. Problem existed since version 7.0, since braced function names were introduced. --- src/files.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/files.c b/src/files.c index fef47b27..fc30ad6f 100644 --- a/src/files.c +++ b/src/files.c @@ -2196,7 +2196,7 @@ int write_it_out(bool exiting, bool withprompt) given = mallocstrcpy(given, answer); #ifdef ENABLE_BROWSER - if (function == to_files) { + if (function == to_files && !ISSET(RESTRICTED)) { char *chosen = browse_in(answer); if (chosen == NULL) @@ -2213,10 +2213,10 @@ int write_it_out(bool exiting, bool withprompt) } else if (function == mac_format) { openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE; continue; - } else if (function == back_it_up) { + } else if (function == back_it_up && !ISSET(RESTRICTED)) { TOGGLE(MAKE_BACKUP); continue; - } else if (function == prepend_it || function == append_it) { + } else if ((function == prepend_it || function == append_it) && !ISSET(RESTRICTED)) { if (function == prepend_it) method = (method == PREPEND) ? OVERWRITE : PREPEND; else From cd53f7cf8cf84b43cdb2e401488e2360b71ec6bc Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 1 Jun 2024 17:07:45 +0200 Subject: [PATCH 20/30] docs: don't say any more that -z was removed, as it has been repurposed --- doc/nano.1 | 1 - doc/nano.texi | 1 - 2 files changed, 2 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index 4e0f618f..fc89b83d 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -432,7 +432,6 @@ See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR for available syntax-coloring definitions. .SH NOTES -Option \fB\-z\fR (\fB\-\-suspendable\fR) has been removed. Suspension is enabled by default, reachable via \fB^T^Z\fR. (If you want a plain \fB^Z\fR to suspend nano, add \fBbind ^Z suspend main\fR to your nanorc.) diff --git a/doc/nano.texi b/doc/nano.texi index f925d529..62191748 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -784,7 +784,6 @@ Note that this overrides option @option{-p} (@option{--preserve}). @end table @sp 1 -Option @code{-z} (@code{--suspendable}) has been removed. Suspension is enabled by default, reachable via @kbd{^T^Z}. (If you want a plain @kbd{^Z} to suspend nano, add @code{bind ^Z suspend main} to your nanorc.) From 05602e29cd3131287b259f1d2b50d994aee45848 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 2 Jun 2024 17:16:22 +0200 Subject: [PATCH 21/30] syntax: patch: recognize also the .rej extension The addition was inspired by `davidhcefx`. --- syntax/patch.nanorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/patch.nanorc b/syntax/patch.nanorc index 13bbb5a0..fb587296 100644 --- a/syntax/patch.nanorc +++ b/syntax/patch.nanorc @@ -1,6 +1,6 @@ ## Syntax highlighting for patch and diff files. -syntax patch "\.(patch|diff|debdiff)$" +syntax patch "\.(patch|diff|debdiff|rej)$" magic "diff output" # There is no official support for comments in patch files. comment "" From dcbbbf813453fc7f587cff14d3ed1e3336f549a5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 3 Jun 2024 15:24:22 +0200 Subject: [PATCH 22/30] input: make sure that a string-bind return value is non-negative A negative value would lead to misinterpretation by parse_kbinput(). This fixes https://savannah.gnu.org/bugs/?65832. Bug existed since version 8.0, commit 51c9f727. --- src/winio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index e5a61546..2a8b362a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -381,7 +381,7 @@ int get_code_from_plantation(void) return PLANTED_A_COMMAND; } else { char *opening = strchr(plants_pointer, '{'); - char firstbyte = *plants_pointer; + unsigned char firstbyte = *plants_pointer; int length; if (opening) { From 0c2caa50cc6c958b517de57be98a3e817203f6d1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 4 Jun 2024 16:51:11 +0200 Subject: [PATCH 23/30] docs: correct the description of --bold, as function tags are unaffected The succinct function descriptions in the help lines are not shown in reverse video by default, so they are not bolded by -D/--bold either. Also, mention 'promptcolor' and 'minicolor' where they were missing. --- doc/nano.1 | 7 ++++--- doc/nano.texi | 14 ++++++++------ doc/nanorc.5 | 7 +++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index fc89b83d..a6229231 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -123,9 +123,10 @@ numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR). The uniquely numbered files are stored in the specified \fIdirectory\fR. .TP .BR \-D ", " \-\-boldtext -For the interface, use bold instead of reverse video. This will be overridden -by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP, -\fBfunctioncolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP in your +For the interface, use bold instead of reverse video. +This can be overridden for specific elements by setting the options +\fBtitlecolor\fP, \fBstatuscolor\fP, \fBpromptcolor\fP, \fBminicolor\fP, +\fBkeycolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP in your nanorc file. See \fBnanorc\fR(5). .TP .BR \-E ", " \-\-tabstospaces diff --git a/doc/nano.texi b/doc/nano.texi index 62191748..016f87fc 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -427,9 +427,10 @@ The uniquely numbered files are stored in the specified directory. @item -D @itemx --boldtext -For the interface, use bold instead of reverse video. This will be overridden +For the interface, use bold instead of reverse video. +This can be overridden for specific elements by setting the options @code{titlecolor}, @code{statuscolor}, -@code{promptcolor}, @code{minicolor}, @code{keycolor}, @code{functioncolor}, +@code{promptcolor}, @code{minicolor}, @code{keycolor}, @code{numbercolor}, and/or @code{selectedcolor} in your nanorc file. @xref{@code{set keycolor}} for details. @@ -917,10 +918,11 @@ with @code{set backup} or @option{--backup} or @option{-B}. The uniquely numbered files are stored in the specified directory. @item set boldtext -Use bold instead of reverse video for the title bar, status bar, key combos, -function tags, line numbers, and selected text. This is overridden by -setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor}, -@code{functioncolor}, @code{numbercolor}, and/or @code{selectedcolor}. +Use bold instead of reverse video for the title bar, status bar, +prompt bar, mini bar, key combos, line numbers, and selected text. +This can be overridden by setting the options @code{titlecolor}, +@code{statuscolor}, @code{promptcolor}, @code{minicolor}, +@code{keycolor}, @code{numbercolor}, and/or @code{selectedcolor}. @item set bookstyle When justifying, treat any line that starts with whitespace as the diff --git a/doc/nanorc.5 b/doc/nanorc.5 index dab6701d..07f1c0fa 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -99,11 +99,10 @@ The uniquely numbered files are stored in the specified \fIdirectory\fR. .TP .B set boldtext Use bold instead of reverse video for the title bar, status bar, -prompt bar, mini bar, key combos, function tags, line numbers, +prompt bar, mini bar, key combos, line numbers, and selected text. This can be overridden by setting the options -\fBtitlecolor\fP, \fBstatuscolor\fP, -\fBpromptcolor\fP, \fBminicolor\fP, \fBkeycolor\fP, \fBfunctioncolor\fP, -\fBnumbercolor\fP, and/or \fBselectedcolor\fP. +\fBtitlecolor\fP, \fBstatuscolor\fP, \fBpromptcolor\fP, \fBminicolor\fP, +\fBkeycolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP. .TP .B set bookstyle When justifying, treat any line that starts with whitespace as the From a1159ff484367c4a1542c080817b6ee800930051 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 6 Jun 2024 12:10:51 +0200 Subject: [PATCH 24/30] syntax: man: colorize some of the things that manipulate hyphenation Reference: https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Hyphenation.html --- syntax/man.nanorc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/man.nanorc b/syntax/man.nanorc index f2ab6e82..cdc65f06 100644 --- a/syntax/man.nanorc +++ b/syntax/man.nanorc @@ -12,9 +12,12 @@ color brightred "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*" color brightblue "^\.((B[IR]?|I[BR]?|R[BI]|S[BM]) |[LP]?P$)" # Inline type faces. color magenta "\\f[BIPR]" +# Hyphenation control. +color purple "\\[%:]" +color yellow "^\.(hc|hla|hlm|hw|hy)" # Relative margins, hyperlinks, and various other stuff. color yellow "^\.(RS|RE|UR|UE|PD|DT)" -color yellow "^\.(ad|bp|br|ce|de|ds|el|ie|if|fi|ft|hy|ig|in|na|ne|nf|nh|ps|so|sp|ti|tr)" +color yellow "^\.(ad|bp|br|ce|de|ds|el|ie|if|fi|ft|ig|in|na|ne|nf|nh|ps|so|sp|ti|tr)" # Comments. color cyan "(^\.)?\\".*" From 6be1f7e95a1a03d20eb0afedab658ed1acb03ab3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 6 Jun 2024 12:17:45 +0200 Subject: [PATCH 25/30] docs: avert hyphenation of the technical words "ncurses" and "terminfo" This prevents an observed wrong hyphenation: "ter-minfo". Also, add markup for "terminfo", like "ncurses" already has. --- doc/nano.1 | 5 ++++- doc/nanorc.5 | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index a6229231..e07a43ad 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -104,6 +104,9 @@ the built-in help (\fB^G\fR) lists all the available ones. The default key bindings can be changed via a \fInanorc\fR file -- see .BR nanorc (5). +.\" Never hyphenate these: +.hw ncurses terminfo + .SH OPTIONS .TP .BR \-A ", " \-\-smarthome @@ -155,7 +158,7 @@ in your \fInanorc\fR file.) .BR \-K ", " \-\-rawsequences Interpret escape sequences directly, instead of asking \fBncurses\fR to translate them. (If you need this option to get some keys to work -properly, it means that the terminfo terminal description that is used +properly, it means that the \fBterminfo\fR terminal description that is used does not fully match the actual behavior of your terminal. This can happen when you ssh into a BSD machine, for example.) Using this option disables \fBnano\fR's mouse support. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 07f1c0fa..83ddb69a 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -50,6 +50,9 @@ lines at the end of your \fInanorc\fR file: .RE .sp +.\" Never hyphenate these: +.hw ncurses terminfo + .SH OPTIONS The configuration file accepts a series of \fBset\fP and \fBunset\fP commands, which can be used to configure nano on startup without using @@ -288,7 +291,7 @@ email, and to rewrap blocks of line comments when writing source code. .B set rawsequences Interpret escape sequences directly, instead of asking \fBncurses\fR to translate them. (If you need this option to get some keys to work -properly, it means that the terminfo terminal description that is used +properly, it means that the \fBterminfo\fR terminal description that is used does not fully match the actual behavior of your terminal. This can happen when you ssh into a BSD machine, for example.) Using this option disables \fBnano\fR's mouse support. From abdf069ce395f87764d30ae06a9cafeceb089138 Mon Sep 17 00:00:00 2001 From: Jaroslav Fowkes Date: Fri, 7 Jun 2024 15:24:09 +0200 Subject: [PATCH 26/30] syntax: fortran: fix a typo (a missing backslash) The typo prevented several keywords from getting colorized. This addresses https://savannah.gnu.org/patch/?10459. Bug existed since version 2.1.6, commit 513157df, since the Fortran syntax was introduced. --- syntax/extra/fortran.nanorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/extra/fortran.nanorc b/syntax/extra/fortran.nanorc index 72a0ff33..5e917ed1 100644 --- a/syntax/extra/fortran.nanorc +++ b/syntax/extra/fortran.nanorc @@ -10,7 +10,7 @@ icolor green "\<(append|asis|assign|assignment|associated|character|common)\>" icolor green "\<(complex|data|default|delim|dimension|double precision)\>" icolor green "\<(elemental|epsilon|external|file|fmt|form|format|huge)\>" icolor green "\<(implicit|include|index|inquire|integer|intent|interface)\>" -icolor green "\<(intrinsic|iostat|kind|logical|module|none|null|only)>" +icolor green "\<(intrinsic|iostat|kind|logical|module|none|null|only)\>" icolor green "\<(operator|optional|pack|parameter|pointer|position|private)\>" icolor green "\<(program|public|real|recl|recursive|selected_int_kind)\>" icolor green "\<(selected_real_kind|subroutine|status)\>" From c70e6919c20323d973a8a4a4b75d8ce0ad2726e9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 8 Jun 2024 11:28:06 +0200 Subject: [PATCH 27/30] syntaxes: mention the original author of most of the syntax files The names of the authors were retrieved from: git log -p --follow syntax/.nanorc and from: git log -p --follow --all -- doc/nanorc.sample For some files the original author is unclear, or the file is/was too small to mention an author for. --- syntax/asm.nanorc | 2 ++ syntax/awk.nanorc | 2 ++ syntax/cmake.nanorc | 2 ++ syntax/css.nanorc | 2 ++ syntax/elisp.nanorc | 2 ++ syntax/extra/fortran.nanorc | 2 ++ syntax/extra/povray.nanorc | 2 ++ syntax/extra/spec.nanorc | 2 ++ syntax/groff.nanorc | 2 ++ syntax/guile.nanorc | 2 ++ syntax/man.nanorc | 2 ++ syntax/objc.nanorc | 2 ++ syntax/patch.nanorc | 2 ++ syntax/php.nanorc | 2 ++ syntax/ruby.nanorc | 2 ++ syntax/sh.nanorc | 2 ++ syntax/sql.nanorc | 2 ++ syntax/tcl.nanorc | 2 ++ syntax/xml.nanorc | 2 ++ 19 files changed, 38 insertions(+) diff --git a/syntax/asm.nanorc b/syntax/asm.nanorc index 2fa39279..6eef092b 100644 --- a/syntax/asm.nanorc +++ b/syntax/asm.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for assembler. +## Original author: Mike Frysinger + syntax asm "\.(S|s|asm)$" magic "assembler source" comment "//" diff --git a/syntax/awk.nanorc b/syntax/awk.nanorc index 02b6230e..e5d1af05 100644 --- a/syntax/awk.nanorc +++ b/syntax/awk.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for AWK scripts. +## Original author: Donnie Berkholz + syntax awk "\.awk$" header "^#!.*awk" magic "awk script" diff --git a/syntax/cmake.nanorc b/syntax/cmake.nanorc index 3bb1f0be..3bb5ab81 100644 --- a/syntax/cmake.nanorc +++ b/syntax/cmake.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for CMake files. +## Original author: Felipe Bugno + syntax cmake "(CMakeLists\.txt|\.cmake)$" comment "#" diff --git a/syntax/css.nanorc b/syntax/css.nanorc index 5a0946db..ec8f185c 100644 --- a/syntax/css.nanorc +++ b/syntax/css.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for CSS files. +## Original author: Simon Rupf + syntax css "\.css$" comment "/*|*/" diff --git a/syntax/elisp.nanorc b/syntax/elisp.nanorc index 7cb06896..3f7296fb 100644 --- a/syntax/elisp.nanorc +++ b/syntax/elisp.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Emacs Lisp. +## Original author: Mark Oteiza + syntax elisp "\.el$" magic "Lisp/Scheme program" comment ";" diff --git a/syntax/extra/fortran.nanorc b/syntax/extra/fortran.nanorc index 5e917ed1..d79dc229 100644 --- a/syntax/extra/fortran.nanorc +++ b/syntax/extra/fortran.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Fortran 90/95. +## Original author: Pascal Gentil + syntax fortran "\.(f|for|f90|f95)$" comment "!" diff --git a/syntax/extra/povray.nanorc b/syntax/extra/povray.nanorc index db0a1c44..cee06e01 100644 --- a/syntax/extra/povray.nanorc +++ b/syntax/extra/povray.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for POV-Ray files. +## Original author: Donnie Berkholz + syntax pov "\.(pov|POV|povray|POVRAY)$" comment "//" diff --git a/syntax/extra/spec.nanorc b/syntax/extra/spec.nanorc index 8c561fb0..5308c778 100644 --- a/syntax/extra/spec.nanorc +++ b/syntax/extra/spec.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for RPM spec files. +## Original author: Asterios Dramis + syntax spec "\.spec(\.[^/]+)?$" comment "#" diff --git a/syntax/groff.nanorc b/syntax/groff.nanorc index 3452cdb5..872d52cd 100644 --- a/syntax/groff.nanorc +++ b/syntax/groff.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for groff. +## Original author: Robert D. Goulding + syntax groff "\.(m[ems]|rof|tmac)$|/tmac\.[^/]+$" comment ".\"" diff --git a/syntax/guile.nanorc b/syntax/guile.nanorc index 2f231fad..1b398531 100644 --- a/syntax/guile.nanorc +++ b/syntax/guile.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Guile Scheme. +## Original author: Mark Oteiza + syntax guile "\.scm$" header "^#!.*guile" comment ";" diff --git a/syntax/man.nanorc b/syntax/man.nanorc index cdc65f06..06404e00 100644 --- a/syntax/man.nanorc +++ b/syntax/man.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for man pages. +## Original author: Mike Frysinger + syntax man "\.[1-9]x?$" magic "troff or preprocessor input" comment ".\"" diff --git a/syntax/objc.nanorc b/syntax/objc.nanorc index d45158b7..1fb24ad6 100644 --- a/syntax/objc.nanorc +++ b/syntax/objc.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for C/C++/Obj-C files. +## Original author: Dave Geering + syntax m "\.m$" magic "Objective-C source" comment "//" diff --git a/syntax/patch.nanorc b/syntax/patch.nanorc index fb587296..4b4d8714 100644 --- a/syntax/patch.nanorc +++ b/syntax/patch.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for patch and diff files. +## Original author: Mike Frysinger + syntax patch "\.(patch|diff|debdiff|rej)$" magic "diff output" # There is no official support for comments in patch files. diff --git a/syntax/php.nanorc b/syntax/php.nanorc index 4acc2f1f..912d5524 100644 --- a/syntax/php.nanorc +++ b/syntax/php.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for PHP. +## Original author: Mike Frysinger + syntax php "\.(php[23457s~]?|phtml|ctp)$" magic "PHP script" comment "//" diff --git a/syntax/ruby.nanorc b/syntax/ruby.nanorc index 1f52879e..2a1f2d59 100644 --- a/syntax/ruby.nanorc +++ b/syntax/ruby.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Ruby. +## Original author: John M. Gabriele + syntax ruby "\.rb$" header "^#!.*ruby" magic "Ruby script" diff --git a/syntax/sh.nanorc b/syntax/sh.nanorc index cebea36e..57a6ac48 100644 --- a/syntax/sh.nanorc +++ b/syntax/sh.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Bourne shell scripts. +## Original author: Mike Frysinger + syntax sh "(\.sh|(^|/|\.)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|(/etc/|(^|/)\.)profile)$" header "^#!.*/(((env|busybox)[[:blank:]]+)?(a|ba|c|da|k|mk|pdk|tc|z)?sh|openrc-run|runscript)\>" header "-\*-.*shell-script.*-\*-" diff --git a/syntax/sql.nanorc b/syntax/sql.nanorc index c8548482..2cadf676 100644 --- a/syntax/sql.nanorc +++ b/syntax/sql.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for (Postgres) SQL scripts. +## Original author: Devrim Gündüz + syntax sql "\.sql$" comment "-- " diff --git a/syntax/tcl.nanorc b/syntax/tcl.nanorc index cb3a2643..b6a97076 100644 --- a/syntax/tcl.nanorc +++ b/syntax/tcl.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for Tcl and Expect scripts. +## Original author: Mike Frysinger + syntax tcl "\.(tcl|exp)$" magic "Tcl(/Tk)? script" comment "#" diff --git a/syntax/xml.nanorc b/syntax/xml.nanorc index d5e41e44..f8ad3501 100644 --- a/syntax/xml.nanorc +++ b/syntax/xml.nanorc @@ -1,5 +1,7 @@ ## Syntax highlighting for XML files. +## Original author: Josef Schugt + syntax xml "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$" header "<\?xml.*version=.*\?>" magic "(XML|SGML) (sub)?document" From a98f82e27bfa504bce5123286d549f863c7210e5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 4 Jun 2024 11:30:51 +0200 Subject: [PATCH 28/30] startup: no not activate --modernbindings when name starts with "e" Activating --modernbindings when the binary's name starts with "e" interferes with Debian's alternatives system that symlinks `editor` to `nano` in a default install. (Also: why "e"? It would have made more sense to check for "m", similar to the checking for "r" for a restricted nano.) This reverts commit 580eaf29 from fifteen months ago. This addresses https://savannah.gnu.org/bugs/?65810. Reported-by: Colin Snover --- src/nano.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index cc894fdf..113853fb 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1874,8 +1874,6 @@ int main(int argc, char **argv) /* If the executable's name starts with 'r', activate restricted mode. */ if (*(tail(argv[0])) == 'r') SET(RESTRICTED); - else if (*(tail(argv[0])) == 'e') - SET(MODERN_BINDINGS); while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z" "abcdef:ghijklmno:pqr:s:tuvwxyz!@%_0/", long_options, NULL)) > 0) { From 00e2309987bcbaae8dbd56689844930a59b9069f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 8 Jun 2024 15:27:10 +0200 Subject: [PATCH 29/30] tweaks: make the inclusion condition for do_center() more strict There is no reason why --enable-help should cause the centering function to be included in a tiny version. --- src/global.c | 6 ++++-- src/move.c | 4 +++- src/prototypes.h | 2 ++ src/rcfile.c | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/global.c b/src/global.c index 9c6b1e66..5c199409 100644 --- a/src/global.c +++ b/src/global.c @@ -619,6 +619,8 @@ void shortcut_init(void) N_("Scroll up one line without moving the cursor textually"); const char *scrolldown_gist = N_("Scroll down one line without moving the cursor textually"); +#endif +#ifndef NANO_TINY const char *center_gist = N_("Center the line where the cursor is"); #endif #ifdef ENABLE_MULTIBUFFER @@ -1079,7 +1081,7 @@ void shortcut_init(void) add_to_funcs(full_refresh, MMAIN, N_("Refresh"), WHENHELP(refresh_gist), TOGETHER); #endif -#if !defined(NANO_TINY) || defined(ENABLE_HELP) +#ifndef NANO_TINY add_to_funcs(do_center, MMAIN, N_("Center"), WHENHELP(center_gist), BLANKAFTER); #endif @@ -1430,7 +1432,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-J", 0, do_full_justify, 0); add_to_sclist(MEXECUTE, "^J", 0, do_full_justify, 0); #endif -#if !defined(NANO_TINY) || defined(ENABLE_HELP) +#ifndef NANO_TINY add_to_sclist(MMAIN, "^L", 0, do_center, 0); #endif add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "^L", 0, full_refresh, 0); diff --git a/src/move.c b/src/move.c index 5d834328..8180928d 100644 --- a/src/move.c +++ b/src/move.c @@ -620,7 +620,9 @@ void do_scroll_down(void) )) edit_scroll(FORWARD); } +#endif /* !NANO_TINY || ENABLE_HELP */ +#ifndef NANO_TINY /* Scroll the line with the cursor to the center of the screen. */ void do_center(void) { @@ -628,7 +630,7 @@ void do_center(void) draw_all_subwindows(); full_refresh(); } -#endif /* !NANO_TINY || ENABLE_HELP */ +#endif /* Move left one character. */ void do_left(void) diff --git a/src/prototypes.h b/src/prototypes.h index 55ab21c1..312442fb 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -386,6 +386,8 @@ void do_down(void); #if !defined(NANO_TINY) || defined(ENABLE_HELP) void do_scroll_up(void); void do_scroll_down(void); +#endif +#ifndef NANO_TINY void do_center(void); #endif void do_left(void); diff --git a/src/rcfile.c b/src/rcfile.c index 9e80c1da..9ecc89fc 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -340,8 +340,6 @@ keystruct *strtosc(const char *input) s->func = do_scroll_up; else if (!strcmp(input, "scrolldown")) s->func = do_scroll_down; - else if (!strcmp(input, "center")) - s->func = do_center; #endif else if (!strcmp(input, "prevword")) s->func = to_prev_word; @@ -360,6 +358,8 @@ keystruct *strtosc(const char *input) s->func = to_top_row; else if (!strcmp(input, "bottomrow")) s->func = to_bottom_row; + else if (!strcmp(input, "center")) + s->func = do_center; #endif else if (!strcmp(input, "pageup") || !strcmp(input, "prevpage")) From bc09f0992efa68c574ce3ced5a3b769177011a0e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 8 Jun 2024 17:08:17 +0200 Subject: [PATCH 30/30] tweaks: reshuffle some lines, to put vaguely related things together And to slightly reduce the number of #ifdefs. --- src/global.c | 8 ++------ src/move.c | 20 +++++++++----------- src/prototypes.h | 4 +--- src/rcfile.c | 6 ++---- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/global.c b/src/global.c index 5c199409..d4918518 100644 --- a/src/global.c +++ b/src/global.c @@ -580,6 +580,7 @@ void shortcut_init(void) const char *replace_gist = N_("Replace a string or a regular expression"); const char *gotoline_gist = N_("Go to line and column number"); #ifndef NANO_TINY + const char *bracket_gist = N_("Go to the matching bracket"); const char *mark_gist = N_("Mark text starting from the cursor position"); const char *zap_gist = N_("Throw away the current line (or marked region)"); const char *indent_gist = N_("Indent the current line (or marked lines)"); @@ -606,23 +607,18 @@ void shortcut_init(void) #ifndef NANO_TINY const char *toprow_gist = N_("Go to first row in the viewport"); const char *bottomrow_gist = N_("Go to last row in the viewport"); + const char *center_gist = N_("Center the line where the cursor is"); #endif const char *prevpage_gist = N_("Go one screenful up"); const char *nextpage_gist = N_("Go one screenful down"); const char *firstline_gist = N_("Go to the first line of the file"); const char *lastline_gist = N_("Go to the last line of the file"); -#ifndef NANO_TINY - const char *bracket_gist = N_("Go to the matching bracket"); -#endif #if !defined(NANO_TINY) || defined(ENABLE_HELP) const char *scrollup_gist = N_("Scroll up one line without moving the cursor textually"); const char *scrolldown_gist = N_("Scroll down one line without moving the cursor textually"); #endif -#ifndef NANO_TINY - const char *center_gist = N_("Center the line where the cursor is"); -#endif #ifdef ENABLE_MULTIBUFFER const char *prevfile_gist = N_("Switch to the previous file buffer"); const char *nextfile_gist = N_("Switch to the next file buffer"); diff --git a/src/move.c b/src/move.c index 8180928d..534d9a31 100644 --- a/src/move.c +++ b/src/move.c @@ -207,7 +207,15 @@ void to_bottom_row(void) place_the_cursor(); } -#endif + +/* Scroll the line with the cursor to the center of the screen. */ +void do_center(void) +{ + adjust_viewport(CENTERING); + draw_all_subwindows(); + full_refresh(); +} +#endif /* !NANO_TINY */ #ifdef ENABLE_JUSTIFY /* Move to the first beginning of a paragraph before the current line. */ @@ -622,16 +630,6 @@ void do_scroll_down(void) } #endif /* !NANO_TINY || ENABLE_HELP */ -#ifndef NANO_TINY -/* Scroll the line with the cursor to the center of the screen. */ -void do_center(void) -{ - adjust_viewport(CENTERING); - draw_all_subwindows(); - full_refresh(); -} -#endif - /* Move left one character. */ void do_left(void) { diff --git a/src/prototypes.h b/src/prototypes.h index 312442fb..7f728e15 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -366,6 +366,7 @@ void do_page_down(void); #ifndef NANO_TINY void to_top_row(void); void to_bottom_row(void); +void do_center(void); #endif #ifdef ENABLE_JUSTIFY void do_para_begin(linestruct **line); @@ -387,9 +388,6 @@ void do_down(void); void do_scroll_up(void); void do_scroll_down(void); #endif -#ifndef NANO_TINY -void do_center(void); -#endif void do_left(void); void do_right(void); diff --git a/src/rcfile.c b/src/rcfile.c index 9ecc89fc..cb9be079 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -322,6 +322,8 @@ keystruct *strtosc(const char *input) s->func = do_undo; else if (!strcmp(input, "redo")) s->func = do_redo; + else if (!strcmp(input, "suspend")) + s->func = do_suspend; #endif else if (!strcmp(input, "left") || !strcmp(input, "back")) @@ -389,10 +391,6 @@ keystruct *strtosc(const char *input) s->func = do_backspace; else if (!strcmp(input, "refresh")) s->func = full_refresh; -#ifndef NANO_TINY - else if (!strcmp(input, "suspend")) - s->func = do_suspend; -#endif else if (!strcmp(input, "casesens")) s->func = case_sens_void; else if (!strcmp(input, "regexp"))