Bill Clementson's Blog

Bits and pieces (mostly Lisp-related) that I collect from the ether.

July 2004
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Jun  Aug

Setting Up SLIME for Win32 CL Implementations

Sunday, July 4, 2004

I've posted (have a look here, here, and here) a number of different times about setting up SLIME for different Win32 implementations and I sometimes get emails from people asking for help in getting things set up properly. So, I've decided to try to write up some definitive instructions so that I can just point people to this posting. I did a similar effort a while back for the CL Cookbook, but that was before SLIME was available. The main complaint that I got about the CL Cookbook page was that it was too complicated. Therefore, I've decided to be very "minimalist" in this set of instructions while still covering the major CL implementations that are available on Win32:

My instructions assume the following base directory structure: If you use the same directories, these instructions and sample files should work unchanged. If you use different directories (or install later versions of the software), you will need to modify some of the following files and instructions:
  1. Install Emacs (duh). These instructions assume basic familiarity with Emacs and are known to work with GNU Emacs version 21.3
  2. Download and install one or more of the above CL implementations. Install them in the c:/bin/ directory with the following directory names:
    • ACL: C:/bin/acl-6.2
    • CLISP: C:/bin/clisp-2.33
    • LispWorks: C:/bin/lispworks-4.3
  3. Download the latest SLIME tarball and unzip it in c:/home/site - make sure you preserve directory names so that you wind up with slime in c:/home/site/slime
  4. Create a Lisp/SLIME initialization file called .slime.lisp in your c:/home directory and put the following in it:
  5. (load "c:/home/site/slime/swank-loader.lisp")
    #+lispworks (mp:initialize-multiprocessing)
    (swank::create-swank-server 4005)
  6. If you are using the commercial LispWorks product (either Professional Edition or Enterprise Edition), you should set up a console version of LispWorks in order to use it "natively" inside of Emacs. In order to do this, do the following two steps:
    1. Create a lisp file called console.lisp in your c:/ root directory with the following contents:
    2. (load-all-patches)
      (save-image "lw4307-console" :console t 
                                   :restart-function 'mp:initialize-multiprocessing 
                                   :environment nil)
      (quit)
    3. Create a Windows batch file called buildlw.bat in your c:/ directory with the following contents:
    4. cd c:\bin\lispworks-4.3\
      lispworks-4300 -init c:\console.lisp
    5. Change to the c:/ directory and run the buildlw.bat file. A new LispWorks executable called lispworks-4307.exe will be created in the c:/bin/lispworks-4.3 directory.
  7. If you are using the free Lispworks Personal Edition (or if you are using the commercial LispWorks product and want to have both the LW IDE and SLIME available), you will need a script that loads the required SLIME support as the free version of LW doesn't support initialization files. Therefore, create a script file called .lw-slime.vbs in your c:/home directory with the following contents:
  8. Dim Wsh
    Set Wsh = Wscript.CreateObject("Wscript.Shell")
    rem Start up LispWorks
    wsh.Run("C:\bin\lispworks-4.3\lispworks-personal-4300")
    rem Wait for a few seconds for it to start
    WScript.Sleep(8000)
    rem Press the OK button on the splash screen
    Wsh.AppActivate "Upgrade LispWorks"
    Wsh.SendKeys "{ENTER}"
    rem Load the SLIME startup code
    Wsh.AppActivate "LispWorks Personal Edition 4.3.6"
    str = "load " & """c:/usr/home/.slime.lisp"""
    WScript.Sleep(100)
    Wsh.SendKeys (str)
    Wsh.SendKeys "{ENTER}"
    WScript.Sleep(100)
    rem Toggle back to Emacs 
    Wsh.SendKeys "%{TAB}"
  9. Create a .emacs file with the following contents in your c:/home directory:
  10. ;;__________________________________________________________________________
    ;;;;    Site-specific locations
    
    (defvar home-dir "c:/home/")
    (defvar bin-dir "c:/bin/")
    ;;__________________________________________________________________________ ;;;; Programming - Common Lisp (setq load-path (append (list (concat home-dir "") (concat home-dir "site/slime") (concat home-dir "site")) load-path)) (require 'slime) (require 'font-lock) (global-font-lock-mode t)
    ;; Specify modes for Lisp file extensions (setq auto-mode-alist (append '(("\.lisp$" . lisp-mode) ("\.lsp$" . lisp-mode) ("\.cl$" . lisp-mode) ("\.asd$" . lisp-mode) ("\.system$" . lisp-mode)) auto-mode-alist))
    ;; Hooks into lisp mode (add-hook 'lisp-mode-hook (lambda () (slime-mode t) (define-key lisp-mode-map [(control j)] 'newline) (define-key lisp-mode-map [(control m)] 'newline-and-indent) (set (make-local-variable lisp-indent-function) 'common-lisp-indent-function)))
    (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t))) (slime-autodoc-mode)
    (defun replace-slime-cmd () "Replaces regular Slime command for ACL and LW Personal." (interactive) (defun slime () "Start Slime without an inferior lisp." (interactive) (slime-connect "localhost" 4005)))
    ;; Franz Allegro Common Lisp (defun acl () (interactive) (shell-command (concat bin-dir "acl-6.2/alisp.exe" " +B +cm -L " home-dir ".slime.lisp&")) (delete-other-windows) (replace-slime-cmd))
    ;; GNU CLISP (defun clisp () (interactive) (setq inferior-lisp-program (concat bin-dir "clisp-2.33/full/lisp.exe" " -B " bin-dir "clisp-2.33/full/" " -M " bin-dir "clisp-2.33/full/lispinit.mem" " -ansi -q")) (load "slime"))
    ;; Xanalys LispWorks (defun lw () (interactive) (setq inferior-lisp-program (concat bin-dir "lispworks-4.3/lw43-console.exe" " -init " home-dir ".slime.lisp")) (load "slime"))
    ;; Xanalys LispWorks Personal (defun lwp () (interactive) (shell-command (concat home-dir ".lw-slime.vbs&")) (delete-other-windows) (replace-slime-cmd))
To run a specific implementation (e.g. - for CLISP), you just type:
M-x clisp
followed by:
M-x slime
Alternatively, if you just use a single CL implementation all the time, just put one of the following statement in your .emacs file (after the rest of the above statements):
(acl)
(clisp)
(lw)
(lwp)
Then you just do "M-x slime" to run SLIME with your CL implementation. Read the SLIME documentation to learn about the features and functionality. The CLiki pages on SLIME also have some good information.

That's it - good luck and enjoy using SLIME!

emacs Copyright © 2005 by Bill Clementson