7

I started using Clojure with leiningen (and now boot).

Now I sometimes want to get quickly to a Clojure{Script} CIDER REPL in Emacs to execute just a few instructions. I don't want to create a project.clj file for that, since I just want a throwaway REPL.

Is there a way to get a Clojure REPL, for instance in the *scratch* buffer ?

nha
  • 17,623
  • 13
  • 87
  • 133

3 Answers3

6

well, you can execute M-x cider-jack-in anywhere you want, even with no project.clj in path. This works for me.

leetwinski
  • 17,408
  • 2
  • 18
  • 42
  • Wow I thought I was sure I tried that, but apparently nope. – nha Oct 12 '15 at 21:45
  • It doesn't allow me to `C-e` from the scratch buffer though, is there a way to do that ? – nha Oct 12 '15 at 21:47
  • 1
    you mean C-c C-e, right? just turn cider-mode, for example in a *scratch* , M-x cider-mode, and it will bootstrap all the stuff. Just checked it, works ok – leetwinski Oct 12 '15 at 21:50
  • Right, I get "No Clojure subprocess; see variable `inf-clojure-buffer" in the minibuffer (with clojure-mode and cider-mode enabled). – nha Oct 12 '15 at 21:54
  • which versions of cider, leiningen and nrepl do you have? maybe you should update them? mine are: `; CIDER 0.10.0snapshot (package: 20151011.151) (Java 1.8.0_45, Clojure 1.7.0, nREPL 0.2.10)`, leiningen 2.5.3 – leetwinski Oct 12 '15 at 22:03
  • Thanks, seems spot on. I upgraded leiningen, now I should have mentioned this message on my REPL : `; CIDER 0.10.0snapshot (package: 20151006.714) (Java 1.8.0_60, Clojure 1.6.0, nREPL 0.2.6) WARNING: CIDER requires nREPL 0.2.7 (or newer) to work properly`. But I am pretty sure also that I have more recent versions of those installed. Is there a way to specify a default version ? `./lein` maybe ? – nha Oct 12 '15 at 22:12
  • yes, you're right, you should probably add cider-nrepl to plugins and org.clojure/tools.nrepl to dependencies in you .lein/profiles.clj , like this: {:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]] :dependencies [[org.clojure/tools.nrepl "0.2.10"]]}} before starting nrepl – leetwinski Oct 12 '15 at 22:21
  • I will try that tomorrow, or I may miss something. I will accept your answer if it works, thanks. – nha Oct 12 '15 at 22:22
4

You can just type lein repl in the friendly console / shell / terminal right next to you -- no project.clj required. This will start a REPL as expected, to which you can then connect from Emacs via M-x cider-connect (which in recent versions will handily suggest host and port to connect to). M-x cider-jack-in basically does the same thing (i.e. lein repl) behind the scenes.

I'm not a boot user, but according to the boot wiki for leiningen users it should be possible to call boot repl -s.

schaueho
  • 3,419
  • 1
  • 21
  • 32
0

Use M-x cider-jack-in, and if you don't want it to warn you that you're running cider-jack-in without a Clojure project, add the following to your emacs.d/init.el:

(setq cider-allow-jack-in-without-project t)
Razzi Abuissa
  • 3,337
  • 2
  • 28
  • 29