Commit Graph

463 Commits (7028adf21165617d249d96af0381730c67447bb4)

Author SHA1 Message Date
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