evil icon indicating copy to clipboard operation
evil copied to clipboard

Button cannot work with customized evil keybindsg on normal state.

Open Vonfry opened this issue 4 years ago • 2 comments
trafficstars

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-button somewhere you want. Now, press i on button will print hello.
  • run the first line in test.el
  • press e on that button but the behaviour is same as origin. It is the problem.
  • run the second line in test.el
  • press b on that button and it works as expection.

Vonfry avatar Jun 15 '21 05:06 Vonfry

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!

tomdl89 avatar Jun 15 '21 21:06 tomdl89

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.

axelf4 avatar Jan 05 '23 18:01 axelf4