+2015-07-25 Benno Schulenberg <bensberg@justemail.net>
+ * src/global.c (shortcut_init, strtosc), src/files.c (savefile),
+ doc/man/nanorc.5, doc/texinfo/nano.texi: Add a new bindable function,
+ 'savefile', which writes a file to disk without first asking for its
+ name. This implements Savannah patch #8208 submitted by Seiya Nuta.
+
2015-07-23 Benno Schulenberg <bensberg@justemail.net>
* doc/man/{nano.1,nanorc.5}, doc/texinfo/nano.texi: Add deprecation
notices for the options 'set const', 'set poslog' and '--poslog'.
Exits from the program (or from the help viewer or the file browser).
.TP
.B writeout
-Writes the current buffer to disk.
+Writes the current buffer to disk, asking for a name.
+.TP
+.B savefile
+Writes the current file to disk without prompting or warning.
.TP
.B insert
Inserts a file into the current buffer (at the current cursor position),
Exits from the program (or from the help viewer or the file browser).
@item writeout
-Writes the current buffer to disk.
+Writes the current buffer to disk, asking for a name.
+
+@item savefile
+Writes the current file to disk without prompting or warning.
@item insert
Inserts a file into the current buffer (at the current cursor position),
display_main_list();
}
+#ifndef NANO_TINY
+/* If it has a name, write the current file to disk without prompting. */
+void do_savefile(void)
+{
+ if (openfile->filename[0] != '\0')
+ write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE);
+ else
+ do_writeout_void();
+}
+#endif
+
/* Return a malloc()ed string containing the actual directory, used to
* convert ~user/ and ~/ notation. */
char *real_dir_from_tilde(const char *buf)
const char *nano_suspend_msg =
N_("Suspend the editor (if suspend is enabled)");
#ifndef NANO_TINY
+ const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
+#ifndef NANO_TINY
+ add_to_funcs(do_savefile, MMAIN,
+ N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
+#endif
+
#ifndef DISABLE_HISTORIES
add_to_funcs(get_history_older_void,
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
s->scfunc = do_exit;
else if (!strcasecmp(input, "writeout"))
s->scfunc = do_writeout_void;
+#ifndef NANO_TINY
+ else if (!strcasecmp(input, "savefile"))
+ s->scfunc = do_savefile;
+#endif
else if (!strcasecmp(input, "insert"))
s->scfunc = do_insertfile_void;
else if (!strcasecmp(input, "whereis"))
#endif
bool do_writeout(bool exiting);
void do_writeout_void(void);
+#ifndef NANO_TINY
+void do_savefile(void);
+#endif
char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
int diralphasort(const void *va, const void *vb);