From b83dd9c78600373216e53daf0e3c275ca6604a10 Mon Sep 17 00:00:00 2001 From: Keith Pinson <3661051+Kazark@users.noreply.github.com> Date: Fri, 18 Sep 2020 13:36:40 -0400 Subject: [PATCH] [core] Fix evil keybindings when a link is selected in Custom-mode (#13963) * [core] Fix evil keybindings when a link is selected in Custom-mode This uses a separate keymap bound directly to the widget and circumvents the existing evil keybindings. This fixes the bug found by @duianto, which he posted [here](https://github.com/syl20bnr/spacemacs/pull/13949#issuecomment-694685304). * [core] Fix q and u to work everywhere in a Custom-mode buffer --- layers/+spacemacs/spacemacs-defaults/packages.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/layers/+spacemacs/spacemacs-defaults/packages.el b/layers/+spacemacs/spacemacs-defaults/packages.el index 8da3bd8c5..3e67546dc 100644 --- a/layers/+spacemacs/spacemacs-defaults/packages.el +++ b/layers/+spacemacs/spacemacs-defaults/packages.el @@ -99,11 +99,17 @@ ;; - `u' as `Custom-goto-parent' conflicts with Evil undo. However it is ;; questionable whether this will work properly in a Custom buffer; ;; choosing to restore this binding. - (evil-define-key 'normal cus-edit-mode-map (kbd "q") 'Custom-buffer-done) - (evil-define-key 'normal cus-edit-mode-map (kbd "u") 'Custom-goto-parent) + (evil-define-key 'normal custom-mode-map (kbd "q") 'Custom-buffer-done) + (evil-define-key 'normal custom-mode-map (kbd "u") 'Custom-goto-parent) ;; `RET' does not work well in the search field. Fix: - (evil-define-key 'insert cus-edit-mode-map (kbd "RET") 'spacemacs/custom-newline) - (evil-define-key 'normal cus-edit-mode-map (kbd "RET") 'spacemacs/custom-newline)) + (evil-define-key '(insert normal) custom-mode-map (kbd "RET") 'spacemacs/custom-newline) + ;; There is a separate map for links, oddly enough. Separate it from the + ;; `custom-mode-map' bindings, which is its parent by default. + (set-keymap-parent custom-mode-link-map nil) + ;; Evil doesn't seem to be properly in control of what is going on in these + ;; widget-induced keymaps, so just use base bindings to sort this out + (define-key custom-mode-link-map (kbd "q") 'Custom-buffer-done) + (define-key custom-mode-link-map (kbd "u") 'Custom-goto-parent)) (defun spacemacs-defaults/init-dired () (spacemacs/set-leader-keys