!!! Note Because connections map one-to-one to REPL buffers, for the purpose of this section we use "REPL" and "connection" interchangeably. ## Sessions CIDER maintains a grouped view of opened connections through [Sesman] sessions. Each session is a collection of connections which share the same nREPL server. Start new sessions with - C-c C-x j j `cider-jack-in-clj` - C-c C-x j s `cider-jack-in-cljs` - C-c C-x j m `cider-jack-in-clj&cljs` - C-c C-x c j `cider-connect-clj` - C-c C-x c s `cider-connect-cljs` - C-c C-x c m `cider-connect-clj&cljs` Add new REPLs to the current session with - C-c C-x s j `cider-connect-sibling-clj` - C-c C-x s s `cider-connect-sibling-cljs` !!! Tip There's also the `cider` command, which is a wrapper around all the aforementioned commands. You can invoke it with C-C M-x. Session life-cycle management commands live in the [Sesman] map (C-c C-s) - C-c C-s s `sesman-start` - C-c C-s r `sesman-restart` - C-c C-s q `sesman-quit` The command `sesman-start` is similar to `cider-jack-in-clj&cljs` except that the `cljs` REPL is started only if ClojureScript requirements have been met. To quit or restart individual connections use cider commands - C-c C-q `cider-quit` - C-c M-r `cider-restart` ## Context Links Sessions can be linked to contexts (projects, directories and buffers) - C-c C-s b `sesman-link-with-buffer` - C-c C-s d `sesman-link-with-directory` - C-c C-s p `sesman-link-with-project` - C-c C-s u `sesman-unlink` ## Current Session All CIDER commands (evaluation, completion, switching to REPL etc.) operate on the relevant REPL within the current session. The current session is the most relevant session among all linked session. Session relevance is decided by the specificity of the linked contexts and recency of the REPL buffers. If the current context is linked to a single session then that session is the current one. If multiple sessions are linked to a context (say, a project) then the current session is the one containing the most recently viewed REPL. Links to more specific contexts have precedence. For example, if you have two sessions linked to the same project and another to a directory within that project, then the session linked to the directory is the current session. Thus, again, there is no ambiguity. By default [Sesman] allows multiple simultaneous links to projects and directories, but only one link per buffer. See `sesman-single-link-contexts` if you would like to change that. Retrieve info on the current session with C-c C-s i (`sesman-show-session-info`). With a single prefix C-u it shows info on all linked sessions, and with double prefix C-u C-u on all CIDER sessions. Display active links with C-c C-s l (`sesman-show-links`). ## Current REPL The current REPL is the most relevant REPL from the current session. REPL relevance is determined by the type of the current buffer. For example if the current buffer is a `clj` buffer then a `clj` REPL is selected. Ambiguous situations could arise when, for instance, there are multiple `clj` REPLs within a session, or the current buffer is a `cljc` buffer and both `clj` and `cljs` REPLs exist in the session. In such cases the current REPL is the most recently viewed REPL of the relevant type. Switch to the current REPL buffer with C-c C-z. You can then use the same key combination to switch back to the Clojure(Script) buffer that you came from. The single prefix C-u C-c C-z, will switch to the current REPL buffer and set the namespace in that buffer based on namespace in the current Clojure(Script) buffer. [Sesman]: https://github.com/vspinu/sesman