Function: cider-repl-emit-result

cider-repl-emit-result is a byte-compiled function defined in cider-repl.el.

Signature

(cider-repl-emit-result BUFFER STRING SHOW-PREFIX &optional BOL)

Documentation

Emit into BUFFER the result STRING and mark it as an evaluation result.

If SHOW-PREFIX is non-nil insert cider-repl-result-prefix at the beginning of the line. If BOL is non-nil insert at the beginning of the line.

STRING is inserted raw, with only the base cider-repl-result-face applied. When cider-repl-use-clojure-font-lock is enabled the assembled value is Clojure-font-locked as a whole by cider-repl--finalize-result once it is complete (i.e. on the done status). This keeps highlighting correct even when nREPL streams the value in several chunks, none of which is on its own a balanced, font-lockable form. Only the first chunk of a result is given the prefix; cider-repl--result-start/cider-repl--result-end track the span.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-repl.el
(defun cider-repl-emit-result (buffer string show-prefix &optional bol)
  "Emit into BUFFER the result STRING and mark it as an evaluation result.
If SHOW-PREFIX is non-nil insert `cider-repl-result-prefix' at the beginning
of the line.  If BOL is non-nil insert at the beginning of the line.

STRING is inserted raw, with only the base `cider-repl-result-face' applied.
When `cider-repl-use-clojure-font-lock' is enabled the assembled value is
Clojure-font-locked as a whole by `cider-repl--finalize-result' once it is
complete (i.e. on the `done' status).  This keeps highlighting correct even
when nREPL streams the value in several chunks, none of which is on its own a
balanced, font-lockable form.  Only the first chunk of a result is given the
prefix; `cider-repl--result-start'/`cider-repl--result-end' track the span."
  (with-current-buffer buffer
    (save-excursion
      (cider-save-marker cider-repl-output-start
        (goto-char cider-repl-output-end)
        (when (and bol (not (bolp)))
          (insert-before-markers "\n"))
        (when (and show-prefix (not cider-repl--result-start))
          (insert-before-markers
           (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face)))
        (let ((value-start (point)))
          (cider-propertize-region
              '(font-lock-face cider-repl-result-face rear-nonsticky (font-lock-face))
            (insert-before-markers string))
          (unless cider-repl--result-start
            (setq cider-repl--result-start (copy-marker value-start)))
          (if cider-repl--result-end
              (set-marker cider-repl--result-end (point))
            (setq cider-repl--result-end (copy-marker (point)))))))))