[Bug?] Evil does not activate when loaded via customize
Hi, list! I'm perverse and want to install Evil via package.el and load it via customize. I notice that Evil does not turn on at startup when I customize evil-mode to t. I still have to explicitly call (evil-mode 1) in my init-file. Is this known behavior? If so, is it a bug? If so, can I fix it somehow? Note: I know the documentation explicitly tells me to install Evil like so: (add-to-list 'load-path "~/.emacs.d/evil") (require 'evil) (evil-mode 1) As said, I'm just being perverse. Thanks for any pointers! -- Trevor Murphy, ASA, MAAA GnuPG Key: 0x83881C0A
Am 29.10.2014 um 17:15 schrieb Trevor Murphy:
Hi, list!
I'm perverse and want to install Evil via package.el and load it via customize. I notice that Evil does not turn on at startup when I customize evil-mode to t. I still have to explicitly call (evil-mode 1) in my init-file.
Is this known behavior?
No, at least for me.
If so, is it a bug?
Perhaps.
If so, can I fix it somehow?
I don't know, never tried. But, is it supposed to work? I see the following problem: the variable `evil-mode` is defined in Evil and is not known to Emacs until Evil is loaded (i.e. until `(require 'evil)`). If you customize `evil-mode` to t, this will change the value of this variable. But Emacs does not know that it has to load Evil to actually get the correct definition of this variable (for Emacs it's just a variable without any relation to some package). I do not know if it is possible to have something like an 'autoload variable', i.e. as soon as a variable is customized Evil loads a corresponding package. It is possible for functions (like the `evil-mode` function), though. Best regards, Frank
Whoops. I may have accidentally sent half of this email previously. My apologies for the noise - I'm still learning git-send-email. On Fri, Oct 31 2014, Frank Fischer wrote:
I do not know if it is possible to have something like an 'autoload variable', i.e. as soon as a variable is customized Evil loads a corresponding package. It is possible for functions (like the `evil-mode` function), though.
Yup, Emacs' autoload-generating functions can handle this case by default. The issue, as far as I can see, is that the current codebase manually configures the autoload cookie for `evil-mode'. The following patches work for me. Could a few folks test them? The first patch removes the manual configuration of the ;;;###autoload cookie on `evil-mode'. I also moved the definition into evil.el, so the whole package gets loaded when the function is called. The second patch is pure aesthetics. I removed the manual override to the `evil-mode' docstring, because the auto-generated one covers the same content plus additional info that's standard to include with globalized minor modes. -- Trevor Murphy, ASA, MAAA GnuPG Key: 0x83881C0A
Do this so that when Emacs generates an autoload for `evil-mode', it references the correct file to later load all of evil. We do that so that we don't have to manually override Emacs' generation of the ;;;###autoload cookie. We do THAT so that we can let Emacs generate the appropriate autoloads to enable the globalized minor mode via `custom-set-variables'. --- evil-core.el | 4 ---- evil.el | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evil-core.el b/evil-core.el index 4ccb78a..cb440b7 100644 --- a/evil-core.el +++ b/evil-core.el @@ -170,10 +170,6 @@ To enable Evil globally, do (evil-mode 1)." (evil-local-mode 1) (evil-initialize-state))) -;;;###autoload (autoload 'evil-mode "evil" "Toggle evil in all buffers" t) -(define-globalized-minor-mode evil-mode - evil-local-mode evil-initialize) - ;; No hooks are run in Fundamental buffers, so other measures are ;; necessary to initialize Evil in these buffers. When Evil is ;; enabled globally, the default value of `major-mode' is set to diff --git a/evil.el b/evil.el index d6caf2c..06f393c 100644 --- a/evil.el +++ b/evil.el @@ -121,6 +121,10 @@ (run-hooks 'evil-after-load-hook) +;;;###autoload +(define-globalized-minor-mode evil-mode + evil-local-mode evil-initialize) + (provide 'evil) ;;; evil.el ends here -- 2.1.2
The `define-globalized-minor-mode' macro generates a docstring that covers the same information, includes references to more functions, and fits the standard used by many global minor modes. --- evil-core.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/evil-core.el b/evil-core.el index cb440b7..7b7309c 100644 --- a/evil-core.el +++ b/evil-core.el @@ -193,12 +193,6 @@ To enable Evil globally, do (evil-mode 1)." (ad-update-regexp "^evil") (with-no-warnings (evil-esc-mode -1)))) -(put 'evil-mode 'function-documentation - "Toggle Evil in all buffers. -Enable with positive ARG and disable with negative ARG. -See `evil-local-mode' to toggle Evil in the -current buffer only.") - (defun evil-change-state (state &optional message) "Change the state to STATE. If STATE is nil, disable all states." -- 2.1.2
Am 01.11.2014 um 19:40 schrieb Trevor Murphy:
Whoops. I may have accidentally sent half of this email previously. My apologies for the noise - I'm still learning git-send-email.
Thanks, I've added both patches. Frank
participants (2)
-
Frank Fischer -
Trevor Murphy