Commit Graph

1240 Commits (0363703073afe35579476e5dc8d3e3df5d7735de)

Author SHA1 Message Date
Benno Schulenberg 5c6fe50487 tweaks: rename a variable, to be a bit clearer 2020-03-01 19:45:02 +01:00
Benno Schulenberg 6c34ae5804 files: don't check uninitialized memory when writing new file [valgrind]
This fixes https://savannah.gnu.org/bugs/?57934.

Bug existed since version 4.3, commit e8e30e51.
2020-03-01 19:22:35 +01:00
Benno Schulenberg 1907174c5f tweaks: drop a check for something that will not occur
The check has been there for a few months, and will be there for
five more years in the next Ubuntu LTS.
2020-02-26 14:01:25 +01:00
Benno Schulenberg be7e000389 tweaks: pull the NUL-terminating of a string into a function
Also, avoid copying one byte too many that afterward gets
overwritten with '\0'.
2020-02-20 17:08:32 +01:00
Benno Schulenberg 8d7f8cda8c tweaks: improve two comments 2020-02-10 17:13:12 +01:00
Benno Schulenberg 75a70d98d5 tweaks: reshuffle two declarations plus a fragment of code
Also, don't bother statting the path that the user provided,
as that case will happen right away in the next 'if'.
2020-02-10 17:12:53 +01:00
Benno Schulenberg b3374ea1fb tweaks: rename two parameters, to not overlap with other names 2020-02-10 16:11:07 +01:00
Benno Schulenberg 0905c6ae7e files: be consistent in which code means "New File"
This fixes https://savannah.gnu.org/bugs/?57782.

Bug existed since commit dd429d9c from yesterday.
2020-02-10 15:57:40 +01:00
Benno Schulenberg 3eeedd7caf tweaks: move a function to before the one that calls it 2020-02-10 09:55:21 +01:00
Benno Schulenberg 410dcee0a1 tweaks: move some definitions closer to where they are used
Also slightly improve a few comments.
2020-02-10 09:53:10 +01:00
Benno Schulenberg 5b4d2350e6 tweaks: condense two fragments of code 2020-02-10 09:40:12 +01:00
Benno Schulenberg 422cd726fa tweaks: normalize the indentation after the previous change 2020-02-09 20:17:05 +01:00
Benno Schulenberg 9f43b4c758 tweaks: update some comments after the previous changes 2020-02-09 20:10:28 +01:00
Benno Schulenberg dd429d9c00 tweaks: rename a variable, reshuffle an assignment, and change a code 2020-02-09 19:50:33 +01:00
Benno Schulenberg b63c90bf6b locking: do not open an empty buffer when respecting the first lock file
When opening multiple files, and the first of them has a lock file,
and the user chooses to not open the corresponding file, then nano
should NOT create an empty buffer in its stead.

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

Bug existed since lock files were introduced, in version 2.4.0,
specifically since commit 6948d2e7.
2020-02-09 17:35:00 +01:00
Benno Schulenberg fa26889d03 tweaks: change a function to return the name of the lock file on success
This makes it possible to fix a small bug in the next commit.
2020-02-09 17:01:38 +01:00
Benno Schulenberg 30011b8525 tweaks: elide one variable and three gotos
Returning the relevant value directly is clearer.
2020-02-09 16:35:18 +01:00
Benno Schulenberg 3ac5432e29 tweaks: reshuffle a few declarations and assignments
Also reshuffle two fragments of code.
2020-02-09 14:54:15 +01:00
Benno Schulenberg 1d52548575 tweaks: change another function with two possible results to boolean 2020-02-09 14:30:57 +01:00
Benno Schulenberg d5ce44820a tweaks: change a function with two possible results to boolean 2020-02-09 14:24:26 +01:00
Benno Schulenberg 325d774393 locking: accept a minimal amount of data, enough for PID plus username
Maybe reading from a remote filesystem happens in small chunks;
don't call foul when the first chunk contains all we need.
2020-02-06 16:13:22 +01:00
Benno Schulenberg 7ce1f6d86d locking: when finding a lock file at startup, quit when user cancels
When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.
2020-02-02 13:00:37 +01:00
Benno Schulenberg 88087f2b2f tweaks: move a function to related ones, and after one that it calls 2020-02-02 12:26:33 +01:00
Benno Schulenberg 16c4f5bbd0 tweaks: move a function to be before the ones that call it 2020-02-02 12:21:28 +01:00
Benno Schulenberg e877c2406e tweaks: allocate the lock data only when ready to write them 2020-02-02 12:05:45 +01:00
Benno Schulenberg b6a1583e8e tweaks: take just one shot at reading the lock file, and correct a type
Don't bother looping until the 1024 bytes are read.  Writing the lock
file takes just one shot too, and that is more important to get right.

Also, correct the type for the result of read(), so that -1 doesn't
get turned into a positive number, which would mean that any error
would get ignored.
2020-02-02 11:41:20 +01:00
Benno Schulenberg 48df800db3 tweaks: rewrite the same file name into the lock file as the first time
It would be better if nano wrote the full filename into the lock file,
because that would be clearer when Vim displays its warning, but...
this is faster and will do for now.

(Nano should simply also store the full filename in the openfile struct,
so that get_full_path() needs to be called just once for each file.)

This addresses https://savannah.gnu.org/bugs/?57713.
2020-02-02 11:22:22 +01:00
Benno Schulenberg ee05daab92 tweaks: do not leak a file descriptor when fdopen() fails 2020-02-02 11:08:59 +01:00
Benno Schulenberg 74f4c37d5f locking: avoid crashing when there is a problem writing the lock file
The call of ferror() as parameter of a %s specifier was a mistake --
it returns a number, not a string.  Avoid the problem by combining
two error checks.

The man page of fwrite() does not say anything about errno, but I guess
that the function calls write() and that the possible error numbers of
that function apply.

In theory it is now possible that fclose() fails and returns an error
that then masks an earlier error of fwrite().  But I can't be bothered:
lock files are not essential, and any errors that might occur are most
likely overlooked anyway because they are not displayed in red.

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

Bug existed since lock files were introduced, in version 2.3.2,
commit bf88d27a.
2020-02-02 10:55:19 +01:00
Benno Schulenberg 073251fdb1 tweaks: condense two comments, and reshuffle an #endif
There is no need to fake success when the whole writing of the lock file
is skipped, because also a zero return value means "continue anyway".
2020-01-31 11:39:11 +01:00
Benno Schulenberg 5a0ee3c2f9 tweaks: harmonize the amount of lock data that we read and write
All the things that we need are located within the first 68 bytes of
the .swp file.  We do write byte 1007 when the file is modified, but
we never reference it.  We always wrote just 1024 bytes to the .swp
file, so it makes no sense to read in any more than that.

(Vim writes 4096 bytes to a .swp at first, before adding undo stuff
four seconds later.  But the 1024 bytes appear to be enough for Vim
to recognize it as a lock file.)
2020-01-31 11:06:11 +01:00
Benno Schulenberg 6bd5dce954 tweaks: ensure that editor name and user name are NUL terminated
When copying those pieces from a lock file, it is not certain that
they end with a NUL character.
2020-01-30 20:00:17 +01:00
Benno Schulenberg f25059c244 tweaks: frob a couple of indentations and white lines 2020-01-30 19:55:26 +01:00
Benno Schulenberg 856f2c433e feedback: ask a clearer question when a valid lock file is encountered
When asking "continue?", I always thought that answering No would mean
that nano would not continue, that it would stop, that it would abort.
But No only means that it will not open the relevant file but continues
anyway to start up.  Asking "open anyway?" is more easily understood in
that way.
2020-01-30 19:44:25 +01:00
Benno Schulenberg 38c5a4465b tweaks: reshuffle some assignments for a return value 2020-01-30 19:43:19 +01:00
Benno Schulenberg f494bfcbb9 locking: when a lock file is unreadable, open the file itself anyway
Unreadable or corrupt lock files are not a user error nor user intent,
so they should not keep the user from editing the corresponding file.

Also, combine some error conditions to compact the code.

This addresses https://savannah.gnu.org/bugs/?57700.
2020-01-30 19:10:34 +01:00
Benno Schulenberg b856fc4664 locking: check two magic bytes, to verify that it is a lock file
Also, when the check fails, then nano should continue and simply
open the file, just like Vim.

This fixes https://savannah.gnu.org/bugs/?57698.
2020-01-30 18:48:35 +01:00
Benno Schulenberg faa96ead44 tweaks: correct the description of what nano writes into the lock file
Also, limit the stored program's name to ten bytes.  Vim uses four for
its name plus a space, and a maximum of six for its version number.
2020-01-30 17:44:04 +01:00
Benno Schulenberg 26444bf8df tweaks: reformat a comment, and resuffle a line to match byte order 2020-01-30 15:55:42 +01:00
Benno Schulenberg 662e8b2d20 tweaks: remove some superfluous conditions for rewriting a lock file
A lock file needs to be rewritten (with the modified flag) only when the
relevant lock file already exists.  All other conditions are redundant.
2020-01-29 19:38:07 +01:00
Benno Schulenberg 4502295a34 locking: do not write a lock file when in view mode
When in view mode, the file cannot be edited, so there is no need to
warn anyone (through a lock file) that the file might soon change.

This fixes https://savannah.gnu.org/bugs/?57694.
2020-01-29 19:14:41 +01:00
Benno Schulenberg e0213b1a41 tweaks: drop a pointless suffix from two function names 2020-01-26 16:36:23 +01:00
Benno Schulenberg 706f3e93f4 tweaks: in comments, reword "titlebar" and "statusbar" to two words each
To differentiate them from the function names.
2020-01-16 19:37:28 +01:00
Benno Schulenberg afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg 3e0bd533db tweaks: free two strings as soon as they are no longer needed 2020-01-14 11:01:32 +01:00
Benno Schulenberg 6896d8df47 tweaks: reduce the scope of two constants and of four variables 2020-01-14 10:35:54 +01:00
Benno Schulenberg 8455251c35 files: revert the previous commit, as the extra warning is annoying
It also erroneously left the succeeding prompt on the screen.

This fixes https://savannah.gnu.org/bugs/?57593.
2020-01-13 21:42:44 +01:00
Benno Schulenberg 5cf351913e files: warn doubly when the user is about to overwrite an existing file 2020-01-13 20:05:56 +01:00
Benno Schulenberg 416386edcd files: alert the user afterward when an overwritten file is being edited
(The ideal behavior would be that nano would warn the user beforehand,
before the file that is being edited by someone else gets overwritten,
but that would require many more changes.  So... just give a helpful
warning -- that's already better than it was.)
2020-01-13 20:00:07 +01:00
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 413b9cb774 tweaks: rename a function, to get rid of a useless suffix 2019-12-15 19:47:05 +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 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 af8ffa8c94 tweaks: silence a warning when configured with --enable-tiny 2019-11-25 19:21:03 +01: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 17c16a4bf5 tweaks: rename a function and elide its first parameter 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 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 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 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 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 cc4ce8d83b tweaks: rename a type, to better fit the general pattern 2019-10-02 17:09:22 +02:00
Benno Schulenberg 2a4d338d97 tweaks: reshuffle a fragment, to group some toggles together 2019-10-02 15:07:04 +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 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 63e04ac31e tweaks: make a function name unique, to not overlap with others 2019-08-09 19:34: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 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 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 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 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 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 122cabd3ba tweaks: elide another parameter, and rename the function to match 2019-05-31 09:33:28 +02:00
Benno Schulenberg c5d157dd9d tweaks: close a buffer differently and elide a parameter 2019-05-31 09:15:12 +02:00
Benno Schulenberg 484523b3bb tweaks: drop two checks that were made redundant by the previous commit 2019-05-30 17:18:30 +02:00
Benno Schulenberg 5a48edc9ae tweaks: reshuffle some code to the one place that needs it
The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
2019-05-30 17:09:49 +02:00
Benno Schulenberg 7e422402d5 tweaks: change a function to void, to make things more direct 2019-05-29 20:02:50 +02:00
Benno Schulenberg 821445d284 tweaks: drop some checks that were made redundant by the previous commit
And move one to a better place.
2019-05-29 19:48:42 +02:00
Benno Schulenberg d656b0d3b9 feedback: show an appropriate message when reading a file was cut short 2019-05-28 17:06:07 +02:00
Benno Schulenberg b75563b88e tweaks: use a symbol instead of zero to refer to standard input 2019-05-28 12:31:16 +02:00
Benno Schulenberg d946f38a2b files: when needed, reconnect the keyboard and reenter curses mode
When after reading a file we are not in curses mode, it means we have
read data from standard input, either from the keyboard or from a pipe.
In the latter case, we first need to reconnect standard input to the tty.
And in both cases, we then need to reenter curses mode before being able
to display the number of lines that were read (or an error message).

So, move the reconnecting code from scoop_stdin() to its own function,
and call this function from read_file() when needed.

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

Bug existed since version 2.1.8 when reading from stdin was introduced.
2019-05-28 11:28:23 +02:00
Benno Schulenberg d972c17050 build: exclude the ability to open a FIFO from the tiny version 2019-05-27 09:55:24 +02:00
Benno Schulenberg f6e182ca72 tweaks: check in a single place for files that should not be opened 2019-05-27 09:42:41 +02:00
Benno Schulenberg 6a83bb7508 tweaks: delete a leftover 2019-05-27 09:33:36 +02:00
Benno Schulenberg 728498fde5 files: don't say "Error...: Success" when aborting after resizing
For some reason 'errno' is not EINTR but zero when a SIGINT is
produced after a SIGWINCH.
2019-05-26 19:49:23 +02:00
Brand Huntsman 05f34bbfaf files: block SIGWINCH while opening a FIFO for reading or writing
This fixes https://savannah.gnu.org/bugs/?56354.
Reported-by: Brand Huntsman <alpha@qzx.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-26 19:40:33 +02:00
Benno Schulenberg 308a094d8d feedback: show a more fitting message when opening a FIFO is interrupted 2019-05-26 14:17:35 +02:00
Benno Schulenberg 5757aa8a0c tweaks: reuse the install and restore functions for a signal handler 2019-05-26 13:57:29 +02:00
Benno Schulenberg 8c5b67379f tweaks: factor out the installing and restoring of the ^C signal handler
So that these two functions can be used elsewhere too.
2019-05-26 13:55:59 +02:00
Benno Schulenberg ea11709564 files: allow to abort the reading of slow files with Ctrl+C
This addresses https://savannah.gnu.org/bugs/?44907.

Original-patch-by: Martin van Zijl <martin.vanzijl@gmail.com>
2019-05-26 13:34:38 +02:00
Benno Schulenberg 8550c6bd93 files: allow to interrupt the opening of a FIFO for writing with Ctrl+C 2019-05-26 11:45:51 +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 b512e253b6 tweaks: drop an unneeded parameter from open_file()
The 'quiet' parameter is only used when opening a help-text tempfile
or a spell-checked tempfile, and these files necessarily exist, so
'quiet' will never be checked for them.  But in the weird case that
the help-text tempfile could not be opened, it is not a problem that
"New File" gets printed to the status bar because nano will crash
shortly afterwards.  And when the spell-checked tempfile could not
be opened, a "Not Found" message is appropriate, but nano will crash
in this case too.
2019-05-24 13:00:00 +02:00
Benno Schulenberg 4cacb626a0 files: allow to interrupt the opening of a FIFO with Ctrl+C
With-help-from: Brand Huntsman <alpha@qzx.com>
2019-05-24 10:51:56 +02:00
Benno Schulenberg acd23551c3 help: don't check for confinement when opening a temporary help-text file
This fixes https://savannah.gnu.org/bugs/?56369.
2019-05-23 12:43:31 +02:00
Benno Schulenberg d7555d071f tweaks: adjust a comment and drop two others, and reshuffle two lines 2019-05-21 19:42:08 +02:00
Benno Schulenberg 9596f7de9d tweaks: delete a now-unused function 2019-05-21 18:56:35 +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 1128a40d42 tweaks: remove an unneeded setting and unsetting of a flag
This twiddling was made superfluous by commit faa0eb99 from a year ago.
2019-05-21 18:55:34 +02:00
Benno Schulenberg 4f1eb5fdd4 tweaks: remove the two remaining handfuls of asserts
They are just clutter -- no one runs a debug build for any length
of time.
2019-05-19 18:58:02 +02:00
Benno Schulenberg 1d3a4df3b3 browser: don't show a mistaken message when exiting from help viewer
This fixes https://savannah.gnu.org/bugs/?56346.

Bug existed since version 3.0, commit 8d6b205e.
2019-05-18 19:59:54 +02:00
Benno Schulenberg afbaf8ae2d files: give feedback while waiting for a FIFO to open up 2019-05-18 19:14:32 +02:00
Benno Schulenberg 1b2018e921 files: check for writability by the access bits, not by trying to append
Trying to append does not work on a fifo, and we'd like to be able to
open a fifo again.  Also, the append test causes a close event for the
given file at the moment of opening it, which makes using 'inotify' for
waiting for this file to be closed useless.

Commit f8f90272 added the append test, but the original request
(https://lists.gnu.org/archive/html/info-nano/2009-05/msg00000.html
by Damien Joldersma) asked only for a warning when the user did not
have enough privileges to write to the file.

So, drop the append test and just check the access bits.

This fixes https://bugs.debian.org/583196
and fixes https://savannah.gnu.org/bugs/?29312.
2019-05-18 19:13:42 +02:00
Benno Schulenberg 26642a39c3 files: allow a given file to be a special file but not a directory
The original requests (https://bugs.debian.org/551717 by Paul Wise,
and https://savannah.gnu.org/bugs/?45383 by Mike Frysinger) asked
only that specifying a directory instead of a file name should not
open a new buffer.  But commit 98ffb642 excluded everything that was
not a normal file.  This avoids a hang when the user accidentally
tries to open a pipe or a socket, but also prevents any user from
doing so on purpose.  And opening a fifo can be useful when wanting
to handle sensitive data that shouldn't be stored on disk.

This prepares the fix for https://bugs.debian.org/583196.
2019-05-18 17:24:13 +02:00
Benno Schulenberg 368f1a1c9d tweaks: elide a function that is called in just one place
Since commit b5f15cb5 from a year ago, there remains just one call
of initialize_buffer_text().
2019-05-16 16:16:52 +02:00
Benno Schulenberg 4fb9f298c9 tweaks: adjust some indentation after the previous change
Also reshuffle some arguments.
2019-05-08 19:35:42 +02:00
Benno Schulenberg c338d86843 tweaks: rename some single-letter variables to the same significant word
And simply elide one of those variables.
2019-05-08 19:35:03 +02:00
Benno Schulenberg c55d144748 tweaks: drop most of the remaining debugging code, and some timing code 2019-05-08 15:23:36 +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 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 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 11aa191bdc tweaks: rename a variable, to distinguish it from a browser function 2019-04-22 19:58:43 +02:00
Benno Schulenberg ea844d28fe tweaks: exclude a bit more code from a single-buffer build 2019-04-22 19:38:19 +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
Brand Huntsman 32431cddf8 files: block the resizing signal while reading from an external command
A SIGWINCH somehow causes the input stream to see EOT, with the result
that any remaining output of an external program would be lost.

This fixes https://savannah.gnu.org/bugs/?56038,
and fixes https://savannah.gnu.org/bugs/?56033.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-04-03 15:14:33 +02:00
Devin Hussey 7ad232d714 files: initialize a variable before referencing it
The lack of initialization caused a nasty bug on some targets (such as
ARMv7) which would make it so that ^S would just say "Cancelled".

While x86 (both 64 and 32 bits) seems to initialize 'response' to zero or
a positive number, ARM does not, and there is usually a negative value in
its place, which triggers the 'if (response < 0)' check and, as a result,
the code says "Cancelled".

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

Bug existed since version 4.0, commit 0f9d60a3.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2019-03-31 12:57:27 +02: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 a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +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 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 0f9d60a386 tweaks: split a variable into two, as they have different roles 2019-02-20 19:33:48 +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 ea4ba3a150 tweaks: add an alias for a string variable, so the code makes more sense 2019-02-12 16:06:24 +01:00
Benno Schulenberg 32d7d3900d tweaks: reshuffle a few lines, and condense some comments 2019-02-12 16:06:24 +01:00
Benno Schulenberg b57336ad00 tweaks: rename some variables, to match others that have the same task 2019-02-12 16:06:24 +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 4bf650f021 tweaks: condense a comment, and drop two others
And replace a statement with a self-explanatory one.
2019-01-22 20:25:07 +01:00
Benno Schulenberg da4b7e430f files: retain a Shift-selected region when switching between buffers
The user did not move the cursor nor intend to move the cursor, so
leave things as they are.

This fixes https://savannah.gnu.org/bugs/?55535.
Indirectly-reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-01-21 12:24:45 +01:00
Benno Schulenberg 0c42c51aa4 tweaks: rename two variables, to indicate better what they mean 2019-01-06 15:46:23 +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 a57c6a6763 tweaks: elide a one-line function that is used just twice 2018-12-27 21:19:47 +01:00
Benno Schulenberg 597d90207e startup: improve two error messages by mentioning the invalid operand
This addresses https://savannah.gnu.org/bugs/?55304.
2018-12-27 21:08:57 +01:00
Benno Schulenberg 929e1b6809 tweaks: rename a parameter plus a variable, and reshuffle an assignment
Also improve the comment.
2018-11-19 16:54:12 +01:00
Benno Schulenberg ca6281e821 tweaks: condense a handful of comments, and drop an assert 2018-11-05 09:38:07 +01:00
Brand Huntsman 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 e9ba058f3d tweaks: elide a function that is used just once and is a oneliner 2018-10-30 19:34:03 +01:00
Benno Schulenberg 63f2be7a2f options: let view mode activate "multibuffer" to allow viewing more files
When --view is used without --ignorercfiles, the user could view
other files anyway if they had 'set multibuffer' in their nanorc.
So, just make this the default when --view is used, also because
"multibuffer" cannot be toggled once nano is running in view mode.

When the viewing of other files in view mode should not be allowed,
one should now additionally use --restricted.
2018-10-23 19:15:27 +02:00
Benno Schulenberg 9c2b67231e tweaks: rename a flag, to match the name of the option 2018-10-02 19:18:55 +02:00
Benno Schulenberg 9e71de12cd tweaks: improve a translator hint and some other comments 2018-09-09 08:17:22 +02:00
Benno Schulenberg 33c4bb22d5 tweaks: adjust some translator hints for past changes, and add two more 2018-08-29 20:20:43 +02:00
Benno Schulenberg 6d62682ddb bindings: move the noconvert toggle from the main to the insert menu
Also add feedback, so that it will be clear whether a file will be
inserted unconverted or not.

This addresses https://savannah.gnu.org/bugs/?54536.
2018-08-25 10:04:03 +02:00
Benno Schulenberg 8d6b205e4c tweaks: remove a superfluous condition and a redundant refresh
When 'inhelp' is true, there are at least two buffers open: an
edit buffer and the help-text buffer.

And bottombars() already does a full refresh of the bottom window.
2018-08-22 18:10:55 +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 115f089d5f speller: hook up a marked-text alternative spellcheck to the undo system 2018-08-07 20:39:50 +02:00
David Lawrence Ramsey 7f6460b804 speller: hook up a full alternative spellcheck to the undo system 2018-08-07 20:39:13 +02:00
David Lawrence Ramsey bc6787826a speller: make replace_marked_buffer() use the cutting functions directly 2018-08-07 20:38:50 +02:00
David Lawrence Ramsey b5f15cb574 speller: make replace_buffer() use the cutting functions directly 2018-08-07 20:38:21 +02:00
Benno Schulenberg f82eefa303 tweaks: exclude the file-prepending code from the tiny version
The prepending and appending toggles are not available in tiny nano,
so there is no need to have the code either.
2018-07-24 19:31:03 +02:00
Benno Schulenberg c46696d40c tweaks: delete some old debugging code that no longer seems useful 2018-07-18 19:53:44 +02:00
Benno Schulenberg 75c7c35cfd tweaks: use a shorter message, because when the screen is small... 2018-07-14 19:42:38 +02:00
Benno Schulenberg d92142c66a easter: show the crawl only when there is room enough for the lines
The crawl needs at least five rows to be perceived as a crawl, and
the widest line is 31 characters (ignoring translations, which might
be even longer).  Formerly, when only two or three rows were available,
nothing was shown at all, which was puzzling.  So, better do the credits
only when there is room enough for them, and print a message otherwise.
2018-07-13 19:45:15 +02:00
Benno Schulenberg f598a4f12d files: add the file format on the status bar when switching buffers
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-07-13 11:15:48 +02:00
Benno Schulenberg 063a8b0870 startup: show the correct number of lines when opening multiple files
When switching to a different buffer, don't just show its name but
also the number of lines it contains.  This is useful extra info.

Then use this same message when at startup multiple files are opened
and (after reading them all) we switch back to the first buffer.

(This loses, when multiple files are opened, the information about
format conversion that nano still shows when a single file is opened,
but... this bug has shown that people don't really look at this line
anyway, so... let it be.  The info can still be seen when writing out
the file with ^O.)

This addresses https://savannah.gnu.org/bugs/?54047.
2018-07-13 09:37:04 +02:00
Devin Hussey b2ff574678 files: speed up reading by using getc_unlocked() instead of getc()
Unlike glibc, which in getc() locks the file only when it is needed,
FreeBSD and Bionic libc will always lock the file, causing a massive
slowdown, as the system has to create and destroy a mutex each time
getc() is called.

Avoid that massive overhead by locking the file before starting to read
and unlocking it after reading is complete, and using getc_unlocked() to
read each byte.  This makes reading on FreeBSD/macOS and Android anywhere
from 2 to 6 times faster, and on glibc roughly seventy percent faster.

This partially addresses https://savannah.gnu.org/bugs/?50406.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-07-12 12:44:35 +02:00
Benno Schulenberg 0c455155ad prompt: concentrate manipulations of 'statusbar_x' into a single file 2018-07-11 10:45:58 +02:00
Benno Schulenberg 2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
Benno Schulenberg 0f2b0ffbd3 tweaks: reshuffle a condition, and adjust a comment and some indentation 2018-05-31 16:27:13 +02:00
Benno Schulenberg f2f901c895 files: give feedback during writeout also when prepending or appending
The only time that feedback about the number of lines written is *not*
wanted is when writing a temporary file.

This fixes https://savannah.gnu.org/bugs/?54025.
2018-05-31 16:08:16 +02:00
Benno Schulenberg 408d9b8708 build: fix compilation failure when configured with --enable-tiny 2018-05-23 11:57:55 +02:00
Marco Diego Aurélio Mesquita f304b9aee1 new feature: allow piping (selected) text to an external command
When executing a command, it is now possible to pipe the entire buffer
(or the marked region, if anything is marked) to the external command.
The output from the command replaces the buffer (or the marked region),
or goes to a new buffer.

This fulfills https://savannah.gnu.org/bugs/?28993,
and fulfills https://savannah.gnu.org/bugs/?53041.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-22 19:36:21 +02:00
Benno Schulenberg bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg b7f8d4819b tweaks: frob some comments plus miscellaneous other stuff 2018-03-22 19:54:20 +01:00
Benno Schulenberg 30fc197b66 tweaks: adjust a couple of types, to reduce the number of warnings
This avoids eleven warnings of the kind "comparison between signed
and unsigned integer expressions [-Wsign-compare]".
2018-03-22 19:33:22 +01:00
Benno Schulenberg b9de5525c4 tweaks: elide a parameter, as it's always the inverse of another 2018-03-22 12:52:28 +01:00
Benno Schulenberg dd157f1494 tweaks: change a parameter of open_buffer() and invert its logic 2018-03-22 12:35:50 +01:00
Benno Schulenberg 624918800b tweaks: bundle some settings for a new buffer 2018-03-22 12:27:04 +01:00
Benno Schulenberg a1132c81a1 files: prevent the undo of reading a file into a new buffer
When the file has just been read, it is in the state that it has
on disk, so there is nothing to undo.

This fixes https://savannah.gnu.org/bugs/?53387.
2018-03-20 11:14:55 +01:00
Benno Schulenberg d3012be095 tweaks: don't call strcmp() to determine whether a string is empty 2018-03-06 11:59:03 +01:00
Benno Schulenberg 97cbbb0cc8 prompt: show whitespace only in the filename, not in the whole line
That is, call display_string() just on the filename, not on the rest
of the prompt text.

This fixes https://savannah.gnu.org/bugs/?52967.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2018-01-26 09:37:18 +01:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg 3981217e5a startup: allow a named pipe as file argument when --noread is used
This fixes https://savannah.gnu.org/bugs/?52896.
Reported-by: Miki Strange <mik@mikistrange.com>
Tested-by: Miki Strange <mik@mikistrange.com>
2018-01-16 21:43:16 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg b574f73e60 tweaks: add a separate function that actually wipes the status bar 2017-12-29 17:40:41 +01:00
Benno Schulenberg eac90c3eff prompt: blank the bar when a "continue?" is answered with No or ^C
This fixes https://savannah.gnu.org/bugs/?52755.
Reported-by: Brand Huntsman <alpha@qzx.com>
2017-12-29 17:01:15 +01:00
Benno Schulenberg dc3618a127 text: set and reset the Modified state correctly when undoing/redoing
Unset the "Modified" marker only at the point where the file was last
saved -- if there is such a point, because it can be missing when the
undo stack was discarded.

This fixes https://savannah.gnu.org/bugs/?52689.
Reported-by: Liu Hao <lh_mouse@126.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2017-12-19 19:22:52 +01:00
Benno Schulenberg 31fe0753e3 tweaks: limit the resetting of "Modified" to writing a full buffer
When doing that, there is no need to save and restore the Modified
state when writing a marked region.
2017-12-19 17:57:49 +01:00
Benno Schulenberg 0c40f87b55 tweaks: invert the logic of a variable, and rename it
To get rid of two double negatives.
2017-12-03 20:49:01 +01:00
Benno Schulenberg 20aa167c14 files: always update the stat info when the entire file is written
This fixes https://savannah.gnu.org/bugs/?52519.
2017-11-26 20:57:30 +01:00
Benno Schulenberg 0c9905dbd0 undo: clear the Modified state when the very first edit is undone
This also means that no question needs to be asked when exiting.

This fixes https://savannah.gnu.org/bugs/?52504.
Reported-by: Peter Passchier <peter@passchier.net>
2017-11-26 19:55:44 +01:00
Benno Schulenberg cf63a2910a files: save the marked region only when we've prompted for a file name
Otherwise we would overwrite the current file with just the selection.

This fixes https://savannah.gnu.org/bugs/?52482.
2017-11-22 20:56:37 +01:00
Benno Schulenberg 7c3c942097 tweaks: adjust indentation after previous change 2017-11-22 19:43:50 +01:00
Benno Schulenberg 77d24300f3 tweaks: reshuffle a couple of lines, and frob a comment or two 2017-11-22 19:36:33 +01:00
Benno Schulenberg c24e95e3d6 tweaks: elide the 'mark_set' boolean -- the 'mark' pointer is enough
The pointer not being NULL is enough indication that the mark is set.

Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
2017-11-21 21:14:33 +01:00
Benno Schulenberg 8165b20fc1 build: fix compilation with --disable-browser --disable-tabcomp
While doing that, move the affected function to the utils.c file
and tweak it a bit.

This fixes https://savannah.gnu.org/bugs/?52468.
2017-11-20 19:37:08 +01:00
Benno Schulenberg f6e83438da tweaks: elide a comment, and improve a couple of others 2017-11-13 19:58:29 +01:00
David Lawrence Ramsey 169da09424 files: don't change file format when inserting into an existing buffer
This fixes https://savannah.gnu.org/bugs/?52392.
2017-11-13 19:42:44 +01:00
Benno Schulenberg 5198c1f139 tweaks: frob a couple of comments 2017-11-12 20:08:28 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg a7f5907b43 tweaks: move a general function to the utils.c file 2017-11-11 11:34:39 +01:00
David Lawrence Ramsey 477b246771 tweaks: use printf's z modifier for most of the size_t/ssize_t types
Also, properly refer to numreplaced as signed, since it's ssize_t
(even though it's only shown when positive).
2017-11-07 17:55:21 +01:00
Benno Schulenberg d054044d30 tweaks: transform the token DISABLE_EXTRA to ENABLE_EXTRA 2017-11-01 20:33:14 +01:00
Benno Schulenberg d5ac1ed395 tweaks: transform the token DISABLE_COLOR to ENABLE_COLOR 2017-11-01 19:45:50 +01:00
Benno Schulenberg 2a4fc9591f tweaks: transform the token DISABLE_SPELLER to ENABLE_SPELLER 2017-10-31 19:32:42 +01:00
Benno Schulenberg 028d12f4fb tweaks: transform the token DISABLE_OPERATINGDIR to ENABLE_OPERATINGDIR 2017-10-29 21:08:07 +01:00
Benno Schulenberg ff35a61355 tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES 2017-10-29 19:43:05 +01:00
Benno Schulenberg 3f27c312c4 tweaks: get rid of some cluttering conditional compilation
In the tiny version, do_prompt() will now have an extra NULL
parameter, which will cost maybe twenty extra bytes of code.
That is acceptable when it saves thirty lines in the source.
2017-10-29 11:39:27 +01:00
Benno Schulenberg ab6e4e36e2 tweaks: fix compilation with --enable-tiny --enable-histories 2017-10-29 10:49:08 +01:00
Benno Schulenberg 84c650b80a files: avoid an abortion when excuting a command in a new buffer
The key sequence ^R ^X M-F <Enter> would cause nano to abort, because
it would try to add an empty string to a history list.  (Furthermore,
simply don't execute an empty command, because it is pointless.)

Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2017-10-28 12:33:03 +02:00
Benno Schulenberg ba65cd48cc bindings: make ^Q and ^S do something useful by default
^S will be the first thing people will try for saving a file,
and ^Q is somewhat mnemonic because it is to the left of ^W:
it searches backward.

Make these keystrokes available also in the tiny version.
2017-10-14 20:34:43 +02:00
Benno Schulenberg a7fa174438 tweaks: adjust indentation and comments after the previous change 2017-10-14 11:58:28 +02:00
Viorel Bota 217cfbf362 files: check for a changed disk file also for 'savefile' and --tempfile
Before writing a file out, nano should check that the file on disk
hasn't been modified since it was read -- not only for the normal
"Write Out" action (^O), but also for "Save File" (future ^S) and
for "Save and Exit" (^X when --tempfile is used).

When writing fails and --tempfile is in effect, don't go on to prompt
for a file name; instead let the user decide what she wants to do.

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

Signed-off-by: Viorel Bota <botaviorel@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-10-13 20:24:10 +02:00
Benno Schulenberg a2b4f00a27 tweaks: fix compilation when configured with --disable-histories 2017-10-03 21:39:09 +02:00