Emacs version: GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8)
Operating System: Arch Linux
Evil version: Evil version 1.15.0
Evil installation type: MELPA
Graphical/Terminal: Wayland/Terminal
Tested in a make emacs session (see CONTRIBUTING.md): No
Reproduction steps
Set variable evil-want-Y-yank-to-eol with use-package
We can see that custom-theme-set-variables is invoked before require. Then our customized value is inevitably overwritten.
Same thing applies to variables
evil-search-module
evil-visual-newline-commands
evil-motions
evil-intercept-maps
evil-overriding-maps
evil-disable-insert-state-bindings
evil-want-Y-yank-to-eol
However, a strange thing is, if these variable are set with setq in either :init or :config block of use-package, they work perfectly fine. I think this might because of the setter of these custom variables, which uses set-default. I don't know too much about this mechanism.
This piece of code seems stale and not update-to-date with current use cases. I can see a lot custom variables now in Evil do not use this initialization idiom.
Issue type
Environment
Emacs version: GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) Operating System: Arch Linux Evil version: Evil version 1.15.0 Evil installation type: MELPA Graphical/Terminal: Wayland/Terminal Tested in a
make emacs
session (see CONTRIBUTING.md): NoReproduction steps
Set variable
evil-want-Y-yank-to-eol
withuse-package
Start Emacs
Expected behavior
The value of
evil-want-Y-yank-to-eol
ist
.Actual behavior
The value of
evil-want-Y-yank-to-eol
isnil
.Further notes
This seems to be a bug caused by the initializers stored in
evil-pending-custom-initialize
.For example, the custom variable
evil-want-Y-yank-to-eol
has a initializerevil-custom-initialize-pending-reset
which adds a initialization form to the listevil-pending-custom-initialize
. https://github.com/emacs-evil/evil/blob/d28206ccff74bc07ba335b8ff77805564f6928d7/evil-vars.el#L623-L628That list is iterated by
evil-run-pending-custom-initialize
. https://github.com/emacs-evil/evil/blob/d28206ccff74bc07ba335b8ff77805564f6928d7/evil-vars.el#L68-L74That function is called by hook
evil-after-load-hook
whenever packageevil
is required. https://github.com/emacs-evil/evil/blob/d28206ccff74bc07ba335b8ff77805564f6928d7/evil.el#L154If we expand a
use-package
formThen we have
We can see that
custom-theme-set-variables
is invoked beforerequire
. Then our customized value is inevitably overwritten.Same thing applies to variables
evil-search-module
evil-visual-newline-commands
evil-motions
evil-intercept-maps
evil-overriding-maps
evil-disable-insert-state-bindings
evil-want-Y-yank-to-eol
However, a strange thing is, if these variable are set with
setq
in either:init
or:config
block ofuse-package
, they work perfectly fine. I think this might because of the setter of these custom variables, which usesset-default
. I don't know too much about this mechanism.Final thought
evil-pending-custom-initialize
was added 11 years ago. https://github.com/emacs-evil/evil/commit/b26b2861d943a601814ac373c8deb7e4863fbaecThis piece of code seems stale and not update-to-date with current use cases. I can see a lot custom variables now in Evil do not use this initialization idiom.
Do we still need it?