[英]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. 我真的很高兴使用vim + lein repl,但是因为有很多人一直说Emacs是Lisps的方法,所以我决定尝试一下。 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). 问题是现在建立一个clojure环境,可以完成人们一直在谈论的所有奇特的事情 - 现在我设法安装了clojure-mode和nREPL,并且工作得相当好,但我需要让repl与我的Leiningen一起工作项目如果这个实验要去某个地方(如果这意味着我必须自己管理所有的依赖项(特别是类路径相关的),那么在编辑器中进行repl将毫无意义)。 The problematic point here is that most articles I see online are 这里有问题的一点是,我在网上看到的大多数文章都是
Now what I'm looking for is: 现在我正在寻找的是:
Assuming you have both lein2 and nrepl.el installed: 假设你安装了lein2和nrepl.el :
Option A: 选项A:
You simply open in Emacs a file belonging to your lein project (like foo.clj
) and you type Mx nrepl-jack-in
. 您只需在Emacs中打开属于您的lein项目的文件(如foo.clj
),然后键入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
. 这将启动一个加载了所有deps的nREPL,您可以使用与swank-clojure
相同的方式或多或少地使用它。 (that's what I do most of the time) (这就是我大部分时间都在做的事)
Option B: 选项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. 然后键入Mx nrepl
将允许您连接到正在运行的nrepl会话。
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). nrepl.el
带有一个方便的次要模式,允许您评估Clojure源文件中的代码并将其直接加载到repl中(与swank-clojure相同)。 A list of all available commands in available in the nREPL
menu section. nREPL
菜单部分中提供的所有可用命令的列表。
PS PS
nrepl.el
was renamed to CIDER
. nrepl.el
更名为CIDER
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.