clojure.contrib 与 slime 和 下面的 lisp 程序问题

发布于 2024-10-04 11:01:59 字数 1675 浏览 7 评论 0原文

我有来自 slime repl 的以下内容(未找到 clojure.contib 函数):

M-X slime
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
java.lang.Exception: Unable to resolve var: clojure.contrib.string/blank? in this context (NO_SOURCE_FILE:10)

从控制台启动 clojure 时有以下内容(但这里一切正常):

adr@~/clojure/cloj-1.2$ java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
-------------------------
clojure.contrib.string/blank?
([s])
  True if s is nil, empty, or contains only whitespace.
nil

在我的 .emacs 中,我有以下内容:

(setq inferior-lisp-program "java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main")

我的 clojure jars (1.2)位于“/home/adr/clojure/cloj-1.2”。

我是 emacs 新手,一直在学习一些教程。一段时间以来,我一直在尝试使用 Emacs 中的 clojure.contrib 库,但“MX slime”找不到 clojure.contrib。请帮助

编辑:如果这有帮助,现在我看到使用MX slime时有一条消息:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

Clojure 1.2.0
user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)

编辑2:但是如果我使用MX则没有这样的错误消息在目录中启动“lein swank”后(尽管即使从“MX slime-connect”开始,在 REPL 中也找不到 clojure-contrib 库(尽管它们是由 leiningen 作为依赖项下载的))。

I have the following from the slime repl (no clojure.contib functions found):

M-X slime
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
java.lang.Exception: Unable to resolve var: clojure.contrib.string/blank? in this context (NO_SOURCE_FILE:10)

And the following when starting clojure from console (but here everything is being found OK):

adr@~/clojure/cloj-1.2$ java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
-------------------------
clojure.contrib.string/blank?
([s])
  True if s is nil, empty, or contains only whitespace.
nil

In my .emacs I have the following:

(setq inferior-lisp-program "java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main")

My clojure jars (1.2) are at '/home/adr/clojure/cloj-1.2'.

I;m a newbie with emacs, been following some tutorials. For some time I've been trying to use the clojure.contrib library from Emacs, but "M-X slime" finds no clojure.contrib. Please, help

Edit: if that would help, now i saw that when using M-X slime there is a message:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

Clojure 1.2.0
user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)

Edit2: But there is no such error message if I use M-X slime-connect after having started a "lein swank" in a directory (though even starting with "M-X slime-connect" there are no clojure-contrib libraries found in the REPL (though they are downloaded by leiningen as dependency)).

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

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

发布评论

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

评论(2

余生一个溪 2024-10-11 11:01:59

这一行:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

是 Common Lisp,不是 Clojure,但由于您将 inferior-lisp-program 设置为 Clojure,slime 无法启动 swank服务器。

请参阅 swank-clojure 项目中的以下部分:

  • 连接 SLIME
  • 嵌入
  • swank-clojure.el

功能你想要的可能是swank-clojure.el,但不再推荐了。

由于您已经在使用 ELPA:

add-to-list 'package-archives
         '("technomancy" . "http://repo.technomancy.us/emacs/") t)

M-x package-install ;(slime-repl)
M-x slime-connect

This line:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

is Common Lisp, not Clojure, but since you set inferior-lisp-program to Clojure, slime can't start a swank server.

See the following sections in swank-clojure project:

  • Connecting with SLIME
  • Embedding
  • swank-clojure.el

The functionality you want is probably in swank-clojure.el, but it is not recommended anymore.

As you're already using ELPA:

add-to-list 'package-archives
         '("technomancy" . "http://repo.technomancy.us/emacs/") t)

M-x package-install ;(slime-repl)
M-x slime-connect
一个人的旅程 2024-10-11 11:01:59

在我看来,我在 REPL 中“要求”库的方式是错误的(由于我对 clojure 缺乏经验);当使用以下语法时:

user=> (require 'clojure.contrib.string)
nil
user=> (clojure.contrib.string/blank? "asd")
false

所有库都被发现正常(无论是否使用“MX slime”用于非 swank REPL 或“MX slime-connect”用于 swank 服务器)。所以这完全是我的错误(我在这个 stackoverflow 答案中找到了关于我的错误的提示:为什么运行时会出现错误(使用 'clojure.contrib.repl-utils)?

It seems to me that I was using the wrong way to "require" libraries in the REPL (due to my inexperience with clojure); when using a syntax such as:

user=> (require 'clojure.contrib.string)
nil
user=> (clojure.contrib.string/blank? "asd")
false

all the libraries are being found OK (no matter if using "M-X slime" for a non-swank REPL or "M-X slime-connect" for a swank server). So it was entirely my mistake (I have found hints about my mistake at this stackoverflow answer: Why do I get an error when I run (use 'clojure.contrib.repl-utils)?)

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