Function: cider-interactive-eval-handler

cider-interactive-eval-handler is a byte-compiled function defined in cider-eval.el.

Signature

(cider-interactive-eval-handler &optional BUFFER PLACE)

Documentation

Make an interactive eval handler for BUFFER.

PLACE is used to display the evaluation result. If non-nil, it can be the position where the evaluated sexp ends, or it can be a list with (START END) of the evaluated region. Update the cider-inspector buffer with the evaluation result when cider-auto-inspect-after-eval is non-nil.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-interactive-eval-handler (&optional buffer place)
  "Make an interactive eval handler for BUFFER.
PLACE is used to display the evaluation result.
If non-nil, it can be the position where the evaluated sexp ends,
or it can be a list with (START END) of the evaluated region.
Update the cider-inspector buffer with the evaluation result
when `cider-auto-inspect-after-eval' is non-nil."

  (let* ((eval-buffer (current-buffer))
         (beg (car-safe place))
         (end (or (car-safe (cdr-safe place)) place))
         (beg (when beg (copy-marker beg)))
         (end (when end (copy-marker end)))
         (fringed nil)
         (res ""))
    (cider-make-eval-handler
     :buffer (or buffer eval-buffer)
     :on-value (lambda (value)
                 (when (buffer-live-p eval-buffer)
                   (with-current-buffer eval-buffer
                     (cider--eval-pending-overlay-remove)))
                 (setq res (concat res value))
                 (cider--display-interactive-eval-result res 'value end))
     :on-content-type (lambda (body content-type)
                        (when (buffer-live-p eval-buffer)
                          (with-current-buffer eval-buffer
                            (cider--eval-pending-overlay-remove)))
                        (unless (cider--display-rich-content body content-type end)
                          (setq res (concat res (cider--rich-content-fallback-string
                                                 body content-type)))
                          (cider--display-interactive-eval-result res 'value end)))
     :on-stdout #'cider-emit-interactive-eval-output
     :on-stderr (lambda (err)
                  (cider-emit-interactive-eval-err-output err)
                  (cider-handle-compilation-errors
                   err eval-buffer
                   ;; Disable jumping behavior when compiling a single form
                   ;; because lines tend to be spurious (e.g. 0:0) and the
                   ;; jump brings us to the beginning of the same form anyway.
                   t))
     :on-done (lambda ()
                ;; Clear the spinner overlay for evaluations that finish
                ;; without a value (e.g. side-effecting forms or errors).
                (when (buffer-live-p eval-buffer)
                  (with-current-buffer eval-buffer
                    (cider--eval-pending-overlay-remove)))
                (if beg
                    (unless fringed
                      (cider--make-fringe-overlays-for-region beg end)
                      (setq fringed t))
                  (cider--make-fringe-overlay end))
                (let ((target (or buffer eval-buffer)))
                  (when (and (cider--auto-inspect-after-eval-p 'interactive)
                             (boundp 'cider-inspector-buffer)
                             (windowp (get-buffer-window cider-inspector-buffer 'visible)))
                    (cider-inspect-last-result)
                    (select-window (get-buffer-window target))))
                (cider--maybe-set-eval-register res)))))