0

I use evil and have general bindings like so defined after evil is installed through use-package.

    (use-package general
        :straight t
        :after evil
        :config
        (general-create-definer leader-def
            :states '(normal visual motion emacs)
            :keymaps 'override
            :prefix "SPC")
        (leader-def "" nil)
        (leader-def
            "bd" 'kill-this-buffer
            "xc" 'save-buffers-kill-terminal
            "fd" 'init-file
            "ff" 'helm-find-files
            "fs" 'save-buffer
            "gs" 'magit-status
            "k" 'switch-to-buffer))

The weird thing is that when I go into a Messages buffer immediately after emacs starts up, my leader key doesn't work and for some time afterwards it still doesn't work even if I use the leader key successfully elsewhere. If I explicitly execute the above elisp again, the leader key does start working in the Messages buffer. Alternatively, the leader key eventually starts working after some condition (not sure what) is met. Any idea what the issue is? My first impression is it's an ordering issue within my init.el but I imagine the above elisp should work as expected on startup.

1

1 Answer 1

1

TLDR:

(with-eval-after-load 'evil
  (general-add-hook 'after-init-hook
                    (lambda (&rest _)
                      (when-let ((messages-buffer (get-buffer "*Messages*")))
                        (with-current-buffer messages-buffer
                          (evil-normalize-keymaps))))
                    nil
                    nil
                    t))

You can look at this FAQ section: Why don’t keys defined with evil-define-key work (immediately)? and these two issue: pace leader key not working in some modes like dired and the help pages, Leader key only works in messages buffer after changing modes (EVIL) to know why this happen. Though I don't know why this is not happening on my side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.