Function: cider-ns-edit--choose

cider-ns-edit--choose is a byte-compiled function defined in cider-ns.el.

Signature

(cider-ns-edit--choose SYMBOL CANDIDATES)

Documentation

Return the one of CANDIDATES to add for SYMBOL.

Ask which when there's more than one, showing the type of each.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-ns.el
(defun cider-ns-edit--choose (symbol candidates)
  "Return the one of CANDIDATES to add for SYMBOL.
Ask which when there's more than one, showing the type of each."
  (if (cdr candidates)
      (let* ((table (mapcar (lambda (c) (cons (nrepl-dict-get c "name") c))
                            candidates))
             (annotate (lambda (name)
                         (when-let* ((candidate (cdr (assoc name table))))
                           (concat " " (nrepl-dict-get candidate "type")
                                   (when-let* ((ns (nrepl-dict-get candidate "ns")))
                                     (format " (%s)" ns))))))
             (choice (completing-read
                      (format "Resolve %s with: " symbol)
                      (lambda (string pred action)
                        (if (eq action 'metadata)
                            `(metadata (annotation-function . ,annotate))
                          (complete-with-action action table string pred)))
                      nil t)))
        (or (cdr (assoc choice table))
            (user-error "Nothing chosen")))
    (car candidates)))