clojure 和普通 lisp 的 emacs 设置,带有 slime-fancy (slime-autodoc) [英] emacs setup for both clojure and common lisp with slime-fancy (slime-autodoc)

查看:16
本文介绍了clojure 和普通 lisp 的 emacs 设置,带有 slime-fancy (slime-autodoc)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

对于clojure:

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

对于普通的 lisp,我将它放在 init.el 中的 ELPA 代码之后:

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))

所以如果我取消对最后一行的注释,clojure 将被破坏.但是 Slime-fancy 是一个非常重要的元包,用于破解普通 lisp.

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?

我发现加载了 slime-fancy 的 slime-autodoc 是挂起的原因.

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

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

这个配置可以运行普通的 lisp 和 clojure SLIME.甚至同时.但没有 Slime-autodoc.

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

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

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

推荐答案

这里有一个解决方案.(使用钩子)
这很丑,但很方便.

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))))

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

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)))))

这篇关于clojure 和普通 lisp 的 emacs 设置,带有 slime-fancy (slime-autodoc)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆