:definer :minor-mode with :genal keyword not working as expected with macrostep mode
Closed this issue · 6 comments
Me code:
(use-package general)
(use-package evil)
(use-package macrostep
:general
("C-c e" 'macrostep-expand)
(:definer 'minor-mode
:states 'normal
:keymaps 'macrostep-mode
"e" 'macrostep-expand))
- Start emacs and type
C-c e
. - Then
C-h k e
, it shows that it'sevil-forward-word-end
. - Press
ESC
thenC-h k e
, now it'smacrostep-expand
.
However, if I write this it works fine:
(use-package macrostep
:general
("C-c e" 'macrostep-expand)
(:states 'normal
:keymaps 'macrostep-keymap
"e" 'macrostep-expand)
:config
(add-hook 'macrostep-mode-hook #'evil-normalize-keymaps))
My guess is that it has something to do with the name macrostep-keymap
not being macrostep-mode-map
, but I don't know how to fix this.
Does this work if you use evil-define-minor-mode-key
directly? This is likely not an issue with general. evil-define-minor-mode-key
doesn't care about the keymap name, only about the minor mode name.
You're right, I write this and it's not working either 😟:
(use-package macrostep
:general
("C-c e" 'macrostep-expand)
:config
(evil-define-minor-mode-key 'normal 'macrostep-mode
"e" 'macrostep-expand))
close now
In that case, you may want to make an issue on the evil repository if you haven't already. @justbur wrote evil-define-minor-mode-key
and may know or be able to more quickly figure out the issue.
This by itself works for me, so it's not an underlying issue with evil-define-minor-mode-key
on my machine at least.
(evil-define-minor-mode-key 'normal 'macrostep-mode
"e" 'macrostep-expand)
@ACEMerlin I've just tried it both with and without general and cannot replicate your problem with either. Are you sure that macrostep-mode
is active when you are presseing e
?
sorry for late response, been busy this week. Anyway, here is the full code I write to replicate this problem:
(setq
straight-repository-branch "develop"
straight-use-package-by-default t
use-package-always-defer t ;; !!
)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(use-package general
:demand t)
(use-package evil
:defer .1
:init
(evil-mode 1))
(use-package macrostep
:general
("C-c e" 'macrostep-expand)
:config
(evil-define-minor-mode-key 'normal 'macrostep-mode
"e" 'macrostep-expand))
I set use-package-always-defer
to true, and I don't want evil to block emacs when starting, load evil immediately after startup, hence the :defer .1
. Maybe this is the cause.
When I change :defer .1
to demand t
, things work fine, when I press C-c e
to expand macro for the first time , e
behaves as macrostep-expand
. Otherwise it expands the macro, but e
is evil-forward-word-end
.