Function: embark--maybe-transform-candidates
embark--maybe-transform-candidates is a byte-compiled function defined
in embark.el.
Signature
(embark--maybe-transform-candidates)
Documentation
Collect candidates and see if they all transform to the same type.
Return a plist with keys :type, :orig-type, :candidates, and
:orig-candidates.
Source Code
;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defun embark--maybe-transform-candidates ()
"Collect candidates and see if they all transform to the same type.
Return a plist with keys `:type', `:orig-type', `:candidates', and
`:orig-candidates'."
(pcase-let* ((`(,type . ,candidates)
(run-hook-with-args-until-success 'embark-candidate-collectors))
(bounds (mapcar #'cdr-safe candidates)))
(setq candidates
(mapcar (lambda (x) (if (consp x) (car x) x)) candidates))
(when (eq type 'file)
(let ((dir (embark--default-directory)))
(setq candidates
(mapcar (lambda (cand)
(abbreviate-file-name
(expand-file-name (substitute-in-file-name cand) dir)))
candidates))))
;; TODO more systematic approach to applying substitute-in-file-name
(append
(list :orig-type type :orig-candidates candidates :bounds bounds)
(or (when candidates
(when-let* ((transformer (alist-get type embark-transformer-alist)))
(pcase-let* ((`(,new-type . ,first-cand)
(funcall transformer type (car candidates))))
(let ((new-candidates (list first-cand)))
(when (cl-every
(lambda (cand)
(pcase-let ((`(,t-type . ,t-cand)
(funcall transformer type cand)))
(when (eq t-type new-type)
(push t-cand new-candidates)
t)))
(cdr candidates))
(list :type new-type
:candidates (nreverse new-candidates)))))))
(list :type type :candidates candidates)))))