Function: corfu-complete

corfu-complete is an interactive and natively compiled function defined in corfu.el.

Signature

(corfu-complete)

Documentation

Complete current input.

If a candidate is selected, insert it. Otherwise invoke corfu-expand. Return non-nil if the input has been expanded.

Key Bindings

corfu-map TAB

Source Code

;; Defined in /nix/store/za087xxa0z5mirfbbagrp0qfaqnfn5wb-emacs-packages-deps/share/emacs/site-lisp/elpa/corfu-20260913.1527/corfu.el
(defun corfu-complete ()
  "Complete current input.
If a candidate is selected, insert it.  Otherwise invoke
`corfu-expand'.  Return non-nil if the input has been expanded."
  (interactive)
  (if (< corfu--index 0)
      (corfu-expand)
    ;; Continue completion with selected candidate.  Exit with status 'finished
    ;; if input is a valid match and no further completion is possible.
    (pcase-let ((`(,_beg ,_end ,table ,pred . ,_) completion-in-region--data)
                (newstr (corfu--insert nil)))
      (and (test-completion newstr table pred)
           (or (not (consp (corfu--try-completion newstr table pred (length newstr))))
               ;; Finish completion if inside simple field, even if other longer
               ;; candidates match, since the user invoked `corfu-complete' with
               ;; an explicitly selected candidate.
               (corfu--simple-field-p newstr table pred))
           (corfu--done newstr 'finished nil))
      t)))