Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corfu keybindings are not set up properly #766

Closed
sebwelkberg opened this issue Dec 23, 2023 · 2 comments
Closed

Corfu keybindings are not set up properly #766

sebwelkberg opened this issue Dec 23, 2023 · 2 comments

Comments

@sebwelkberg
Copy link

An error message appears in the echo area which states that
evil-normalize-keymaps is called with a wrong number of arguments as
the Corfu completion popup is shown.

The issues is created by setting evil-normalize-keymaps as an advice
to the setup and teardown function. The problem is that the Corfu
functions take a fixed set of arguments while evil-normalize-keymaps
just has one optional argument. Since advices must have the same
signature as the function, the apply call fails.

This is fixed by just using a lambda with &rest that consumes the
arguments and calls evil-normalize-keymaps.

I have a branch ready that I could push. Otherwise this is the required change:

-  (advice-add 'corfu--setup :after 'evil-normalize-keymaps)
-  (advice-add 'corfu--teardown :after 'evil-normalize-keymaps))
+  (advice-add 'corfu--setup :after (lambda (&rest r) (evil-normalize-keymaps)))
+  (advice-add 'corfu--teardown :after  (lambda (&rest r) (evil-normalize-keymaps))))
@AlexanderArvidsson
Copy link

A temporary workaround until your fix is merged upstream is like this:

(use-package corfu
  :custom
  (corfu-auto t)
  
  :init
  (global-corfu-mode)

  ;; https://github.com/emacs-evil/evil-collection/issues/766
  (advice-remove 'corfu--setup 'evil-normalize-keymaps)
  (advice-remove 'corfu--teardown 'evil-normalize-keymaps)

  (advice-add 'corfu--setup :after (lambda (&rest r) (evil-normalize-keymaps)))
  (advice-add 'corfu--teardown :after  (lambda (&rest r) (evil-normalize-keymaps))))

Basically, remove the advices introduced by evil-collection and add the correct ones from @sebwelkberg.
This has to be done right after global-corfu-mode because the incorrect code (in evil-collection-corfu-setup) runs as a hook on global-corfu-mode.

@minad
Copy link

minad commented Jan 3, 2024

This issue is resolved by #767 and #769.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants