options: rename --tempfile to --saveonexit, to be far clearer
A long option should describe what it does, not vaguely hint at it. Also, in several places of nano's code we deal with actual temp files, and then having a flag called TEMP_FILE that doesn't have anything to do with temp files is somewhat confusing.master
parent
af062af490
commit
d4ee6a2b53
|
@ -291,7 +291,7 @@ The default value is \-8.
|
||||||
Use this command to perform spell checking and correcting, instead of
|
Use this command to perform spell checking and correcting, instead of
|
||||||
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
|
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
|
||||||
.TP
|
.TP
|
||||||
.BR \-t ", " \-\-tempfile
|
.BR \-t ", " \-\-saveonexit
|
||||||
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
||||||
.TP
|
.TP
|
||||||
.BR \-u ", " \-\-unix
|
.BR \-u ", " \-\-unix
|
||||||
|
|
|
@ -411,10 +411,10 @@ corrector, which requires either @command{hunspell} or GNU @command{spell}
|
||||||
to be installed.
|
to be installed.
|
||||||
|
|
||||||
@item -t
|
@item -t
|
||||||
@itemx --tempfile
|
@itemx --saveonexit
|
||||||
Don't ask whether to save a modified buffer when exiting with @kbd{^X}, but
|
Save a changed buffer without prompting (when exiting with @kbd{^X}).
|
||||||
assume yes. This option is useful when @command{nano} is used as the
|
This can be handy when @command{nano} is used as the composer of an
|
||||||
composer of a mailer program.
|
email program.
|
||||||
|
|
||||||
@item -u
|
@item -u
|
||||||
@item --unix
|
@item --unix
|
||||||
|
@ -1476,7 +1476,7 @@ When writing a file, creates a backup of the current file.
|
||||||
|
|
||||||
@item discardbuffer
|
@item discardbuffer
|
||||||
When about to write a file, discard the current buffer without saving.
|
When about to write a file, discard the current buffer without saving.
|
||||||
(This function is bound by default only when option @option{--tempfile}
|
(This function is bound by default only when option @option{--saveonexit}
|
||||||
is in effect.)
|
is in effect.)
|
||||||
|
|
||||||
@item browser
|
@item browser
|
||||||
|
|
|
@ -247,6 +247,9 @@ system either Backspace acts like Delete or Delete acts like Backspace.
|
||||||
Do regular-expression searches by default.
|
Do regular-expression searches by default.
|
||||||
Regular expressions in \fBnano\fR are of the extended type (ERE).
|
Regular expressions in \fBnano\fR are of the extended type (ERE).
|
||||||
.TP
|
.TP
|
||||||
|
.B set saveonexit
|
||||||
|
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
|
||||||
|
.TP
|
||||||
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
|
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||||
Specify the color combination to use for selected text.
|
Specify the color combination to use for selected text.
|
||||||
See \fBset titlecolor\fR for more details.
|
See \fBset titlecolor\fR for more details.
|
||||||
|
@ -293,9 +296,6 @@ greater than 0. The default value is \fB8\fR.
|
||||||
.B set tabstospaces
|
.B set tabstospaces
|
||||||
Convert typed tabs to spaces.
|
Convert typed tabs to spaces.
|
||||||
.TP
|
.TP
|
||||||
.B set tempfile
|
|
||||||
Save automatically on exit, don't prompt.
|
|
||||||
.TP
|
|
||||||
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
|
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||||
Specify the color combination to use for the title bar.
|
Specify the color combination to use for the title bar.
|
||||||
Valid names for the foreground and background colors are:
|
Valid names for the foreground and background colors are:
|
||||||
|
@ -796,7 +796,7 @@ When writing a file, creates a backup of the current file.
|
||||||
.TP
|
.TP
|
||||||
.B discardbuffer
|
.B discardbuffer
|
||||||
When about to write a file, discard the current buffer without saving.
|
When about to write a file, discard the current buffer without saving.
|
||||||
(This function is bound by default only when option \fB\-\-tempfile\fR
|
(This function is bound by default only when option \fB\-\-saveonexit\fR
|
||||||
is in effect.)
|
is in effect.)
|
||||||
.TP
|
.TP
|
||||||
.B browser
|
.B browser
|
||||||
|
|
|
@ -130,6 +130,10 @@
|
||||||
## Regular expressions are of the extended type (ERE).
|
## Regular expressions are of the extended type (ERE).
|
||||||
# set regexp
|
# set regexp
|
||||||
|
|
||||||
|
## Save a changed buffer automatically on exit; don't prompt.
|
||||||
|
# set saveonexit
|
||||||
|
## (The old form of this option, 'set tempfile', is deprecated.)
|
||||||
|
|
||||||
## Put the cursor on the highlighted item in the file browser, and show
|
## Put the cursor on the highlighted item in the file browser, and show
|
||||||
## the cursor in the help viewer; useful for people who use a braille
|
## the cursor in the help viewer; useful for people who use a braille
|
||||||
## display and people with poor vision.
|
## display and people with poor vision.
|
||||||
|
@ -159,9 +163,6 @@
|
||||||
## Convert typed tabs to spaces.
|
## Convert typed tabs to spaces.
|
||||||
# set tabstospaces
|
# set tabstospaces
|
||||||
|
|
||||||
## Save automatically on exit; don't prompt.
|
|
||||||
# set tempfile
|
|
||||||
|
|
||||||
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||||
# set trimblanks
|
# set trimblanks
|
||||||
|
|
||||||
|
|
|
@ -2060,7 +2060,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||||
/* Write the current file to disk. If the mark is on, write the current
|
/* Write the current file to disk. If the mark is on, write the current
|
||||||
* marked selection to disk. If exiting is TRUE, write the entire file
|
* marked selection to disk. If exiting is TRUE, write the entire file
|
||||||
* to disk regardless of whether the mark is on. Do not ask for a name
|
* to disk regardless of whether the mark is on. Do not ask for a name
|
||||||
* when withprompt is FALSE nor when the TEMP_FILE flag is set and the
|
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
|
||||||
* file already has a name. Return 0 on error, 1 on success, and 2 when
|
* file already has a name. Return 0 on error, 1 on success, and 2 when
|
||||||
* the buffer is to be discarded. */
|
* the buffer is to be discarded. */
|
||||||
int do_writeout(bool exiting, bool withprompt)
|
int do_writeout(bool exiting, bool withprompt)
|
||||||
|
@ -2113,7 +2113,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
present_path = mallocstrcpy(present_path, "./");
|
present_path = mallocstrcpy(present_path, "./");
|
||||||
|
|
||||||
/* When we shouldn't prompt, use the existing filename. */
|
/* When we shouldn't prompt, use the existing filename. */
|
||||||
if ((!withprompt || (ISSET(TEMP_FILE) && exiting)) &&
|
if ((!withprompt || (ISSET(SAVE_ON_EXIT) && exiting)) &&
|
||||||
openfile->filename[0] != '\0')
|
openfile->filename[0] != '\0')
|
||||||
answer = mallocstrcpy(answer, openfile->filename);
|
answer = mallocstrcpy(answer, openfile->filename);
|
||||||
else {
|
else {
|
||||||
|
@ -2184,7 +2184,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
* "zzy" as the filename to save under (hence "xyzzy"), and
|
* "zzy" as the filename to save under (hence "xyzzy"), and
|
||||||
* this is the first time we've done this, show an Easter
|
* this is the first time we've done this, show an Easter
|
||||||
* egg. Display the credits. */
|
* egg. Display the credits. */
|
||||||
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
|
if (!did_credits && exiting && !ISSET(SAVE_ON_EXIT) &&
|
||||||
strcasecmp(answer, "zzy") == 0) {
|
strcasecmp(answer, "zzy") == 0) {
|
||||||
if (LINES > 5 && COLS > 31) {
|
if (LINES > 5 && COLS > 31) {
|
||||||
do_credits();
|
do_credits();
|
||||||
|
@ -2273,7 +2273,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
|
|
||||||
/* When in tool mode and not called by 'savefile',
|
/* When in tool mode and not called by 'savefile',
|
||||||
* overwrite the file right here when requested. */
|
* overwrite the file right here when requested. */
|
||||||
if (ISSET(TEMP_FILE) && withprompt) {
|
if (ISSET(SAVE_ON_EXIT) && withprompt) {
|
||||||
free(given);
|
free(given);
|
||||||
if (choice == 1)
|
if (choice == 1)
|
||||||
return write_file(openfile->filename, NULL,
|
return write_file(openfile->filename, NULL,
|
||||||
|
|
|
@ -482,7 +482,7 @@ size_t shown_entries_for(int menu)
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When --tempfile is not used, widen the grid of the WriteOut menu. */
|
/* When --saveonexit is not used, widen the grid of the WriteOut menu. */
|
||||||
if (menu == MWRITEFILE && first_sc_for(menu, discard_buffer) == NULL)
|
if (menu == MWRITEFILE && first_sc_for(menu, discard_buffer) == NULL)
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
|
@ -1390,7 +1390,7 @@ void shortcut_init(void)
|
||||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
||||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
|
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
|
||||||
#endif
|
#endif
|
||||||
if (ISSET(TEMP_FILE) && !ISSET(PRESERVE))
|
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
|
||||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||||
|
|
21
src/nano.c
21
src/nano.c
|
@ -570,7 +570,7 @@ void usage(void)
|
||||||
print_opt(_("-s <prog>"), _("--speller=<prog>"),
|
print_opt(_("-s <prog>"), _("--speller=<prog>"),
|
||||||
N_("Enable alternate speller"));
|
N_("Enable alternate speller"));
|
||||||
#endif
|
#endif
|
||||||
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
|
print_opt("-t", "--saveonexit", N_("Save changes on exit, don't prompt"));
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
print_opt("-u", "--unix", N_("Save a file by default in Unix format"));
|
print_opt("-u", "--unix", N_("Save a file by default in Unix format"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -719,9 +719,9 @@ void version(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the current file buffer has been modified, and the TEMP_FILE flag
|
/* If the current file buffer has been modified, and the SAVE_ON_EXIT
|
||||||
* isn't set, ask whether or not to save the file buffer. If the
|
* 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
|
* SAVE_ON_EXIT flag is set and the current file has a name, save it
|
||||||
* unconditionally. Then, if more than one file buffer is open, close
|
* 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
|
* the current file buffer and switch to the next one. If only one file
|
||||||
* buffer is open, exit from nano. */
|
* buffer is open, exit from nano. */
|
||||||
|
@ -733,15 +733,15 @@ void do_exit(void)
|
||||||
* save. */
|
* save. */
|
||||||
if (!openfile->modified)
|
if (!openfile->modified)
|
||||||
choice = 0;
|
choice = 0;
|
||||||
/* If the TEMP_FILE flag is set and the current file has a name,
|
/* If the SAVE_ON_EXIT flag is set and the current file has a name,
|
||||||
* pretend the user chose to save. */
|
* pretend the user chose to save. */
|
||||||
else if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE))
|
else if (openfile->filename[0] != '\0' && ISSET(SAVE_ON_EXIT))
|
||||||
choice = 1;
|
choice = 1;
|
||||||
/* Otherwise, ask the user whether or not to save. */
|
/* Otherwise, ask the user whether or not to save. */
|
||||||
else {
|
else {
|
||||||
/* If the TEMP_FILE flag is set, and the current file doesn't
|
/* If the SAVE_ON_EXIT flag is set, and the current file doesn't
|
||||||
* have a name, warn the user before prompting for a name. */
|
* have a name, warn the user before prompting for a name. */
|
||||||
if (ISSET(TEMP_FILE))
|
if (ISSET(SAVE_ON_EXIT))
|
||||||
warn_and_shortly_pause(_("No file name"));
|
warn_and_shortly_pause(_("No file name"));
|
||||||
|
|
||||||
choice = do_yesno_prompt(FALSE, _("Save modified buffer? "));
|
choice = do_yesno_prompt(FALSE, _("Save modified buffer? "));
|
||||||
|
@ -1709,7 +1709,8 @@ int main(int argc, char **argv)
|
||||||
#ifdef ENABLE_SPELLER
|
#ifdef ENABLE_SPELLER
|
||||||
{"speller", 1, NULL, 's'},
|
{"speller", 1, NULL, 's'},
|
||||||
#endif
|
#endif
|
||||||
{"tempfile", 0, NULL, 't'},
|
{"saveonexit", 0, NULL, 't'},
|
||||||
|
{"tempfile", 0, NULL, 't'}, /* Deprecated; remove in 2022. */
|
||||||
{"view", 0, NULL, 'v'},
|
{"view", 0, NULL, 'v'},
|
||||||
#ifdef ENABLE_WRAPPING
|
#ifdef ENABLE_WRAPPING
|
||||||
{"nowrap", 0, NULL, 'w'},
|
{"nowrap", 0, NULL, 'w'},
|
||||||
|
@ -1992,7 +1993,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 't':
|
case 't':
|
||||||
SET(TEMP_FILE);
|
SET(SAVE_ON_EXIT);
|
||||||
break;
|
break;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
case 'u':
|
case 'u':
|
||||||
|
|
|
@ -504,7 +504,7 @@ enum
|
||||||
VIEW_MODE,
|
VIEW_MODE,
|
||||||
USE_MOUSE,
|
USE_MOUSE,
|
||||||
USE_REGEXP,
|
USE_REGEXP,
|
||||||
TEMP_FILE,
|
SAVE_ON_EXIT,
|
||||||
CUT_FROM_CURSOR,
|
CUT_FROM_CURSOR,
|
||||||
BACKWARDS_SEARCH,
|
BACKWARDS_SEARCH,
|
||||||
MULTIBUFFER,
|
MULTIBUFFER,
|
||||||
|
|
|
@ -86,13 +86,14 @@ static const rcoption rcopts[] = {
|
||||||
{"rawsequences", RAW_SEQUENCES},
|
{"rawsequences", RAW_SEQUENCES},
|
||||||
{"rebinddelete", REBIND_DELETE},
|
{"rebinddelete", REBIND_DELETE},
|
||||||
{"regexp", USE_REGEXP},
|
{"regexp", USE_REGEXP},
|
||||||
|
{"saveonexit", SAVE_ON_EXIT},
|
||||||
#ifdef ENABLE_SPELLER
|
#ifdef ENABLE_SPELLER
|
||||||
{"speller", 0},
|
{"speller", 0},
|
||||||
#endif
|
#endif
|
||||||
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
|
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
|
||||||
{"suspendable", SUSPENDABLE},
|
{"suspendable", SUSPENDABLE},
|
||||||
{"tabsize", 0},
|
{"tabsize", 0},
|
||||||
{"tempfile", TEMP_FILE},
|
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
|
||||||
{"view", VIEW_MODE},
|
{"view", VIEW_MODE},
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
{"afterends", AFTER_ENDS},
|
{"afterends", AFTER_ENDS},
|
||||||
|
|
|
@ -7,7 +7,7 @@ comment "#"
|
||||||
color brightred ".*"
|
color brightred ".*"
|
||||||
|
|
||||||
# Keywords
|
# Keywords
|
||||||
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
|
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>"
|
||||||
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||||
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||||
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
|
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
|
||||||
|
|
Loading…
Reference in New Issue