Function: cider-eval-form-and-replace

cider-eval-form-and-replace is an interactive and byte-compiled function defined in cider-eval.el.

Signature

(cider-eval-form-and-replace)

Documentation

Evaluate the form point indicates and replace it with its result.

How the expression is located is controlled by cider-form-targeting.

Key Bindings

Aliases

cider-eval-last-sexp-and-replace (obsolete since 2.1.0)

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-eval-form-and-replace ()
  "Evaluate the form point indicates and replace it with its result.
How the expression is located is controlled by `cider-form-targeting'."
  (interactive)
  (let* ((bounds (cider-form-bounds))
         (last-sexp (apply #'buffer-substring-no-properties bounds)))
    ;; we have to be sure the evaluation won't result in an error
    (cider-nrepl-sync-request:eval last-sexp)
    ;; seems like the sexp is valid, so we can safely kill it
    (apply #'kill-region bounds)
    (cider-interactive-eval last-sexp
                            (cider-eval-print-handler)
                            nil
                            (cider--nrepl-pr-request-plist))))