Closed haji-ali closed 1 year ago
This behavior seems expected to me.
Usually you don't have only a single candidate, which will prevent the single candidate tab completion behavior.
auto completion should only set in if your input is longer than corfu-prefix-length and if the input matches candidates.
Completing empty input makes sense when explicitly requested. This allows you to see all candidates.
-We could distinguish explicitly interactive invocation of cape-abbrev from invoking via completion-at-point-functions and only completely empty input in the explicit case. But I am not too fond of introducing such a distinction.
That's the issue then. I have corfu-auto-prefix
(which is what I assume you mean) set to 3, but when I press TAB on an empty line I still get the auto-completion menu (or expansion in case of cape-abbrev).
BTW, I just tried calling cape-symbol
using M-x
on the latest versions of cape
and corfu
and noticed that the auto-complete menu shows up but pressing C-n
and C-p
doesn't cycle the candidates but moves the cursor and I cannot hide the menu until I call cape-symbol
again. Do you see this on your end? If not, I will investigate the issue.
Strangely, if I call cape-symbol
using a keyboard binding (C-c TAB s
) it works as expected.
Yes, it is expected that TAB opens the menu if completion at point is possible. Nothing wrong with that even with empty input.
The C-n and C-p movement seems like an issue of your config. Please test a minimal recipe with emacs -Q and let me know how it goes.
I also ran into this and was surprised by the behavior.
Adding a few more abbrevs generated the pop-up, which I found less confusing.
https://github.com/minad/cape/assets/21134999/16869cff-7f9e-4891-8402-bc6a3737d3eb
You can try the new setting:
(setq corfu-on-exact-match 'show)
You can also check the behavior of default completion (with corfu-mode
disabled). There you will see that if a Capf returns a single candidate, this candidate will be inserted when pressing TAB:
;; 1. Evaluate this code in *scratch*
(corfu-mode -1)
(setq-local completion-at-point-functions (list #'test-capf))
(defun test-capf ()
(let ((bounds (or (bounds-of-thing-at-point 'word) (cons (point) (point)))))
(list (car bounds) (cdr bounds) '("test"))))
;; 2. Press TAB, | is the cursor -> "test" will be inserted.
| <TAB>
I noticed that
cape-abbrev
by default auto-completes even when there's no text that matches any of the abbrevations. In my case,(cape--abbrev-list)
returns a single word("word")
and that word is inserted whenever I pressTAB
and no indentation is needed (or when I callcape-abbrev
).I would expect that the auto-completion should only activate if some text is inserted.