From 196e9136814e71f43d9ae17e4f16058d56dc1a35 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 22 Jan 2020 13:12:52 +0100 Subject: [PATCH] tweaks: elide three checks of a shortcut's meta flag A control code cannot be a Meta keystroke, and a plain printable character as key code necessarily means it is a Meta keystroke. So, comparing just the key code is enough. --- src/global.c | 8 ++------ src/rcfile.c | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/global.c b/src/global.c index 24091aa3..c6b5944d 100644 --- a/src/global.c +++ b/src/global.c @@ -443,10 +443,7 @@ size_t shown_entries_for(int menu) return count; } -/* Return the shortcut that corresponds to the values of kbinput (the - * key itself) and meta_key (whether the key is a meta sequence). The - * returned shortcut will be the first in the list that corresponds to - * the given sequence. */ +/* Return the first shortcut in the current menu that matches the given input. */ const keystruct *get_shortcut(int *kbinput) { /* Plain characters and upper control codes cannot be shortcuts. */ @@ -462,8 +459,7 @@ const keystruct *get_shortcut(int *kbinput) return NULL; for (keystruct *s = sclist; s != NULL; s = s->next) { - if ((s->menus & currmenu) && *kbinput == s->keycode && - meta_key == s->meta) + if ((s->menus & currmenu) && *kbinput == s->keycode) return s; } diff --git a/src/rcfile.c b/src/rcfile.c index 87f42ed2..273f1de0 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -823,8 +823,7 @@ void parse_binding(char *ptr, bool dobind) assign_keyinfo(newsc, keycopy, keycode); /* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */ - if ((!newsc->meta && newsc->keycode == ESC_CODE) || - (newsc->meta && newsc->keycode == '[')) { + if (newsc->keycode == ESC_CODE || newsc->keycode == '[') { jot_error(N_("Keystroke %s may not be rebound"), keycopy); free_things: free(keycopy);