Function: consult--multi-lookup
consult--multi-lookup is a natively compiled function defined in
consult.el.
Signature
(consult--multi-lookup SOURCES SELECTED CANDIDATES &rest _)
Documentation
Lookup SELECTED in CANDIDATES given SOURCES.
Source Code
;; Defined in /nix/store/6higv2v1wk916v4ynnybyrdkfy2gq44d-emacs-packages-deps/share/emacs/site-lisp/elpa/consult-20261004.957/consult.el
(defun consult--multi-lookup (sources selected candidates &rest _)
"Lookup SELECTED in CANDIDATES given SOURCES."
(if (or (string-blank-p selected)
(not (consult--tofu-p (aref selected (1- (length selected))))))
;; Non-existing candidate without Tofu or default submitted (empty string)
(let* ((src (cond
(consult--narrow (seq-find (lambda (src)
(let ((n (plist-get src :narrow)))
(eq (or (car-safe n) n -1) consult--narrow)))
sources))
((seq-find (lambda (src) (plist-get src :default)) sources))
((seq-find (lambda (src) (not (plist-get src :hidden))) sources))
((aref sources 0))))
(idx (seq-position sources src))
(def (and (string-blank-p selected) ;; default candidate
(seq-find (lambda (cand) (eq idx (consult--tofu-get cand))) candidates))))
(if def
(cons (cdr (get-text-property 0 'multi-category def)) src)
`(,selected :match nil ,@src)))
(if-let* ((found (member selected candidates)))
;; Existing candidate submitted
(cons (cdr (get-text-property 0 'multi-category (car found)))
(consult--multi-source sources selected))
;; Non-existing Tofu'ed candidate submitted, e.g., via Embark
`(,(substring selected 0 -1) :match nil ,@(consult--multi-source sources selected)))))