Commit Graph

948 Commits (fc716156a49901639d851af5285d8a5f79390baf)

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