简体   繁体   中英

How to get Emacs, nrepl.el and Leiningen to play along?

I was actually quite happy with using vim + lein repl, but since so many people keep saying that Emacs is the way to go when it comes to Lisps, I've decided to give it a try. The problem is now setting up a clojure environment that does all the fancy things that people keep talking about - for now I managed to install clojure-mode and nREPL and that works reasonably well, but I need to get the repl to work with my Leiningen projects if this experiment is going to go somewhere (having a repl in the editor would be pretty pointless if that meant having to manage of all my dependencies (especially classpath related ones) on my own again). The problematic point here is that most articles I see online are

  • A) about swank-clojure, which is deprecated
  • B) about Leiningen 1.x, which is deprecated
  • C) both
  • D) Only cover installation, not how to actually use the things you just installed (or even what they do)

Now what I'm looking for is:

  • Get nrepl.el to respect my project.clj
  • Find out what the normal workflow with leiningen + emacs + clojure-mode + nrepl.el is
  • Has nothing to do with the question, but I'd be interested in why emacs sometimes covers up text (changes font color to background color until hit by the cursor) without me asking it to.

Assuming you have both lein2 and nrepl.el installed:

Option A:

You simply open in Emacs a file belonging to your lein project (like foo.clj ) and you type Mx nrepl-jack-in . This will start a nREPL with all the deps loaded in and you can play with it more or less in the same manner as with swank-clojure . (that's what I do most of the time)

Option B:

You go to your project's dir in a terminal and type there:

lein repl

Afterwards typing Mx nrepl will allow you to connect to the running nrepl session.

nrepl.el comes with a handy minor mode that allows you to evaluate code in your Clojure source files and load it directly in the repl (same as swank-clojure). A list of all available commands in available in the nREPL menu section.

PS

nrepl.el was renamed to CIDER .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM