From 4f3f976030a679280cd6958a18b49094f612a03d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 16 Jun 2014 20:44:34 +0000 Subject: [PATCH] Displaying "No file name" on the statusbar for two seconds when --tempfile was given and the current buffer has no name. This fixes Savannah bug #41750. Patch by David Lawrence Ramsey. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4974 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/files.c | 3 ++- src/nano.c | 31 +++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d3affbe..74532c70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-16 David Lawrence Ramsey + * src/nano.c (do_exit): Display the message "No file name" on the + statusbar for two seconds when --tempfile was given and the current + buffer has no name. This fixes Savannah bug #41750. + 2014-06-16 Benno Schulenberg * configure.ac: For the sake of statically linked systems, make sure the compiler also links against libz, which is used by libmagic. diff --git a/src/files.c b/src/files.c index b0115cc3..44a16511 100644 --- a/src/files.c +++ b/src/files.c @@ -2208,7 +2208,8 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp, /* Write the current file to disk. If the mark is on, write the current * marked selection to disk. If exiting is TRUE, write the file to disk * regardless of whether the mark is on, and without prompting if the - * TEMP_FILE flag is set. Return TRUE on success or FALSE on error. */ + * TEMP_FILE flag is set and the current file has a name. Return TRUE + * on success or FALSE on error. */ bool do_writeout(bool exiting) { int i; diff --git a/src/nano.c b/src/nano.c index 50c8b4b5..ac1ee223 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1086,9 +1086,10 @@ void nano_disabled_msg(void) /* If the current file buffer has been modified, and the TEMP_FILE flag * isn't set, ask whether or not to save the file buffer. If the - * TEMP_FILE flag is set, save it unconditionally. Then, if more than - * one file buffer is open, close the current file buffer and switch to - * the next one. If only one file buffer is open, exit from nano. */ + * TEMP_FILE flag is set and the current file has a name, save it + * unconditionally. Then, if more than one file buffer is open, close + * the current file buffer and switch to the next one. If only one file + * buffer is open, exit from nano. */ void do_exit(void) { int i; @@ -1097,13 +1098,31 @@ void do_exit(void) * save. */ if (!openfile->modified) i = 0; - /* If the TEMP_FILE flag is set, pretend the user chose to save. */ - else if (ISSET(TEMP_FILE)) + /* If the TEMP_FILE flag is set and the current file has a name, + * pretend the user chose to save. */ + else if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) i = 1; /* Otherwise, ask the user whether or not to save. */ - else + else { + /* If the TEMP_FILE flag is set, and the current file doesn't + * have a name, handle it the same way Pico does. */ + if (ISSET(TEMP_FILE)) { + curs_set(0); + + /* Warn that the current file has no name. */ + statusbar(_("No file name")); + beep(); + + /* Ensure that we see the warning. */ + doupdate(); + napms(2000); + + curs_set(1); + } + i = do_yesno_prompt(FALSE, _("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ")); + } #ifdef DEBUG dump_filestruct(openfile->fileage);