divinedominion · 2022-07-22 09:17
I'm migrating from Company to Corfu to try its integration with Orderless. I want to replace `M-i`, my "invoke company manually" key binding, with a trigger for Corfu.
But I couldn't find a built-in function to invoke Corfu. It's usually triggered by TAB, but I prefer TAB to indent and never complete at the moment.
I whipped up this hack by looking at how Corfu's UI is being triggered:
(defun ct/corfu-trigger ()
(interactive)
(corfu--auto-complete (corfu--auto-tick)))
(global-set-key (kbd "M-i") #'ct/corfu-trigger)
It injects the auto tick so the internal equal check passes.
I tried to bind to `completion-at-point` but even though that's what the TAB key (with the suggested configuration) is eventually calling, my bindings spawned the completions in the minibuffer instead of going through Corfu.
What's a more elegant way?
**Edit:** Was a configuration bug caused by myself. This works fine:
(global-set-key (kbd "M-i") #'completion-at-point)
fzmad · 2022-07-22 09:33
Just do `M-x global-corfu-mode`. After that completions will be shown in corfu as soon as you invoke `completion-at-point`
divinedominion · 2022-07-22 14:03
I have! The question then is:
How do I invoke `completion-at-point` so that Corfu is used?
This for example doesn't use corfu, but the minibuffer:
(global-set-key (kbd "M-i") #'completion-at-point)
sebhoagie · 2022-07-22 15:59
I've tried setting up Corfu a few times but I always run into these small issues. And the list of candidates is sometimes different than with Company.
I'm sure I'm doing something wrong on my end...
fzmad · 2022-07-22 17:24
Hm... It works for me as expected:
1. `emacs -Q`
2. `M-x package-initialize`
3. `M-x global-corfu-mode`
4. Type `(se`
5. `M-x completion-at-point`
Completions are shown via Corfu
Now, after `M-: (global-set-key (kbd "M-i") #'completion-at-point)` I press `M-i` and completions are show via Corfu.
Can you please try it in `emacs -Q`?
divinedominion · 2022-07-23 08:16
Can confirm it works now, too. Must've botched up something in my early config attempts.
Thanks for persisting!
JDRiverRun · 2022-07-23 11:56
The key to corfu (and a real advantage) is it’s just a replaced interface for
completion-at-point. So wherever that would occur with plain completion instead invokes corfu. By default it’s M-Tab.