Function: cider-ns-edit--magic-require
cider-ns-edit--magic-require is a byte-compiled function defined in
cider-ns.el.
Signature
(cider-ns-edit--magic-require)
Documentation
Require the namespace the alias before the slash at point stands for.
See cider-ns-magic-requires. This runs as the user types, so instead
of signaling an error it says what went wrong in the echo area.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-ns.el
(defun cider-ns-edit--magic-require ()
"Require the namespace the alias before the slash at point stands for.
See `cider-ns-magic-requires'. This runs as the user types, so instead
of signaling an error it says what went wrong in the echo area."
(with-demoted-errors "Magic require failed: %S"
(when-let* ((alias (cider-ns-edit--alias-before-slash))
(ns-start (cider-ns-edit--ns-form-start))
;; nil while the ns form is still unbalanced, or out of
;; reach in a narrowed buffer
(ns-end (ignore-errors (scan-sexps ns-start 1))))
(unless (or buffer-read-only
;; typing in the ns form itself
(< ns-start (point) ns-end)
(member alias cider-ns-edit--declined-aliases)
(cider-ns-edit--has-alias-p ns-start ns-end alias))
(when-let* ((candidates (cider-ns-edit--alias-candidates alias))
(ns (cider-ns-edit--choose-alias-ns alias candidates)))
;; The require undoes on its own, apart from the typing around it.
(undo-boundary)
(condition-case err
(pcase-let ((`(,status . ,libspec)
;; An error from the evaluation of the ns form
;; mustn't take the keystrokes that follow.
(let ((cider-ns-edit--select-error-buffer nil))
(cider-ns-edit--edit
(lambda (start) (cider-ns-edit--add-require start ns alias))))))
(when status
;; so that the next keystroke doesn't join the require's
;; undo step
(setq this-command #'cider-ns-edit--magic-require))
(cider-ns-edit--require-message ns status libspec))
(user-error (message "%s" (error-message-string err)))))))))