From 76f47d0632efffd560125fc511b7eb940ddbdd92 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 24 Oct 2021 10:20:05 +0200 Subject: [PATCH] suspension: enable ^Z by default; drop the -z option and the M-Z toggle I can't think of a good reason for disabling ^Z. If the user happens to hit ^Z by accident, the instruction to type 'fg' for getting back to nano is right there on the screen. Also, other editors like vim, emacs, lpe, and ne all have a functional ^Z, out of the box -- none of them balk and say "Not enabled". Furthermore, Debian and Ubuntu have always had 'set suspend' in /etc/nanorc, so a considerable portion of Linux users have had ^Z enabled by default for a long time, and no one seems to have complained. So... just enable it. If the keystroke bothers the user (hitting it too often by accident), they can unbind the keystroke 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. --- src/global.c | 3 --- src/nano.c | 22 ++++++---------------- src/rcfile.c | 5 +---- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/global.c b/src/global.c index 9130dff8..ddcddd66 100644 --- a/src/global.c +++ b/src/global.c @@ -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: diff --git a/src/nano.c b/src/nano.c index cbbefdb3..60627d6f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -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 @@ -955,11 +951,10 @@ void do_suspend(int signal) /* Put nano to sleep (if suspension is enabled). */ 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 '%': @@ -2181,7 +2172,6 @@ int main(int argc, char **argv) * since they 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); diff --git a/src/rcfile.c b/src/rcfile.c index 137157ec..f7485999 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -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 */ { -- 2.29.3