rcfile: reject an attempt to bind ^[

Also, for <Esc> <Esc> [, report that it is unbindable.

This fixes https://savannah.gnu.org/bugs/?55336.
master
Benno Schulenberg 2018-12-30 19:28:17 +01:00
parent fb4ce71cfc
commit 34b8d58871
2 changed files with 7 additions and 4 deletions

View File

@ -1568,7 +1568,9 @@ void unbound_key(int code)
statusline(ALERT, _("Unbindable key: M-["));
else
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
} else if (code < 0x20)
} else if (code == ESC_CODE)
statusline(ALERT, _("Unbindable key: ^["));
else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
else
statusline(ALERT, _("Unbound key: %c"), code);

View File

@ -464,9 +464,10 @@ void parse_binding(char *ptr, bool dobind)
newsc->menus = menu;
assign_keyinfo(newsc, keycopy, 0);
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
if (newsc->meta && newsc->keycode == 91) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
(newsc->meta && newsc->keycode == '[')) {
rcfile_error(N_("Keystroke %s may not be rebound"), keycopy);
free_things:
free(keycopy);
free(newsc);