Function: cider-ns-edit--choose-alias-ns
cider-ns-edit--choose-alias-ns is a byte-compiled function defined in
cider-ns.el.
Signature
(cider-ns-edit--choose-alias-ns ALIAS CANDIDATES)
Documentation
Return the namespace to require as ALIAS, out of CANDIDATES, or nil.
Ask which when there's more than one, or cider-ns-magic-requires says
to ask. Picking none, or quitting, declines ALIAS for the buffer.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-ns.el
(defun cider-ns-edit--choose-alias-ns (alias candidates)
"Return the namespace to require as ALIAS, out of CANDIDATES, or nil.
Ask which when there's more than one, or `cider-ns-magic-requires' says
to ask. Picking none, or quitting, declines ALIAS for the buffer."
(if (and (null (cdr candidates)) (eq cider-ns-magic-requires t))
(nrepl-dict-get (car candidates) "ns")
(let* ((table (mapcar (lambda (c) (cons (nrepl-dict-get c "ns") c)) candidates))
(annotate (lambda (ns)
(when-let* ((candidate (cdr (assoc ns table))))
(pcase (nrepl-dict-get candidate "source")
("project" (let ((n (nrepl-dict-get candidate "count")))
(format " used in %s file%s" n (if (eql n 1) "" "s"))))
(source (concat " " source))))))
(choice (condition-case nil
(completing-read
(format "Require as %s (empty for none): " alias)
(lambda (string pred action)
(if (eq action 'metadata)
`(metadata (annotation-function . ,annotate)
(display-sort-function . identity))
(complete-with-action action table string pred)))
nil t)
(quit ""))))
(if (string-empty-p choice)
(progn (push alias cider-ns-edit--declined-aliases)
nil)
choice))))