+2015-10-29 David Lawrence Ramsey <pooka109@gmail.com>
+ * src/files.c (do_writeout), src/nano.c (no_current_file_name_warning,
+ do_exit): When option -t is given, make ^O work the same way as under
+ Pico, writing out the file without prompting. And make it work even
+ better than Pico when the current file doesn't yet have a name.
+
2015-10-28 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_redo): For an INSERT, 'u->mark_begin_lineno' is not
an actual line number, so spoof it. It can be spoofed, because 'f'
#endif
bool retval = FALSE;
- if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
+ if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
retval = write_file(openfile->filename, NULL, FALSE, OVERWRITE,
FALSE);
(append == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
+ /* If we're not exiting, and the TEMP_FILE flag is set, and
+ * the current file doesn't have a name, warn the user before
+ * prompting for a name. If we are exiting, we've already
+ * warned the user just before the "Save modified buffer"
+ * prompt, so we don't need to do it again. */
+ if (!exiting && openfile->filename[0] == '\0' && ISSET(TEMP_FILE))
+ no_current_file_name_warning();
+
/* If we're using restricted mode, the filename isn't blank,
* and we're at the "Write File" prompt, disable tab
* completion. */
return ISSET(NO_HELP) ? 2 : 0;
}
+/* Indicate that the current file has no name, in a way that gets the
+ * user's attention. This is used when trying to save a file with no
+ * name with the TEMP_FILE flag set, just before the filename prompt. */
+void no_current_file_name_warning(void)
+{
+ curs_set(0);
+
+ /* Warn that the current file has no name. */
+ statusbar(_("No file name"));
+ beep();
+
+ /* Ensure that we see the warning. */
+ doupdate();
+ napms(1800);
+
+ curs_set(1);
+}
+
/* 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 and the current file has a name, save it
/* Otherwise, ask the user whether or not to save. */
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);
- }
+ * have a name, warn the user before prompting for a name. */
+ if (ISSET(TEMP_FILE))
+ no_current_file_name_warning();
i = do_yesno_prompt(FALSE,
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
void version(void);
int more_space(void);
int no_help(void);
+void no_current_file_name_warning(void);
void do_exit(void);
void signal_init(void);
RETSIGTYPE handle_hupterm(int signal);