From 2fd7888a510917017477fa4ab06659b231fa3cc1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 20 Jan 2023 14:47:06 +0100 Subject: [PATCH 01/12] bindings: show ^- instead of ^/ for 'flipgoto' when on a Linux console This should have been part of commit 344db835 from three days ago. --- src/global.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global.c b/src/global.c index bbdac81d..ed93fa31 100644 --- a/src/global.c +++ b/src/global.c @@ -1404,7 +1404,7 @@ void shortcut_init(void) add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0); add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0); - add_to_sclist(MWHEREIS|MGOTOLINE, "^/", 0, flip_goto, 0); + add_to_sclist(MWHEREIS|MGOTOLINE, SLASH_OR_DASH, 0, flip_goto, 0); #ifdef ENABLE_HISTORIES add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_older_item, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_newer_item, 0); From c374c773ad6b0aa6e9bc29d6895ecda4609cdf47 Mon Sep 17 00:00:00 2001 From: Matteo Raso Date: Fri, 20 Jan 2023 02:50:38 -0500 Subject: [PATCH 02/12] syntax: python: colorize decorators specially Decorators are documented at https://peps.python.org/pep-0318/. Signed-off-by: Matteo Raso Signed-off-by: Benno Schulenberg --- syntax/python.nanorc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syntax/python.nanorc b/syntax/python.nanorc index e8ba17e2..51bc4691 100644 --- a/syntax/python.nanorc +++ b/syntax/python.nanorc @@ -24,6 +24,9 @@ color brightcyan "\<(exec|print)([[:blank:]]|$)" # Special values. color brightmagenta "\<(False|None|True)\>" +# Decorators. +color cyan "@[[:alpha:]_][[:alnum:]_.]*" + # Mono-quoted strings. color brightgreen "'([^'\]|\\.)*'|"([^"\]|\\.)*"|'''|"""" color normal "'''|"""" From 69dd0c40bba94834965e5ecc8390602510c7b942 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 23 Jan 2023 16:30:15 +0100 Subject: [PATCH 03/12] help: give the "Replace with" prompt its own help text This addresses https://savannah.gnu.org/bugs/?63691. Problem existed since the help texts were introduced, in version 1.1.3, commit b3655b4c. --- src/help.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/help.c b/src/help.c index 56411612..1d3855fe 100644 --- a/src/help.c +++ b/src/help.c @@ -50,7 +50,7 @@ void help_init(void) char *ptr; /* First, set up the initial help text for the current function. */ - if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) { + if (currmenu & (MWHEREIS|MREPLACE)) { htx[0] = N_("Search Command Help Text\n\n " "Enter the words or characters you would like to " "search for, and then press Enter. If there is a " @@ -65,6 +65,13 @@ void help_init(void) "will be replaced.\n\n The following function keys are " "available in Search mode:\n\n"); htx[2] = NULL; + } else if (currmenu == MREPLACEWITH) { + htx[0] = N_("=== Replacement ===\n\n " + "Type the characters that should replace the characters that " + "you typed at the previous prompt, and press Enter.\n\n"); + htx[1] = N_(" The following function keys " + "are available at this prompt:\n\n"); + htx[2] = NULL; } else if (currmenu == MGOTOLINE) { htx[0] = N_("Go To Line Help Text\n\n " "Enter the line number that you wish to go to and hit " From b896670e85f0ff3c9ad7424e6fdd5ae1916e1d8a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 25 Jan 2023 16:45:50 +0100 Subject: [PATCH 04/12] tweaks: make two strings equal to a third, to slightly ease translation --- src/help.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/help.c b/src/help.c index 1d3855fe..f2e1962c 100644 --- a/src/help.c +++ b/src/help.c @@ -133,8 +133,8 @@ void help_init(void) "shown in brackets after the search prompt. Hitting " "Enter without entering any text will perform the " "previous search.\n\n"); - htx[1] = N_(" The following function keys are available in " - "Browser Search mode:\n\n"); + htx[1] = N_(" The following function keys " + "are available at this prompt:\n\n"); htx[2] = NULL; } else if (currmenu == MGOTODIR) { htx[0] = N_("Browser Go To Directory Help Text\n\n " @@ -174,8 +174,8 @@ void help_init(void) htx[1] = N_("If you just need another blank buffer, do not enter any " "command.\n\n You can also pick one of four tools, or cut a " "large piece of the buffer, or put the editor to sleep.\n\n"); - htx[2] = N_(" The following function keys are " - "available in Execute Command mode:\n\n"); + htx[2] = N_(" The following function keys " + "are available at this prompt:\n\n"); } else if (currmenu == MLINTER) { htx[0] = N_("=== Linter ===\n\n " "In this mode, the status bar shows an error message or " From 51c9f7270c44420688d4bb0a75c59c9df569f9d6 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 25 Jan 2023 17:04:23 +0100 Subject: [PATCH 05/12] input: let the handler of string binds return a byte whenever possible The function get_code_from_plantation() should return ERR only when the string bind is fully exhausted. In the normal case, where some bytes are still available, it should return the first of these bytes, so that the {verbatim} function will work too. This fixes https://savannah.gnu.org/bugs/?63702. Bug existed since version 7.0, commit 958ec294, since command cartouches were introduced. --- src/winio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/winio.c b/src/winio.c index c1cbe7b7..1f53d2ca 100644 --- a/src/winio.c +++ b/src/winio.c @@ -383,6 +383,7 @@ int get_code_from_plantation(void) return PLANTED_COMMAND; } else { char *opening = strchr(plants_pointer, '{'); + char firstbyte = *plants_pointer; int length; if (opening) { @@ -391,12 +392,12 @@ int get_code_from_plantation(void) } else length = strlen(plants_pointer); - for (int index = length - 1; index >= 0; index--) + for (int index = length - 1; index > 0; index--) put_back((unsigned char)plants_pointer[index]); plants_pointer += length; - return ERR; + return (firstbyte) ? firstbyte : ERR; } } #endif From 7abddbd752810a5370243f5fe493efa0d654cc28 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 26 Jan 2023 14:54:34 +0100 Subject: [PATCH 06/12] tweaks: slightly improve a comment, to be more accurate A string bind can only contain bytes (chars), not keycodes (integers, in nano upto 0x4FF). So, apart from an error code or a placeholder command code, get_code_from_plantation() can only return a byte. --- src/winio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 1f53d2ca..fee2a84e 100644 --- a/src/winio.c +++ b/src/winio.c @@ -350,7 +350,7 @@ void implant(const char *string) } /* Continue processing an expansion string. Returns either an error code, - * a plain keycode, or a placeholder for a command shortcut. */ + * a plain character byte, or a placeholder for a command shortcut. */ int get_code_from_plantation(void) { if (*plants_pointer == '{') { From 1c307bc1be2906f10f7a4430f7603a3c620fb064 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 26 Jan 2023 15:01:08 +0100 Subject: [PATCH 07/12] docs: add a clarifying note to the description of --tabstospaces --- doc/nano.1 | 1 + doc/nano.texi | 2 ++ doc/nanorc.5 | 1 + 3 files changed, 4 insertions(+) diff --git a/doc/nano.1 b/doc/nano.1 index 1eb19c5f..71fae647 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -112,6 +112,7 @@ nanorc file. See \fBnanorc\fR(5). .BR \-E ", " \-\-tabstospaces Convert each typed tab to spaces -- to the number of spaces that a tab at that position would take up. +(Note: pasted tabs are not converted.) .TP .BR \-F ", " \-\-multibuffer Read a file into a new buffer by default. diff --git a/doc/nano.texi b/doc/nano.texi index 007712c2..42e50bb1 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -406,6 +406,7 @@ nanorc file. @xref{@code{set keycolor}} for details. @itemx --tabstospaces Convert each typed tab to spaces --- to the number of spaces that a tab at that position would take up. +(Note: pasted tabs are not converted.) @item -F @itemx --multibuffer @@ -1140,6 +1141,7 @@ greater than 0. The default value is @t{8}. @item set tabstospaces Convert each typed tab to spaces --- to the number of spaces that a tab at that position would take up. +(Note: pasted tabs are not converted.) @item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor} Use this color combination for the title bar. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 0786069c..70f26e08 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -335,6 +335,7 @@ greater than 0. The default value is \fB8\fR. .B set tabstospaces Convert each typed tab to spaces -- to the number of spaces that a tab at that position would take up. +(Note: pasted tabs are not converted.) .TP .B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR Use this color combination for the title bar. From 26025f79ce854d84bba41fb56d4d7f3c1949f767 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 29 Jan 2023 12:17:05 +0100 Subject: [PATCH 08/12] docs: add a reference to the 'help-nano' mailing list --- doc/nano.1 | 3 +++ doc/nano.texi | 3 +++ 2 files changed, 6 insertions(+) diff --git a/doc/nano.1 b/doc/nano.1 index 71fae647..ddda56da 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -405,6 +405,9 @@ that name already exists in the current directory, it will add ".save" plus a number (e.g.\& ".save.1") to the current filename in order to make it unique. In multibuffer mode, \fBnano\fP will write all the open buffers to their respective emergency files. +.sp +If you have any question about how to use \fBnano\fR in some specific +situation, you can ask on \fIhelp-nano@gnu.org\fR. .SH BUGS The recording and playback of keyboard macros works correctly only on a diff --git a/doc/nano.texi b/doc/nano.texi index 42e50bb1..691eed4a 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -123,6 +123,9 @@ following options: @option{--breaklonglines}, @blankline Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}. +@blankline +Questions about using nano you can ask at @email{help-nano@@gnu.org}. + @blankline For background information see @url{https://nano-editor.org/}. From 078d612b9ef5cf39c9c83ed64b0761d8e581a34b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 3 Feb 2023 17:30:27 +0100 Subject: [PATCH 09/12] tweaks: add a missing 'type' attribute to a From 0662fc4d4289b39e795aaf4a0532cbf18b59f771 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 8 Feb 2023 17:15:05 +0100 Subject: [PATCH 10/12] shutdown: ignore a modified buffer when in view mode In view mode it should be impossible to modify any buffer, but... when (through some bug) the user did succeed in modifying a buffer, this should not lead to writing out this modified buffer to disk. Had this safety stop been present earlier, it would have prevented the second part of https://savannah.gnu.org/bugs/?63616. --- src/nano.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nano.c b/src/nano.c index c6db6dd3..4d5e7ea6 100644 --- a/src/nano.c +++ b/src/nano.c @@ -303,7 +303,7 @@ void do_exit(void) /* When unmodified, simply close. Else, when doing automatic saving * and the file has a name, simply save. Otherwise, ask the user. */ - if (!openfile->modified) + if (!openfile->modified || ISSET(VIEW_MODE)) choice = NO; else if (ISSET(SAVE_ON_EXIT) && openfile->filename[0] != '\0') choice = YES; From 866490c41f5e123ce4d0239223203db1f44e0ecb Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 16 Feb 2023 10:44:10 +0100 Subject: [PATCH 11/12] docs: add two examples of custom key bindings to the nanorc manpage --- doc/nano.1 | 3 +++ doc/nanorc.5 | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/nano.1 b/doc/nano.1 index ddda56da..8fc40dff 100644 --- a/doc/nano.1 +++ b/doc/nano.1 @@ -392,6 +392,9 @@ 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.) .sp +When you want to copy marked text from \fBnano\fR to the system's clipboard, +see one of the examples in the \fBnanorc\fR(5) man page. +.sp If no alternative spell checker command is specified on the command line nor in one of the \fInanorc\fP files, \fBnano\fP will check the \fBSPELL\fP environment variable for one. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 70f26e08..61b2f771 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -399,12 +399,6 @@ and disappears after 1.5 seconds or upon the next keystroke. With \fBM\-Z\fR the title bar plus status bar can be toggled. With \fBM\-X\fR the help lines. -.SH NOTES -Option \fBset 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.) - .SH SYNTAX HIGHLIGHTING Coloring the different syntactic elements of a file is done via regular expressions (see the \fBcolor\fR command below). @@ -1039,6 +1033,20 @@ For \fBbind\fR it means all menus where the specified \fIfunction\fR exists; for \fBunbind\fR it means all menus where the specified \fIkey\fR exists. .RE +.SH EXAMPLES +To make \fBCtrl+Z\fR suspend nano: +.sp +.RS +.B bind ^Z suspend main +.RE +.sp +To make \fBShift+Alt+C\fR copy the marked region to the system's clipboard: +.sp +.RS +.B bind Sh-M-C """{execute}| xsel -ib {enter}{undo}""" main +.RE +.sp + .SH FILES .TP .I /etc/nanorc From 7681090c12d7553083e8aeff5bf74b7b28fa5692 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 16 Feb 2023 11:02:15 +0100 Subject: [PATCH 12/12] docs: clarify that a fileregex is matched against the absolute filename --- doc/nano.texi | 7 ++++--- doc/nanorc.5 | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/nano.texi b/doc/nano.texi index 691eed4a..8aca07b4 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -1235,9 +1235,10 @@ will be added to this syntax, until a new @code{syntax} command is encountered. When @command{nano} is run, this syntax will be automatically -activated if the current filename matches the extended regular -expression @var{fileregex}. Or the syntax can be explicitly -activated by using the @option{-Y} or @option{--syntax} +activated (for the relevant buffer) if the absolute filename +matches the extended regular expression @var{fileregex}. +Or the syntax can be explicitly activated (for all buffers) +by using the @option{-Y} or @option{--syntax} command-line option followed by the @var{name}. The @code{default} syntax is special: it takes no @var{fileregex}, diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 61b2f771..84db959d 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -439,9 +439,10 @@ will be added to this syntax, until a new \fBsyntax\fR command is encountered. .sp When \fBnano\fR is run, this syntax will be automatically -activated if the current filename matches the extended regular -expression \fIfileregex\fR. Or the syntax can be explicitly -activated by using the \fB\-Y\fR or \fB\-\-syntax\fR +activated (for the relevant buffer) if the absolute filename +matches the extended regular expression \fIfileregex\fR. +Or the syntax can be explicitly activated (for all buffers) +by using the \fB\-Y\fR or \fB\-\-syntax\fR command-line option followed by the \fIname\fR. .sp The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,