Function: cider-pprint-form-to-comment

cider-pprint-form-to-comment is a byte-compiled function defined in cider-eval.el.

Signature

(cider-pprint-form-to-comment FORM-FN INSERT-BEFORE)

Documentation

Evaluate the form selected by FORM-FN and insert result as comment.

FORM-FN can be either cider-last-sexp or cider-defun-at-point.

The comment style is controlled by cider-comment-style. For the default line style the formatting is further controlled via the cider-comment-prefix, cider-comment-continued-prefix and cider-comment-postfix options.

If INSERT-BEFORE is non-nil, insert before the form, otherwise afterwards. Any existing eval comment is replaced.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-pprint-form-to-comment (form-fn insert-before)
  "Evaluate the form selected by FORM-FN and insert result as comment.
FORM-FN can be either `cider-last-sexp' or `cider-defun-at-point'.

The comment style is controlled by `cider-comment-style'.  For the default
`line' style the formatting is further controlled via the `cider-comment-prefix',
`cider-comment-continued-prefix' and `cider-comment-postfix' options.

If INSERT-BEFORE is non-nil, insert before the form, otherwise afterwards.
Any existing eval comment is replaced."
  (pcase-let* ((bounds (funcall form-fn 'bounds))
               (insertion-point (nth (if insert-before 0 1) bounds))
               (`(,prefix ,continued ,postfix) (cider--comment-format))
               ;; we need a newline after the output to
               ;; avoid commenting the first line of the form
               (comment-postfix (concat postfix "\n")))
    (cider-interactive-eval nil
                            (cider-eval-pprint-with-multiline-comment-handler
                             (current-buffer)
                             insertion-point
                             prefix
                             continued
                             comment-postfix)
                            bounds
                            (cider--nrepl-print-request-plist fill-column))))