Commit Graph

1143 Commits (73cd96838e5ea7cb2f72d335ff31eaeb796d7764)

Author SHA1 Message Date
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 17c16a4bf5 tweaks: rename a function and elide its first parameter 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 7c5b104859 tweaks: rename three variables, to match others elsewhere 2019-10-16 11:46:22 +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 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 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 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 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 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 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 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 ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +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 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 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 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 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 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 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
Benno Schulenberg e98847200e tweaks: reshuffle some lines, to reduce duplication 2019-05-31 17:42:42 +02:00
Benno Schulenberg 58ca5fb0f3 build: move an #include to where it is needed 2019-05-31 17:14:28 +02:00
Benno Schulenberg 3a65c0d192 feedback: when the last line is empty, don't include it in the count
Now M-D will report 0 lines instead of 1 line for an empty buffer, and
will match the output of 'wc --lines' as long the file is a POSIX file.

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

Bug existed since before version 2.1.10.
2019-05-30 19:51:25 +02:00
Benno Schulenberg e1c011c9a1 tweaks: rename a variable, to match the style of its brothers 2019-05-30 19:34:57 +02:00
Benno Schulenberg 85eb9b9a53 tweaks: use a cheaper way to switch between buffers where possible
For this one quick switch back and forth there is no need to report
anything on the status bar nor to update colors and such.  In this
case, those things are just a waste of time.
2019-05-30 17:42:37 +02:00
Benno Schulenberg add1159675 tweaks: don't bother checking the return value of wait()
It is not done for the external spell checker either.
2019-05-28 17:39:19 +02:00
Benno Schulenberg dbdf38cce5 tweaks: consistently report failures to fork (and the like) as errors 2019-05-28 17:36:32 +02:00
Benno Schulenberg 6dcfcd11ce tweaks: rename two functions, to better describe what they do 2019-05-27 17:24:35 +02:00
Benno Schulenberg f21b094dad tweaks: condense a couple of comments, and reshuffle a line 2019-05-27 17:21:05 +02:00
Benno Schulenberg 98ffb19746 tweaks: stop checking for a NULL result from line_from_number()
No one ever reported seeing the message that was removed in commit
c039aaad one month ago, so most likely the code is correct and nano
never calls line_from_number() with a non-existent line number.
2019-05-24 19:08:29 +02:00
Benno Schulenberg 93edd12099 tweaks: rename a function, to be clearer and to stop using an old abbrev 2019-05-24 18:56:34 +02:00
Benno Schulenberg 9a475bf2d3 speller: don't crash when the spell-checked tempfile cannot be opened
This addresses https://savannah.gnu.org/bugs/?56361.
2019-05-24 17:31:35 +02:00
Benno Schulenberg 137c4467ef speller: ensure that a Shift-selected region is retained
For both an integrated and an external spell check, fake the Shift key
being held so that (when the cursor is moved by a changed length of a
word) a Shift-selected region is not unexpectedly cancelled.

This fixes https://savannah.gnu.org/bugs/?56365.
2019-05-24 12:30:07 +02:00
Benno Schulenberg e3e81879b1 tweaks: condense the setup of the two signal handlers for Ctrl+C
Don't bother checking for an error from sigaction(), because the only
things it could error out for is when it is passed an invalid signal
(which SIGINT isn't) or oldaction/newaction would point to memory that
is outside of nano's control (which is obviously not the case).

Also, the setup of signal handlers during startup does not check for
errors, so why do it here?
2019-05-24 10:48:03 +02:00
Benno Schulenberg 12bf3bfce4 feedback: don't clear off possible error messages after a spell check
If functions deeper down would put up some message on the status bar,
it should not be cleared.  The chance that messages from a spell-check
program stay onscreen is minute: the edit window is fully refreshed,
the status bar is fully drawn, and the help lines (if there are any)
are redrawn.  Only the title bar is not refreshed, but the chance that
an error message has spilled onto the top row...  And anyway, the
spell checker should not print any error messages at all.
2019-05-21 19:42:44 +02:00
Benno Schulenberg 20635b40f4 tweaks: merge two very similar functions into a single one 2019-05-21 18:56:13 +02:00
Benno Schulenberg 2669d3623d tweaks: set a boolean directly, instead of using a function call 2019-05-21 12:15:37 +02:00
Benno Schulenberg 3c959fd038 tweaks: drop a useless tidying-up call, as spelling does not use regexes
The integrated spell checker does not use regular expressions, and
'refresh_needed' is set to TRUE anyway, so the tidy_up_after_search()
call there is effectively a no-op.
2019-05-06 10:57:45 +02:00
Benno Schulenberg 9bc6bc83c0 tweaks: rename two variables, for more contrast 2019-05-01 19:14:06 +02:00
Benno Schulenberg d4468b2def tweaks: condense a comment and reshuffle a couple of lines 2019-05-01 19:10:56 +02:00
Benno Schulenberg 404a6862cd tweaks: really don't bother renumbering the lines in the cutbuffer
The lines from the cutbuffer will be renumbered when it matters: when
they get pasted.

The only place that used the numbering of (a copy of) the cutbuffer
(the updating of an undo item) already iterates through its lines.
Just add a counter there instead of making use of the line numbers.
2019-05-01 13:09:22 +02:00
Benno Schulenberg 85fc41470b tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
All extractions are done into the cutbuffer, so it is pointless to pass
'cutbuffer' and 'cutbottom' in and back out as parameters all the time.
Just use those global variables directly.

Also, rename the function as there is no longer a buffer among its
parameters.
2019-05-01 11:33:37 +02:00
Benno Schulenberg 2b9dd6c574 tweaks: don't bother saving and restoring 'cutbottom' all the time
The 'cutbottom' variable is only ever used when cutting or copying
consecutive lines: for appending the current line to the already
existing lines in the cutbuffer.  As soon as some other operation
is performed, 'cutbottom' becomes irrelevant, it could be set to
anything, it doesn't matter: the pasting of the cutbuffer does not
use the value of 'cutbottom', nor does any other operation.
2019-05-01 11:19:14 +02:00
Benno Schulenberg 17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg 37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg 0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +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 fcad442d80 tweaks: declare a function as const and let its allocated string leak
Avoiding this leak is more trouble than it's worth: invocation_error()
will be called seldomly, and when it is called, the user will probably
quickly exit from nano to fix things.

Also declare the speller functions as const again, so they don't give
the impression that their result can be freed.

Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-04-23 12:07:56 +02:00
Benno Schulenberg 34d22d3f00 wrapping: improve the persistence of the prepending behavior
Now you can have a look elsewhere in the buffer (and even delete
or paste stuff there) and when you return to the original line
and continue typing, any spillover from automatic hard-wrapping
will spill over onto the same line it spilled over to before.

You can even switch to a different buffer and return and continue
typing, and stuff will still spill over to the same line.

In the bargain, this gets rid of a bit of flag-resetting code
that was run for many keystrokes, in most cases needlessly.

This addresses https://savannah.gnu.org/bugs/?56189.
2019-04-23 10:20:12 +02:00
Benno Schulenberg 1326af7eae tweaks: drop an unneeded saving and restoring of a variable
Since commit aa1ae0a1, from three years ago, do_next_word() no longer
changes 'placewewant'.
2019-04-23 10:18:46 +02:00
Benno Schulenberg 493f215513 speller: do not crash by trying to free something that cannot be freed
Most of the returned error messages are fixed strings, not allocated
strings.

This fixes https://savannah.gnu.org/bugs/?56188.
Reported-by: Aliaksei Sakovets <alexeysakovets@gmail.com>

Bug existed since version 4.1, commit f645009a.
2019-04-22 11:32:03 +02:00
Benno Schulenberg 723451a5ce tweaks: adjust a few comments and some indentation 2019-04-21 11:58:08 +02:00
Benno Schulenberg 326e41d799 tweaks: elide an unneeded intermediate variable 2019-04-21 11:41:54 +02:00
Benno Schulenberg 3ce74eb8fe wrapping: compute the width of a succeeding line in the correct manner
Its number of columns needs to be computed, not its number of bytes.
2019-04-21 11:39:06 +02:00
Benno Schulenberg ec4883b6a9 tweaks: remove an unneeded condition
The 'prepend_wrap' flag gets set to TRUE only when there is a next line,
and it can remain TRUE only when the cursor stays on the current line.
2019-04-21 11:26:00 +02:00
Benno Schulenberg e8f69e40d1 wrapping: add a missing space only when the remainder will be prepended
When automatic hard-wrapping causes some piece of a line to be pushed
to the next line, then a separating space needs to be added at the tail
of this piece only when this piece actually gets prepended.

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

Bug existed since version 2.9.2, commit 29f7654a.
2019-04-21 10:35:11 +02:00
Benno Schulenberg 297fb013cb wrapping: trim any trailing blanks when cursor goes to next line
When typing a space causes both the succeeding word and the cursor to
be pushed to the next line, then this space (and any contiguous ones)
does need to be snipped (when --trimblanks is in effect).

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

Bug existed since version 2.9.3, commit 91073be4.
2019-04-21 09:31:18 +02:00
Benno Schulenberg 192a303e40 tweaks: condense and improve a handful of comments 2019-04-20 14:00:07 +02:00
Benno Schulenberg dcec8a4112 tweaks: rename a variable, for a little more meaning 2019-04-19 10:10:14 +02:00
Benno Schulenberg 5316f5078f tweaks: elide an unneeded variable
After a line break, the preceding line is readily available through
the 'prev' element.
2019-04-19 10:06:57 +02:00
Benno Schulenberg 286c877853 tweaks: elide an unneeded parameter, as the function already assumes it
The do_wrap() function always gets 'openfile->current' as parameter,
and, internally, it assumes that it is handling the current line.
2019-04-19 09:47:21 +02:00
Benno Schulenberg c039aaad9d tweaks: remove several unneeded bad-state checks and their messages
No one ever reported seeing any of them, and each of these checks
has been there for at least a year.
2019-04-14 19:38:04 +02:00
Benno Schulenberg baca8bb19e indenting, commenting: ensure a partial line stays displayed properly
Do the same as in the previous commit: re-evaluate the start of the
viewport when lines that are located above this viewport may have
changed.  This is relevant when softwrap is on.
2019-04-13 11:51:14 +02:00
Benno Schulenberg 1c707d4f99 unindent: ensure that a partial line gets displayed properly afterwards
When only the trailing chunk of a line is displayed on the top row of
the screen, and the unindenting of this line leads to a reduction in
the number of chunks, then the starting point of the viewport needs
to be re-evaluated.  For simplicity, do this always when something is
unindented.

This fixes https://savannah.gnu.org/bugs/?56102.
Reported-by: Devin Hussey <husseydevin@gmail.com>

Bug existed since around version 2.9.2.
2019-04-13 11:36:53 +02:00
Benno Schulenberg d83a8eb359 justify: correctly compute the number of lines to take, to avoid a crash
When the file starts with one or more blank lines, the first paragraph
doesn't start on line 1.

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

Bug existed since version 4.0, commit ac8bd2a2.
2019-04-11 16:11:49 +02:00
Benno Schulenberg 98cc39e8e5 tweaks: reshuffle some lines, to elide an 'if' 2019-04-11 15:12:04 +02:00
Benno Schulenberg b20fadd604 tweaks: free the copy of a linter message in all cases [valgrind] 2019-04-11 14:17:32 +02:00
Benno Schulenberg cdf0f8e68a tweaks: drop two 'const' qualifiers, to silence the compiler 2019-04-11 12:31:50 +02:00
Benno Schulenberg f645009a5e tweaks: free the result string from an invocation error [coverity] 2019-04-11 10:05:39 +02:00
Benno Schulenberg 2b2736d41a tweaks: free some memory before a possible error exit [coverity] 2019-04-11 09:55:18 +02:00
Benno Schulenberg 5a6029a938 tweaks: rename some variables, for more contrast and to match others 2019-04-11 09:38:06 +02:00
Benno Schulenberg 8d272db4e6 tweaks: rename two variables, for more contrast 2019-04-11 09:14:30 +02:00
Benno Schulenberg 70885d0f9a tweaks: use a signed type for a result that could be negative [coverity] 2019-04-11 09:11:53 +02:00
Benno Schulenberg 5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg fb04dff6d7 tweaks: don't bother reallocating the data when a line gets hard-wrapped
This will waste some memory, but... if the user keeps editing, she is
likely to revisit the line and the data will get reallocated soon enough.
2019-04-04 14:44:44 +02:00
Benno Schulenberg c224ea3ce7 tweaks: reshuffle two lines, and reword a comment 2019-04-04 14:23:07 +02:00
Benno Schulenberg 2a2fe7208a tweaks: condense a bit of copying code 2019-04-04 14:11:52 +02:00
Benno Schulenberg 3f9d8011b9 tweaks: don't bother copying the NUL byte -- it is set nine lines down 2019-04-04 13:59:00 +02:00
Benno Schulenberg 4788c5f97d tweaks: don't bother reallocating the squeezed string, just terminate it
The string will be rewrapped right after, within microseconds.
2019-04-04 13:56:41 +02:00
Benno Schulenberg a5869ba450 tweaks: rename another variable, to be more fitting 2019-04-04 13:52:27 +02:00
Benno Schulenberg 7bc324f276 tweaks: rename two variables, to be more distinct and more fitting 2019-04-04 13:48:34 +02:00
Benno Schulenberg 8d40b568fa tweaks: rename a variable, to be more distinct and more apt 2019-04-04 13:39:11 +02:00
Benno Schulenberg 0c0afb0039 tweaks: simplify a message, and normalize the spelling of another one
The word "buffer" in relation to undo has been confusing to translators.

Also, drop the exclamation mark, as there is nothing important or urgent
about these messages.
2019-04-04 12:55:58 +02:00
Benno Schulenberg 2281ec9a31 tweaks: remove an unneeded check for NULL [coverity] 2019-04-04 12:47:20 +02:00
Benno Schulenberg cd0917fe10 tweaks: remove an unneeded check for NULL and its associated message
The message (or its equivalent) has been there for years
and no one ever reported seeing it.
2019-04-04 12:40:03 +02:00
Benno Schulenberg 1a1519b6cd tweaks: drop an assignment whose value is never used [scan-build]
This useless assignment has been there for ages, since before 2.0.0.
2019-04-03 19:10:21 +02:00
Benno Schulenberg b0c9809a2e speller: block the resizing signal also during an integrated spell check
Because somehow something goes wrong when SIGWINCHes are handled while
reading from a pipe.

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

Bug existed since version 2.4.2, commit 75d64e67.
2019-04-01 20:21:23 +02:00
Benno Schulenberg e5a8c35104 feedback: show a message while executing an external command
Some commands can take a little while to execute; showing just the prompt
during that time could give the impression that nothing is happening.

This addresses https://savannah.gnu.org/bugs/?56041.
2019-03-31 18:04:52 +02:00
Benno Schulenberg 3f695b8fb7 speller: resizing can happen also when configured with --enable-tiny
When nano was configured with --enable-tiny --enable-speller, the
block_sigwinch() function should be available, to mask SIGWINCHes
during a spell check.
2019-03-30 19:23:15 +01:00
Benno Schulenberg 55699dc171 tweaks: rename some variables, to be less repititious
The repeated 'read_buff_' made everything look the same.
2019-03-30 19:10:44 +01:00
Benno Schulenberg fa48d523b2 tweaks: stop doing tandem assignments (one passing through the other) 2019-03-30 18:52:45 +01:00
Benno Schulenberg 6f07f2b444 tweaks: rename a function plus parameter, to stay closer to what it does 2019-03-27 19:46:37 +01:00
Benno Schulenberg f58869d072 tweaks: put the unblocking of SIGWINCHes in a better place
The blocking is needed only during the wait(), so unblock SIGWINCH
again right after the wait() -- also to have the unblocking before
a possible error exit.
2019-03-27 19:10:24 +01:00
Benno Schulenberg 978c121de1 speller: block the resizing signal again during an external spell check
Somehow a SIGWINCH pushes nano past the wait() in do_alt_speller(),
even though the external spelling program hasn't finished.

This fixes https://savannah.gnu.org/bugs/?56010
by reverting commit 1f39f60b.

Bug existed since version 3.2.
2019-03-27 17:43:43 +01:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg 6755b7c0a0 tweaks: rename four functions, to make more sense 2019-03-21 17:18:50 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg 04cfe5a258 tweaks: rename a function for aptness, and two variables for shortness 2019-03-19 21:17:06 +01:00
Benno Schulenberg 954cab81b4 tweaks: improve and condense some comments, and remove an unneeded one 2019-03-19 21:13:34 +01:00
Benno Schulenberg 43c6bc6619 tweaks: add a consistency check plus a corresponding warning
Since commit 4c6ec637 from about half a year ago, the 'action' parameter
of update_undo() is unused.  Verify that this parameter matches the type
of the item at the top of the undo stack, so that in another half year
the parameter can be safely removed.
2019-03-17 20:51:43 +01:00
Benno Schulenberg e0fab690cc tweaks: don't pass a pointer when a boolean is expected
For some reason, when configured with --with-slang, some extra compiler
warnings are enabled that are not enabled by --extra-warnings.  :|
2019-03-17 19:13:24 +01:00
David Lawrence Ramsey 37be9b54ca justify: initialize a variable before making use of its value
When the mark is off, initialize not just 'bot_x' but also 'top_x'.

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

Bug existed since the justifying of a marked region was introduced,
four days ago, with commit f7f5514e.
2019-03-14 11:48:07 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
David Lawrence Ramsey 932a35c072 tweaks: normalize the indentation, and remove unneeded braces 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 877a649819 justify: when justifying a marked region, strip whitespace after the lead
This matches Pico's behavior.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 5d7b723c16 justify: put a mid-line marked region onto separate lines
This matches Pico's behavior.  However, Pico doesn't add the quoting +
indentation to the line in which the selection ends, but this is wrong,
so nano does add it.  Also, Pico doesn't account for partial quoting +
indentation at the start or end of a selection, but this is wrong, so
nano does.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 053244db70 justify: handle the leading part when justifying a marked region
Unlike a regular paragraph, marked text may have different quotes and
more than two types of indentation.  Handle this by replacing deviant
quotes with the quote of the first line, and deviant indentation with
the indentation of the second line.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey f7f5514eef new feature: marked text gets justified into a single, new paragraph
This is modelled after Pico's behavior.  However, Pico won't do anything
if you do a full-justify while the mark is on.  But this is unnecessarily
limiting, so, when the mark is on, nano will handle a full-justify and a
plain justify the same.

This currently does not handle the lead (quoting + indentation) in
justified selections, does not put mid-line justified selections onto
separate lines, and does not strip whitespace after the lead in justified
selections, the latter two of which Pico does.  These behaviors are
forthcoming.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey afa0097ceb tweaks: rename a variable, to prepare for its new role 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 6e960012c2 tweaks: split justify_paragraph() into three separate functions
concat_paragraph() concatenates a paragraph into a single line, and
rewrap_paragraph() rewraps that line into multiple lines again.

These two will be needed when the justifying of marked text is added.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 311a7138b2 tweaks: adapt find_paragraph()/justify_paragraph() for multiple quotes
Instead of passing 'quote_len' to these functions, calculate it directly
in them.

This will be needed when the justifying of marked text is added.  When
unmarked text is justified, it is a single paragraph and by definition
has a uniform quoting part.  But marked text may be a jumble of lines
that have different quoting parts.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 0ac04347d5 tweaks: remove unnecessary variable initializations 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey f13dd140eb display: correctly trim an overshooting character from a prompt answer
Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
2019-02-28 19:47:55 +01:00
Benno Schulenberg 70da1889ee feedback: complete the removal of some superfluous words
This should have been part of commit 1053a3c4.
2019-02-25 10:04:10 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 1053a3c440 feedback: remove some superfluous words from Undid/Redid messages
Also, change some words to nouns, to fit the scheme.
2019-02-24 16:27:47 +01:00
Benno Schulenberg d3fdd20471 tweaks: rename an overlooked variable from a single letter to a word 2019-02-20 17:39:04 +01:00
Benno Schulenberg b6a762232e tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE 2019-02-19 19:45:55 +01:00
Benno Schulenberg 54055b6174 tweaks: switch from referencing NO_WRAP to referencing BREAK_LONG_LINES 2019-02-19 19:45:55 +01:00
Benno Schulenberg ebfe752841 tweaks: rename some variables from a single letter to meaningful word 2019-02-12 16:06:24 +01:00
Benno Schulenberg 14f32577ee display: ensure that spotlighted text is not treated as a prompt answer
When doing replacements or fixing misspelled words, and edit_refresh()
is called to highlight the relevant word, then the current menu can be
anything from MREPLACEWITH, MYESNO, MSPELL, or MMAIN.  Make sure it is
always set to the latter just before calling edit_refresh(), so that
display_string() will use the full length and the word gets properly
highlighted.

This fixes https://savannah.gnu.org/bugs/?55680.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug was introduced by the previous commit, 56181896.
2019-02-12 15:07:55 +01:00
Benno Schulenberg 0ae80ce362 tweaks: reduce two parameters to a single one by summing them
Also, rename the remaining parameter and rename a variable.
2019-01-06 17:56:46 +01:00
Benno Schulenberg f74a120803 tweaks: refer to the magic line as "magic line", not as "magicline" 2019-01-06 15:35:31 +01:00
Benno Schulenberg 4104376e7c tweaks: rename a variable, elide another, and adjust two comments
Also, adjust the type of a parameter to 'size_t', as it is a
character index.
2019-01-02 18:05:58 +01:00
Benno Schulenberg ffa0a9ef64 tweaks: calculate the length of a completion word in a more direct way 2019-01-02 17:44:15 +01:00
David Lawrence Ramsey eef6b2b442 tweaks: use proper variable types in the word-completion functions
Use 'size_t' for character indexes, and 'ssize_t' for the threshold.
2019-01-01 17:48:23 +01:00
Benno Schulenberg 16c20ad873 tweaks: move the character/word-deletion functions to a better location
Having all the cutting and deleting functions together in one file
kind of makes sense.
2019-01-01 17:48:02 +01:00
Benno Schulenberg f9bb5382aa tweaks: reshuffle and frob a couple of comments, and reindent two lines 2019-01-01 17:33:10 +01:00
Benno Schulenberg 329b82d284 undo: set the correct file size for a redo of a character deletion
The reduced file size should be stored not just when joining two lines
but also when simply a character in the middle of a line is deleted.

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

Bug existed since version 2.5.0, commit 66e21416.
2019-01-01 12:35:53 +01:00
David Lawrence Ramsey d0982536a7 undo: after undoing a cut, don't remove the magicline if we're on it
This fixes https://savannah.gnu.org/bugs/?55332.
2018-12-31 14:10:02 +01:00
Benno Schulenberg fb4ce71cfc tweaks: correct a comment typo, and trim a few other comments 2018-12-30 18:00:28 +01:00
David Lawrence Ramsey 7e152f2a48 undo: when undoing a cut, remove also the magicline if it added one
Reuse the WAS_FINAL_LINE flag to signal a cut that added a magicline,
for both a marked cut and cut-to-eof.

This fixes https://savannah.gnu.org/bugs/?55305.
2018-12-30 11:37:46 +01:00
David Lawrence Ramsey 8854ddb728 undo: set and check 'xflags' in a bitwise manner
This allows multiple flags to be set, which will be needed for the
next commit.
2018-12-30 11:36:49 +01:00
Benno Schulenberg b1b2369541 tweaks: rewrap a line and improve a few comments 2018-12-26 15:11:20 +01:00
Benno Schulenberg 8a88cea256 tweaks: elide a variable that is a copy of another 2018-12-26 14:56:29 +01:00
Benno Schulenberg 6f23d9c18c tweaks: rename a variable, because it also serves as "last line" 2018-12-26 14:37:36 +01:00
Benno Schulenberg dfbffff4b0 tweaks: remove a superfluous incrementing and decrementing of a variable 2018-12-26 14:28:54 +01:00
Benno Schulenberg ea73d7fd70 tweaks: condense a couple of comments and rewrap a few lines 2018-12-26 14:26:54 +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
David Lawrence Ramsey 6e3b9ac058 options: exit on a bad quoting regex, instead of crashing later
The paragraph-jumping functions used the regex unverified...

This fixes https://savannah.gnu.org/bugs/?55169.
2018-12-11 10:29:29 +01:00
Benno Schulenberg 41c561c5cf tweaks: schedule a call of edit_refresh() instead calling it directly
The direct call was a leftover of the old unjustify mechanism.

Also, move two statements to the end of the do_justify() routine,
since that is their place in comparable routines.

Suggested-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-12-10 17:38:39 +01:00
Benno Schulenberg 6bead051d2 justify: move the check for a bad quoting regex to a better place
So that the cursor will not move when a justification is attempted.
2018-11-26 10:56:20 +01:00
Benno Schulenberg ac8bd2a227 tweaks: elide a parameter -- do the NULL checks in the caller
Determine more directly: the length of the last paragraph line,
and the exit condition for a full justify.
2018-11-26 10:38:04 +01:00
Benno Schulenberg 0d96df7a91 tweaks: condense and improve a couple of comments 2018-11-26 09:38:02 +01:00
Benno Schulenberg e2c61d83ef tweaks: change do_para_end() to not step beyond end of paragraph
Not stepping beyond the last line of the paragraph means that the
length of the paragraph is always the difference in line numbers
(between first and last line of the paragraph) plus one.
2018-11-26 09:16:09 +01:00
Benno Schulenberg 2c126b201f text: turn the mark off when justifying, to not confuse an undo
When leaving the mark on while justifying and then undoing the
justification, things are likely to get messed up.  My applying
David's patches only partially caused this breakage.

This fixes https://savannah.gnu.org/bugs/?55074.
2018-11-25 20:10:30 +01:00
Benno Schulenberg 2500debbd2 tweaks: don't bother zeroing the x position when doing a full justify
The x position of the cursor is irrelevant when doing justifications.
2018-11-25 15:23:24 +01:00
Benno Schulenberg 500c41b83b tweaks: move the check for beginning-of-paragraph to a better place
Only the first search for a paragraph needs to check whether we're
currently in the middle of a paragraph.  When the 'while' loop for
a full justify is executed, all calls of find_paragraph() start
either on the first line of a paragraph or between two paragraphs.
2018-11-25 15:20:48 +01:00
Benno Schulenberg 2c83047842 tweaks: condense the logic of find_paragraph()
To find a paragraph, what needs to be done is:

  a) When not in a paragraph, move forward until we find one, if any.
  b) When in a paragraph but not at its start, move back to its start.
  c) Move forward to the end of the paragraph, if any.
2018-11-25 13:22:45 +01:00
Benno Schulenberg 5f5682240a tweaks: remove a superfluous check for a special case
The case is handled fine by the rest of the code.  The unnecessary
check wastes some cycles for every call of find_paragraph().
2018-11-25 12:43:29 +01:00
Benno Schulenberg 66cd897dc4 justify: correctly detect when we've reached end of buffer
When, in the 'while' loop for a full justify, 'filebot_inpar' becomes
TRUE, it means that EOF has been reached and find_paragraph() should
not be called again.  To allow 'filebot_inpar' to convey this meaning,
it should not be set to TRUE elsewhere, so another boolean is needed
for setting the correct length of the final line of the cutbuffer.

This fixes https://savannah.gnu.org/bugs/?55086.
2018-11-25 11:57:10 +01:00
Benno Schulenberg 67e6eee26e tweaks: rename two parameters to be more descriptive
Also rename one variable, to be more general, as it does not always
point to a line in a paragraph.
2018-11-22 20:54:22 +01:00
Benno Schulenberg 7ccdb1970a tweaks: elide two unneeded intermediate variables 2018-11-22 20:43:40 +01:00
Benno Schulenberg 539a18e4c7 tweaks: condense and improve a handful of comments, and rewrap two lines 2018-11-22 20:02:29 +01:00
Benno Schulenberg a7083d632b tweaks: improve a comment, and add an intermediate variable for clarity 2018-11-21 19:49:09 +01:00
David Lawrence Ramsey d54840c152 text: hook the new justify mechanism up to the undo system
This fixes https://savannah.gnu.org/bugs/?46900.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 14c085898b text: make do_justify() use the cutbuffer
This is the last preparation for making justifications undoable in
the regular way.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey fb38995d36 tweaks: adjust some indentation after the previous change 2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 2cdb87ee62 text: remove the old unjustify mechanism, to prepare for the new justify
This leaves two variables unused, but they will be used again two commits
from now, when do_justify() is converted to use the cutbuffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey ba8462a458 text: properly check again for no paragraphs after the current line
The removal of the x-coordinate handling affected this.  Reshuffle things
so that we can check for it after we have moved (the same way we check for
it at the beginning of the function before we move) without having to set
'quote_len' and 'par_len' unnecessarily.

Also, adjust some comments accordingly.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 4af81823e2 text: make find_paragraph() work on any buffer
Move detecting the final line of the paragraph to find_paragraph(),
since a paragraph of which the final line is the last line of the
buffer will still be that way after being justified.

Also, move all x-coordinate handling to do_justify(), since it only
applies to the current buffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 2c28a22971 text: prepare to make find_paragraph() work on any buffer
Move a few references to the current buffer to do_justify().  Also,
the check for being at the end of the buffer needs to be done after the
first paragraph is found, so that the existing behavior of finding an
initial paragraph regardless of cursor position is preserved.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey c8e5c85113 moving: make the generic paragraph movement functions work on any buffer
The functions do_para_begin() and do_para_end() can now move through any
buffer, while the functions do_para_begin_void() and do_para_end_void()
operate on the current buffer.  The latter function also returns TRUE
if the last line in the buffer is part of the paragraph.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 4c0572a799 text: make justify_paragraph() work on any buffer
Remove the handling of 'edittop', 'totsize', and the mark, to make the
function more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 9aa382e69e text: make justify_format() work on any buffer
The function assumes that it works on the current buffer by handling
'totsize' and the mark.  Remove this handling to make the function
more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +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
Brand Huntsman 5662a38802 new feature: a bindable 'zap', to erase text without changing cutbuffer
This function allows the user to "make space": annihilating lines or
regions while keeping intact for pasting the stuff in the cutbuffer
that was cut or copied earlier.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:19 +01:00
Benno Schulenberg 477f63d8b5 linter: do not pause when there are no messages for unopened files
Return immediately to editing mode when there are no messages for
the original file and the user does not wish to open any of the
included files that do have messages.

Also, reword the message that the linter gives then, and leave it
on the status bar (just like when Cancel is pressed).
2018-10-24 17:14:02 +02:00
Benno Schulenberg 280ac81b31 display: ensure that the help lines are shown when in linting mode
The help lines will help differentiate this mode from normal editing
mode, and will tell the user how to jump to other messages.

This is a third step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:35:21 +02:00
Benno Schulenberg b7f53096fb display: use a different color when showing a linting message
This is a second step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:31:40 +02:00
Benno Schulenberg f7f7767e7d display: let the title bar show when nano is in linting mode
This is a first step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:30:22 +02:00
Brand Huntsman 71de0b9e2f linter: throttle "first"/"last" message on repeated key presses
To avoid stacking up pauses, which would make nano unresponsive
for too long.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-10-22 20:36:00 +02:00
Benno Schulenberg b8c51329f6 linter: for "first"/"last", reshow actual message after a short pause
This fixes https://savannah.gnu.org/bugs/?54754.
2018-10-21 17:57:28 +02:00
Benno Schulenberg bab5eeb808 bindings: allow using <Enter> to exit from the linter
Understand the key as: "Enter into editing mode on the current line".
2018-10-21 17:55:17 +02:00
David Lawrence Ramsey c2e4f77594 display: do spotlighting as part of drawing the screen
When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
2018-10-09 20:03:47 +02:00
Benno Schulenberg d245b07c25 tweaks: remove a now-unused parameter from four functions 2018-10-01 19:56:32 +02:00
David Lawrence Ramsey 13a4f3130d tweaks: normalize the indentation of the shuffled code
And remove some superfluous braces.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey b32deee382 tweaks: move the justifying of a single paragraph into its own function
The new function, justify_paragraph(), takes a quote length and a
paragraph length (which it should get from find_paragraph()), and
runs the paragraph at (current, current_x) through justify_format().
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey 076bc31ce5 tweaks: simplify by using a 'do/while' loop instead of 'while (TRUE)'
The do/while loop will run once when doing a justify, and enough times
for the entire file when doing a full-justify.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey 22c8ef6c39 tweaks: reshuffle some code to avoid several checks for having justified
Move some fragments out of the justifying loop, and adjust/clarify comments
to account for the changes.  This will allow some of the code to be cleaned
up and simplified in the next commits.
2018-09-30 20:47:08 +02:00
Benno Schulenberg 4b32c62674 tweaks: reshuffle some lines to get standard order (first up, then down) 2018-09-29 09:46:05 +02:00
Benno Schulenberg b4b9e9b012 linter: allow using <Ctrl+Up> and <Ctrl+Down> to jump to other message
These are more "natural" keystrokes for jumping than <PgUp> and <PgDn>.
2018-09-29 09:42:25 +02:00
Benno Schulenberg 0b63de335e tweaks: elide a wrapper function that is no longer useful 2018-09-28 20:09:12 +02:00
David Lawrence Ramsey bed997171c speller: restore the mark coordinates slightly later
To avoid a confusing mishighlighting of just part of a marked region.

This partially addresses https://savannah.gnu.org/bugs/?54721.
2018-09-26 19:45:38 +02:00
Benno Schulenberg 8d0b7a490d undo: move another piece of checking to the two places that need it
And in the bargain get rid of a function that is used just once.
2018-09-26 19:25:21 +02:00
Benno Schulenberg efa323ec88 tweaks: improve two comments, and reshuffle a line for consistency
(Line number first, x position second.)
2018-09-25 20:26:26 +02:00
Benno Schulenberg 4c6ec6377f undo: move some special checking code to the one place that needs it
Only for BACK and DEL was the first call to update_undo() -- all other
types of action would call add_undo() first, so for them the action in
update_undo() would never be different, but the line number might have
changed (like for ENTER and INSERT), so for them exceptions needed to
be made, which was wasteful.

This addresses https://savannah.gnu.org/bugs/?54728.
2018-09-25 18:09:28 +02:00
Benno Schulenberg be69a7c299 tweaks: rename a variable, to be a bit more fitting 2018-09-23 14:51:40 +02:00
Benno Schulenberg 33b576c289 speller: remove a pointless message -- it is never seen
When using the internal spell checker, the message gets overwritten
immediately by "Creating misspelled word list...", and when using
the external spell checker, nano immediately exits from curses mode
and thus the message disappears (when in a terminal emulator) or it
soon gets wiped by the spell checker (when on a Linux console), thus
creating a little flash on the bottom row, which we can do without.
2018-09-23 14:41:25 +02:00
Benno Schulenberg 1f39f60b2f tweaks: there is no reason to block SIGWINCHes while waiting for speller
In the past, SIGWINCHes were responded to immediately (which was madness),
but since commit 75d64e67 all a SIGWINCH does is set a flag so that, when
the time comes to update the screen, nano knows the dimensions may have
changed.  The mentioned commit removed most blockings and unblockings of
SIGWINCH, but not this one.
2018-09-23 14:07:36 +02:00
Benno Schulenberg e21ce0db1f cutting: when deleting whole words, don't join lines unexpectedly
That is, wait with deleting words until they start under cursor,
so the user can see which word is goin to be eaten, and join lines
only when the cursor already sits at the edge of a line.
2018-09-07 19:35:01 +02:00
David Lawrence Ramsey 93c8e316a8 justify: verify being in a paragraph before trying to find its beginning
If find_paragraph() detects that we're not in a paragraph, it moves
forward a paragraph and then backward to that paragraph's beginning.
Make it check whether we're in a paragraph before moving backward
(since there might not *be* any more paragraphs), to prevent going
forth-and-back and never reaching the end of the buffer.

This fixes https://savannah.gnu.org/bugs/?54573.
2018-08-27 20:27:02 +02:00
David Lawrence Ramsey 03f9761c35 undo: store the correct cursor position after a paired cut+insert
And restore the cursor to this position when redoing the cut+insert.

Also remove two unneeded conditions.

This fully fixes https://savannah.gnu.org/bugs/?54466.
2018-08-21 19:21:14 +02:00
Benno Schulenberg ec339d3b08 filtering: wait for the data-sending process to terminate too
When piping the buffer (or the marked region) to an external command,
we should wait not only for the external command to terminate but also
for the data-sending process, so that it will release its resources.

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

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-08-20 19:46:38 +02:00
Benno Schulenberg 3218d8358a tweaks: remove a redundant "struct" word, and replace it in comments 2018-08-20 19:33:31 +02:00
David Lawrence Ramsey 07447f3278 undo: restore the cursor position when a cut and paste are paired
When undoing/redoing an alternate spell check (of the entire file
or of a backwards marked region), put the cursor back where it was
when the spell check was invoked/finished.

This fixes https://savannah.gnu.org/bugs/?54466.
2018-08-15 19:58:46 +02:00
David Lawrence Ramsey fd65f74428 undo: always initialize the 'newsize' element in the undo struct
So that do_redo() cannot set the file size to a "random" value.

This fixes https://savannah.gnu.org/bugs/?54478.
2018-08-11 10:07:20 +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 94b4f07281 tweaks: adjust indentation after the previous change
Also improve a couple of comments.
2018-08-08 19:53:05 +02:00
Benno Schulenberg 61b4eeda66 speller: do not replace the text when the temporary file did not change 2018-08-08 19:44:40 +02:00
Benno Schulenberg 667fcea65e undo: differentiate between general filtering and spell checking
With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-08-07 20:42:39 +02:00
David Lawrence Ramsey c39c9c241b undo: actually enable undoing/redoing an alternative spellcheck
Make sure the inserts of the spell-checked text are undoable, and no
longer discard the undo stack after running the alternate spell checker.
2018-08-07 20:41:05 +02:00
David Lawrence Ramsey bc6787826a speller: make replace_marked_buffer() use the cutting functions directly 2018-08-07 20:38:50 +02:00
Benno Schulenberg 60ee4408be signals: don't call a print routine in a signal handler
Print routines are not asynchronous-safe.

But... the only reason the call of kill() could return an error code
is when the relevant process has already terminated -- which is not
a problem, because that was the goal of calling kill().

This fixes https://savannah.gnu.org/bugs/?54409.
Reported-by: Daniel Kozovsky <dkozovsk@redhat.com>
2018-07-30 20:22:24 +02:00
Benno Schulenberg 72a590d60a tweaks: rename a variable and a function, for more clarity 2018-07-30 20:07:25 +02:00
Benno Schulenberg c4d09cc24b text: add auto-whitespace to the file size after creating the undo item
The undo item for ENTER should record the file size *before* the amount
of auto-indentation whitespace is added to it.

This fixes https://savannah.gnu.org/bugs/?54344.
Reported-by: Liu Hao <lh_mouse@126.com>
2018-07-23 17:57:47 +02:00
Benno Schulenberg 05592a84ec completion: when the cursor is not after a word fragment, say so
Instead of being entirely silent when ^] is hit after whitespace
or punctuation, report what is lacking -- similar to M-] saying
"Not a bracket" when the cursor is not sitting on a bracket.
This makes the ^] keystroke more discoverable.
2018-07-19 19:29:24 +02:00
Benno Schulenberg 6d3b16b761 tweaks: close a temp file only when descriptor is valid [coverity scan] 2018-07-14 21:33:46 +02:00
Benno Schulenberg 14b9a42f5b tweaks: move a call to where it will be executed [coverity scan] 2018-07-14 21:02:32 +02:00
Benno Schulenberg d994af0334 tweaks: avoid dereferencing a pointer when it is NULL [coverity scan] 2018-07-14 20:02:03 +02:00
Benno Schulenberg 3ac821ee0c build: fix compilation when configured with --enable-tiny 2018-07-10 15:31:04 +02:00
Benno Schulenberg f456794045 tweaks: adjust two comments, to be more accurate and general 2018-07-08 17:40:19 +02:00
David Lawrence Ramsey 20971e8392 undo: position the cursor properly when undoing/redoing magicline cuts
Take our cue from undoing/redoing line joins: when they take place on
the magicline without --nonewlines, they produce undo/redo items that
don't do anything to the text, but still position the cursor properly.
Reshuffle a bit of code so that we can do the same for magicline cuts.

This fixes https://savannah.gnu.org/bugs/?54032.
2018-07-08 17:29:28 +02:00
Benno Schulenberg fb372ed0a8 tweaks: remove two superfluous assignments
The variable 'last_action' is set at the end of these functions,
serving to prevent a fresh action from being merged with an older
action further down on the stack.  Setting 'last_action' before
exiting from undo()/redo() makes no sense.

Also adjust a sideways related old Changelog item.
2018-06-02 19:32:54 +02:00
Benno Schulenberg ed433f6af0 tweaks: drop a condition that has been made redundant two commits ago 2018-06-02 18:17:31 +02:00
Benno Schulenberg 44814055b5 tweaks: correct a comment, rewrap a line, and drop some debugging stuff
An add can be contiguous even when the cursor has moved around in the
meantime but has returned to the same spot before more characters are
typed.
2018-06-02 18:04:36 +02:00
Benno Schulenberg 71f859377d cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the
cutbuffer will be cleared at the right moments.
2018-06-02 17:57:19 +02:00
Benno Schulenberg 5550d15418 tweaks: improve a couple of comments, and reshuffle a group of lines 2018-06-01 16:56:56 +02:00
Benno Schulenberg 6df30a634e docs: register Marco as the author of the filtering feature
The macro stuff, however, is basically my code: I told him exactly
how to do it, and I changed most of the patch before applying it.

Also, put myself in second place, as I've just about overtaken David
in the duration of maintainership.
2018-06-01 10:00:08 +02:00
Benno Schulenberg ad5d0f7530 wrapping: use "smart" autoindenting only when hard-wrapping is enabled
The paragraph-aware indenting is needed only when automatic long-line
wrapping is on (that is, when not using 'nowrap': when writing prose).
When writing code, the user most likely uses --nowrap, which will make
nano indent a new line always to the same amount as the preceding line
-- when --autoindent is in effect, of course.
2018-06-01 08:45:25 +02:00
David Lawrence Ramsey dc4146f077 tweaks: avoid an unused variable warning with --enable-tiny
This fixes https://savannah.gnu.org/bugs/?53998.
2018-05-29 09:00:08 +02:00
Benno Schulenberg 738487f13d tweaks: make better use of an existing variable 2018-05-28 10:39:47 +02:00
Benno Schulenberg c8a9a96578 build: fix compilation when configured with --disable-justify 2018-05-28 09:57:24 +02:00
David Lawrence Ramsey fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg ebdb647450 tweaks: adjust a translator hint 2018-05-27 17:53:36 +02:00
Benno Schulenberg 0c2aac5ff8 tweaks: reshuffle a couple of assignments 2018-05-27 17:45:51 +02:00