Function: cider-interactive-eval
cider-interactive-eval is a byte-compiled function defined in
cider-eval.el.
Signature
(cider-interactive-eval FORM &optional CALLBACK BOUNDS ADDITIONAL-PARAMS)
Documentation
Evaluate FORM and dispatch the response to CALLBACK.
If the code to be evaluated comes from a buffer, it is preferred to use a nil FORM, and specify the code via the BOUNDS argument instead.
This function is the main entry point in CIDER's interactive evaluation
API. Most other interactive eval functions should rely on this function.
If CALLBACK is nil use cider-interactive-eval-handler.
BOUNDS, if non-nil, is a list of two numbers marking the start and end
positions of FORM in its buffer.
ADDITIONAL-PARAMS is a plist to be merged into the request message.
If cider-interactive-eval-override is a function, call it with the same
arguments and only proceed with evaluation if it returns nil.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-interactive-eval (form &optional callback bounds additional-params)
"Evaluate FORM and dispatch the response to CALLBACK.
If the code to be evaluated comes from a buffer, it is preferred to use a
nil FORM, and specify the code via the BOUNDS argument instead.
This function is the main entry point in CIDER's interactive evaluation
API. Most other interactive eval functions should rely on this function.
If CALLBACK is nil use `cider-interactive-eval-handler'.
BOUNDS, if non-nil, is a list of two numbers marking the start and end
positions of FORM in its buffer.
ADDITIONAL-PARAMS is a plist to be merged into the request message.
If `cider-interactive-eval-override' is a function, call it with the same
arguments and only proceed with evaluation if it returns nil."
(let ((form (or form (apply #'buffer-substring-no-properties bounds)))
(additional-params (nrepl--alist-to-plist additional-params))
(start (car-safe bounds))
(end (car-safe (cdr-safe bounds))))
(when (and start end)
;; NOTE: don't use `remove-overlays' as it splits and leaves behind
;; partial overlays, leading to duplicate eval results in some situations.
(dolist (ov (overlays-in start end))
(when (eq (overlay-get ov 'cider-temporary) t)
(delete-overlay ov))))
(unless (and cider-interactive-eval-override
(functionp cider-interactive-eval-override)
(condition-case _
(funcall cider-interactive-eval-override form callback bounds additional-params)
(wrong-number-of-arguments
;; fallback for backward compatibility
(funcall cider-interactive-eval-override form callback bounds))))
;; #3028: `cider-map-repls' with `:auto' is intentionally lenient (it
;; doesn't error when there's no matching REPL, so multi-file loads
;; can skip missing REPL types). That made every `cider-eval-*'
;; command fail silently with no connection at all, so guard the
;; dispatch with an explicit connection check.
(cider-ensure-session)
;; Mark the form with a spinner overlay while the evaluation is pending,
;; and suppress the mode-line spinner so it doesn't spin in two places.
(let* ((pending (when (cider--eval-pending-overlay-p callback end)
(cider--eval-pending-overlay-start end)))
(cider--eval-spinner-inhibit-mode-line (and pending t)))
(cider-map-repls :auto
(lambda (connection)
(cider--prep-interactive-eval form connection)
(cider-nrepl-send-eval-request
form
(or callback (cider-interactive-eval-handler nil bounds))
;; always eval ns forms in the user namespace
;; otherwise trying to eval ns form for the first time will produce an error
:ns (if (cider-ns-form-p form) "user" (cider-current-ns))
:line (when start (line-number-at-pos start))
:column (when start (cider-column-number-at-pos start))
;; Opt in to content-typed responses, but only for the default
;; handler (which knows how to render them); custom callbacks
;; (eval-to-comment, pprint flows, third parties) keep getting
;; plain values only, so the server may safely omit `value'
;; from content-typed responses.
:additional-params (append (when (and cider-eval-rich-content-destination
(null callback))
(list "content-type" "true"))
additional-params)
:connection connection)))))))