diff --git a/ChangeLog b/ChangeLog index 1d3affbe63126e31fe7d98fdcaed76e89fad3e5b..74532c70fbb56e53716c8d6d00e3f368d8394c35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-16 David Lawrence Ramsey <pooka109@gmail.com> + * 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 <bensberg@justemail.net> * 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 b0115cc3afbe3f7cf75dbf8e88112fd94c6b2308..44a1651170ec33c43ee98551a0b7db50fde4da56 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 50c8b4b5096b4afd8a3675c02c53888565e75a3c..ac1ee22363b71d33b1448a29395e19c725c0ad11 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);