使用 slime-fancy (slime-autodoc) 为 clojure 和 common lisp 设置 emacs

发布于 2024-10-07 08:19:38 字数 1287 浏览 0 评论 0原文

我为 clojure 和 common lisp 设置了 emacs,但我也想为 common lisp 设置 (slime-setup '(slime-fancy)) 。如果我将该行添加到 init.el 中,clojure 将无法工作:它为我提供了 repl,但在我运行任何代码后它会挂起。

我的配置

对于 clojure:

  • 我通过 ELPA 设置了 clojure-mode、slime、slime-repl
  • 我在项目目录中运行 $ lein swank
  • 然后 Mx slime-connect 来破解 clojure

(add-to-list 'load-path "~/.elisp/slime")
(require 'slime)
(add-to-list 'slime-lisp-implementations '(sbcl ("/opt/local/bin/sbcl") :coding-system utf-8-unix))
;; (slime-setup '(slime-fancy))

对于 common lisp,我将其放在 init.el 中的 ELPA 代码之后 如果我取消最后一行的注释,Clojure 将被破坏。但是 slime 喜欢一个非常重要的元包来破解 common lisp。


当我需要切换语言时,有没有一种方法可以将它们设置为工作,而无需更改配置并重新启动?


更新

我发现装有 slime-fancy 的 slime-autodoc 是挂起的原因。

(slime-setup '(slime-fancy))
(setq slime-use-autodoc-mode nil)

此配置允许运行 common lisp 和 clojure SLIME。甚至同时。但没有 slime-autodoc。

我还发现我正在使用 SLIME 的 CVS 版本,因为我在 ELPA 代码之后手动执行 (add-to-list 'load-path "~/.elisp/slime") 。这并不能解决问题。也许某个神奇日期有一个与 clojure 一起使用的版本?这里有人说 CVS 版本适合他:http://www .youtube.com/watch?v=lf_xI3fZdIg&feature=player_detailpage#t=221s

I set up emacs for both clojure and common lisp, but I want also (slime-setup '(slime-fancy)) for common lisp. If I add that line to init.el, clojure won't work: it gives me repl, but it hangs after I run any code.

My configuration

For clojure:

  • I set up clojure-mode, slime, slime-repl via ELPA
  • I run $ lein swank in project directory
  • Then M-x slime-connect to hack clojure

For common lisp I place this after ELPA code in init.el:

(add-to-list 'load-path "~/.elisp/slime")
(require 'slime)
(add-to-list 'slime-lisp-implementations '(sbcl ("/opt/local/bin/sbcl") :coding-system utf-8-unix))
;; (slime-setup '(slime-fancy))

So if I uncomment the last line, clojure will be broken. But slime-fancy a very important meta package for hacking common lisp.


Is there a way to set them both up to work without changing configuration and restarting when I need to switch languages?


Update

I found that slime-autodoc loaded with slime-fancy is the cause of hangs.

(slime-setup '(slime-fancy))
(setq slime-use-autodoc-mode nil)

This configuration lets run both common lisp and clojure SLIMEs. Even simultaneously. But without slime-autodoc.

I also found I'm using the CVS version of SLIME since I manually do (add-to-list 'load-path "~/.elisp/slime") after ELPA code. That does not solve the problem. Maybe there is a version from some magic date which works with clojure? Here a guy says CVS version works for him: http://www.youtube.com/watch?v=lf_xI3fZdIg&feature=player_detailpage#t=221s

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

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

发布评论

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

评论(3

谁的年少不轻狂 2024-10-14 08:19:38

这是一个解决方案。 (使用钩子)
这虽然丑陋,但很方便。

(add-hook 'slime-connected-hook
          (lambda ()
            (if (string= (slime-lisp-implementation-type) "Clojure")
                (setq slime-use-autodoc-mode nil)
              (setq slime-use-autodoc-mode t))
            ))

(add-hook 'slime-mode-hook
          (lambda ()
            (if (eq major-mode 'clojure-mode)
                  (slime-autodoc-mode 0)
                (slime-autodoc-mode 1))))

更新
如果 slime-repl 缓冲区仍然存在问题,请尝试以下代码:

(add-hook 'slime-repl-mode-hook
          (lambda ()
            (if (string= (slime-lisp-implementation-type) "Clojure")
                (progn (setq slime-use-autodoc-mode nil)
                       (slime-autodoc-mode 0))
              (progn (setq slime-use-autodoc-mode t)
                     (slime-autodoc-mode 1)))))

Here is a solution. (using hooks)
That is ugly but quite convenient.

(add-hook 'slime-connected-hook
          (lambda ()
            (if (string= (slime-lisp-implementation-type) "Clojure")
                (setq slime-use-autodoc-mode nil)
              (setq slime-use-autodoc-mode t))
            ))

(add-hook 'slime-mode-hook
          (lambda ()
            (if (eq major-mode 'clojure-mode)
                  (slime-autodoc-mode 0)
                (slime-autodoc-mode 1))))

Update
If the problem still exists on the slime-repl buffer, try the following code:

(add-hook 'slime-repl-mode-hook
          (lambda ()
            (if (string= (slime-lisp-implementation-type) "Clojure")
                (progn (setq slime-use-autodoc-mode nil)
                       (slime-autodoc-mode 0))
              (progn (setq slime-use-autodoc-mode t)
                     (slime-autodoc-mode 1)))))
记忆里有你的影子 2024-10-14 08:19:38

我最近一直在思考同样的问题。问题是 ELPA 中的 SLIME 被精简了,对于 Common Lisp 来说几乎毫无用处。避免该问题的一种方法是在签出 ELPA 包的同一天从 CVS 签出 SLIME,并手动添加缺少的内容。 #clojure 上的某人告诉我他这样做了并且解决方案有效。
我个人觉得这样的解决方案相当丑陋,但在有人设法将 Clojure 支持引入上游 SLIME 之前,不会有更好的解决方案了。

或者,您可以将功能逐一添加到 slime-setup 中,并通过 Clojure 评估查看到底是哪些功能导致了问题 - 毕竟 slime-fancy 只是一个元功能,仅加载最流行的 contrib 功能。

顺便说一句,您不需要行

(add-to-list 'load-path "~/.elisp/slime/contrib")
(setq slime-backend "~/.elisp/slime/swank-loader.lisp")
(require 'slime)

The contrib dir 将自动添加到加载路径,后端是默认的,如果您使用“slime-autoloads”,您应该在此之前需要 slime,因为这违背了自动加载。

I've been contemplating on the same problem recently. The issue is that the SLIME in ELPA is trimmed down and is next to useless for Common Lisp. One way you can circumvent the problem is to check out SLIME from CVS from the same date as the checkout was done for the ELPA package and add manually the missing stuff. Someone on #clojure told me he did that and the solution worked.
I personally find such a solution pretty ugly, but until someone manages to get the Clojure support into upstream SLIME there won't be a better one.

Alternatively you can add features to the slime-setup one by one and see what feature exactly is causing the problem with the Clojure evaluation - after all slime-fancy is simply a metafeature that just loads the most popular contrib features.

Btw you don't need the lines

(add-to-list 'load-path "~/.elisp/slime/contrib")
(setq slime-backend "~/.elisp/slime/swank-loader.lisp")
(require 'slime)

The contrib dir will be added automatically to the load path, the back-end is the default and if you're using 'slime-autoloads you should require slime before that, since this defeats the purpose of the autoload.

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