evil
evil copied to clipboard
Button cannot work with customized evil keybindsg on normal state.
Issue type
- Bug report
- Enhancement request
Environment
Emacs version: GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
Operating System: Linux pc-lab-shmtu 5.10.37 #1-NixOS SMP Fri May 14 07:50:46 UTC 2021 x86_64 GNU/Linux
Evil version: Evil version 1.14.0
Evil installation type: MELPA through nix-community/emacs-overlay
Graphical/Terminal: Grahpical
Tested in a make emacs session (see CONTRIBUTING.md): No
Reproduction steps
- Start Emacs
- switch to
*scratch* - input and eval setup.el
- call
scratch-insert-buttonsomewhere you want. Now, pression button will print hello. - run the first line in test.el
- press
eon that button but the behaviour is same as origin. It is the problem. - run the second line in test.el
- press
bon that button and it works as expection.
Thanks for the bug report. I thought I'd found the cause of this, but actually it's not so simple. This one may take a while!
This is because evil-normalize-keymaps is not executed after every cursor movement - and in particular not when the cursor enters an overlay with a keymap property. E.g. try changing states while on the button with a<ESC>: Now the e binding works.
My preferred workaround is to use extended menu items:
(define-key scratch-test--button-map "e" `(menu-item "" scratch-test--message :filter ,(lambda (cmd) (when (evil-normal-state-p) cmd)))))
with :filter as appropriate.