1
1

Adding a new bindable function that writes a file to disk without

first asking for its name.  Patch was suggested by Seiya Nuta.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5318 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Benno Schulenberg 2015-07-25 19:25:50 +00:00
родитель 25c775af21
Коммит ee7b095678
6 изменённых файлов: 38 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,9 @@
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'.

Просмотреть файл

@ -380,7 +380,10 @@ Cancels the current command.
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),

Просмотреть файл

@ -950,7 +950,10 @@ Cancels the current command.
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),

Просмотреть файл

@ -2459,6 +2459,17 @@ void do_writeout_void(void)
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)

Просмотреть файл

@ -601,6 +601,7 @@ void shortcut_init(void)
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 =
@ -911,6 +912,11 @@ void shortcut_init(void)
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),
@ -1299,6 +1305,10 @@ sc *strtosc(char *input)
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"))

Просмотреть файл

@ -321,6 +321,9 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
#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);