Reputation: 14998
I use IntelliJ in order to write Clojure. I use the built-in REPL to run my code. I don't know why, but after I run my project, I always have to do “Switch REPL NS to current file” and then "Load file in REPL" in order to use the REPL for main namespace. I want to ask whether there is a way avoid these clicks and working with the REPL immediately after the run is over.
Upvotes: 2
Views: 2237
Reputation: 6956
In Cursive, there are two ways of sending forms to the currently active REPL:
Execute Current Statement
(default Ctrl-Enter
)Send top form to REPL
(default Ctrl-Shift-P
, I rebound it to Ctrl-Enter
)From the REPL command line, forms will always be evaluated in the current namespace of the REPL (user
by default). If you want to evaluate the form in another namespace, you will first have to switch to that namespace by either:
ns
namespace) commandSwitch REPL NS to current file
(default Ctrl-Shift-N
)However, when you send the form from the file editor, it can infer which namespace you want it executed in from the file itself. In the background, it will:
This way you won't ever have to switch the namespaces in the REPL, and there's far less chances of namespace mix-ups.
However, it will only do that if the setting Evaluate forms in REPL namespace
is unchecked. If not, it will evaluate the form in the current REPL namespace, just as if you entered it through the REPL commandline, needing the same manual switching of namespaces.
Upvotes: 3