Function: vertico--compute
vertico--compute is a natively compiled function defined in
vertico.el.
Signature
(vertico--compute INPUT)
Documentation
Compute state given INPUT.
Source Code
;; Defined in /nix/store/h1nc2k1rxmi6k9cfflcd37cf4zfhp2v5-emacs-packages-deps/share/emacs/site-lisp/elpa/vertico-20260913.1525/vertico.el
(defun vertico--compute (input)
"Compute state given INPUT."
(pcase-let* ((`(,str . ,pt) input)
(table minibuffer-completion-table)
(pred minibuffer-completion-predicate)
(before (substring str 0 pt))
(after (substring str pt))
;; bug#47678: `completion-boundaries' fails for `partial-completion'
;; if the cursor is moved before the slashes of "~//".
;; See also corfu.el which has the same issue.
(bounds (condition-case nil
(completion-boundaries before table pred after)
(t (cons 0 (length after)))))
(field (substring str (car bounds) (+ pt (cdr bounds))))
;; bug#75910: category instead of `minibuffer-completing-file-name'
(completing-file (eq 'file (vertico--metadata-get 'category)))
(`(,all . ,hl)
(dlet ((completion-lazy-hilit t) (completion-lazy-hilit-fn nil))
(cons (completion-all-completions str table pred pt vertico--metadata)
completion-lazy-hilit-fn)))
(base (or (when-let* ((z (last all))) (prog1 (cdr z) (setcdr z nil))) 0))
(vertico--base (substring str 0 base))
(def (or (car-safe minibuffer-default) minibuffer-default))
(rm minibuffer--require-match)
(groups) (def-missing) (allow-prompt) (lock))
;; Filter the ignored file extensions. We cannot use modified predicate for
;; this filtering, since this breaks the special casing in the
;; `completion-file-name-table' for `file-exists-p' and `file-directory-p'.
(when completing-file
(let ((exact (and (not (equal field "")) (member field all))))
(setq all (completion-pcm--filename-try-filter all))
(and exact (not (member field all)) (push field all))))
;; Sort using the `display-sort-function' or the Vertico sort functions
(setq all (funcall (or (vertico--sort-function) #'identity) all))
;; Move special candidates: "field" appears at the top, before "field/", before default value
(when (and (stringp def) (not (equal def "")))
(setq all (vertico--move-to-front def all)))
(unless (equal field "")
(when (and completing-file (not (string-suffix-p "/" field)))
(setq all (vertico--move-to-front (concat field "/") all)))
(setq all (vertico--move-to-front field all)))
(setq all (delete-consecutive-dups all))
(when-let* ((fun (and all (vertico--metadata-get 'group-function))))
(setq groups (vertico--group-by fun all) all (car groups)))
(setq def-missing (and def (equal str "") (not (member def all)))
allow-prompt (and (not (eq vertico-preselect 'no-prompt))
(or def-missing (eq vertico-preselect 'prompt)
(functionp rm)
(memq rm '(nil confirm confirm-after-completion))
(test-completion str table pred)))
lock (and vertico--lock-candidate ;; Locked position of old candidate.
(if (< vertico--index 0) (and allow-prompt -1)
(seq-position all (nth vertico--index vertico--candidates)))))
`((vertico--input . ,input)
(vertico--base . ,vertico--base)
(vertico--metadata . ,vertico--metadata)
(vertico--candidates . ,all)
(vertico--total . ,(length all))
(vertico--hilit . ,(or hl #'identity))
(vertico--allow-prompt . ,allow-prompt)
(vertico--lock-candidate . ,lock)
(vertico--groups . ,(cdr groups))
(vertico--index . ,(or lock
(if (or def-missing (eq vertico-preselect 'prompt) (not all)
(and completing-file (eq vertico-preselect 'directory)
(= (length vertico--base) (length str))
(test-completion str table pred)))
-1 0))))))