Delay running `evil-collection-setup-hook` for modes like eshell (#602)
This commit is contained in:
parent
71630c9477
commit
8d42153481
|
@ -106,6 +106,31 @@ This will bind additional find-* type commands, e.g. usages, assignments, etc.."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'evil-collection)
|
:group 'evil-collection)
|
||||||
|
|
||||||
|
(defvar evil-collection--modes-with-delayed-setup
|
||||||
|
`(eshell)
|
||||||
|
"List of modes whose keybinds aren't completely set up after the mode is
|
||||||
|
loaded. This can be a problem for cases where we're doing key translations
|
||||||
|
using `evil-collection-setup-hook' which would result in an empty keymap.
|
||||||
|
|
||||||
|
Normally we run `evil-collection-setup-hook' right away after the mode
|
||||||
|
is loaded in `with-eval-after-load' (see `evil-collection-init') but for these
|
||||||
|
modes, we skip running that hook and let the corresponding `evil-collection'
|
||||||
|
package handle running `evil-collection-setup-hook'.
|
||||||
|
|
||||||
|
Elements in this list either match a target mode symbol or the car of a list in
|
||||||
|
`evil-collection--supported-modes'.
|
||||||
|
|
||||||
|
If `evil-collection-always-run-setup-hook-after-load' is t, this list isn't
|
||||||
|
read and `evil-collection-setup-hook' will be ran in the
|
||||||
|
`with-eval-after-load' block in `evil-collection-init'.")
|
||||||
|
|
||||||
|
(defcustom evil-collection-always-run-setup-hook-after-load nil
|
||||||
|
"Whether to always run `evil-collection-setup-hook' after mode is loaded.
|
||||||
|
|
||||||
|
See `evil-collection-init' and `evil-collection--modes-with-delayed-setup'."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'evil-collection)
|
||||||
|
|
||||||
(defvar evil-collection--supported-modes
|
(defvar evil-collection--supported-modes
|
||||||
`(2048-game
|
`(2048-game
|
||||||
ag
|
ag
|
||||||
|
@ -803,8 +828,10 @@ instead of the modes in `evil-collection-mode-list'."
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(symbol-value
|
(symbol-value
|
||||||
(intern (format "evil-collection-%s-maps" m))))))
|
(intern (format "evil-collection-%s-maps" m))))))
|
||||||
(run-hook-with-args 'evil-collection-setup-hook
|
(when (or evil-collection-always-run-setup-hook-after-load
|
||||||
m mode-keymaps))))))
|
(not (memq m evil-collection--modes-with-delayed-setup)))
|
||||||
|
(run-hook-with-args 'evil-collection-setup-hook
|
||||||
|
m mode-keymaps)))))))
|
||||||
(when evil-collection-want-unimpaired-p
|
(when evil-collection-want-unimpaired-p
|
||||||
(evil-collection-require 'unimpaired)
|
(evil-collection-require 'unimpaired)
|
||||||
(evil-collection-unimpaired-setup)))
|
(evil-collection-unimpaired-setup)))
|
||||||
|
|
|
@ -137,7 +137,12 @@ appropriate in some cases like terminals."
|
||||||
"gk" 'eshell-previous-prompt
|
"gk" 'eshell-previous-prompt
|
||||||
"gj" 'eshell-next-prompt
|
"gj" 'eshell-next-prompt
|
||||||
"0" 'eshell-bol
|
"0" 'eshell-bol
|
||||||
"^" 'eshell-bol))
|
"^" 'eshell-bol)
|
||||||
|
|
||||||
|
(evil-normalize-keymaps)
|
||||||
|
(unless evil-collection-always-run-setup-hook-after-load
|
||||||
|
(run-hook-with-args
|
||||||
|
'evil-collection-setup-hook 'eshell evil-collection-eshell-maps)))
|
||||||
|
|
||||||
;; TODO: Compare this setup procedure with evil-ediff.
|
;; TODO: Compare this setup procedure with evil-ediff.
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Reference in New Issue