suspension: enable ^Z by default -- ignore -z option and drop M-Z toggle

In the beginning, the goal for nano was to be a drop-in replacement for
Pico.  Pico did not know a Suspend command, so the ^Z keystroke needed
to be conditionalized on an option (-z or --suspend or the toggle M-Z),
just like the ^S and ^Q keystrokes (for stopping and resuming terminal
output) were conditionalized on --preserve.

But nano has abandoned full Pico compatibility since version 4.0.  It
is time to unconditionalize ^Z as well.  This should not be a problem:
Debian and Ubuntu have had 'set suspend' in their /etc/nanorc for years,
so a considerable portion of nano users have had ^Z enabled by default
for a long time, and no one seems to have complained.

If the keystroke bothers some user, they can unbind it in their nanorc.
They will still be able to suspend nano through the Execute menu: ^T^Z.

This addresses https://savannah.gnu.org/bugs/?61372.
master
Benno Schulenberg 2021-10-24 10:20:05 +02:00
parent 8762e04631
commit 83f94a88df
3 changed files with 11 additions and 27 deletions

View File

@ -617,7 +617,7 @@ void shortcut_init(void)
N_("Count the number of words, lines, and characters");
#endif
const char *refresh_gist = N_("Refresh (redraw) the current screen");
const char *suspend_gist = N_("Suspend the editor (if suspension is enabled)");
const char *suspend_gist = N_("Suspend the editor (return to the shell)");
#ifdef ENABLE_WORDCOMPLETION
const char *completion_gist = N_("Try and complete the current word");
#endif
@ -1379,7 +1379,6 @@ void shortcut_init(void)
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPENDABLE);
#endif /* !NANO_TINY */
add_to_sclist(((MMOST & ~MMAIN) | MYESNO), "^C", 0, do_cancel, 0);
@ -1523,8 +1522,6 @@ const char *flagtostr(int flag)
return N_("Conversion of typed tabs to spaces");
case USE_MOUSE:
return N_("Mouse support");
case SUSPENDABLE:
return N_("Suspension");
case LINE_NUMBERS:
return N_("Line numbering");
default:

View File

@ -639,10 +639,6 @@ void usage(void)
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
#ifndef NANO_TINY
print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
#endif
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspendable", N_("Enable suspension"));
#ifndef NANO_TINY
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
#endif
@ -952,14 +948,13 @@ void do_suspend(int signal)
#endif
}
/* Put nano to sleep (if suspension is enabled). */
/* Put nano to sleep. */
void do_suspend_void(void)
{
if (!ISSET(SUSPENDABLE)) {
statusline(AHEM, _("Suspension is not enabled"));
beep();
} else
do_suspend(0);
if (in_restricted_mode())
return;
do_suspend(0);
ran_a_tool = TRUE;
}
@ -1059,9 +1054,6 @@ void regenerate_screen(void)
/* Handle the global toggle specified in flag. */
void do_toggle(int flag)
{
if (flag == SUSPENDABLE && in_restricted_mode())
return;
TOGGLE(flag);
focusing = FALSE;
@ -1104,7 +1096,7 @@ void do_toggle(int flag)
else if (!ISSET(MINIBAR) || !ISSET(STATEFLAGS) || flag == SMART_HOME ||
flag == NO_SYNTAX || flag == WHITESPACE_DISPLAY ||
flag == CUT_FROM_CURSOR || flag == TABS_TO_SPACES ||
flag == USE_MOUSE || flag == SUSPENDABLE) {
flag == USE_MOUSE) {
bool enabled = ISSET(flag);
if (flag == NO_HELP || flag == NO_SYNTAX)
@ -1726,7 +1718,7 @@ int main(int argc, char **argv)
{"nowrap", 0, NULL, 'w'},
#endif
{"nohelp", 0, NULL, 'x'},
{"suspendable", 0, NULL, 'z'},
{"suspendable", 0, NULL, 'z'}, /* Obsolete; remove in 2022. */
#ifndef NANO_TINY
{"smarthome", 0, NULL, 'A'},
{"backup", 0, NULL, 'B'},
@ -2033,7 +2025,6 @@ int main(int argc, char **argv)
break;
#endif
case 'z':
SET(SUSPENDABLE);
break;
#ifndef NANO_TINY
case '%':
@ -2177,11 +2168,10 @@ int main(int argc, char **argv)
if (ISSET(BOLD_TEXT))
hilite_attribute = A_BOLD;
/* When in restricted mode, disable backups, suspending, and history files,
* since they allow writing to files not specified on the command line. */
/* When in restricted mode, disable backups and history files, since they
* would allow writing to files not specified on the command line. */
if (ISSET(RESTRICTED)) {
UNSET(MAKE_BACKUP);
UNSET(SUSPENDABLE);
#ifdef ENABLE_NANORC
UNSET(HISTORYLOG);
UNSET(POSITIONLOG);

View File

@ -91,7 +91,7 @@ static const rcoption rcopts[] = {
{"speller", 0},
#endif
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
{"suspendable", SUSPENDABLE},
{"suspendable", SUSPENDABLE}, /* Obsolete; remove in 2022. */
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
#ifndef NANO_TINY
{"afterends", AFTER_ENDS},
@ -482,9 +482,6 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif
else if (!strcmp(input, "suspendable") ||
!strcmp(input, "suspendenable")) /* Deprecated; remove in 2022. */
s->toggle = SUSPENDABLE;
else
#endif /* !NANO_TINY */
{