Commit Graph

5858 Commits (0c249de9e534d3fc092171045696101f41d3bb64)

Author SHA1 Message Date
Benno Schulenberg 497f126bb2 files: write a lock file also for a new file and when the name changed
(When the new or changed name is that of an existing file AND this
file is being edited by some other editor (or nano itself), then the
behavior is rather strange: nano asks whether to continue, but the
file has already been overwritten and there is nothing the user can
do to cancel or revert things.  A later commit should improve this.)

This fixes https://savannah.gnu.org/bugs/?47975,
and fixes https://savannah.gnu.org/bugs/?53883.
2020-01-13 20:00:07 +01:00
Benno Schulenberg 4687322398 tweaks: rewrap two lines, for consistency with similar lines 2020-01-13 20:00:07 +01:00
Benno Schulenberg 99f0265d34 tweaks: condense a fragment of code 2020-01-12 12:32:20 +01:00
Benno Schulenberg 7d483987ce input: do not auto-indent when something is pasted into nano from outside
Also, do not break overlong lines and do not convert tabs to spaces,
nor interpret a <Tab> as an indent command (when the mark is on).
In other words: accept an outside paste as literally as possible.

This fulfills https://savannah.gnu.org/bugs/?40060.
Requested-by: Egmont Koblinger <egmont@gmail.com>

And fulfills https://savannah.gnu.org/bugs/?57527.
Requested-by: Sébastien Desreux <seb@h-k.fr>
Requested-by: Hans Ecke <hecke@gxt.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Brand Huntsman f705a9674b input: recognize the start and stop sequences of a bracketed paste
Also, tell the terminal to switch on bracketed-paste mode, and toggle
a boolean when the start and stop sequences of such a paste are seen.
This boolean can later be used to suppress auto-indent and such.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Benno Schulenberg 3233e9cfe0 tweaks: correct a comment
The maximum length was increased two weeks ago, in commit 4dcbd40c.
2020-01-12 11:18:29 +01:00
Benno Schulenberg 5a98a51173 bindings: do not show the Full-Justify keystroke when in View mode
The file may not be modified when in View mode, so it makes no sense
to prominently show the M-J keystroke in the Search menu when in that
mode, especially since the keystroke does not really belong there.

This addresses https://savannah.gnu.org/bugs/?57574.
2020-01-10 17:24:29 +01:00
Benno Schulenberg 2eaba21a4c help: increase the minimum help-text width from 24 to 32 columns
Even at 32 columns, the key descriptions are already hopelessly
fragmented.  Any width smaller than that is useless.
2020-01-09 15:10:52 +01:00
Benno Schulenberg 9a227de3e7 tweaks: recompute the wrapping point just once
Instead of for every row after the intro.
2020-01-09 14:47:48 +01:00
Benno Schulenberg 3f57200e10 help: prevent double spaces from protruding across the right edge
This fixes https://savannah.gnu.org/bugs/?57563.
2020-01-09 12:02:49 +01:00
Benno Schulenberg 1486f32d42 help: when a key description wraps, indent its wrapped part
This prevents the wrapped text from cluttering up the two key columns.

This addresses https://savannah.gnu.org/bugs/?57451.
2020-01-09 11:37:49 +01:00
Benno Schulenberg e3edce4e7b tweaks: elide a helper function, in preparation for an improvement 2020-01-09 11:02:36 +01:00
Benno Schulenberg 0e559c5bbc tweaks: initialize three more booleans straightaway, at declaration
Also improve three comments.
2020-01-09 10:37:56 +01:00
Benno Schulenberg edfbfbfd0a tweaks: initialize three booleans straightaway, when they are declared
Also improve three comments.
2020-01-08 16:55:45 +01:00
Benno Schulenberg a4eae770ce tweaks: rename a function, to be a bit more expressive 2020-01-08 16:13:04 +01:00
Benno Schulenberg 72e5c15110 tweaks: move three functions to the file where they are mainly used
The extract() and copy_from_buffer() functions are mainly used for
cutting a line or a region, so move them to src/cut.c.  Also move
the function for which copy_from_buffer() is a wrapper.
2020-01-08 16:04:49 +01:00
Benno Schulenberg 97c8140cea tweaks: rename two functions, to make more sense 2020-01-08 11:09:57 +01:00
Benno Schulenberg c5b03ca4ae tweaks: rename two variables, to make more sense 2020-01-08 11:00:51 +01:00
Benno Schulenberg c2f2c659d9 tweaks: rename a parameter and invert its logic, and correct a comment
This changes the main injection routine in the same way that the prompt
injection routine was changed four years ago in commit e540053e.
2020-01-08 10:49:19 +01:00
Benno Schulenberg 9364bd6c81 tweaks: reword two comments, and rewrap another 2020-01-08 10:27:30 +01:00
Benno Schulenberg baa2be3217 tweaks: improve a comment by indirectly referring to the ncurses docs
See https://invisible-island.net/ncurses/ncurses-intro.html#xterm.
2020-01-07 20:25:31 +01:00
Benno Schulenberg 3f0d2fd5ca display: don't let a message write over the second help line
When suspending nano on a Linux console (or FreeBSD console), the
helpful message about using the 'fg' command overwrote the start
of the second help line, kind of hiding the message.  So, output
a double newline before the message to make it stand out.

Also, drop a pointless cursor movement, as endwin() determines
the placement of the cursor all by itself.
2020-01-07 13:38:52 +01:00
Benno Schulenberg 5b07e5fd1f input: discard partial sequences that Slang produces for F17 to F24
This fixes https://savannah.gnu.org/bugs/?57503.
2020-01-03 12:34:15 +01:00
Benno Schulenberg 3cae32390d display: show the cursor during suspension also when built with Slang
This fixes https://savannah.gnu.org/bugs/?57517.

Bug existed since version 2.9.0.
2020-01-03 12:08:27 +01:00
Benno Schulenberg 1be0285832 tweaks: delete some fragments of code that have become irrelevant
Since the previous commit, USE_SLANG can only be defined when NANO_TINY
is also defined.  This means that code that is present only in non-tiny
versions does not need to cater for Slang.
2020-01-03 12:00:06 +01:00
Benno Schulenberg c4d2bf59fb display: adjust line and column count upon a resize also when using Slang
This partially fixes https://savannah.gnu.org/bugs/?57513.
2020-01-01 14:17:03 +01:00
Benno Schulenberg 5527883c43 input: don't discard the first keystroke after a resize when using Slang
With ncurses, a window resize will cause getch() to return immediately
with some dummy value, which nano can discard.  But with Slang, getch()
will return only when the next keystroke is typed, so the received code
should then not be discarded.

This fixes https://savannah.gnu.org/bugs/?57507.
2020-01-01 13:54:07 +01:00
Benno Schulenberg 84b305f3f0 build: exclude the escape sequences for F13...F16 from the tiny version
The F13 to F16 function keys are no longer bound by default, and when
there is no nanorc file, there is no way to bind them, so there is no
point in recognizing their escape sequences.
2019-12-30 11:55:41 +01:00
Benno Schulenberg 67b89459d5 tweaks: drop an unneeded call of keypad() -- we never read from topwin
The title bar is used only for showing things, never for typing anything
into.  That is: we never call wgetch() with 'topwin' as an argument.
2019-12-29 14:14:08 +01:00
Benno Schulenberg 6d916c6c4a tweaks: rewrap a comment and a line, and reshuffle a fragment of code 2019-12-29 14:13:27 +01:00
Benno Schulenberg 87542eeaf1 tweaks: move a function to before the one that calls it
And condense its logic.  And improve its comment.
2019-12-27 17:01:15 +01:00
Benno Schulenberg 29f2e3181a tweaks: rename a function and its parameter, to be more fitting
Also, avoid calling a case-changing function when it's not needed.
And elide a default case that can never occur (because the function
always gets called with one of the four letters).
2019-12-27 16:48:07 +01:00
Benno Schulenberg 8255696b45 tweaks: condense five more fragments of repetitious code 2019-12-27 13:49:03 +01:00
Benno Schulenberg fc00e89499 tweaks: comment fully, so that all handled escape sequences are findable
Also correct a few other comments.
2019-12-27 13:48:36 +01:00
Benno Schulenberg 55946c15e7 tweaks: reshuffle some lines, to group all ignored keystrokes together 2019-12-27 12:16:50 +01:00
Benno Schulenberg 2e539e2c97 tweaks: stop recognizing escape sequences for a key without meaning
Nano does not do anything for the keystroke anyway (KEY_B2, the center
key on the numeric keypad, gets translated to ERR later on), so there
is no point in recognizing some of its escape sequences -- let those
sequences result in "Unknown sequence" instead.
2019-12-27 12:13:40 +01:00
Benno Schulenberg 38c286c019 input: recognize the raw escape sequences for F13 to F16 on xterm too
For symmetry with Gnome Terminal, Konsole, and the Linux console.

This fixes https://savannah.gnu.org/bugs/?57482.
2019-12-26 17:07:51 +01:00
Benno Schulenberg 56d842258c tweaks: condense three fragments of repetitious code 2019-12-26 16:50:19 +01:00
Benno Schulenberg 8ed8ab69d5 tweaks: make a couple of comments more precise 2019-12-26 14:32:44 +01:00
Benno Schulenberg 4dcbd40c49 input: consume and ignore the raw escape sequences for F17 to F24
When --rawsequences is used, consume the full escape sequences for
the F17 to F24 function keys (on xterm-compatible terminals and on
the Linux console), to prevent them entering junk into the buffer.

This fixes https://savannah.gnu.org/bugs/?57483.
2019-12-26 14:02:17 +01:00
Benno Schulenberg 72645b160d input: correct the escape sequence for PageUp/PageDown on Eterm/Urxvt
There is not a single terminal in the terminfo database that has an
"Esc [ n ^" sequence for any keystroke (where n is a digit).
2019-12-26 12:23:08 +01:00
Benno Schulenberg dda1b167c9 help: don't waste the last column in the help viewer on narrow terminals
When a line in a help text is wider than the terminal, then do not break
that line at COLS - 1, but simply at COLS.  In olden times it made some
sense to have an empty column on the right of the introductory text, to
mirror the one on the left.  But since the width of the introductions
got limited to 74 columns (four years ago, in commit a9aa0ef9), those
texts have (on a default 80-column terminal) at least six empty columns
on their righthand side.  And on narrower terminals, we really don't
want to waste anything and should use all available space.

Also, this whole mechanism of making an exception for end-of-string or
end-of-paragraph and letting only those make use of the final column,
it was a waste of time: it kind-of did the whole break_line() process
again, but then for the entire string (which can be some five hundred
characters long in the introductory texts).  So... get rid of it, make
it simple.  On an 80-column terminal it doesn't make any difference.
2019-12-25 14:39:17 +01:00
Benno Schulenberg 074cf40409 tweaks: remove a superfluous check
When break_line() is called with its last parameter set to TRUE
(meaning that it will break also at a newline) it will return a
value that is bigger than 1.  So it is pointless to ensure that
it is at least 1.
2019-12-25 14:32:04 +01:00
Benno Schulenberg 4991b3bb1a input: Ctrl+arrow is "Esc O x" on Eterm, as on rxvt -- not "Esc o x"
(Checked on Eterm-0.9.6 running on Xubuntu 18.04.)
2019-12-24 20:01:48 +01:00
Benno Schulenberg 4314feae11 build: fix compilation for --enable-tiny --enable-wrapping 2019-12-22 12:56:18 +01:00
Benno Schulenberg 410280b089 build: fix compilation when configured with --disable-justify 2019-12-22 11:32:49 +01:00
Benno Schulenberg 178dd9181f tweaks: slightly streamline the search for a possible wrapping point
That is, elide an 'if' for the it-is-a-blank case.
2019-12-19 19:22:02 +01:00
Benno Schulenberg d30ca576b7 tweaks: optimize the trimming of trailing whitespace
When justifying a paragraph, always first squeeze() is called on
the text (which at that moment consists of a single long line),
which means that (in its wrappable part) this line contains only
single spaces as word separators (and maybe a double space after
a period).  So there is no need to call the general is_blank()
function -- checking for a space is enough.
2019-12-19 12:16:15 +01:00
Benno Schulenberg ed520c89bc tweaks: improve two comments and the ordering of some operands 2019-12-19 12:15:47 +01:00
Benno Schulenberg cb44a2bd2c tweaks: reshuffle and rename a few things, to elide duplication 2019-12-19 10:52:06 +01:00
Benno Schulenberg a0055f3640 wrapping: never break in the quoting part nor in the indentation part
Rationale: nano should not wrap inside the quoting part of a line
because it would change the quoting level, which would misrepresent
things, nor should it wrap inside the indentation part because when
the user tries to indent something beyond the target wrapping width,
she/he does not intend to create a line containing only whitespace,
but effectively wants to push the text beyond the wrapping width.

This copies the behavior of the rewrap_paragraph() routine that is
used during justification, so that automatic hard-wrapping ends up
with the same result as justifying.

Also, always do automatic hard-wrapping when --breaklonglines is in
effect, also when --autoindent is active.

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

The bug was old -- it existed since at least version 2.0.6.

This furthermore avoids https://savannah.gnu.org/bugs/?57422.
Reported-by: Sébastien Desreux <seb@h-k.fr>

That bug existed since version 4.4, commit 8fce33af.
2019-12-18 11:22:30 +01:00
Benno Schulenberg b00c1d6110 justify: treat consecutive indentations that look the same as the same
That is: allow tabs and spaces to be mixed when comparing indentation.
When the mix of tabs and spaces pushes the text of a line to the same
column as on a consecutive line, then those two lines are considered
to have the same indentation and thus belong to the same paragraph.

This reverts the previous commit (594ef222), and improves upon how
nano has behaved since version 2.9.8.

This fixes https://savannah.gnu.org/bugs/?57404 differently.
2019-12-17 16:56:28 +01:00
Benno Schulenberg 594ef2225f justify: distinguish between tabs and spaces when comparing indentation
That is: two consecutive lines are considered to belong to separate
paragraphs when the smallest indentation of those two lines is not
character-by-character identical with the corresponding piece of
indentation of the other line.

In other words: if one line is indented with spaces, and a consecutive
line is indented by the same distance but with tabs, they are taken to
belong to different paragraphs: a justification will not merge them.

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

Bug existed since version 2.9.8, commit 432a7d77.
2019-12-17 12:23:55 +01:00
Benno Schulenberg 9631e858f2 display: don't color the space that separates line numbers from text
Go back to how line numbers were colored in versions 2.7.1 to 4.3 --
coloring the space (when a background color is used) was unintented.

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

Bug existed since version 4.4, commit 699cacf7.
2019-12-16 19:23:08 +01:00
Benno Schulenberg 413b9cb774 tweaks: rename a function, to get rid of a useless suffix 2019-12-15 19:47:05 +01:00
Benno Schulenberg d3a8d81afb tweaks: rename a function, to get out of the way for another rename 2019-12-15 19:40:22 +01:00
Benno Schulenberg e16026eacd linter: beep when trying to go beyond first or last message 2019-12-15 16:15:54 +01:00
Benno Schulenberg 90f18af8bd tweaks: reshuffle two declarations, for compactness 2019-12-15 15:30:48 +01:00
Benno Schulenberg 011e8de480 rcfile: demand that function 'exit' is bound in the file browser
For symmetry with the help viewer.

Even though the user could still exit with the bare Q, E, or X keys,
these are not listed in the help text, so they don't really count.
2019-12-15 15:28:22 +01:00
Benno Schulenberg 4e8afb2877 tweaks: drop M-Space and ^Space from the browser's key list
The 'prevword' and 'nextword' functions do not exist in the browser.

The mistake was made in commit a8c13d79 from five years ago.
2019-12-13 19:29:15 +01:00
Benno Schulenberg c7ad5c8d86 tweaks: reshuffle an item, to avoid a lone 'else' 2019-12-13 19:06:39 +01:00
Benno Schulenberg 0b1a766964 rcfile: accept also function names and menu names only in lowercase 2019-12-13 19:03:38 +01:00
Benno Schulenberg a7e11495bd tweaks: move three functions to the file where they are used
Also move the corresponding two arrays.
2019-12-13 18:57:42 +01:00
Benno Schulenberg e3957ee5ee rcfile: accept only keywords in all lowercase, for speed of comparison
As was noted two months ago: nowhere in the manual does it say that
keywords are case-insensitive, and the manual shows all keywords in
lowercase, and all the examples are in lowercase too.  So... simply
expect keywords to be in all lowercase.
2019-12-12 19:18:56 +01:00
Benno Schulenberg 2a73b4a050 tweaks: reshuffle a fragment of code, for efficiency
First comparing each keystring that starts with "^" against "^Space"
was a waste of time when only one out of fifty such strings actually
is "^Space".
2019-12-12 19:00:52 +01:00
Benno Schulenberg ef7c78910c tweaks: reshuffle a few lines, for brevity or speed or consistency
Also, don't compare case-insensitively where it is not needed.
2019-12-12 12:34:56 +01:00
Benno Schulenberg 772f1029e5 tweaks: avoid using strlen() where it is not needed 2019-12-12 12:14:38 +01:00
Benno Schulenberg 3251a216cd tweaks: unwrap a few lines, and move some strings to among their peers 2019-12-12 11:41:04 +01:00
Benno Schulenberg 76d90617cc build: avoid three compiler warnings when using gcc-9.2 or newer
This addresses https://savannah.gnu.org/bugs/?57360.
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-08 11:27:06 +01:00
Benno Schulenberg f516cddce7 build: fix compilation on macOS, where 'st_mtim' is unknown
This fixes https://savannah.gnu.org/bugs/?57367.
Reported-by: Bo Anderson <bo@toxicflames.co.uk>
Tested-by: Bo Anderson <bo@toxicflames.co.uk>
2019-12-06 12:19:32 +01:00
Benno Schulenberg a921bdadbf tweaks: remove a stray space
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-05 11:23:47 +01:00
Benno Schulenberg 0271e4a187 input: make <Tab> indent only when mark and cursor are on different lines
It allows entering a TAB character at the cursor position while the
mark is on the same line as the cursor, as some users sometimes do.

This refines the feature that was added in version 2.9.2, and makes
it behave like in the Gedit and Kate editors, for example.

This addresses https://savannah.gnu.org/bugs/?57357.
Reported-by: Sébastien Desreux <seb@h-k.fr>
2019-12-04 17:29:40 +01:00
Benno Schulenberg e484918ef2 tweaks: reshuffle a few lines, for symmetry with the preceding function 2019-12-01 17:04:15 +01:00
Benno Schulenberg ec569b4bd0 tweaks: rename a variable, to be a bit more fitting 2019-11-27 11:58:40 +01:00
Benno Schulenberg 38743b0016 tweaks: reshuffle an 'if' to avoid a negation, and improve a comment 2019-11-27 11:56:35 +01:00
Benno Schulenberg 68c3aaf2df softwrap: when switching to another buffer, re-align the starting column
When we switch to another buffer, the window may have been resized
since we were last in this buffer, so make sure that 'firstcolumn'
gets a fitting value.

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

Bug existed since version 2.8.0, since the softwrap overhaul.
2019-11-27 11:49:09 +01:00
Benno Schulenberg 2a97cb9f41 bindings: allow to rebind ^/, even though it is synonymous with ^_
This fixes https://savannah.gnu.org/bugs/?57302.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>
2019-11-26 19:25:24 +01:00
Benno Schulenberg af8ffa8c94 tweaks: silence a warning when configured with --enable-tiny 2019-11-25 19:21:03 +01:00
Benno Schulenberg 3ffefbfddc build: fix compilation for --enable-tiny --enable-histories 2019-11-25 19:17:41 +01:00
Benno Schulenberg 4d77e0adbb speller: prefer 'hunspell' over 'spell', because it can handle UTF-8
Also, 'hunspell' is sensitive to the 'LANG' environment variable,
so that spell checking will take place for the language that the
user is using, instead of always for English.  (This is a behavior
change, and some people may not like it, expecting the spell check
to occur always for English, but... we'll see.)
2019-11-25 16:57:04 +01:00
Benno Schulenberg 576502a5c5 speller: when 'spell' is not found, try running 'hunspell -l' instead
This increases the chances that spell checking will work out of the box,
without any extra installing or configuration.

This addresses https://savannah.gnu.org/bugs/?57296.
2019-11-24 12:12:38 +01:00
Benno Schulenberg ec9a11c761 display: do refresh the edit window when exiting from the help viewer
There are several cases (searching, replacing, spell checking, ...)
where exiting from the help viewer does NOT return the user to the
editing of the buffer.

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

Bug existed since version 4.3, commit 5817e83e.
2019-11-23 20:22:31 +01:00
Benno Schulenberg 1c63bf0e38 bindings: the 'all' keyword should include the browser menu always
Also for the "universal" functions (like cursor movement) and the
special 'implant' function, the 'all' keyword should include the
browser menu.

This fully fixes https://savannah.gnu.org/bugs/?57280.

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 13:21:20 +01:00
Benno Schulenberg 4aa1678f3b bindings: the 'all' keyword should encompass the browser menu too
This fixes https://savannah.gnu.org/bugs/?57280.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 12:44:28 +01:00
Benno Schulenberg c60d3bbb97 tweaks: don't do in the parent something that only the child needs 2019-11-17 08:20:32 +01:00
Benno Schulenberg 90d4b51837 tweaks: group the closing of two descriptors, and reword two comments 2019-11-17 08:15:52 +01:00
Benno Schulenberg 9151abcd45 tweaks: avoid setting and resetting a variable when there is no need 2019-10-28 10:28:52 +01:00
Benno Schulenberg 432388b23e tweaks: add two translator hints
And unmark two identical strings, to cause the marked ones to sit
next to each other in the POT file.
2019-10-27 16:30:50 +01:00
Benno Schulenberg bad618e537 tweaks: harmonize a message with another 2019-10-27 16:19:45 +01:00
Benno Schulenberg 7ae305fdc0 tweaks: group the closing of descriptors together, for compactness 2019-10-27 10:40:09 +01:00
Benno Schulenberg 7d4f279c04 tweaks: close the unused reading ends of two more output pipes
It is done for 'spell', so do it also for 'sort' and 'uniq'.
2019-10-27 10:34:12 +01:00
Benno Schulenberg f230c46e5e tweaks: drop the unneeded closing of descriptors when exiting anyway
Also, when something goes wrong in the later stages of the pipeline,
the error code would try to close descriptors that are already closed,
which is not right.  So, just let exit() handle any file descriptors
that are still open.
2019-10-27 10:25:37 +01:00
Benno Schulenberg bc5a225678 tweaks: improve some comments, and trim some repetitive ones 2019-10-27 10:10:03 +01:00
Benno Schulenberg 493b334ebb tweaks: mark two strings for translation
The marking was accidentally lost two weeks ago in commit d12191db.
2019-10-26 17:09:00 +02:00
Benno Schulenberg 7d54207627 tweaks: be explicit about which program complained 2019-10-26 12:04:10 +02:00
Benno Schulenberg 458933f09e tweaks: elide an unneeded and leaky function 2019-10-26 12:01:23 +02:00
Benno Schulenberg 2b49a19793 linter: report it as an error when running the linting program fails
When something goes wrong, nano should beep and the status bar should
use the error color (red by default).

This fixes https://savannah.gnu.org/bugs/?57116.
2019-10-26 11:52:53 +02:00
Benno Schulenberg fc716156a4 tweaks: correct a comment, and retype a variable 2019-10-26 11:18:38 +02:00
Benno Schulenberg 2b9f06194f formatter: don't let output from the program pollute the screen
Run the formatting program outside of curses mode, so that any output
(complaints) that it produces will be on the terminal after exiting
from nano -- at least on a terminal emulator, not on a Linux VT.

This also allows the formatter to be an interactive program.

The disadvantage is that the screen flickers when typing M-F.

This fixes https://savannah.gnu.org/bugs/?57104.
2019-10-25 19:23:24 +02:00
Benno Schulenberg 631defb8b2 tweaks: reword an undo/redo string that was overlooked during the rename 2019-10-25 19:21:17 +02:00
Benno Schulenberg a6dae403e6 formatter: accept the formatted result also upon a nonzero exit status
For a nonzero exit status of the formatting program, report on the
status bar that the program "complained", but read in the (probably)
reformatted text anyway -- it can be easily undone with M-U.  Only
report failure when the intended program could not be run.

This fixes https://savannah.gnu.org/bugs/?57105.
2019-10-25 17:45:52 +02:00
Benno Schulenberg 4281b6becb commands: rename 'fixer' to 'formatter', to be less misleading
The word "fixer" sounds too much as if the command would be able
to fix mistakes or correct errors.  Especially when seen next to
"linter", it sounds as if one does a syntax check and the other
fixes the found mistakes.  (Although the command might in theory
be used for this, it is not its intended purpose.)
2019-10-25 17:24:28 +02:00
Benno Schulenberg 3c695664ec tweaks: elide a function call for the plain ASCII case
When dealing with a plain, seven-bit ASCII character, don't bother
calling is_cntrl_mbchar() but determine directly whether it is a
control character.  Also reshuffle things so that we don't compare
charlen == 1 when we already know it is 1.
2019-10-21 18:52:44 +02:00
Benno Schulenberg 8a7634f070 tweaks: rename two parameters plus a variable, to match others
Also improve a comment and normalize an indentation.
2019-10-21 13:02:17 +02:00
Benno Schulenberg fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg c2d8641f01 chars: add a faster version of the character-parsing function
It elides a parameter that is always NULL, and elides two ifs
that always take the same path.
2019-10-21 12:24:23 +02:00
Benno Schulenberg 95ae124891 history: don't wait when there is something wrong with the history files
Do not wait for the user to press a key when there is some problem
with any of the history files.  Just start and indicate the problem
on the status bar.  The precise error message is stored and will be
shown on the terminal when exiting from nano.

This addresses https://savannah.gnu.org/bugs/?56524.
2019-10-20 14:30:04 +02:00
Benno Schulenberg 1a8646393a tweaks: condense a fragment of code by making use of a helper function
(It copies a byte too many, which then gets overwritten in the next
statement, but this is not speed-critical code.)
2019-10-20 09:45:58 +02:00
Benno Schulenberg 054559dc93 tweaks: rename three variables, to be more descriptive 2019-10-20 09:45:58 +02:00
Benno Schulenberg fdeab9b4c9 tweaks: order two functions more sensibly 2019-10-20 09:45:58 +02:00
Benno Schulenberg f26c121ca9 tweaks: adjust two comments, to better fit the actual functions 2019-10-20 09:45:58 +02:00
Benno Schulenberg 17c16a4bf5 tweaks: rename a function and elide its first parameter 2019-10-20 09:45:58 +02:00
Benno Schulenberg 46566572d6 utils: don't accept NULL for the string to be copied
This should not occur, so crash when it does happen.
2019-10-20 09:45:58 +02:00
Benno Schulenberg b4a5fac744 tweaks: use a literal NULL instead of a variable that is NULL
Now all calls of mallocstrncpy() have NULL as the first parameter
(apart from one call in utils.c, but that can be changed), so the
function can be simplified.
2019-10-20 09:45:58 +02:00
Benno Schulenberg f816da413a tweaks: elide a variable that is the same as another 2019-10-18 17:12:51 +02:00
Benno Schulenberg 3a0ac428ba tweaks: remove a redundant check for an existing emergency file
This case is caught (by O_EXCL) later on, at the appropriate moment:
when the file is created.

Also, this removes a superfluous lstat() for each temporary file.
2019-10-18 17:04:55 +02:00
Benno Schulenberg 97ab28a164 tweaks: exclude two fragments of code from the tiny version
Also improve a comment, and recorrect an indentation.
2019-10-18 14:25:55 +02:00
Benno Schulenberg ccb739dd7d tweaks: don't wrap calls of statusline() that slightly overshoot 80 cols 2019-10-18 14:04:15 +02:00
Benno Schulenberg 1082f2adec files: don't mention the name of the temp file when reading goes wrong
When writing a temp file goes wrong, its name is not mentioned either.
2019-10-18 13:38:20 +02:00
Benno Schulenberg 042b8394a0 tweaks: use a simpler positive/negative check for after copy_file() 2019-10-18 13:25:38 +02:00
Benno Schulenberg f2d6e6fa5e tweaks: check the return value of copy_file() also after its other uses 2019-10-18 12:37:39 +02:00
Benno Schulenberg 5390f96900 files: distinguish between read error and write error when prepending
This fixes https://savannah.gnu.org/bugs/?57066.

Bug existed in this form since version 2.4.3 -- in older versions
it segfaulted.
2019-10-18 12:15:14 +02:00
Benno Schulenberg 50ed18be17 tweaks: move a call of umask() closer to where it is relevant 2019-10-17 17:29:11 +02:00
Benno Schulenberg a6365707c0 tweaks: remove the superfluous closing of a file descriptor
The file itself is closed three lines earlier; this also closes the
corresponding descriptor.
2019-10-17 16:43:07 +02:00
Benno Schulenberg 6fad6a17da tweaks: rename a variable, to be distinct and visible 2019-10-17 12:17:09 +02:00
Benno Schulenberg eb757e7c5b tweaks: simplify the opening of files when prepending
There is no need for a file descriptor: all reading and writing
is done on streams.
2019-10-17 12:12:07 +02:00
Benno Schulenberg b554606047 tweaks: add a local variable, for clarity, to not preuse another one 2019-10-17 11:49:21 +02:00
Benno Schulenberg e915fb1650 tweaks: adjust the indentation after the previous change, and another 2019-10-17 11:45:03 +02:00
Benno Schulenberg 4e40ec057e tweaks: elide an unneeded check when making a backup
When making a backup, we can be certain that the relevant file
is not a temporary file, so 'stream' will necessarily be NULL.
2019-10-17 11:45:03 +02:00
Benno Schulenberg bd0026be86 tweaks: elide another two calls of umask(), and rename two variables 2019-10-17 11:43:42 +02:00
Benno Schulenberg a1bef0e953 tweaks: avoid three unneeded calls of umask() in the normal case 2019-10-16 19:17:42 +02:00
Benno Schulenberg f5693d4151 tweaks: elide a duplicate opening of the existing file when prepending 2019-10-16 17:40:52 +02:00
Benno Schulenberg e3807f00a2 tweaks: rename two variables, and add a third, for more contrast 2019-10-16 17:16:48 +02:00
Benno Schulenberg 022cc084a7 files: when opening a file for copying, it should NOT be created
Weird bug.  The first occurrence is probably never hit because the
existing file has been tentatively opened fourteen lines earlier,
but that looks superfluous: double work.  And the second occurrence
will not be hit because the temp file is unlikely to have disappeared.
2019-10-16 16:27:23 +02:00
Benno Schulenberg 0f98466e2f tweaks: adjust the indentation after the previous change
Also, don't bother assigning the stream pointer of the existing file
to variable 'f', as it gets overwritten right away by the pointer of
the temp file.
2019-10-16 16:05:40 +02:00
Benno Schulenberg 40c067133a tweaks: remove two superfluous conditions when prepending
When prepending, we cannot be writing to a temp file,
so 'stream' (and thus 'f') will necessarily be NULL.
2019-10-16 15:47:35 +02:00
Benno Schulenberg 36270748dc tweaks: condense or improve some comments 2019-10-16 13:47:30 +02:00
Benno Schulenberg 1894c81412 tweaks: rename two parameters, for contrast and to match others 2019-10-16 13:07:41 +02:00
Benno Schulenberg e917ef0105 tweaks: die on an impossible condition -- to be removed later 2019-10-16 12:27:27 +02:00
Benno Schulenberg 3347682fd0 tweaks: remove a pointless updating of the title bar
A possible change in filename won't be pushed to the screen until a
doupdate() is done, and that won't happen until nano is waiting for
a keystroke again.  So... just let it be.
2019-10-16 12:22:39 +02:00
Benno Schulenberg 7c5b104859 tweaks: rename three variables, to match others elsewhere 2019-10-16 11:46:22 +02:00
Benno Schulenberg 3b9a24a7ca tweaks: rename a local variable, to not shadow another 2019-10-16 11:11:19 +02:00
Benno Schulenberg 7d3290fb91 tweaks: rename three variables, to be consistent with other linestructs 2019-10-16 11:04:26 +02:00
Benno Schulenberg df0ae2ace5 tweaks: reshuffle a few declarations, and reduce the scope of one 2019-10-16 10:48:14 +02:00
Benno Schulenberg bc91af2e3c tweaks: pass an empty string as an answer instead of a NULL pointer
Also, rename a parameter, to be more distinct and to avoid an abbrev.
2019-10-15 13:39:57 +02:00
Benno Schulenberg 48b94d71c7 tweaks: pass an empty string for copying instead of a non-existent one 2019-10-15 11:49:07 +02:00
Benno Schulenberg f14be47878 tweaks: move two functions to after the one that they make use of 2019-10-15 11:23:09 +02:00
Benno Schulenberg c51f5f4bff docs: mention that the 'nopauses' option is obsolete 2019-10-15 11:23:05 +02:00
Benno Schulenberg 7f8851caa8 statusbar: show only the first error message, with dots to indicate more
The old default behavior of showing the first three messages with a
long pause after each of them was annoying, and the final "Further
messages were suppressed" hid the relevant information.  So, when
there is more than one error message, just pause very briefly and
then add trailing dots to the first message.

This makes the 'nopauses' option a no-op.

This addresses https://savannah.gnu.org/bugs/?57048.
2019-10-15 11:17:20 +02:00
Benno Schulenberg d8c03cd4cd tweaks: elide a variable, and add a condition to elide an assignment 2019-10-14 10:28:45 +02:00
Benno Schulenberg 1536a76ced tweaks: normalize the indentation after the previous change 2019-10-14 10:28:45 +02:00
Benno Schulenberg d2fb371fe2 feedback: say it when spell check or manipulation did not change anything 2019-10-14 10:28:45 +02:00
Benno Schulenberg 34170611d3 restored feature: a per-syntax 'fixer' command that processes the buffer
The command can be used to run some kind of formatter or corrector or
arranging tool on the buffer.  By default the command is bound to M-F.
The formatter/corrector/arranging program must be non-interactive.

This addresses https://savannah.gnu.org/bugs/?55365,
and addresses https://savannah.gnu.org/bugs/?54651.
2019-10-14 10:28:45 +02:00
Benno Schulenberg 23c36ba667 tweaks: remove two pointless re-inclusion guards
The nano.h file is included only by proto.h, and the proto.h file is
included just once by each src/*.c file.  The include guards for these
two header files serve no purpose.

(Include guards are useful when you have bunches of header files
and several of them include others from amongst themselves.)
2019-10-13 19:14:27 +02:00
Benno Schulenberg 31d5cb1118 build: slightly speed up the compilation of the tiny version
Don't include header files when they won't actually be needed.

(Also, remove a superfluous #ifdef.)
2019-10-13 18:55:49 +02:00
Benno Schulenberg f551c07e7a tweaks: add some "fall-through" comments, and reshuffle some breaks 2019-10-13 17:35:57 +02:00
Benno Schulenberg 2656f543f4 undo: don't try to copy a string that doesn't exist
This fixes https://savannah.gnu.org/bugs/?57051.

Bug existed since commit d256d0cb from earlier today.
2019-10-13 17:31:53 +02:00
Benno Schulenberg ba79602281 tweaks: condense two comments, and rename two parameters
Also use 'while' instead of 'for'.
2019-10-13 16:45:02 +02:00
Benno Schulenberg 094758be15 tweaks: reshuffle a fragment of code into two alternatives 2019-10-13 16:11:15 +02:00
Benno Schulenberg 06bbc70d4a tweaks: use a string-copy function that checks for out-of-memory 2019-10-13 12:38:46 +02:00
Benno Schulenberg d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg ab6635c3a6 tweaks: use the given string instead of the found match, for clarity 2019-10-13 11:52:09 +02:00
Benno Schulenberg 416ad4c5fd tweaks: use a better variable name for the argument of an option 2019-10-13 11:46:22 +02:00
Benno Schulenberg 0374708597 undo: put the cursor back on the original row for a full-buffer operation
When an operation that replaces the entire buffer is undone, the
position of the viewport is lost.  Compensate for this by storing
the row of the cursor in the undo item, and, after executing the
undo item, arranging the viewport so that the cursor is back on
the original row -- the row where the operation was invoked.

This fixes https://savannah.gnu.org/bugs/?57039.
2019-10-12 11:20:41 +02:00
Benno Schulenberg 101987f5c6 build: fix compilation when configured with --disable-color 2019-10-12 11:20:19 +02:00
Benno Schulenberg ad451933c6 tweaks: rename a function and add a parameter, so it becomes more general
Also adjust the comments and rename three variables.
2019-10-10 08:28:08 +02:00
Benno Schulenberg 222e67300e tweaks: reshuffle some declarations, and rename a variable 2019-10-10 08:23:16 +02:00
Benno Schulenberg d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg 785efc2087 tweaks: make a function do a check so its calls don't need to 2019-10-09 18:58:30 +02:00
Benno Schulenberg 557ad827f9 tweaks: condense two comments, and rewrap a line 2019-10-09 14:49:42 +02:00
Benno Schulenberg 600f81cf98 tweaks: rename three variables, and reshuffle some lines 2019-10-09 14:20:29 +02:00
Benno Schulenberg 56d98052d1 tweaks: adjust the indentation after the previous change 2019-10-08 11:51:47 +02:00
Benno Schulenberg 265d3245af rcfile: process extensions to file-matching commands straightaway
When 'extendsyntax' is used with a 'header' or 'magic' command, it
must be processed immediately.  It is pointless to store the command,
because when then it is processed (when the syntax gets used), it is
too late to have any effect.

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

With-help-from: Brand Huntsman <alpha@qzx.com>

Bug existed since version 4.3, commit cba9d8d0.
2019-10-08 11:37:02 +02:00
Benno Schulenberg 53d4224be9 cutting: do nothing when trying to chop a word leftward at start of file
Instead of marking the buffer as modified, provide the feedback that
"nothing was cut", like when trying to chop a word rightward at the
end of the buffer.

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

Bug existed since version 4.4, commit 4314b8de.
2019-10-07 17:24:18 +02:00
Benno Schulenberg f813fd0f4d rcfile: allow binding also F17...F24
For historical reasons the rebinding code allows binding F13...F16,
which on most terminals are typable with Shift plus F1...F4.  But,
at least on an Xfce Terminal, Shift plus F1...F12 produce F13...F24.
On a Linux console, Shift plus F1...F8 produce F13...F20.  So: allow
to bind the full shifted F13...F24 range.  It costs no extra code
and makes things more rounded.
2019-10-07 16:23:40 +02:00
Benno Schulenberg ff0e01a69e bindings: don't hard-bind ^H in the help viewer or the file browser
Hard-binding the ^H control code prevents the user from rebinding
the keystroke.

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

Bug existed since version 4.0, commit 72a49dbb.
2019-10-05 12:43:46 +02:00
Benno Schulenberg b480e7fc9c tweaks: remove some timing code that has served its purpose 2019-10-03 19:00:50 +02:00
Benno Schulenberg 3e33d1eba6 tweaks: rewrap a line, reshuffle a declaration, and improve some comments 2019-10-03 17:22:55 +02:00
Benno Schulenberg 31ff7ead73 tweaks: move a function to before its callers and next to its kind
Also, improve the indentation of two random lines.
2019-10-03 11:24:01 +02:00
Benno Schulenberg 5398d986ef tweaks: speed up determining the width of plain ASCII characters 2019-10-03 11:09:21 +02:00
Benno Schulenberg b02dccc51f tweaks: elide a function from a non-UTF8 build
In a non-UTF8 build, mbwidth() returns always 1, so it is pointless
to call that function and compare its result to zero then.

Also, don't bother special-casing the function for a non-UTF8 locale.
2019-10-03 10:48:10 +02:00
Benno Schulenberg 3158133edd tweaks: rename three variables, for contrast and more sense 2019-10-03 10:12:30 +02:00
Benno Schulenberg acf50ae26d tweaks: improve a handful of comments, and reduce the needed padding
Reshuffle a few struct elements so they will require less padding.
2019-10-02 19:33:03 +02:00
Benno Schulenberg 01b840890d tweaks: rename another type, again to better fit the general pattern 2019-10-02 19:32:41 +02:00
Benno Schulenberg 9bd60e7d5d tweaks: frob a few comments 2019-10-02 17:46:20 +02:00
Benno Schulenberg c5e46101b1 tweaks: reshuffle some lines, to elide an unneeded assignment 2019-10-02 17:39:45 +02:00
Benno Schulenberg 53b77cb4c6 tweaks: rename another type, to also better fit the general pattern 2019-10-02 17:18:51 +02:00
Benno Schulenberg cc4ce8d83b tweaks: rename a type, to better fit the general pattern 2019-10-02 17:09:22 +02:00
Benno Schulenberg 23c8ef70aa tweaks: reshuffle some lines, to have the same order as elsewhere 2019-10-02 15:20:49 +02:00
Benno Schulenberg 2a4d338d97 tweaks: reshuffle a fragment, to group some toggles together 2019-10-02 15:07:04 +02:00
Benno Schulenberg 9c202198a3 tweaks: simplify a calculation, as done elsewhere 2019-10-01 15:03:40 +02:00
Benno Schulenberg c8dc67717b tweaks: mark as 'const' a parameter that takes fixed strings [coverity] 2019-10-01 15:02:08 +02:00
Benno Schulenberg 4df2f81295 tweaks: avoid recomputing a maximum value every time round the loop 2019-10-01 13:28:50 +02:00
Benno Schulenberg 78def852d1 mouse: make the clickable width of menu items more consistent
When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.
2019-10-01 12:46:31 +02:00
Benno Schulenberg a4933873c9 tweaks: avoid leaking memory when finding an invalid string [coverity] 2019-09-30 19:42:27 +02:00
Benno Schulenberg 1861052234 tweaks: avoid a comparison between signed and unsigned [coverity] 2019-09-30 19:30:54 +02:00
Benno Schulenberg 2307b31887 tweaks: use 'void' in prototypes of parameterless functions [coverity] 2019-09-30 19:06:25 +02:00
Benno Schulenberg e0d9b7a8af tweaks: add a translator hint, and correct two others 2019-09-29 15:08:57 +02:00
Benno Schulenberg b3ace4d8f6 tweaks: don't burden all menus with something meant for the WriteOut menu
The first_sc_for() function is somewhat costly, so avoid calling it
when it is not necessary.

Most menus have either so many entries that unbinding some keys does
not reduce the number of shown entries, or they have so few entries
that each entry already has space enough and will not profit from
having more room available.  But the WriteOut menu is an edge case.
Most translators don't use --tempfile and translate the key tags for
the WriteOut menu making use of all 17 positions that are available
for each of them.  This makes that when --tempfile is used, some of
those tags get truncated.  This is not so bad, because --tempfile is
normally not used.  But when it isn't used (when the discardbuffer
function isn't bound), the WriteOut menu should make full use of the
available width to avoid truncating any translated tags.
2019-09-29 13:27:03 +02:00
Benno Schulenberg 5103bfe6b8 bindings: add a dedicated keycode for <Tab> for when a region is marked
In this way the keycode cannot be unbound from the 'indent' function,
so pressing <Tab> on a marked region will always indent the region.

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

Bug existed since the "tabbing" of a marked region was introduced,
in version 2.9.2, commit 09958ebd.
2019-09-28 12:39:42 +02:00
Benno Schulenberg cfd17f5722 tweaks: speed up the counting of the menu entries to be shown
Instead of first counting all available entries and then capping it
at MAIN_VISIBLE, simply stop counting when MAIN_VISIBLE is reached.
2019-09-28 12:03:02 +02:00
Benno Schulenberg 43235c2f16 tweaks: rename a function, to be a bit more fitting 2019-09-27 19:07:25 +02:00
Benno Schulenberg b14ad451a9 tweaks: rename two variables, away from single letters 2019-09-27 18:53:44 +02:00
Benno Schulenberg cd00d0975e tweaks: move a fragment of common code into the appropriate function 2019-09-27 18:49:39 +02:00
Benno Schulenberg 40f6dbc34e tweaks: move two functions to after the ones that they call 2019-09-27 18:41:22 +02:00
Benno Schulenberg a9fb56a8c9 tweaks: move a function to a better file, to be amongst its kind 2019-09-27 17:43:28 +02:00
Benno Schulenberg 3644d51b97 new feature: a 'tabgives' command to define what the Tab key produces
The 'tabgives' command is syntax-specific and should be followed by a
string containing the character(s) that a single press of the <Tab> key
should produce -- most likely a single TAB or a small bunch of spaces,
but any string is allowed.  This overrides the 'tabstospaces' option.

When one wants to make sure <Tab> inserts always four spaces and never
a TAB when editing a Python file, one could add to one's nanorc:

  extendsyntax python tabgives "    "

where there are four spaces between the quotes.  And when one wants
to ensure, when editing a Makefile, that <Tab> always inserts a TAB
and never spaces, independent of what tabstospaces is set to, one
could add to one's nanorc:

  extendsyntax makefile tabgives "	"

where there is a literal TAB character between the quotes.

This fulfills https://savannah.gnu.org/bugs/?53661,
Requested-by: Andrew Pennebaker <andrew.pennebaker@gmail.com>
And addresses https://savannah.gnu.org/bugs/?54760.
Requested-by: Henry van Megen <hvanmegen@gmail.com>
And addresses part of https://savannah.gnu.org/bugs/?54775.
Requested-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
2019-09-25 19:35:07 +02:00
Benno Schulenberg 591d3170aa tweaks: add some translator hints, be more precise on permissible length 2019-09-24 17:15:42 +02:00
Benno Schulenberg b5eda7f812 tweaks: reshuffle two fragments, to group things better 2019-09-23 13:03:52 +02:00
Benno Schulenberg 4d44b03fc8 tweaks: rename a variable, to be more compact 2019-09-22 17:38:22 +02:00
Benno Schulenberg 2d16c27820 tweaks: add two hints for translators, to try and help avoid mistakes 2019-09-22 17:31:27 +02:00
Benno Schulenberg ad65b79ac7 usage: mark the -J/--guidestripe option plus argument as translatable
This fixes https://savannah.gnu.org/bugs/?56930.

Bug existed since the vertical guiding bar was introduced,
in version 4.0, commit 66c6eb51.
2019-09-21 19:50:55 +02:00
Benno Schulenberg fe5bd8cdef usage: properly align --help output also when it has accented characters
As printf() is not UTF8-aware, we have to determine ourselves how many
columns each short and long flag take up and add the required number of
spaces (not tabs, because their size is not fixed) to fill things up.

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

Bug existed since version 4.3, commit 2f169107.
2019-09-21 19:31:48 +02:00
Benno Schulenberg c848ec3d53 tweaks: elide two multiplications with something that is always 1 2019-09-18 15:25:42 +02:00
Benno Schulenberg ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +02:00
Benno Schulenberg 48124fdba4 tweaks: use a more effecient way to skip storing an empty file name
Position history refers only to actual files, so when the filename
is blank...  there is nothing that needs to be remembered.
2019-09-18 14:18:48 +02:00
Benno Schulenberg ebd9eb346d tweaks: improve a bunch of comments, and reshuffle some declarations 2019-09-17 17:38:42 +02:00
Benno Schulenberg 413116e1b5 tweaks: rename another variable, for a better fit 2019-09-17 16:46:11 +02:00
Benno Schulenberg 69a3d39bc4 tweaks: rename three variables, for more contrast 2019-09-17 16:42:53 +02:00
Benno Schulenberg f081fa3047 tweaks: rename two variables, to better describe what they contain
The 'tilded' variable is used for two purposes: a user's home directory,
and an intermediate user name.
2019-09-17 14:26:09 +02:00
Benno Schulenberg 4383b01b9b tweaks: adjust indentation after previous change, reshuffle declarations 2019-09-17 14:11:45 +02:00
Benno Schulenberg b901a20a06 tweaks: use an early return when there is no tilde
Also improve a comment, and use a 'while' instead of a 'for'.
2019-09-17 14:09:40 +02:00
Benno Schulenberg d6e05d8376 tweaks: simplify the determination of a canonical path
Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-09-17 13:32:15 +02:00
Benno Schulenberg 21e307e820 tweaks: rename a variable, normalize a comment, and reshuffle a free() 2019-09-16 17:25:47 +02:00
Benno Schulenberg dbcf4f0cbe color: don't concatenate an absolute path with the working directory
When the user specified an absolute path... it is NOT relative to the
current working directory.

This fixes https://savannah.gnu.org/bugs/?56902.
Reported-by: Brand Huntsman <alpha@qzx.com>

Bug existed since version 2.4.2, commit ec8d51be.
2019-09-16 17:12:25 +02:00
Benno Schulenberg 7b88557ef5 tweaks: meld two calls of free() into a single one, to elide an 'else' 2019-09-16 16:55:03 +02:00
Benno Schulenberg ba5b85baf0 tweaks: rename three variables, to better indicate what they hold
They hold not a terminal but flags, settings, state.
2019-09-06 19:40:38 +02:00
Benno Schulenberg 9f95fa9ce5 tweaks: reshuffle a line, to group things better 2019-09-06 19:25:43 +02:00
Brand Huntsman 8853bc448d search: accept a match at start of file when searching from command line
For a forward search from the command line, pass FALSE to 'skipone'
so that an occurrence at the head of the file is not skipped over.

This fixes https://savannah.gnu.org/bugs/?56845.
Reported-by: Derek Wolfe <dwwolfe1@gmail.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-09-02 09:05:50 +02:00
Benno Schulenberg 15148a5e6d search: after search-at-startup, store the column (for vertical movement)
This fixes https://savannah.gnu.org/bugs/?56846.
2019-09-01 16:15:15 +02:00
Benno Schulenberg 5c399dfc6e build: exclude the search-at-startup feature from the tiny version 2019-08-18 13:03:11 +02:00
Benno Schulenberg ed4b6486a1 search: don't wipe the status bar at startup when there was an error 2019-08-18 12:59:23 +02:00
Brand Huntsman 2326bf695e search: accept toggles for case and regex when searching at startup
Allow the user to specify that the search string should be interpreted
case-sensitively and/or as a regular expression by preceding the search
indicator (/ or ?) with c and/or r.  Or to switch these things off by
using C and/or R.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-08-18 12:59:04 +02:00
Benno Schulenberg a9dd73fb16 new feature: allow specifying a search string to "jump to" at startup
The string to "jump to" is specified with +/ for a forward search
(from the top of the file), or with +? for a backward search (from
the bottom of the file).

This fulfills https://savannah.gnu.org/bugs/?54535.
Requested-by: Derek Wolfe <dwwolfe1@gmail.com>

With-help-from: Brand Huntsman <alpha@qzx.com>
2019-08-18 11:16:03 +02:00
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 f7d5a82a5d search: wipe the status bar before searching again (M-W / M-Q)
So that any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?56737.
2019-08-10 13:11:41 +02:00
Benno Schulenberg 63e04ac31e tweaks: make a function name unique, to not overlap with others 2019-08-09 19:34:03 +02:00
Benno Schulenberg 0c63b50fdc tweaks: move a general function to a better place 2019-08-09 19:24:30 +02:00
Benno Schulenberg 8fce33afe0 text: copy leading quote characters when automatic hard-wrapping occurs
When the user is typing a long text and --breaklonglines is in effect,
then any leading comment or quoting characters are automatically added
to each automatic new line.

This fulfills https://savannah.gnu.org/bugs/?56042.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2019-08-06 09:10:34 +02:00
Benno Schulenberg 4314b8ded3 display: blank the status bar on a successful cut or paste
But don't blank it when using the word-deletion functions.

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

Original-patch-by: Bill Hager <prog00@protonmail.com>
2019-08-03 19:32:54 +02:00
Benno Schulenberg a578d2706c copying: do not prevent M-6 from copying emptiness into the cutbuffer
The check mistakenly prevented the user from copying a region that
ended at EOF.  Removing the check also gives the user a way to clear
the cutbuffer (with M-A M-6 or ^6 M-6, for example).

This fixes https://savannah.gnu.org/bugs/?56563.
Reported-by: Liu Hao <lh_mouse@126.com>
2019-07-29 19:00:22 +02:00
Benno Schulenberg 44d38815cc display: clear the remainder of a row only when there actually is some
Make display_string() report back (via a global variable) whether the
just converted string has room to spare within the allotted span, so
that draw_row() can avoid trying to clear the remainder when there is
nothing to clear.

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

Bug existed since commit 699cacf7 from three days ago.
2019-06-28 20:45:47 +02:00
Benno Schulenberg b23a5d5b29 tweaks: rewrap two lines, and reshuffle some logic to make more sense 2019-06-26 19:44:51 +02:00
Benno Schulenberg b96cc8c212 tweaks: rename a parameter in three functions, to say what it points to 2019-06-26 19:44:51 +02:00
Benno Schulenberg 09ad0eb5f7 tweaks: rename a function, to suit better, and reshuffle its parameters 2019-06-26 19:44:51 +02:00
Benno Schulenberg 62ca113ed3 tweaks: reword and condense two comments, and correct another 2019-06-26 19:07:08 +02:00
Benno Schulenberg 5cfb74650d scrolling: don't overscroll when the edit window has just one row
If the edit window consists of a single row, then the do_down() call
has already brought the desired line or chunk into view -- no attempt
should then be made to scroll the screen further.

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

Bug existed since version 2.9.6, commit 0d9080a2.
2019-06-26 12:55:29 +02:00
Benno Schulenberg 8cd6aa0a32 display: when linenumbering, correctly spotlight text that spans two rows
This fixes https://savannah.gnu.org/bugs/?56552.

Bug existed since line numbers were introduced, in version 2.7.1.
2019-06-26 11:24:44 +02:00
Benno Schulenberg fcbe41942f tweaks: reshuffle an assignment, and trim some excessive blank lines 2019-06-26 10:18:32 +02:00
Benno Schulenberg 39e5b52734 tweaks: call the correct lighting function directly when softwrapping 2019-06-26 10:12:23 +02:00
Benno Schulenberg 70b347183b tweaks: condense some comments, and drop two unneeded initializations 2019-06-26 09:47:07 +02:00
Benno Schulenberg 699cacf7a4 display: don't clear a row beforehand -- just clear the remainder
It is a waste of time to first fully clear a row when right afterward
text will be written to it (for most of the row, on average).  So...
just clear the part of the row after the written text.  Curses has the
perfect function for this: clrtoeol().
2019-06-25 12:09:28 +02:00
Benno Schulenberg 23cb26c58f tweaks: improve a handful of comments 2019-06-25 11:34:04 +02:00
Benno Schulenberg 3422ec3419 browser: draw a bar of spaces only where needed -- for the selected item
The edit window has been fully cleared just before the list-drawing
loop has started, so there is no need to wipe anything.  Only for the
highlighting bar all its characters need to be drawn with the correct
attributes.
2019-06-25 11:25:03 +02:00
Benno Schulenberg 5f1d9af375 tweaks: drop two parameters that are no longer needed 2019-06-25 11:13:35 +02:00
Benno Schulenberg f3a441043d display: where needed, use slow blanking, but elsewhere do it much faster
Where the row needs to be filled with spaces with the attributes that
were set (title bar, prompt bar, and browser highlight), use printw().
But when the row needs to be actually cleared, use the much faster
clrtoeol().

This reduces the time needed to clear a full row with 95 percent.
2019-06-25 11:12:27 +02:00
Benno Schulenberg e6c629951f display: use a somewhat faster method to clear a row
On an 80-column terminal, using a single printw() instead of
a loop of addch() reduces the time taken with 13 percent.
2019-06-23 20:49:01 +02:00
Benno Schulenberg c06d5452f5 tweaks: move a call from two different places to a single place 2019-06-23 19:57:15 +02:00
Benno Schulenberg 1fcb9b99cf tweaks: move a function to before the first one that calls it 2019-06-23 12:29:17 +02:00
Benno Schulenberg d8c840692e tweaks: reshuffle an 'if' out of a function, and rename the function 2019-06-23 12:15:19 +02:00
Benno Schulenberg 8c7b6bd21a tweaks: when precalculating, allocate all the cache space upfront
Instead of doing it haphazardly while lines are getting categorized.
2019-06-23 11:57:27 +02:00
Benno Schulenberg 21d0755de5 tweaks: try the allocation of a multidata cache just once per line
It does not need to be allocated for each multiline regex separately.
2019-06-23 11:45:03 +02:00
Benno Schulenberg bbab9e2e62 tweaks: shorten two messages that translators tend to make too long 2019-06-19 19:34:19 +02:00
Benno Schulenberg 9ea1cd947c tweaks: add a translator hint, to clarify four short words 2019-06-19 19:14:47 +02:00
Benno Schulenberg 47068c3770 build: fix compilation when configured with --disable-color 2019-06-17 09:59:15 +02:00
Benno Schulenberg 345cf5accc files: don't close a newly-created buffer when it is the only one
This fixes https://savannah.gnu.org/bugs/?56504.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since commit 7e422402 from two weeks ago.
2019-06-16 19:12:52 +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 ce69d5be88 tweaks: condense two comments, and normalize the whitespace of a label 2019-06-12 11:10:27 +02:00
Benno Schulenberg 3da4240229 tweaks: rename a variable, to fit a little better 2019-06-12 11:03:03 +02:00
Benno Schulenberg 43caf7bb7b tweaks: avoid an unneeded, extra stat() for temporary files 2019-06-12 10:48:03 +02:00
Benno Schulenberg e8e30e5197 tweaks: elide an unneeded, duplicate stat() for the FIFO check 2019-06-12 10:34:53 +02:00
Benno Schulenberg 189de5ee78 files: suppress feedback when writing an emergency or temporary file
This fixes https://savannah.gnu.org/bugs/?56474.

Bug existed since commit 47770bd3 from two weeks ago.
2019-06-12 09:51:14 +02:00
Benno Schulenberg c57d040e99 tweaks: don't bother calling mblen() in a non-UTF-8 build
There is no need, because in non-UTF-8 encodings nano treats
each single byte as one character anyway.
2019-06-11 19:48:03 +02:00
Benno Schulenberg 0adb15c7a1 display: properly show all characters in a non-UTF-8 build
Also, don't use mblen() directly, to not get stuck when it returns -1,
which it will when running a non-UTF-8 build in a UTF-8 locale.

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

Bug existed since commit cd094822 from yesterday.
2019-06-11 19:07:34 +02:00
Benno Schulenberg 1e48df388e build: avoid a warning when using --disable-utf8 2019-06-11 14:24:30 +02:00
Benno Schulenberg d477775871 build: avoid a warning on FreeBSD, OpenBSD, and Alpine 2019-06-11 12:29:32 +02:00
Benno Schulenberg ed40fd8031 tweaks: reorder some code, to further optimize display_string() for ASCII
The majority of characters in the files that get edited with nano will
be single-byte printable ASCII characters, so their case should come
first in the main loop of display_string().
2019-06-11 12:08:28 +02:00
Benno Schulenberg 5c4b0b38f4 chars: redo the speedup for plain ASCII from three commits ago
It was lost in the elision of length_of_char() two commits ago.
2019-06-11 11:10:53 +02:00
Benno Schulenberg bd331b0198 tweaks: reshuffle some lines and frob some comments 2019-06-10 20:07:10 +02:00
Benno Schulenberg cd09482231 tweaks: elide a function that is an amalgam of three others
In addition, the function was used just once, had a weird return value,
and now some more code can be excluded from a non-UTF8 build.

Make use of the fact that any single-byte character always occupies
just one column, and call the costly mbtowc() and wcwidth() only for
characters that actually are multibyte.
2019-06-10 19:43:50 +02:00
Benno Schulenberg c5955d14ce chars: speed up the determination of length and width for plain ASCII 2019-06-10 17:22:41 +02:00
Benno Schulenberg 7d38379919 tweaks: rename two parameters, away from single letters 2019-06-10 12:36:16 +02:00
Benno Schulenberg 45bf18f8fe tweaks: rename three variables, to get rid of a suffix or an underscore
Also drop an unneeded cast.
2019-06-10 12:34:24 +02:00
Benno Schulenberg 787dca6724 tweaks: elide an unneeded variable 2019-06-10 12:06:12 +02:00
Benno Schulenberg 15e36956b5 tweaks: avoid parsing a character twice
Let mbtowc() do all the work, and thus also elide a variable.
2019-06-10 12:01:10 +02:00
Benno Schulenberg 967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg 1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg 3457039cee tweaks: rename a variable, to get out of the way of the next commit 2019-06-09 19:31:01 +02:00
Benno Schulenberg ca77254968 tweaks: use a slightly faster function where appropriate
Also, correct a call of move_mbright() to use the intended format.
2019-06-09 19:22:24 +02:00
Benno Schulenberg 710a600f22 chars: speed up case-insensitive searching by roughly one percent
It is less of a speedup than I was hoping for, though.
2019-06-09 19:13:25 +02:00
Benno Schulenberg 843eef65b8 tweaks: put some timing code back into the search function 2019-06-09 18:48:52 +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 aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg 71236e145d tweaks: rename two variables, away from a single letter
And adjust the indentation after the previous change.
2019-06-09 11:08:34 +02:00
Benno Schulenberg 7be76af418 tweaks: speed up the counting of characters in mbstrlen()
This function is used in get_totsize(), so speed is important.

There is no reason why the length of the string must limited to a
certain size -- that is just a leftover from the function merge in
commit ba2e6f43 from a year ago.
2019-06-09 11:04:52 +02:00
Benno Schulenberg fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Benno Schulenberg 33fea90bcd justify: remove "--" from the quoting regex, to avoid false paragraphs
The use of a double dash (for an option name or as sentence separator)
is too common to allow it to be seen always as a comment introducer.
Users of Lua and Postgres will have to redefine 'quotestr' themselves
if they want to be able to rewrap block comments with ^J.

The other characters that were added in commit c5a72103 (!, %, and ;)
are less problematic because they tend to be glued to the end of words,
so they are unlikely to appear at the start of a line.

This fixes https://savannah.gnu.org/bugs/?56462,
and fixes https://savannah.gnu.org/bugs/?56461.

Bug existed since version 4.0, commit c5a72103.
2019-06-08 16:47:08 +02:00
Benno Schulenberg f03c87c300 tweaks: squeeze excess spaces out of a line in situ
There is no need to make a copy of the line, because if there are some
bytes that are moved, they are always moved toward the left -- the line
can only shrink, never expand.
2019-06-08 16:17:59 +02:00
Benno Schulenberg 45b1a38b82 tweaks: factor out a fragment of code that is repeated three times 2019-06-08 14:17:41 +02:00
Benno Schulenberg c3bf17a801 tweaks: improve a handful of comments 2019-06-08 14:00:24 +02:00
Benno Schulenberg 8582e4a6b9 tweaks: don't bother keeping track of whether a squeezed line has shrunk
When squeezing excess spaces from a line has proved unsuccessful, we
have already copied all of its data, so it hardly makes a difference
whether we free the old or the new data.  Choose to free always the
old data, so that we can simplify things.
2019-06-08 14:00:03 +02:00
Benno Schulenberg 9b34d0a4fb tweaks: rename two variables, to be unique 2019-06-08 10:10:31 +02:00
Benno Schulenberg 26d16ab9d1 tweaks: rename a variable, to better suit its counterpart 2019-06-08 10:05:32 +02:00
Benno Schulenberg 6ca8518428 tweaks: make better use of two variables, and reshuffle two comments 2019-06-08 10:03:15 +02:00
Benno Schulenberg 8d4e171d3c tweaks: improve a couple of comments 2019-06-05 16:23:34 +02:00
Benno Schulenberg 6f1e5912a9 tweaks: stop allocating and freeing a holder struct for every cut/paste
This "holder" information is needed for every cut and paste and other
block operation.  Instead of allocating and freeing it for every such
operation, just have the six elements as static variables.  This saves
a little churn, and saves having to declare a type that is used just
once.  Plus, the access to these variables will be a little quicker.
2019-06-05 16:10:07 +02:00
Benno Schulenberg 28a6d9f300 tweaks: rename four elements of the holder struct, for more contrast 2019-06-05 15:32:50 +02:00
Benno Schulenberg f92606491c speller: when something goes wrong with 'sort', do not blame 'spell'
That is, check the exit status of 'sort' before the one of 'spell'.
2019-06-05 15:07:33 +02:00
Benno Schulenberg 260588af1e speller: be more concise and to the point when something goes wrong 2019-06-05 14:57:24 +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
Brand Huntsman fb10a94f35 startup: prevent a crash when no applicable syntax is found
This fixes https://savannah.gnu.org/bugs/?56434.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 12:42:24 +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 ea1016efdb feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
2019-06-03 13:38:21 +02:00
Benno Schulenberg f63fee79e3 tweaks: merge two functions, as the first is called just once 2019-06-01 11:14:21 +02:00
Benno Schulenberg 2003413989 tweaks: move a function to the file where it is used 2019-06-01 10:52:38 +02:00
Benno Schulenberg 9369af77ce tweaks: elide a function that is used just once 2019-06-01 10:43:50 +02:00
Benno Schulenberg 35d2bc6b38 build: fix compilation on another system
The <signal.h> header file is needed to define 'sig_atomic_t'.
(Don't know why on my main system it compiled fine without it.)
2019-05-31 20:53:00 +02:00
Benno Schulenberg b52d166afa tweaks: rename a type, to make more sense
The sphere, the holder, is everything *around* the partition;
it was confusing to call this holder type 'partition'.

Also correct and improve some comments.
2019-05-31 19:44:47 +02:00
Benno Schulenberg 3952dcb629 tweaks: rename a variable, reduce its scope, and use it consistently 2019-05-31 19:25:50 +02:00
Benno Schulenberg 7e9dd385f5 tweaks: elide a parameter and a return value
As 'filepart' is a global variable, there is no need to pass it around.
Just use it directly.
2019-05-31 19:00:20 +02:00
Benno Schulenberg 2e81023553 tweaks: rename two variables, and reshuffle their declarations 2019-05-31 17:45:51 +02:00
Benno Schulenberg b9f994b2c0 tweaks: elide a variable, drop a comment, and remove unneeded braces
There is no need to save, clear, and restore the mark when counting
words, lines and characters, because partitioning and unpartitioning
the buffer does not use the mark nor affect it.
2019-05-31 17:43:40 +02:00