Commit Graph

48 Commits (fea5d7c6128e8df8bbeff1fb082c663a6ace8111)

Author SHA1 Message Date
Benno Schulenberg 079a679431 tweaks: rename two functions, to better indicate what they do 2020-04-15 17:20:03 +02:00
Benno Schulenberg 2148e857e5 copyright: update the years for significantly changed files 2020-01-15 12:11:56 +01:00
Benno Schulenberg afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg 95ae124891 history: don't wait when there is something wrong with the history files
Do not wait for the user to press a key when there is some problem
with any of the history files.  Just start and indicate the problem
on the status bar.  The precise error message is stored and will be
shown on the terminal when exiting from nano.

This addresses https://savannah.gnu.org/bugs/?56524.
2019-10-20 14:30:04 +02:00
Benno Schulenberg 31d5cb1118 build: slightly speed up the compilation of the tiny version
Don't include header files when they won't actually be needed.

(Also, remove a superfluous #ifdef.)
2019-10-13 18:55:49 +02:00
Benno Schulenberg ba79602281 tweaks: condense two comments, and rename two parameters
Also use 'while' instead of 'for'.
2019-10-13 16:45:02 +02:00
Benno Schulenberg 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 48124fdba4 tweaks: use a more effecient way to skip storing an empty file name
Position history refers only to actual files, so when the filename
is blank...  there is nothing that needs to be remembered.
2019-09-18 14:18:48 +02:00
Benno Schulenberg 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 17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg de47b58dc1 tweaks: move declaration of variable that does not need to be global
More importantly: searching in src/history.c will now not only find
the uses of 'position_history' but also its declaration.
2019-02-27 19:54:43 +01:00
Brand Huntsman a5ef013e82 history: use an unfreed 'position_history' to avoid a possible crash
The reload_positions_if_needed() routine can free the existing
'position_history' and allocate a new one.  Using the old one,
from before the reload, could lead to a crash.

This fixes https://savannah.gnu.org/bugs/?55792.
Reported-by: Enrico Mioso <mrkiko.rs@gmail.com>

Bug existed since the reloading of the position-history file was
introduced, a year and a half ago, in commit bfc53f30.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-02-27 18:03:08 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 757d223064 tweaks: don't bother executing two functions that are empty
The get_history_older_void() and get_history_newer_void() functions
are mere names, they don't actually do anything.  So... don't bother
to execute them, so the 'finished' variable doesn't have to be reset
after calling them.

Also, normalize the order of those two empty functions.
2019-02-12 16:06:24 +01: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 1e5064ef84 tweaks: fix a typo, remove a blank line, and improve some comments 2018-04-23 12:19:25 +02: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 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 73c7f1cbdc history: make nano's state directory accessible for the user only 2017-11-26 19:54:47 +01:00
Benno Schulenberg 4200ed3003 history: create the path '~/.local/share/' when it is needed
On a freshly installed system, or for a new user, the default
XDG data directory may not exist yet.  So, create it when not.

Reported-by: Brand Huntsman <alpha@qzx.com>
2017-11-26 19:54:47 +01:00
Benno Schulenberg 1e718cec35 tweaks: reshuffle a couple of lines, to put similar things together 2017-11-26 18:01:02 +01:00
Benno Schulenberg 5487551ce9 history: save the positions file also when a record was deleted
When a file is closed with the cursor on line 1, column 1, this
position is not recorded in file-positions history file -- if a
record for the file existed, it is deleted.  In the latter case
the history file needs to be saved, so that other instances of
nano will know about the deletion.

This fixes https://savannah.gnu.org/bugs/?52505.
2017-11-26 09:28:36 +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 2122a1a2b5 tweaks: constify the result strings of getenv(), as a reminder
Also, remove an unneeded pair of braces.
2017-11-10 20:03:07 +01:00
Marco Diego Aurélio Mesquita e2d3bba86c general: do not free strings gotten from getenv(), to avoid a crash
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2017-11-10 19:55:44 +01:00
Benno Schulenberg 478e34a80c ouch: set the positions-file name also when using the legacy state dir
One should test a change before pushing, also when it worked last time.
2017-11-08 21:15:28 +01:00
Benno Schulenberg ea47879911 tweaks: don't construct the positions-history filename time and again 2017-11-08 20:38:34 +01:00
Brand Huntsman bfc53f308c history: prevent overwriting of positions between multiple instances
Whenever a buffer is closed, check whether the positions file on disk
was modified, and if so, reload it.  Then update the position for the
closed buffer and write out the positions file to disk.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-11-08 20:38:34 +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
David Lawrence Ramsey 7d653e5a17 history: fix the check for an existing $HOME/.nano/ directory
This fixes https://savannah.gnu.org/bugs/?52339.
2017-11-05 20:35:52 +01:00
Simon Ochsenreither c16e79b612 startup: look for nanorc and history files also in the XDG directories
When not finding a .nanorc file in the user's home directory, nano will
look for a nanorc file in $XDG_CONFIG_HOME and in the ~/.config/nano/
fallback directory.  And when not finding a .nano/ subdir in the user's
home directory, nano will look for (or create) the history files in
$XDG_DATA_HOME or in the ~/.local/share/nano/ fallback directory.

This is a partial implementation of the XDG Base Directory Specification:
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html,
for the purpose of reducing the clutter in a user's home directory, and
to make it easier to back up just the configuration files.

Signed-off-by: Simon Ochsenreither <simon@ochsenreither.de>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-11-04 20:11:57 +01:00
Benno Schulenberg 4e03a245ac tweaks: adjust two comments, and correct and a few cosmetic mistakes 2017-10-30 19:12:22 +01:00
Benno Schulenberg ff35a61355 tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES 2017-10-29 19:43:05 +01:00
Benno Schulenberg 15738c6b39 history: remove the migration service for the old searches file
The code has been there for the last thirty releases -- for six
whole years -- more than enough time to have served its purpose.
2017-10-03 21:18:38 +02:00
Benno Schulenberg fd86696658 tweaks: rename one variable once more
So that it is not a substring of some other name.
2017-09-17 21:40:59 +02:00
Benno Schulenberg 09ab91c79c tweaks: strip four unneeded checks
The functions to read and write history files will not even be called
when the home directory is missing, so there is no need to check for
that eventuality again.
2017-09-17 21:34:16 +02:00
Benno Schulenberg 5f4fb8e513 tweaks: frob some comments and rename a few variables and a function 2017-09-17 20:17:13 +02:00
Benno Schulenberg 7a9d010186 tweaks: rename two variables, to be more indicative of what they do 2017-09-17 17:48:03 +02:00
Benno Schulenberg 231fe4bf01 tweaks: rename a function and swap its two parameters 2017-09-17 17:29:43 +02:00
Benno Schulenberg 067a920517 tweaks: improve some comments, and rename a variable for symmetry 2017-09-17 17:16:36 +02:00
Benno Schulenberg 36e88032cb tweaks: rename two variables, to make a little more sense 2017-09-17 16:54:45 +02:00
Benno Schulenberg e0a73f58f3 tweaks: drop a bunch of outdated asserts 2017-09-17 12:48:13 +02:00
Benno Schulenberg 1be8eb3b30 tweaks: elide an unneeded check
When history has changed, not all three listst can be empty.
2017-09-17 12:47:28 +02:00
Benno Schulenberg fb9c180bae history: after loading the lists, mark them as unchanged
Populating the search, replace, and execute lists makes use of the
function update_history() which sets history_changed to TRUE, which
meant that the search_history file would always get written even if
nothing had changed.
2017-09-17 12:47:11 +02:00
Benno Schulenberg c10a1e54dc tweaks: elide an unneeded function now that stuff is grouped together 2017-09-17 12:46:49 +02:00
Benno Schulenberg a1c73317f7 organization: move all history-related stuff to its own file 2017-09-17 12:46:36 +02:00