emacs-evil / evil

The extensible vi layer for Emacs.
GNU General Public License v3.0
3.38k stars 281 forks source link

Button cannot work with customized evil keybindsg on normal state. #1477

Open Vonfry opened 3 years ago

Vonfry commented 3 years ago

Issue type

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

tomdl89 commented 3 years ago

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!

axelf4 commented 1 year ago

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.