Hi, sorry I’m super new at using Spacemacs, trying out REPL Driven development, I just wanna ask, whats the difference between cider-ns-refresh
and cider-ns-reload
and cider-eval-buffer
and when should use which?
@hewrin Its a very good question.
Use cider-eval-buffer
when you first start the REPL in cider (cider-jack-in or cider-connect), run this command with the main namespace file open in the current buffer. This will load all the code in that namespace, except commented code) and will load the all the Clojure core into Ciders memory (runtime state). This makes things like cider-doc work.
Also use cider-eval-buffer
if you made changes to a number of functions or defs and want to evaluate all the changes. It will update any changes to functions and defs (but not defonce
expressions)
Take a look at this page to understand more about refresh and reload (I dont really use them that much and sometimes its easier to restart the repl, but they can be useful) https://practicalli.github.io/spacemacs/clojure-repl/refresh-restart-repl.html
Thanks for the explanation @jr0cket! Am I correct in assuming I need to run cider-eval-buffer every time I make a change in my file for it to be able to be evaluated by the REPL?
@hewrin you should evaluate changes to the code if you want to use them in the repl. These are usually done on a specific expression
For example, if you change a function definition, defn
expression, then you can just evaluate that defn expression using , e f
I usually evaluate an expression as soon as I have changed it, to make sure it does what I think it does.
If you have changed a few different expression without evaluating them, then evaluating the buffer is a quick way to do so.
If you have any code you don't want to call when evaluating the buffer, for example experimental code, I use the (comment ,,, ) expression. I can still go an evaluate those expressions in the repl individual