clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.54k stars 645 forks source link

*cider-scratch* doesn't obey "current REPL" rules #2742

Open tomdl89 opened 4 years ago

tomdl89 commented 4 years ago

Expected behavior

In a project where both clj and cljs REPLs exist in the session, the *cider-scratch* buffer should behave like a cljc buffer. Namely, it should obey the rule described in the "Managing Connections" section of the Cider Docs: "In such cases the current REPL is the most recently viewed REPL of the relevant type".

Actual behavior

The *cider-scratch* buffer's current repl is always the clj repl, regardless of the most recently viewed REPL.

Steps to reproduce the problem

cider-jack-in-clj&cljs Wait for cljs repl to load & connect etc. Ensure it is the most recently viewed REPL Goto *cider-scratch* buffer Evaluate some code Observe it is evaluated using the clj REPL

Environment & Version information

CIDER version information

CIDER 0.23.0 (Lima), nREPL 0.6.0 Clojure 1.10.0, Java 1.8.0_152

Lein/Boot version

Leiningen 2.9.0

Emacs version

GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu)

Operating system

RHEL release 7.3 (Maipo)

bbatsov commented 4 years ago

In the source buffers the behaviour of the code dispatching is governed by the source file extension. Here we'll probably have to add some explicit way to pick the flavor of a scratch buffer in case of ambiguities - e.g. you get prompted to pick a type if case of REPLs of multiple types. Alternatively - we can just ask for the type of the scratch buffer when it's created. Not sure if @vspinu doesn't have any better ideas about the dispatch.