简体   繁体   中英

How to connect Hyperspec documentation to Emacs SLIME on MS Windows

With this minimal init file:

(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. Mx slime-describe-symbol RET print RET results in this error:

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

What do I need to add in my init file to make it work?

I also tried downloading the hyperspec tar file and extracting it to a directory, and this code:

(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.

Versions:

  • MS Windows 7
  • Emacs version 24.3.1 (probably latest stable)
  • 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)
  • GNU CLISP 2.49 (latest stable)

UPDATE

Cc Cd f RET print RET works fine. This is bound to slime-describe-function , which is undocumented, and not listed in SLIME menu. 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. Looks like only `slime-describe-symbol doesn't work.

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.

I'd also get SLIME from Quicklisp via (ql:quickload "quicklisp-slime-helper") , but if your slime works ok, no real need.

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 :

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 :

(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 is also a container to which you can add your own SLIME customization code.

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.

(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:

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

and restart 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.

I should confess that I am sourcing from my own article and also answering my own question after about 8 months. The answer is tested with latest SLIME from MELPA and on a vanilla GNU Emacs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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