From 16a495c97dd796ec20939d07bad3beb38586a1fe Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 6 Feb 2021 06:54:18 -0500 Subject: [PATCH] Fix #4548: global TAB overwritten by evil keybind --- core/core-lib.el | 6 +++--- modules/config/default/+evil-bindings.el | 21 ++++++++++++++++----- modules/editor/evil/config.el | 1 - 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index ed399b59e..54caab026 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -94,10 +94,10 @@ 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) +(defun doom-lookup-key (keys &rest keymaps) "Like `lookup-key', but search active keymaps if KEYMAP is omitted." - (if keymap - (lookup-key keymap keys) + (if keymaps + (cl-some (doom-rpartial #'lookup-key keys) keymaps) (cl-loop for keymap in (append (cl-loop for alist in emulation-mode-map-alists append (mapcar #'cdr diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 4968999aa..e500ba4a7 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -42,13 +42,24 @@ (bound-and-true-p yas-minor-mode) (yas-maybe-expand-abbrev-key-filter 'yas-expand)) #'yas-expand - (and (featurep! :completion company +tng) - (+company-has-completion-p)) - #'company-complete-common) - :v [tab] (cmds! (and (bound-and-true-p yas-minor-mode) + (featurep! :completion company +tng) + #'company-indent-or-complete-common) + :m [tab] (cmds! (and (bound-and-true-p yas-minor-mode) + (evil-visual-state-p) (or (eq evil-visual-selection 'line) (not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\)))))) - #'yas-insert-snippet) + #'yas-insert-snippet + (and (featurep! :editor fold) + (save-excursion (end-of-line) (invisible-p (point)))) + #'+fold/toggle + ;; Fixes #4548: without this, this tab keybind overrides + ;; mode-local ones for modes that don't have an evil + ;; keybinding scheme or users who don't have :editor (evil + ;; +everywhere) enabled. + (doom-lookup-key [tab] (list (current-local-map))) + it + (fboundp 'evil-jump-item) + #'evil-jump-item) (:after help :map help-mode-map :n "o" #'link-hint-open-link) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index 1c8d1d754..05992fe95 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -420,7 +420,6 @@ directives. By default, this only recognizes C directives.") (map! :v "@" #'+evil:apply-macro :m [C-i] #'evil-jump-forward - :m [tab] #'evil-jump-item ;; implement dictionary keybinds ;; evil already defines 'z=' to `ispell-word' = correct word at point