Commit Graph

534 Commits (9f92341c844a24e51bafa1353fa9fbff7133a0d9)

Author SHA1 Message Date
Benno Schulenberg 073bd3ad6e rcfile: properly handle an empty syntax before an 'include' statement
So that in the error message the correct filename gets shown
instead of the name of the (first) include file.

Reported-by: Brand Huntsman <alpha@qzx.com>
2019-08-18 10:56:17 +02:00
Brand Huntsman 304f07258b rcfile: for an empty syntax, show the line number of the 'syntax' command
When reporting a syntax without any color commands, show the line number
of the relevant 'syntax' command instead of the line number where the
emptiness is concluded, because the latter can be many lines later.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:47:19 +02:00
Benno Schulenberg e1c2573c7a tweaks: improve a comment, and drop a superfluous one 2019-08-17 13:28:47 +02:00
Benno Schulenberg 07ec7de8eb tweaks: remove a saving and restoring that has become superfluous
The previous commit saves and restores filename and linenumber for
each single included file (after globbing), so it is now redundant
to do it for each 'include' command.
2019-08-17 13:21:34 +02:00
Brand Huntsman 82f5fed45a rcfile: report the correct command location for an invalid 'include'
For each included file, save and restore file name and line number of
the including file, so that an error message about a faulty 'include'
command can indicate the location of this 'include'.

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

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:07:20 +02:00
Benno Schulenberg 47068c3770 build: fix compilation when configured with --disable-color 2019-06-17 09:59:15 +02:00
Benno Schulenberg c7ca60b046 tweaks: don't check the user's nanorc file for accessibility twice
Also, condense some alternatives into a single 'if'.
2019-06-16 17:53:44 +02:00
Benno Schulenberg 01e4f85f29 tweaks: remove a check that is no longer relevant
Since commit 7028adf2 from three days ago, also the color commands of
syntaxes that are defined in a main nanorc will get parsed during a
second pass, so it is perfectly possible to extend such syntaxes
later on in the same (or another) nanorc file.
2019-06-16 11:02:03 +02:00
Benno Schulenberg 6bfbb2bcd9 tweaks: remove two more unneeded assignments
'opensyntax' is relevant only during the first pass through all the
nanorc files (intros_only == TRUE) when it is checked that syntax
commands are grouped properly and not mixed with others.  And
'lastcolor' is relevant only during the second pass of a specific
syntax, because only then the color commands are actually parsed.
2019-06-16 10:41:53 +02:00
Benno Schulenberg d82c753ba4 rcfile: at terminating points, verify that a defined syntax is not empty
Whenever, in an rcfile, a command is encountered that is not part of a
syntax definition, a currently open syntax should be closed, but only
after checking that the syntax contains at least one color command.

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

Bug existed since version 2.3.3.
2019-06-15 19:42:31 +02:00
Benno Schulenberg 0af9ce926b rcfile: close off a syntax when a non-syntax command is encountered
The 'color' commands of a syntax definition should not be allowed to
be interspersed with other, non-syntax commands.

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

Bug existed since before version 2.6.0.
2019-06-15 15:07:57 +02:00
Benno Schulenberg 4e14a8a977 tweaks: remove two unneeded assignments, and improve a comment
Also reshuffle a line, for esthetics.
2019-06-15 14:35:53 +02:00
Benno Schulenberg accd17c249 tweaks: remove four unneeded pre-processor directives
The parse_next_word() function is not being used by the history code
anymore since commit ecd18c16, more than two years ago.
2019-06-15 14:17:13 +02:00
Benno Schulenberg e8eb30cad6 tweaks: just mark four rcfile errors for translation, like the others
The messages get translated when they get stored in the linked list.
This is to economize on the number of actual calls of gettext().
2019-06-15 14:13:20 +02:00
Benno Schulenberg 36bd68f3ab tweaks: rename a function, to better suit what it does 2019-06-15 14:07:57 +02:00
Benno Schulenberg 03692363a2 tweaks: move a syntax check to a better place, to reduce duplication 2019-06-15 13:04:01 +02:00
Benno Schulenberg 0e94575c6b rcfile: check for missing color commands only when a syntax is still open
This fixes https://savannah.gnu.org/bugs/?56497.

Bug existed since commit 7028adf2 from two days ago.
2019-06-15 12:17:33 +02:00
Benno Schulenberg 27cc3117e2 tweaks: rename two parameters, for more contrast, and elide another
Also rename a function.
2019-06-14 10:56:49 +02:00
Benno Schulenberg 19f71632c8 tweaks: remove an unneeded "closing" of a syntax after extending it
As 'extendsyntax' commands are no longer interpreted immediately when
the rcfiles are read, there is no need to set 'opensyntax' to FALSE
after interpreting such a command -- for a single syntax they are all
interpreted in a row.
2019-06-14 10:56:49 +02:00
Benno Schulenberg e3f18e7a6c tweaks: rename two variables, and frob some comments
Also reshuffle the newline stripping, as it's pointless for lines
that are skipped.
2019-06-14 10:56:49 +02:00
Benno Schulenberg b55923f5ec tweaks: reshuffle some lines, to group things more sensibly 2019-06-14 10:56:49 +02:00
Benno Schulenberg 7028adf211 rcfile: fully read each included file, so all its syntaxes are seen
An included file can contain multiple syntaxes.  If reading would stop
as soon as a command different from 'syntax' and 'header' and 'magic'
is found, any later syntaxes would not be seen.  So each nanorc file
needs to be fully scanned -- it's just the interpretation of all the
color commands that we want to delay until the syntax gets actually
used.

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

Bug existed since commit cba9d8d0 from a month ago.
2019-06-14 10:49:30 +02:00
Benno Schulenberg d7df7c694a tweaks: elide a pre-processor #else clause, by using braces instead 2019-06-13 15:47:29 +02:00
Benno Schulenberg 781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg cdc9482d8f tweaks: rename three variables, to use full words instead of abbrevs 2019-06-05 14:50:01 +02:00
Benno Schulenberg 7c1b649eb8 tweaks: rename a function and its parameters, to be more fitting
Also, reshuffle their order, and improve or adjust some comments.
And change the type of 'pairnum' to short, what ncurses uses too.
2019-06-05 13:08:14 +02:00
Brand Huntsman 57b3f83cfe rcfile: compile the color regexes just once
When a syntax gets parsed, store the compiled color regexes right away,
instead of compiling them a second time in color_update().

This addresses https://savannah.gnu.org/bugs/?56432.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-06-04 19:57:46 +02:00
Brand Huntsman 8bc2d18fa9 tweaks: remove an unneeded pre-processor '#else' clause
Commit 1e2e6733 added braces and made the semicolon no longer needed
when libmagic is not used.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 19:27:34 +02:00
Benno Schulenberg 9b30bb15cc tweaks: adjust the indentation after the previous change
And reshuffle two declarations.
2019-06-03 15:51:07 +02:00
Benno Schulenberg a1669e1bfd rcfile: disallow extending a syntax that is defined in a main nanorc
The /etc/nanorc file should not define any syntax directly (and
preferably not include any either, to not slow startup down with
syntaxes the user is never going to use), and if the ~/.nanorc file
defines a syntax directly, there is no need to use 'extendsyntax':
the command can be added to the syntax itself -- it would be better
even: it keeps things together.
2019-06-03 15:42:06 +02:00
Benno Schulenberg 3d6eca3f26 tweaks: reshuffle some lines, to put the most likely candidate first 2019-06-03 15:04:00 +02:00
Benno Schulenberg c025a60ce9 tweaks: rename a function and a variable, for contrast and variety 2019-06-03 15:01:28 +02:00
Benno Schulenberg 5e1f90d8fa tweaks: don't bother to free the content of 'extendsyntax' commands
Extending a syntax will be rather rare, so the amount of memory it
takes up will be minimal.  It's not worth the trouble to free this
memory -- it only takes time.  Plus: we don't bother to free the
memory of a syntax that gets fully redefined either.
2019-06-03 14:37:27 +02:00
Benno Schulenberg 7f3ffe8544 tweaks: remove a bit of redundant code
When an included file has just been fully parsed, 'lastcolor' is still
pointing at the last color regex that was added to the list -- no need
to refind the end of this list.
2019-06-03 14:21:17 +02:00
Benno Schulenberg 844214b4a0 tweaks: rename two variables, to not be abbreviations
Also reshuffle two declarations.
2019-05-31 12:54:20 +02:00
Benno Schulenberg f9dfca7d5a tweaks: rename a variable, to be shorter 2019-05-31 12:46:15 +02:00
Benno Schulenberg fe40e8867d tweaks: rename a struct element, to be distinct
And to match the style of its sisters.
2019-05-31 12:25:15 +02:00
Benno Schulenberg 923a90cba0 tweaks: rename a type, for more contrast 2019-05-31 12:18:30 +02:00
Benno Schulenberg 1e2e6733df tweaks: add a pair of braces, to silence a compiler warning
Also, put an 'else' on the same line as the preceding closing brace.
2019-05-21 17:25:45 +02:00
Benno Schulenberg da8c74a44f docs: note Brand as the author of the delayed syntax parsing 2019-05-20 10:45:33 +02:00
Brand Huntsman cba9d8d05e rcfile: fully parse a syntax file only when needed
When parsing an included syntax file, stop reading when a command other
than 'syntax', 'header' or 'magic' is encountered.  The syntax file is
fully parsed the first time that a file needs it.  Each 'extendsyntax'
command is stored for unloaded syntaxes and applied after the syntax
is loaded.

Closing a buffer does not unload the syntax, even if no longer used by
another buffer.

This addresses https://savannah.gnu.org/bugs/?54928.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Brand Huntsman 0e29c2a24a rcfile: store errors and display them when nano terminates
This is needed to implement the demand loading of syntax files, as any
errors that these files may contain would otherwise overwrite things on
the screen and the messages wouldn't be on the terminal when nano exits.

It also allows nano to start up on a Linux console when there are errors.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Benno Schulenberg 8720cfcce9 tweaks: rename two more functions, to be simpler too 2019-05-04 11:21:45 +02:00
Benno Schulenberg 954c4d03ac tweaks: rename two functions, to be simpler 2019-05-04 11:21:45 +02:00
Benno Schulenberg 00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg 2552307064 options: remove -f (--finalnewline); go back to auto-adding this newline
For relatively inexperienced users (as most users of nano probably are)
it is far better that nano produces POSIX text files by default, where
each line ends with a newline character.  This means that these files
will "print" properly (not gluing the next prompt at the end of the
last line), tools will see and process each line of them, and, while
editing, adding text at the end is easier.

This addresses https://savannah.gnu.org/bugs/?55997.
Reported-by: Ralph Corderoy <ralph@inputplus.co.uk>
2019-04-07 10:02:05 +02:00
Benno Schulenberg c3f97bc9b7 rcfile: read the syntax files in alphabetical order when globbing
The reading order must be predictable, otherwise things might get
colored differently from system to system.

This fixes https://savannah.gnu.org/bugs/?56012.
2019-04-06 17:50:55 +02:00
Benno Schulenberg 4399b734db bindings: disallow executing an external command when in view mode
Otherwise the user could do something like

  ^R^X  sed -i 's/a/surprise!/g' name-of-current-file  <Enter>

and the file being viewed would be modified anyway.
2019-04-06 17:41:44 +02:00
Benno Schulenberg 408f15954e feedback: replace an assert with a check plus error message at startup 2019-04-06 10:03:52 +02:00
Benno Schulenberg 947ccbb597 rcfile: don't break a chain of 'else if' [scan-build]
The mistake was made when 'guidestripe' was added, in commit 66c6eb51.
2019-04-03 19:06:04 +02:00
Benno Schulenberg 671db5e1e3 tweaks: rename an overshort type to something that makes some sense 2019-04-03 17:34:05 +02:00
Benno Schulenberg acfee2538e tweaks: rename a cryptic type to something that makes a little sense 2019-04-03 17:11:24 +02:00
Benno Schulenberg b58418b32f tweaks: rename a variable, to be more distinct 2019-03-21 19:21:45 +01:00
Benno Schulenberg 23190aa60f tweaks: make an assignment only when the option is valid, like elsewhere 2019-03-21 19:17:03 +01:00
Benno Schulenberg 01e6d435fe tweaks: rename a function, to be simpler and more accurate 2019-03-21 17:42:34 +01:00
Benno Schulenberg 20514eca19 feedback: make two error messages better match the option
And keep them identical.
2019-03-11 09:07:08 +01:00
Benno Schulenberg 4205567bb1 tweaks: add deprecation comments to the four superseded options 2019-03-10 17:05:19 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
Benno Schulenberg 916b4d81d0 rcfile: add 'stripecolor' for changing the color of the guiding stripe
The default is now simply reverse video, which works better than a
"loud" colored bar in an interface that for the rest is monochrome.
2019-03-09 09:27:08 +01:00
Benno Schulenberg 66c6eb5166 new feature: option --guidestripe that shows a vertical guiding bar
Option -J (--guidestripe) takes a column number as argument and then
shows a vertical, colored bar over the entire height of the buffer,
to aid the user in regulating the width of the text when the terminal
is wider than this desired width.

This fulfills https://bugs.debian.org/916392.
Requested-by: Arturo Borrero González <arturo@debian.org>
And fulfills https://savannah.gnu.org/bugs/?55315.
Requested-by: Bryan Christ <bryan.christ@gmail.com>
2019-03-09 09:27:08 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 894aff0816 options: let --fill no longer imply automatic hard-wrapping
Now --fill only sets the target width for hard-wrapping and justifying,
but automatic hard-wrapping itself is switched on with --breaklonglines.
2019-02-18 09:34:18 +01:00
Benno Schulenberg 4d40bea58a rcfile: add the options that correspond to -b, -f, -j, and -e 2019-02-18 09:34:18 +01:00
Benno Schulenberg 2482cfca56 build: eradicate the --disable-wrapping-as-root configure option
Hard-wrapping is disabled by default for any user, so this special
configure option is no longer needed.
2019-01-25 11:37:51 +01:00
Benno Schulenberg b596639f95 options: actually rename --rebindkeypad to --rawsequences (-K) 2018-12-31 18:35:46 +01:00
Benno Schulenberg 798695ff1e utils: retire the fixbounds() function -- it is no longer needed
All tested systems (FreeBSD, NetBSD, OpenBSD, Alpine, and Ubuntu)
support the GNU-style word boundaries (\< and \>), either natively
or through using the regex module from gnulib.

If this change breaks regexes containing \< or \> on your system,
please report a bug: https://savannah.gnu.org/bugs/?group=nano

This addresses https://savannah.gnu.org/bugs/?55207.
2018-12-31 13:49:07 +01:00
Benno Schulenberg 34b8d58871 rcfile: reject an attempt to bind ^[
Also, for <Esc> <Esc> [, report that it is unbindable.

This fixes https://savannah.gnu.org/bugs/?55336.
2018-12-30 19:47:43 +01:00
Benno Schulenberg 997826d794 tweaks: rename a symbol, to match its corresponding option 2018-12-28 17:47:03 +01:00
David Lawrence Ramsey 77bd8c2630 tweaks: swap the names of the variables 'wrap_at' and 'fill'
Now 'fill' contains the original specified value,
and 'wrap_at' the column that 'fill' translates to.
2018-12-18 19:50:59 +01:00
Benno Schulenberg 3121ee4b2e options: stop recognizing and mentioning --quiet and 'set quiet'
Those options have been a no-op and obsolete for over a year.

Just continue to accept and ignore -q, for some "compatibility"
with Pico.
2018-12-18 19:29:40 +01:00
Benno Schulenberg 762cee242a tweaks: reshuffle a bit of code, to have the exit point near the end 2018-12-18 19:27:17 +01:00
Benno Schulenberg 3a170d2c3e rcfile: when rebound, DO unbind a keystroke from its earlier function
When not unbinding it from its earlier function (in the same menu),
it would result in showing the keystroke twice in the help text.

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

Bug was introduced a month ago, by commit f81d174f.
2018-12-18 19:25:33 +01:00
Benno Schulenberg 3a79766da6 rcfile, docs: remove deprecated forms of two options and five bindables
This addresses https://savannah.gnu.org/bugs/?53785.
2018-12-03 10:25:55 +01:00
Benno Schulenberg d3f0d32e16 rcfile: don't report an error when the globbing pattern matches nothing
Because a message like "Error expanding EMPTY/*.nanorc: Success"
looks silly.

Indirectly-reported-by: Ντέντος Σταύρος <stdedos@gmail.com>
(https://lists.gnu.org/archive/html/nano-devel/2018-11/msg00044.html)
2018-11-19 12:06:43 +01:00
Benno Schulenberg 3f309bc36a tweaks: rename three variables, and reshuffle two declarations 2018-11-19 11:47:02 +01:00
Benno Schulenberg 2516b64046 tweaks: adjust the indentation after the previous change
Also reshuffle two declarations and improve two comments.
2018-11-14 17:58:34 +01:00
Benno Schulenberg 0ad0dcc926 tweaks: reshuffle some code, to require two fewer ifs 2018-11-14 17:57:20 +01:00
Benno Schulenberg f81d174f11 rcfile: when a keystroke is rebound, don't bother unbinding it
The new binding will be put at the head of the list and thus will
be the one that is found -- the old binding will never be seen, so
rubbing it out is just a waste of time.
2018-11-14 17:41:32 +01:00
Benno Schulenberg ca6281e821 tweaks: condense a handful of comments, and drop an assert 2018-11-05 09:38:07 +01:00
Brand Huntsman ae3ec1784d options: add --zap, that makes <Bsp> and <Del> erase a marked region
Using --zap or -Z on the command line, or 'set zap' in a nanorc file,
makes the <Bsp> and <Del> keys erase selected text (a marked region)
as they do in some other editors, and without affecting the cutbuffer.

This fulfills https://savannah.gnu.org/bugs/?54837.
Requested-by: Liu Hao <lh_mouse@126.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:57 +01:00
David Lawrence Ramsey 16a3dc90c7 wrapping: make relative fill values work again also for screen resizes
The 'wrap_at' variable, removed in commit e90b7cf4, is actually needed
to store the original value of the --fill option when it is negative.
Otherwise, changing the screen width will not update the wrapping point
properly.

This fixes https://savannah.gnu.org/bugs/?54861.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-10-18 20:35:49 +02:00
Benno Schulenberg 9c2b67231e tweaks: rename a flag, to match the name of the option 2018-10-02 19:18:55 +02:00
Benno Schulenberg 5ca444e5df startup: allow reading nanorc in restricted mode, to permit customization
Move the unsetting of some options further down, to prevent the user's
nanorc enabling things that are not permitted in restricted mode.

Also, in restricted mode, suppress error messages about functions not
being present in the requested menus, so that a nanorc that is valid in
normal mode does not cause unnecessary messages when using --restricted.

This fulfills https://savannah.gnu.org/bugs/?54732.
Requested-by: Mark Webb-Johnson <mark@webb-johnson.net>
2018-10-02 19:18:55 +02:00
Benno Schulenberg 9e71de12cd tweaks: improve a translator hint and some other comments 2018-09-09 08:17:22 +02:00
Brand Huntsman 6e80772311 tweaks: correct four spaces of indentation to a tab, in two places
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-29 18:01:21 +02:00
Brand Huntsman b5ede4ff65 tweaks: remove the 'bright' field from the colortype struct
Put the corresponding value into the 'attributes' field sooner.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-25 10:54:20 +02:00
Benno Schulenberg e40e6bbf10 tweaks: rename a function to better match its counterpart
Also rename its parameter, to describe what it ought to be.
2018-08-11 09:55:22 +02:00
Benno Schulenberg 2147e161bf rcfile: when a vital function is not mapped, mention in which menu
Add the reverse of the name-to-menu function to accomplish this.

This fixes https://savannah.gnu.org/bugs/?54449.
2018-08-11 09:46:03 +02:00
Benno Schulenberg 52d851a1aa startup: don't overwrite rcfile error messages on a Linux console
On a Linux VT, refuse to start when there are errors in a nanorc file,
so that the messages no longer get overwritten -- which prevented the
user from seeing and reading them.

This fixes https://savannah.gnu.org/bugs/?54442.
2018-08-10 19:41:54 +02:00
Benno Schulenberg 975b491235 dropping a feature: remove the ability to use the 'formatter' command
Since the last version, the user can filter an entire buffer through
an external command.  This external command can also be a formatting
program, so there is no longer any need for this specific and special
formatter command.
2018-08-09 20:29:30 +02:00
Benno Schulenberg 4c66a6259c tweaks: slightly improve error message when vital function is unmapped
This fails to fix https://savannah.gnu.org/bugs/?54449, because
it would take far too much code for an exceptional case.
2018-08-06 19:35:47 +02:00
Benno Schulenberg ad79a4fcfb rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
(In the Search and Replace menus Cancel is not essential.  And in the
Goto Line menu Cancel is not needed at all: a simple <Enter> after an
empty answer works fine.)

This fixes the second part of https://savannah.gnu.org/bugs/?54447.
2018-08-05 20:11:48 +02:00
Benno Schulenberg e90b7cf4aa tweaks: elide an unneeded/duplicate variable 2018-08-04 11:34:44 +02:00
Benno Schulenberg bb90de0eb4 tweaks: rename a constant, to match what it actually means
Wrapping is concerned with columns, not with number of characters.
2018-08-04 11:21:42 +02:00
Benno Schulenberg 157c7b1bc4 rcfile: explicitly check for disallowed keywords in included files
This fixes https://savannah.gnu.org/bugs/?54441.
2018-08-04 07:29:36 +02:00
Benno Schulenberg 9a47a9c4c0 rcfile, docs: no longer recognize nor mention 'set backwards'
The option has been a no-op since 2.9.0.  And now that the
^W/^Q/M-W/M-Q set is available, 'set backwards' is entirely
outdated.
2018-07-29 21:00:12 +02:00
Benno Schulenberg f2adefb158 tweaks: drop some old debugging code 2018-07-08 10:45:43 +02:00
Benno Schulenberg 7ae8f3bca4 tweaks: elide a function that is used just once 2018-07-08 10:40:22 +02:00
Benno Schulenberg 2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
David Lawrence Ramsey fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00