简体   繁体   English

如何将Hyperspec文档连接到MS Windows上的Emacs SLIME

[英]How to connect Hyperspec documentation to Emacs SLIME on MS Windows

With this minimal init file: 使用这个最小的init文件:

(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")

Everything seems to work, such as slime-eval-defun and slime-complete-symbol, except for looking up documentation. 除了查找文档之外,一切似乎都有效,例如slime-eval-defun和slime-complete-symbol。 Mx slime-describe-symbol RET print RET results in this error: Mx slime-describe-symbol RET print RET导致此错误:

CLHS-ROOT: variable *CLHS-ROOT-DEFAULT* has no value

What do I need to add in my init file to make it work? 我需要在init文件中添加什么才能使其正常工作?

I also tried downloading the hyperspec tar file and extracting it to a directory, and this code: 我也尝试下载hyperspec tar文件并将其解压缩到一个目录,这段代码:

(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp"
      common-lisp-hyperspec-root "c:/run/HyperSpec/"
      common-lisp-hyperspec-symbol-table "c:/run/HyperSpec/Data/Map_Sym.txt")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")

That doesn't work either. 这也行不通。 I do not know if the bug is in that init file, or in the SLIME version I am using, because this is my first time with SLIME. 我不知道bug是在那个init文件中,还是在我正在使用的SLIME版本中,因为这是我第一次使用SLIME。

Versions: 版本:

  • MS Windows 7 MS Windows 7
  • Emacs version 24.3.1 (probably latest stable) Emacs版本24.3.1(可能最新稳定)
  • SLIME version 20130626.1151 (latest from MELPA) (One from Marmalade says it can't compile nil, I don't know what that means and so I am using one from MELPA instead) SLIME版本20130626.1151(来自MELPA的最新版本)(一个来自Marmalade说它无法编译为零,我不知道这意味着什么,因此我使用的是MELPA中的一个)
  • GNU CLISP 2.49 (latest stable) GNU CLISP 2.49(最新稳定版)

UPDATE UPDATE

Cc Cd f RET print RET works fine. Cc Cd f RET print RET工作正常。 This is bound to slime-describe-function , which is undocumented, and not listed in SLIME menu. 这与slime-describe-function绑定,该slime-describe-function未记录,未在SLIME菜单中列出。 There is also slime-documentation-lookup which is bound to Cc Cd Cd which can open documentation for variables (not just functions) in a browser, and that works too. 还有slime-documentation-lookupCc Cd Cd绑定,它可以在浏览器中打开变量(不仅仅是函数)的文档,并且也可以。 Looks like only `slime-describe-symbol doesn't work. 看起来只有`slime-describe-symbol不起作用。

I haven't done it on Windows, but if I were you, I'd try to do this with Quicklisp: (ql:quickload "clhs") and follow the printed directions. 我没有在Windows上完成它,但如果我是你,我会尝试使用Quicklisp: (ql:quickload "clhs")并按照打印的说明进行操作。

I'd also get SLIME from Quicklisp via (ql:quickload "quicklisp-slime-helper") , but if your slime works ok, no real need. 我也会从Quicklisp获得SLIME (ql:quickload "quicklisp-slime-helper") ,但是如果你的粘液工作正常,没有真正的需要。

Assuming that SLIME is installed from an emacs package archive (preferably MELPA) (and that GNU CLISP is installed), here is combination of relevant portions from How to install Common Lisp and SLIME on MS Windows : 假设SLIME是从emacs包存档(最好是MELPA)安装的(并且安装了GNU CLISP),这里是如何在MS Windows上安装Common Lisp和SLIME的相关部分的组合:

Assuming starting from scratch after commenting out any SLIME customization code you already have, start by putting the following code to your init file which should be evaluated after package-initialize : 假设在评论出您已经拥有的任何SLIME自定义代码后从头开始,首先将以下代码放入init文件中,该文件应在package-initialize之后进行评估:

(setq inferior-lisp-program "clisp")
(setq slime-auto-connect 'ask)

(defun my-slime-setup ()
  (require 'slime)
  (slime-setup))
(defvar my--slime-setup-done nil)
(defun my-slime-setup-once ()
  (unless my--slime-setup-done
    (my-slime-setup)
    (setq my--slime-setup-done t)))
(defadvice lisp-mode (before my-slime-setup-once activate)
  (my-slime-setup-once))

What that does is defining my-slime-setup and make sure the function runs just once if you are using SLIME that day. 这样做的目的是定义my-slime-setup并确保在当天使用SLIME时该函数只运行一次。 my-slime-setup is also a container to which you can add your own SLIME customization code. my-slime-setup也是一个容器,您可以添加自己的SLIME自定义代码。

Now to connect the downloaded documentation to SLIME, extract the downloaded archive and you will get a folder with name Hyperspec , and then you move that folder to the Emacs bin directory, or its parent directory, or its grandparent directory, Put the following code in Emacs init file. 现在将下载的文档连接到SLIME,解压缩下载的存档,您将获得一个名为Hyperspec的文件夹,然后将该文件夹移动到Emacs bin目录,或其父目录或其祖父目录,将以下代码放入Emacs init文件。

(defun my-hyperspec-setup ()
  (let ((dir (locate-dominating-file invocation-directory "HyperSpec/")))
    (if dir
        (progn
          (setq common-lisp-hyperspec-root (expand-file-name "HyperSpec/" dir)))
      (warn "No HyperSpec directory found"))))

and add my-hyperspec-setup to my-slime-setup like this: 并将my-hyperspec-setup添加到my-slime-setup如下所示:

(defun my-slime-setup ()
  (my-hyperspec-setup)
  (require 'slime)
  (slime-setup))

and restart Emacs. 并重新启动Emacs。

And now when you do Mx slime-describe-symbol RET print RET in a lisp buffer, it should show the description of PRINT in another buffer. 现在当你在lisp缓冲区中执行Mx slime-describe-symbol RET print RET时,它应该在另一个缓冲区中显示PRINT的描述。

I should confess that I am sourcing from my own article and also answering my own question after about 8 months. 我应该承认,我从自己的文章中采购,并在大约8个月后回答我自己的问题。 The answer is tested with latest SLIME from MELPA and on a vanilla GNU Emacs. 答案是使用MELPA的最新SLIME和香草GNU Emacs测试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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