From a567834ff8feb890c40ae7860d65625cebf029f0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 3 Jan 2021 22:40:06 -0500 Subject: [PATCH] Fix #4457: broken key sequences ending with C-i --- core/core-keybinds.el | 14 +++++++++----- core/core-lib.el | 12 ++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 705dde5ec..6d78c6db1 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -41,12 +41,16 @@ and Emacs states, and for non-evil users.") ;; HACK Fixes Emacs' disturbing inability to distinguish C-i from TAB. (define-key key-translation-map [?\C-i] - (cmd! (if (and (not (cl-position 'tab (this-single-command-raw-keys))) - (not (cl-position 'kp-tab (this-single-command-raw-keys))) - (display-graphic-p)) + (cmd! (if (let ((keys (this-single-command-raw-keys))) + (and keys + (not (cl-position 'tab keys)) + (not (cl-position 'kp-tab keys)) + (display-graphic-p) + (let ((key + (doom-lookup-key + (vconcat (cl-subseq keys 0 -1) [C-i])))) + (not (or (numberp key) (null key)))))) [C-i] [?\C-i]))) -;; However, ensure falls back to the old keybind if it has no binding. -(global-set-key [C-i] [?\C-i]) ;; diff --git a/core/core-lib.el b/core/core-lib.el index 783fb5fa8..eed0837ab 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -94,6 +94,18 @@ at the values with which this function was called." (lambda (&rest pre-args) (apply fn (append pre-args args)))) +(defun doom-lookup-key (keys &optional keymap) + "Like `lookup-key', but search active keymaps if KEYMAP is omitted." + (if keymap + (lookup-key keymap keys) + (cl-loop for keymap + in (append (mapcar #'cdr (mapcar #'symbol-value emulation-mode-map-alists)) + (list (current-local-map)) + (mapcar #'cdr minor-mode-alist) + (list (current-global-map))) + if (lookup-key keymap keys) + return it))) + ;; ;;; Sugars