Ensure evil-collection doesn't load early

This commit is contained in:
Henrik Lissner 2020-08-17 18:00:11 -04:00
parent 8fa5b9406c
commit 1c9918e61e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -225,6 +225,11 @@ and complains if a module is loaded too early (during startup)."
(with-demoted-errors "evil-collection error: %s" (with-demoted-errors "evil-collection error: %s"
(evil-collection-init (list module))))) (evil-collection-init (list module)))))
(defadvice! +evil-collection-disable-blacklist-a (orig-fn)
:around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC
(let (evil-collection-key-blacklist)
(funcall-interactively orig-fn)))
;; These modes belong to packages that Emacs always loads at startup, causing ;; These modes belong to packages that Emacs always loads at startup, causing
;; evil-collection to load immediately. We avoid this by loading them after ;; evil-collection to load immediately. We avoid this by loading them after
;; evil-collection has first loaded... ;; evil-collection has first loaded...
@ -245,34 +250,30 @@ and complains if a module is loaded too early (during startup)."
(mapc #'+evil-collection-init '(comint custom help))) (mapc #'+evil-collection-init '(comint custom help)))
(defadvice! +evil-collection-disable-blacklist-a (orig-fn)
:around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC
(let (evil-collection-key-blacklist)
(funcall-interactively orig-fn)))
;; ...or on first invokation of their associated major/minor modes. ;; ...or on first invokation of their associated major/minor modes.
(add-transient-hook! 'Buffer-menu-mode (after! evil
(+evil-collection-init '(buff-menu "buff-menu"))) (add-transient-hook! 'Buffer-menu-mode
(add-transient-hook! 'image-mode (+evil-collection-init '(buff-menu "buff-menu")))
(+evil-collection-init 'image)) (add-transient-hook! 'image-mode
(add-transient-hook! 'emacs-lisp-mode (+evil-collection-init 'image))
(+evil-collection-init 'elisp-mode)) (add-transient-hook! 'emacs-lisp-mode
(add-transient-hook! 'occur-mode (+evil-collection-init 'elisp-mode))
(+evil-collection-init '(occur replace))) (add-transient-hook! 'occur-mode
(add-transient-hook! 'minibuffer-setup-hook (+evil-collection-init '(occur replace)))
(when evil-collection-setup-minibuffer (add-transient-hook! 'minibuffer-setup-hook
(+evil-collection-init 'minibuffer) (when evil-collection-setup-minibuffer
(evil-collection-minibuffer-insert))) (+evil-collection-init 'minibuffer)
(add-transient-hook! 'process-menu-mode (evil-collection-minibuffer-insert)))
(+evil-collection-init '(process-menu simple))) (add-transient-hook! 'process-menu-mode
(add-transient-hook! 'xwidget-webkit-mode (+evil-collection-init '(process-menu simple)))
(+evil-collection-init 'xwidget)) (add-transient-hook! 'xwidget-webkit-mode
(+evil-collection-init 'xwidget))
;; HACK Do this ourselves because evil-collection break's `eval-after-load' ;; HACK Do this ourselves because evil-collection break's `eval-after-load'
;; load order by loading their target plugin before applying keys. This ;; load order by loading their target plugin before applying keys. This
;; makes it hard for end-users to overwrite these keybinds with a ;; makes it hard for end-users to overwrite these keybinds with a
;; simple `after!' or `with-eval-after-load'. ;; simple `after!' or `with-eval-after-load'.
(dolist (mode evil-collection-mode-list) (dolist (mode evil-collection-mode-list)
(dolist (req (or (cdr-safe mode) (list mode))) (dolist (req (or (cdr-safe mode) (list mode)))
(with-eval-after-load req (with-eval-after-load req
(+evil-collection-init mode +evil-collection-disabled-list))))) (+evil-collection-init mode +evil-collection-disabled-list))))))