nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 95c966c3fcb0755ba9bb1c3615f2754d1c5e55d2
parent 982e226c3fcb7d6fe49e3e4385b69278eed7fbe2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  8 May 2020 10:55:39 +0200

tweaks: do the saving of histories in a single place

Also, when finish() is called when the user presses Cancel upon
encountering a lock file, there is no need to save any history
files because nothing has changed.

Diffstat:
Msrc/nano.c | 22++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -252,14 +252,6 @@ void finish(void) display_rcfile_errors(); #endif -#ifdef ENABLE_HISTORIES - /* If the user wants history persistence, write the relevant files. */ - if (ISSET(HISTORYLOG)) - save_history(); - if (ISSET(POSITIONLOG) && openfile) - update_poshistory(); -#endif - /* Get out. */ exit(0); } @@ -763,13 +755,13 @@ void close_and_go(void) if (ISSET(LOCKING) && openfile->lock_filename) delete_lockfile(openfile->lock_filename); #endif +#ifdef ENABLE_HISTORIES + if (ISSET(POSITIONLOG)) + update_poshistory(); +#endif #ifdef ENABLE_MULTIBUFFER /* If there is another buffer, close this one; otherwise terminate. */ if (openfile != openfile->next) { -#ifdef ENABLE_HISTORIES - if (ISSET(POSITIONLOG)) - update_poshistory(); -#endif switch_to_next_buffer(); openfile = openfile->prev; close_buffer(); @@ -778,7 +770,13 @@ void close_and_go(void) titlebar(NULL); } else #endif + { +#ifdef ENABLE_HISTORIES + if (ISSET(HISTORYLOG)) + save_history(); +#endif finish(); + } } /* Note that Ctrl+C was pressed during some system call. */