+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.
/* 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;
/* 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;
* 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);