Commit Graph

9874 Commits

Author SHA1 Message Date
Benno Schulenberg
485eb18d83 syntaxes: use one regex for coloring quoted strings, to avoid overlap
Quoted strings cannot start within another quoted string and end after
that other string has ended.  Therefore single-quoted and double-quoted
strings should (as much as possible) be colorized by a single rule, so
that overlapping colorations are avoided.

(This also fixes a double typo in the PHP syntax (\. --> \\.) that has
been there since the PHP syntax was added in 2008, commit 90ee8ee4.)

This fixes https://savannah.gnu.org/bugs/?61387.

Bug existed since each of these syntaxes was introduced,
the oldest ones around 2006, a few others around 2015.

The one that got it right was the Lua syntax from 2011.
2021-10-26 13:28:33 +02:00
Benno Schulenberg
375b30507e syntax: ruby: colorize embedded documentation as a comment
Vim and Emacs do this too.

Reference:
  https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Lexicology

Also, when colorizing double-hashed comments specially anyway,
avoid colorizing ##.* as a single-hashed comment.
2021-10-25 13:45:21 +02:00
Benno Schulenberg
7691527f35 tweaks: remove redundant parentheses, trim comments, fold some regexes 2021-10-25 12:45:45 +02:00
Benno Schulenberg
3313fac8eb tweaks: remove redundant pair of parentheses, and swap two alternatives 2021-10-25 12:45:45 +02:00
Benno Schulenberg
e52c81f5db syntax: nanorc: improve the file-matching regex
The "\.?" part was pointless.  It says that the string "nanorc"
*might* be preceded with a period.  Sure, but if the period is
absent, then anything else may be there too, so the optional
period gives zero restriction.

The restriction should be: either the filename has the extension
".nanorc" OR the full filename is "nanorc".  So the "nanorc" part
must be preceded by either a period or a slash.

(However, in the times of commits 3dc0e23e and dc9c40a5, fifteen
and eighteen years ago, it was still the user-provided filename
that was matched against the regex, not the full-path filename.
The latter method arrived in commit ec8d51be, six years ago.)
2021-10-25 12:44:28 +02:00
Benno Schulenberg
9b419d0bff tweaks: rename a function, to describe better what it does nowadays 2021-10-22 11:50:04 +02:00
Benno Schulenberg
0f40752139 docs: add a hint about making ^L do just 'refresh' to the sample nanorc
Just for the sake of completeness -- I doubt anyone ever uses Refresh.
2021-10-22 11:50:04 +02:00
Benno Schulenberg
d57bfc057f syntax: rust: do not colorize as string the text between two strings
Strings may not contain a double quote unless it is escaped.

Reference:
  https://doc.rust-lang.org/reference/tokens.html#string-literals

(This will still not colorize multi-line strings with an unescaped
newline, will still colorize "this\" as if it were a valid string,
and will still miscolor things when there is another string after
the closing quote of a two-line string.  But those things can't
be helped -- line-based regexes cannot emulate a full parser.)

This fixes https://savannah.gnu.org/bugs/?61361.
Reported-by: Elias Jonsson <e@ejon.eu>

Bug existed since version 2.6.1, since the Rust syntax was introduced.
2021-10-22 10:44:49 +02:00
Benno Schulenberg
918ce1afa3 tweaks: just let do_wrap() set 'refresh_needed' instead of returning TRUE
This gets rid of performing an action in the condition of an 'if'.
2021-10-21 11:58:43 +02:00
Benno Schulenberg
5d285ca896 tweaks: rewrap three old NEWS items, for esthetics, and fix a date
Version 2.1.2 was released in June 2008, not April.
2021-10-21 11:47:44 +02:00
Benno Schulenberg
f368e2732d docs: reword several of the descriptions in the chapter on building nano 2021-10-20 16:12:48 +02:00
Benno Schulenberg
ad13746da9 docs: reword the beginning of the chapter on nanorc files
Also, move the text about valid color names to another item,
for shorter cross references.
2021-10-20 16:05:01 +02:00
Benno Schulenberg
440f39e558 docs: correct the description of the layout -- four areas, not five
Also, remove the concept of "shortcut list", as there is no need.
Just use "two help lines" instead, like elsewhere.
2021-10-19 16:17:53 +02:00
Benno Schulenberg
108c84daf8 docs: move the chapter about editor basics into third position
Or rather, move the chapter about command-line options to between
the chapters on file browser and feature toggles.  Also, rename the
chapter about the built-in help, and move the section about screen
layout to be the first in the editor-basics chapter.
2021-10-19 15:53:49 +02:00
Benno Schulenberg
e63fe3be69 tweaks: reword a paragraph, and use usual M- to depict Meta keystrokes 2021-10-19 15:36:38 +02:00
Benno Schulenberg
bc4a141cba tweaks: mark keystrokes consistently with @kbd in the manual
The @key command has the same visual result in the Info output, but
looks different (non-italic) from @kbd in the HTML and PDF outputs.
2021-10-19 14:21:28 +02:00
Benno Schulenberg
0dbe857ba2 syntaxes: undouble the backslash within bracket expressions
Within a bracket expression, the backslash is not special,
so it does not need to be escaped.

The double backslashes within brackets were found with:

  grep -o  '\[[^][]*\\\\[^][]*\]'  syntax{,/extra}/*rc

Also, incorporate the square brackets into some bracket expressions
by listing the closing bracket first, saving a separate regex for
those two brackets.
2021-10-18 12:14:05 +02:00
Benno Schulenberg
483538f8f3 syntax: email: use a character class, as \s does not work inside brackets
This fixes https://savannah.gnu.org/bugs/?61347.

Bug existed since version 4.9.3, commit 4f9bebdd.
2021-10-18 11:52:05 +02:00
Benno Schulenberg
1f36d5411a docs: improve the title of the manual, away from the bare "nano"
Also, suppress two unwanted blank lines in the HTML output, and
use a macro to avoid repeating the same three lines eight times.
2021-10-18 10:47:32 +02:00
Benno Schulenberg
46f76ca8b8 docs: avoid large Table of Contents at top of HTML version of manual
Texinfo-6.8 (that was used to build the docs of nano-5.9) changed
the way the @contents command is processed for HTML output, with as
result a detailed table of contents at the start of the HTML page.
That is ugly and too much detail.  To avoid that, produce a table
of contents only when generating output meant for printing.

This fixes https://savannah.gnu.org/bugs/?61344.

Bug existed since version 5.9.
2021-10-17 16:55:24 +02:00
Benno Schulenberg
3a09577e0c tweaks: replace the obscure @* with the slightly clearer @sp
What @* does is guesswork when you don't use Texinfo regularly.
That the "sp" in the @sp command refers to vertical space is not
very clear either, but the command is used on nearby lines too,
so better use it more.

Also, improve two wordings and fix a four-year old typo.
2021-10-17 12:36:57 +02:00
Benno Schulenberg
b9f472a905 syntax: texinfo: be more precise in colorizing @commands
An @command must either start at the beginning of the line and be
followed by whitespace or EOL, or it must be followed by a brace.
Colorizing just any "@text" string colored too much.
2021-10-17 12:25:01 +02:00
Benno Schulenberg
557d8131ca docs: prevent a black square in the PDF after the long synopsis line
Also, prevent an unwanted break in a keystroke.
2021-10-16 17:46:33 +02:00
Benno Schulenberg
89fd11109d docs: add a meta description for the HTML rendering of the manual
Also, drop the Emacs mode line -- we don't use Emacs,
and Emacs doesn't need it.
2021-10-16 17:03:45 +02:00
Benno Schulenberg
badf3edc55 syntax: texinfo: colorize the special @-plus-punctuation commands too
Also, allow an @} and another @command{} within a pair of braces,
colorize only the valid @-commands with uppercase in their names,
unbold enclosed command arguments, colorize the directory entries
for the manual, and properly colorize also the comments that use
the full @comment command.

Reference:
  https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Command-List.html

Testing was done with:
  info texinfo @-C "Command List" --output=list
  sed -i -e "s/^'//" -e "s/'$//" list
  nano list -Ytexinfo
2021-10-16 17:03:45 +02:00
Benno Schulenberg
36e3284979 help: ensure there is a blank line between title bar and start of text
In olden times, each help text started with a title line in the text
window followed by a blank line.  But since version 2.8.2, since the
help texts have become almost regular buffers (and thus searchable),
the title of the help text is in the title bar, and since version 4.0,
since --morespace became the default, the text will start immediately
below it.  But a title line immediately followed by text, without a
blank line between them, does not look nice.  So, add such a blank
line back when not using --emptyline (and also when using --minibar,
because the top of the terminal window is like a title bar).
2021-10-15 11:29:44 +02:00
Benno Schulenberg
4ac932bd21 syntaxes: drop three redundant end-of-line anchors
Also fold two regexes into one, for conciseness.
2021-10-15 10:17:28 +02:00
Benno Schulenberg
f9468fa987 history: process file faster by not filtering out hypothetical duplicates
When the history file has been created by nano, it will not contain
any duplicate search or replace strings, nor duplicate commands, so
checking for such a duplicate for each read item was a waste of time.

And if the user edited the history file and created duplicates, who
are we to filter them out?  They will not cause the history mechanism
to malfunction; they just take a little extra memory.
2021-10-14 09:58:07 +02:00
Benno Schulenberg
fb7c12f644 tweaks: rename a function, to make it make sense 2021-10-14 09:18:28 +02:00
Benno Schulenberg
9341c96def tweaks: rename two parameters and one variable, away from single letters 2021-10-14 09:18:05 +02:00
Benno Schulenberg
74fd78adb1 tweaks: reshuffle a few lines, and rename a variable 2021-10-13 16:45:15 +02:00
Benno Schulenberg
c8ab81dd1c tweaks: rename two variables, to fit with the names of similar ones 2021-10-13 16:38:23 +02:00
Benno Schulenberg
185e4d6b12 tweaks: rename two variables, away from abbreviations
Also reshuffle a few declarations, for Christmas.
2021-10-12 18:02:24 +02:00
Benno Schulenberg
99607a5bbe tweaks: invert a condition, to get an early return instead of indentation 2021-10-12 17:52:24 +02:00
Benno Schulenberg
7e807cdd2f memory: avoid leaking the filename when dottifying it on the minibar
This fixes https://savannah.gnu.org/bugs/?61334.

Bug existed since version 5.5, since the minibar was introduced.
2021-10-12 12:49:08 +02:00
Benno Schulenberg
e51f6596d4 tweaks: reassign a copy of a string to a variable more economically 2021-10-12 09:33:08 +02:00
Benno Schulenberg
42610db847 memory: avoid a tiny leak when an option with an argument is given twice
(Aaah, being able to define a keyboard macro
came in very handy when making this edit.)

This fixes https://savannah.gnu.org/bugs/?61331.

Bug existed since before version 2.2.0.
2021-10-11 17:18:07 +02:00
Benno Schulenberg
6018de2466 tweaks: condense the definitions of all the empty functions 2021-10-11 11:21:31 +02:00
Benno Schulenberg
af757d3b3f docs: reshuffle a GNU marker, to make the title clearer in search engines 2021-10-11 09:27:56 +02:00
Benno Schulenberg
30abc02277 tweaks: reshuffle two conditions, re-indent, and rewrap a line
If all is programmed well, then the functions 'get_older_item' and
'get_newer_item' will only occur when a history list is passed to
acquire_an_answer().  But let's keep it certain we don't dereference
a NULL pointer.
2021-10-10 11:55:15 +02:00
Benno Schulenberg
9a9714fe0c tweaks: rename a variable, to be easier to read and to make more sense
Also update and improve five comments.
2021-10-10 10:43:00 +02:00
Benno Schulenberg
77457fa6e9 prompt: avoid resetting the history pointer when the search is cancelled
When the user immediately cancels a search (^W^C), then nothing in
the history stack has changed, so then there is no need to reset the
history pointer to the bottom.

This slightly improves the fix for https://savannah.gnu.org/bugs/?61316.
2021-10-10 10:21:24 +02:00
Benno Schulenberg
9c45b5da6c tweaks: rename a function and its parameter, to be clearer 2021-10-10 10:11:47 +02:00
Benno Schulenberg
e9f0597e2e tweaks: rename two empty functions, to be more to the point
Also, move them to global.c, where all the other empty functions are.
2021-10-09 17:33:32 +02:00
Benno Schulenberg
87cde1590d tweaks: elide two functions that each were called just once
This also gets rid of an assignment in an 'if' clause (twice),
elides a local variable, and makes it clearer that a pointer
gets moved to the previous or next item (instead of hiding it
as a side effect of the function call).
2021-10-09 17:18:32 +02:00
Benno Schulenberg
65d81c60cd help: do not show ^S when --preserve is in effect
This fixes https://savannah.gnu.org/bugs/?61317.

Bug existed since version 5.0, since the Execute menu was overhauled.
2021-10-09 13:05:27 +02:00
Benno Schulenberg
3d6dcb9568 prompt: begin at bottom of history list when at secondary prompt
Whenever invoking a search prompt, calling up historical search items
should start with the newest item.

This fixes https://savannah.gnu.org/bugs/?61316.

Bug existed since version 2.8.2, since help texts became searchable.
2021-10-09 12:15:11 +02:00
Benno Schulenberg
1ca2911b84 prompt: keep a clear answer clear also after an excursion into history
When the answer at the prompt was clear before the user went up into
the history list, the answer should be cleared again when the user
comes back down to the present.

This fixes https://savannah.gnu.org/bugs/?61308.

Bug existed since before version 2.2.0.
2021-10-08 12:36:32 +02:00
Benno Schulenberg
8ef74b3aac tweaks: rename five empty functions, to get rid of a meaningless suffix
For consistency, these five names ought to start with "flip_", but
then the bindable functions would need to be renamed too, and that
would be annoying for the user, *and* it would create too many names
that start with "flip" -- it wouldn't be distinctive any more.
2021-10-08 10:58:47 +02:00
Benno Schulenberg
aeae4fb4b9 tweaks: reshuffle some lines, one for clarity, others for conciseness 2021-10-07 19:04:20 +02:00