From 8b2114a25ff01d855e16fb61f4fb4dec65eeb791 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 4 Aug 2020 17:11:05 +0200 Subject: [PATCH] rcfile: allow to bind M-[ (even though it is an escape-sequence starter) The user had better avoid using the keystroke in a macro, but when typing directly at a responsive machine there is no problem, M-[ is a perfectly valid and recognizable keystroke. This fulfills https://savannah.gnu.org/bugs/?58820. --- src/nano.c | 9 ++++----- src/rcfile.c | 4 ++-- syntax/nanorc.nanorc | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nano.c b/src/nano.c index bc502b13..94074201 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1280,17 +1280,16 @@ void unbound_key(int code) else if (code > 0x7F) statusline(ALERT, _("Unbound key")); else if (meta_key) { - if (code == '[') - statusline(ALERT, _("Unbindable key: M-[")); #ifndef NANO_TINY - else if (code < 0x20) + if (code < 0x20) statusline(ALERT, _("Unbindable key: M-^%c"), code + 0x40); + else #endif #ifdef ENABLE_NANORC - else if (shifted_metas && 'A' <= code && code <= 'Z') + if (shifted_metas && 'A' <= code && code <= 'Z') statusline(ALERT, _("Unbound key: Sh-M-%c"), code); -#endif else +#endif statusline(ALERT, _("Unbound key: M-%c"), toupper(code)); } else if (code == ESC_CODE) statusline(ALERT, _("Unbindable key: ^[")); diff --git a/src/rcfile.c b/src/rcfile.c index 733db378..d848f4d0 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -853,8 +853,8 @@ void parse_binding(char *ptr, bool dobind) newsc->keystr = keycopy; newsc->keycode = keycode; - /* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */ - if (newsc->keycode == ESC_CODE || newsc->keycode == '[') { + /* Disallow rebinding (^[). */ + if (newsc->keycode == ESC_CODE) { jot_error(N_("Keystroke %s may not be rebound"), keycopy); free_things: free(keycopy); diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc index dd06c188..33290e34 100644 --- a/syntax/nanorc.nanorc +++ b/syntax/nanorc.nanorc @@ -11,8 +11,8 @@ color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>" 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:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)" -color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" +color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)" +color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*" color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)" color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"