简体   繁体   English

如何让Emacs,nrepl.el和Leiningen一起玩?

[英]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 这里有问题的一点是,我在网上看到的大多数文章都是

  • A) about swank-clojure, which is deprecated A)关于swank-clojure,不推荐使用
  • B) about Leiningen 1.x, which is deprecated B)关于Leiningen 1.x,已被弃用
  • C) both C)两者
  • D) Only cover installation, not how to actually use the things you just installed (or even what they do) D)仅涵盖安装,而不是如何实际使用您刚刚安装的东西(甚至他们做的事情)

Now what I'm looking for is: 现在我正在寻找的是:

  • Get nrepl.el to respect my project.clj 让nrepl.el尊重我的project.clj
  • Find out what the normal workflow with leiningen + emacs + clojure-mode + nrepl.el is 了解leiningen + emacs + clojure-mode + nrepl.el的正常工作流程
  • 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. 与这个问题无关,但我感兴趣的是为什么emacs有时会覆盖文本(将字体颜色更改为背景颜色,直到光标命中),而不是我要求它。

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.

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