Function: cider-ensure-session
cider-ensure-session is a byte-compiled function defined in
cider-session.el.
Signature
(cider-ensure-session)
Documentation
Signal a user-error unless CIDER has a session available here.
The CIDER-level nREPL senders (e.g. cider-nrepl-send-request,
cider-nrepl-sync-request) already ensure a connection - they resolve the
REPL with cider-current-repl ENSURE - so commands don't need this for
correctness. Use it only to fail fast, before doing interactive or
side-effecting work, rather than at the point of the first request.
Mirror the resolution precedence of cider-current-repl and cider-repls:
honor a buffer pinned to a REPL (via cider--pinned-session) and a
cider-default-session before falling back to sesman's linked sessions.
Otherwise this guard would reject buffers where evaluation actually works,
such as a dependency's source jumped to via cider-find-var (which lives
outside the project and so has no linked session, only a pin - see
https://github.com/clojure-emacs/cider/issues/4120).
Aliases
cider-ensure-connected (obsolete since 2.0.0)
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-session.el
(defun cider-ensure-session ()
"Signal a `user-error' unless CIDER has a session available here.
The CIDER-level nREPL senders (e.g. `cider-nrepl-send-request',
`cider-nrepl-sync-request') already ensure a connection - they resolve the
REPL with `cider-current-repl' ENSURE - so commands don't need this for
correctness. Use it only to fail fast, before doing interactive or
side-effecting work, rather than at the point of the first request.
Mirror the resolution precedence of `cider-current-repl' and `cider-repls':
honor a buffer pinned to a REPL (via `cider--pinned-session') and a
`cider-default-session' before falling back to sesman's linked sessions.
Otherwise this guard would reject buffers where evaluation actually works,
such as a dependency's source jumped to via `cider-find-var' (which lives
outside the project and so has no linked session, only a pin - see
https://github.com/clojure-emacs/cider/issues/4120)."
(or (cider--pinned-session)
(cider--default-session)
(sesman-ensure-session 'CIDER)))