Function: cider-current-repl

cider-current-repl is a byte-compiled function defined in cider-connection.el.

Signature

(cider-current-repl &optional TYPE ENSURE)

Documentation

Get the most recent REPL of TYPE from the current session.

TYPE is either clj, cljs, multi, infer or any. When infer or nil, infer the type from the current buffer. If ENSURE is non-nil, throw an error if either there is no linked session or there is no REPL of TYPE within the current session.

Aliases

cider-current-connection

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-connection.el
(defun cider-current-repl (&optional type ensure)
  "Get the most recent REPL of TYPE from the current session.
TYPE is either clj, cljs, multi, infer or any.
When infer or nil, infer the type from the current buffer.
If ENSURE is non-nil, throw an error if either there is
no linked session or there is no REPL of TYPE within the current session."
  (let ((type (cider-maybe-intern type)))
    (if (and (derived-mode-p 'cider-repl-mode)
             (or (null type)
                 (eq 'any type)
                 (eq 'infer type)
                 (eq cider-repl-type type)))
        ;; shortcut when in REPL buffer
        (current-buffer)
      (or cider--ancillary-buffer-repl
          (let* ((type (if (or (null type)
                               (eq 'infer type))
                           (cider-repl-type-for-buffer)
                         type))
                 (repls (cider-repls type ensure))
                 (repl (if (<= (length repls) 1)
                           (car repls)
                         ;; pick the most recent one
                         (seq-find (lambda (b)
                                     (member b repls))
                                   (buffer-list)))))
            (if (and ensure (null repl))
                (cider--no-repls-user-error type)
              repl))))))