2
votes

EDIT For a reason which I haven't fully understood yet my C-x C-e was bound to eval-last-sexp and instead of (?) slime-eval-last-expression. Now I can C-x C-e from the .clj buffer and I can at least see directly when my function is (in)correct but, however, this apparently doesn't make the function I just slime-eval-last-expression "available" to the REPL.

I've set up my Emacs to do some Clojure programming and I don't know if my setup is correct or not.

I've got two buffers: one for the .clj file and one for the REPL. I'm using clojure-jack-in to start the REPL.

Apparently I need to always compile the .clj (which also always forces me to save the file with a prompt) and I then need to switch to the REPL and issue a (use 'myname.space) in the REPL before being able to try, say, a new function I wrote.

This is a lot of keys to press for what seems like a very simple thing.

Now, of course, I could write an Emacs macro doing the whole save / confirm / switch to REPL / issue (use 'myname.space) shebang but I was wondering if my setup was correct or not?

I guess that my question in other words would be: is the REPL I'm connected to supposed to always be "in synch" with the buffer containing the .clj I'm working on or not?

1

1 Answers

3
votes

You should be using Slime if you're editing clojure with Emacs. See https://github.com/technomancy/swank-clojure

Then, when you've used M-x clojure-jack-in to start and connect a REPL in emacs, you can just do C-x C-e to compile and load the current sexp, or C-x C-k to compile and load the current buffer.

In other words, your repl is not "automatically" in sync with whatever you've just typed in some clojure code buffer, but there are much quicker and easier ways to send code from a buffer to the running clojure program.