use-package
use-package copied to clipboard
Setting a variable before loading while byte-compiling
:wave: Hi use-package folks! I'm running into an annoying warning with evil-collection when byte-compiling. The evil-collection readme suggests the following use-package incantation:
(use-package evil
:ensure t
:init
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
:config
(evil-mode 1))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
This works properly, but during byte-compile I still get the warning Warning (evil-collection): Make sure to set 'evil-want-keybinding' to nil before loading evil or evil-collection.. Presumably this is because use-package tries to load evil without running the :init block while byte-compiling. Is there a way to set some variables such that they get set before loading the package while byte-compiling? I tried using :preface but that didn't seem to do the trick, instead I got the error message Warning (evil-collection): 'evil-want-keybinding' was set to nil but not before loading evil. (so I guess :preface runs after loading the package when byte-compiling?)
Presumably this is because use-package tries to load evil ... while byte-compiling.
This is one of the odd use-package behavior. (I think. I know this behavior comes from different design)
You can use eval-when-compile to tell the byte compiler to evaluate during compilation.
(eval-when-compile (setq evil-want-keybinding nil))
(use-package evil
:ensure t
:init
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
:config
(evil-mode 1))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))