Function: cider-popup-eval-handler

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

Signature

(cider-popup-eval-handler &optional BUFFER BOUNDS SOURCE-BUFFER)

Documentation

Make a handler for printing evaluation results in popup BUFFER,
_BOUNDS representing the buffer bounds of the evaled input,
and SOURCE-BUFFER the original buffer

This is used by pretty-printing commands.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-popup-eval-handler (&optional buffer _bounds source-buffer)
  "Make a handler for printing evaluation results in popup BUFFER,
_BOUNDS representing the buffer bounds of the evaled input,
and SOURCE-BUFFER the original buffer

This is used by pretty-printing commands."
  ;; NOTE: cider-eval-register behavior is not implemented here for performance reasons.
  ;; See https://github.com/clojure-emacs/cider/pull/3162
  (let ((chosen-buffer (or buffer (current-buffer))))
    (cider-make-eval-handler
     :buffer chosen-buffer
     :on-value (lambda (value)
                 (cider-emit-into-popup-buffer chosen-buffer (ansi-color-apply value) nil t))
     :on-stdout #'cider-emit-interactive-eval-output
     :on-stderr #'cider-emit-interactive-eval-err-output
     :on-eval-error (lambda ()
                      (when (and (buffer-live-p chosen-buffer)
                                 (member (buffer-name chosen-buffer)
                                         cider-ancillary-buffers))
                        (with-selected-window (get-buffer-window chosen-buffer)
                          (cider-popup-buffer-quit-function t)))
                      ;; also call the default nrepl-err-handler-function so
                      ;; our custom behavior doesn't void the base behavior:
                      (when nrepl-err-handler-function
                        (funcall nrepl-err-handler-function source-buffer)))
     :on-truncated (lambda ()
                     (let ((warning (format "\n... output truncated to %sB ..."
                                            (file-size-human-readable cider-print-quota))))
                       (cider-emit-into-popup-buffer chosen-buffer warning
                                                     'font-lock-warning-face t))))))