Fork me on GitHub
#spacemacs
<
2021-01-16
>
Faris16:01:17

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?

practicalli-johnny17:01:47

@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)

practicalli-johnny18:01:38

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

Faris18:01:34

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?

practicalli-johnny23:01:44

@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.

practicalli-johnny23:01:15

If you have changed a few different expression without evaluating them, then evaluating the buffer is a quick way to do so.

practicalli-johnny23:01:03

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