Skip to content

Completing in the minibuffer

Corfu can be used for completion in the minibuffer, since it relies on child frames to display the candidates. The Corfu popup floats on top of the Emacs frame and can be shown even if it doesn’t fit inside the minibuffer.

global-corfu-mode activates corfu-mode in the minibuffer if the variable global-corfu-minibuffer is ‘t’. In order to avoid interference with specialised minibuffer completion UIs like Vertico or Mct, Corfu is only enabled if the minibuffer sets the variable completion-at-point-functions locally. This way minibuffers with completion can be detected, such that minibuffer commands like M-: (eval-expression) or M-! (shell-command) are enhanced with Corfu completion.

If needed, one can also enable Corfu more generally in all minibuffers, as long as no completion UI is active. In the following example we set global-corfu-minibuffer to a predicate function, which checks for Mct and Vertico. Furthermore we ensure that Corfu is not enabled if a password is read from the minibuffer.

emacs-lisp
(setq global-corfu-minibuffer
      (lambda ()
        (not (or (bound-and-true-p mct--active)
                 (bound-and-true-p vertico--input)
                 (eq (current-local-map) read-passwd-map)))))