Emacs: mini-buffer input that conflicts with completion
In Emacs 29 with company-mode
, I have gotten stuck using find-file
in the mini-buffer when creating a new file in that completion only offers what exists and C-g
quits find-file, <return>
will replace input with the selected/default completion. The answer is simple, but not documented anywhere I could find, vertico-exit-input
!
I've been reinventing my emacs configuration with Emacs 29 and replacing/adding features. One of them is company-mode
, which is complete-anything (anywhere or everywhere), which works remarkable well. Except for one scenario, opening a new file. After C-x C-f
, in the mini-buffer with "Find file" mode, company-mode
offers completions for what exists. When typing a name that does not exist the mode does its best to match something/anything. At this point there is a default completion so pressing RET
will drop the input and send the completion. Pressing C-g
(the way to do company-abort
elsewhere), aborts find-file
. After various attempts of adding to a keymap (see my useless attempts below), none of which worked, while find-file
was active I did C-h b
which lists all the bindings in effect. I found that vertico-exit-input
was bound to M-RET
. No knowing what that function actually does, I tried the key and it did pass my input to find-file.
What is vertico-exit-input
you may ask, as I did? Help says:
vertico-exit-input is an interactive byte-compiled Lisp function in
‘vertico.el’.
(vertico-exit-input)
Exit minibuffer with input.
and that describes what I wanted. Another case of not knowing how to ask the question to get the answer.
These bindings did nothing of use, but may be useful for something else:
(keymap-set company-active-map "C-M-g" 'company-abort)
(keymap-set company-mode-map "C-M-g" 'company-abort)
(keymap-set company-mode-map "C-<return>" 'company-abort)
(keymap-set company-active-map "C-<return>" 'company-abort)