Clojure 1.2 发布了!如何让 swank-clojure 使用这个?

发布于 2024-09-15 17:09:35 字数 305 浏览 5 评论 0原文

我刚刚安装了一个新的 emacs,安装了 ELPA,并使用 ELPA 安装了 swank-clojure。虽然 Clojure 1.2 已发布,但当我点击“Mx slime”时,它仍然为我下载 Clojure 1.1 而不是 1.2 既然

1.2 可用,我如何让它使用它?我必须手动完成吗?我是否必须等待 slime/swank 更新才能使用 1.2?

更新:感谢您对使用 leiningen 的建议,但我所追求的是 emacs 本身启动 REPL。发生这个问题是因为 ELPA 中的 swank-clojure 包没有更新吗?

I just set up a new emacs installation, installed ELPA and installed swank-clojure with using ELPA. Although Clojure 1.2 is released, when I hit "M-x slime", it still downloaded Clojure 1.1 for me instead of 1.2

How do I get it to use 1.2 now that it's available? Do I have to do it manually? Do I have to wait for slime/swank to be updated to use 1.2?

Update: Thanks for the recommendations for using leiningen, but what I'm after is for emacs to just launch a REPL itself. Is this problem happening because the swank-clojure package in ELPA is not being updated?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

错々过的事 2024-09-22 17:09:35

使用 Leiningen 1.3,可以轻松创建独立的 swank 会话:

$ lein install swank-clojure 1.3.0-SNAPSHOT
$ ~/.lein/bin/swank-clojure

您可以将 ~/.lein/bin 添加到 $PATH 中以简化此操作。

然后在 Emacs 内部:

M-x slime-connect

可以使用 Mx lein-swank 从 Emacs 内部启动 swank 如果您位于项目目录中。但是,通过 swank-clojure.el 自动下载和安装 Clojure 及其他依赖项很容易出错,因此已被弃用。

With Leiningen 1.3, it's easy to create a standalone swank session:

$ lein install swank-clojure 1.3.0-SNAPSHOT
$ ~/.lein/bin/swank-clojure

You can add ~/.lein/bin to your $PATH to make this easier.

Then inside Emacs:

M-x slime-connect

Launching swank from inside Emacs can be done with M-x lein-swank if you are inside a project directory. However, auto-download and install of Clojure and other dependencies via swank-clojure.el is error-prone and deprecated.

笛声青案梦长安 2024-09-22 17:09:35

我相信,通过您描述的那种设置,Mx slime 会将所有内容放入 ~/.clojure~/.swank-clojure在类路径上。您可以通过设置 swank-clojure-classpath 变量来自定义它(我将其自定义为仅使用 ~/.clojure;这就是我将基本的 jar 集放在有用的地方 选项

一旦您需要在类路径上添加更多内容,上述方法就不够了,有两种方法可以管理这些更复杂的情况:

1:启动 Swank,然后连接

最直接的方法是使用。 Leiningen 将其放入您的 project.clj 中:

(defproject repl-base "1.0.0-SNAPSHOT"
  :description "A project to start Swank in."
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]]
  :dev-dependencies [[swank-clojure "1.2.1"]])

然后使用 lein swank 在项目目录中启动 swank 服务器并使用 Mx slime-connect 从 Emacs 中连接到它

作为另一种可能性,David Edgar Liebke 的 cljr 显然会为您启动独立的 Swank 实例;有关详细信息,请参阅 README。

选项 2:从 Emacs

Now 中启动 Swank,以老实说,我自己倾向于从 Emacs 中启动 Swank —— 设置起来可能有点棘手(因此一开始可能不建议这样做),但以后会很方便。请参阅我对旧版本的回答问题是我用来启动 Clojure 特定的 Swank 实例的函数的一个版本,并为 Leiningen 风格的项目提供了正确的类路径配置。

I believe that with the sort of setup that you describe, M-x slime will put everything in ~/.clojure and ~/.swank-clojure on the classpath. You can customise this by setting the swank-clojure-classpath variable (I have it customised to use ~/.clojure only; that's where I put the basic set of jars useful for launching one-off experimental REPLs.

As soon as you need more stuff on the classpath, the above is inadequate. There are two options for managing those more complex cases:

Option 1: launch Swank, then connect

The most straightforward approach is to use Leiningen. Put this in your project.clj:

(defproject repl-base "1.0.0-SNAPSHOT"
  :description "A project to start Swank in."
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]]
  :dev-dependencies [[swank-clojure "1.2.1"]])

Then use lein swank in your project's directory to start a swank server and use M-x slime-connect to connect to it from within Emacs.

As another possibility, David Edgar Liebke's cljr will apparently launch stand-alone Swank instances for you; consult the README for details.

Option 2: launch Swank from within Emacs

Now, to be entirely honest, I tend to start Swank from within Emacs myself -- it's maybe a bit trickier to setup (and thus possibly not advisable in the beginning), but quite convenient later on. See my answer to an older question for one version of a function I use to launch Clojure-specific Swank instances complete with proper classpath configuration for Leiningen-style projects.

风向决定发型 2024-09-22 17:09:35

我使用 leiningen 将 emacs slime 连接到 clojure 实例。在项目中,您总是会遇到一些依赖项,leiningen 很好地将它们放在类路径上。

它使用一个小的 clojure 文件来描述依赖关系,例如:

(defproject myprojecy "0.1.0-SNAPSHOT"
   :description "A project."
   :dependencies [[org.clojure/clojure "1.2.0-beta1"]
                 [org.clojure/clojure-contrib "1.2.0-beta1"]]
   :dev-dependencies [[swank-clojure "1.2.1"]])

您可以看到更改版本只需在编辑器中敲击几次键即可。 Leiningen 从网络下载依赖项,这使得项目非常小并且可以快速进行版本控制。

运行 lein swank 会启动程序和 swank 中的 repl :

ptimac:cljhack pti$ lein swank
user=> Connection opened on local port  4005
#<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=4005]>

您现在可以使用 Mx slime-connect 在 emacs 中连接并接受默认值。

I use leiningen to connect emacs slime to the clojure instance. In a project you always end up with a couple of dependencies, which leiningen nicely places on the classpath.

It uses a small clojure file to describe the dependencies, e.g. :

(defproject myprojecy "0.1.0-SNAPSHOT"
   :description "A project."
   :dependencies [[org.clojure/clojure "1.2.0-beta1"]
                 [org.clojure/clojure-contrib "1.2.0-beta1"]]
   :dev-dependencies [[swank-clojure "1.2.1"]])

You can see that changing versions is just a couple of keystrokes in an editor. Leiningen downloads the dependencies from the 'net which keeps the projects really smal and fast to version control.

running lein swank starts the program and the repl in swank :

ptimac:cljhack pti$ lein swank
user=> Connection opened on local port  4005
#<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=4005]>

you can now connect in emacs using M-x slime-connect and accept the defaults.

鲜血染红嫁衣 2024-09-22 17:09:35

您只需要在点击 Mx slime 之前设置 swank-clojure-classpath 变量

假设您在 c:\jars 下有 clojure.jar、clojure-contrib.jar 和 swank-clojure.jar

在暂存缓冲区中粘贴此

(setq swank-clojure-classpath '("c:/jars/clojure.jar" "c:/jars/cloure-contrib.jar" 
"c:/jars/swank-clojure.jar"))

Hit Cx Ce 和 Mx 史莱姆,应该可以了。

有关详细信息,请查看

https://github.com/ jochu/swank-clojure/blob/master/swank-clojure.el#L32-34

http://en.wikibooks.org/wiki/Clojure_Programming/FAQ#Where_does_swank-clojure_.28SLIME.29_look_for_Clojure.27s_jars.3F

You just need to set the swank-clojure-classpath variable before you hit M-x slime

Say if you have the clojure.jar, clojure-contrib.jar and swank-clojure.jar under c:\jars

In the scratch buffer paste this

(setq swank-clojure-classpath '("c:/jars/clojure.jar" "c:/jars/cloure-contrib.jar" 
"c:/jars/swank-clojure.jar"))

Hit C-x C-e and the M-x slime , that should do it.

For details checkout

https://github.com/jochu/swank-clojure/blob/master/swank-clojure.el#L32-34

http://en.wikibooks.org/wiki/Clojure_Programming/FAQ#Where_does_swank-clojure_.28SLIME.29_look_for_Clojure.27s_jars.3F

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文