emacs-evil / evil-collection

A set of keybindings for evil-mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Entering normal mode doesn't quit corfu popup

sudo-human opened this issue · comments

I have the following corfu and evil-collection setup.

  :bind (:map corfu-map
         ("C-c" . corfu-quit))
  :custom
  (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
  (corfu-auto t)                 ;; Enable auto completion
  (corfu-auto-delay 0)
  (corfu-auto-prefix 1)
  (tab-always-indent 'complete)
  
  :init
  (global-corfu-mode))

(use-package! evil-collection-corfu
  :when (featurep! :editor evil +everywhere)
  :defer t
  :init (setq evil-collection-corfu-key-themes '(default magic-return))
  :config
  (evil-collection-corfu-setup))

I read that evil-collection-corfu-setup will bind escape key to evil-collection-corfu-quit-and-escape function. But it seems that it is not working.

commented

Does eval (evil-collection-corfu-setup) help?

Does eval (evil-collection-corfu-setup) help?

Nope, I already tried this. All the other setup that's there in this function works except escape key.

commented

Do you have an emacs -Q? It works for meTM (though I'm not sure if it's anything specific to my setup.)

Feel free to re-open and sorry for the late replay.

FWIW, I encountered the same issue and found that the reason was that I had set evil-disable-insert-state-bindings to t, to be able to use emacs bindings in insert mode. This seems to give ESC one job only, to return to normal state, which overrides the binding to corfu-quit. At least, that's my guess. Once I removed the evil-disable-insert-state-bindings setting (leaving it at the default nil), ESC does quit corfu.

Someone found a solution for this and posted it on reddit:

(defvar my-override-keymap-alist '())
(add-to-ordered-list 'emulation-mode-map-alists 'my-override-keymap-alist 0)
(add-hook 'my-override-keymap-alist
          `(completion-in-region-mode . ,(define-keymap "<escape>" #'corfu-quit)))

I have used this now for several days and it does the trick, successfully combining evil-disable-insert-state-bindings and ESC doing corfu-quit.

This can be combined with evil-collection-corfu by replacing #'corfu-quit in the code with #'evil-collection-corfu-quit-and-escape.