My recent install guide for CLISP, Emacs, and SLIME on Windows XP was a big hit – it has had about 2000 hits and 5 sincere thanks in the comments (it even got praise from a troll!). In it I promised a similar guide for SBCL, and here it is.
The nice thing is that swapping out Common Lisp implementations within an Emacs/SLIME setup is easy, so maybe 3/4 of this guide is identical to the CLISP guide. I’ll put a disclaimer at the beginning of each section saying whether there’s anything new or whether you can skip it.
0. Files to Download [DIFF: The only difference is the link to the SBCL installer instead of the CLisp installer]
If you want to get started on downloading the setup files, here are the links:
- 7-zip (download v4.57 – 840K) – for unpacking .tar and .tar.gz files commonly used in *nix.
- Emacs (download v22.2 – 37MB)
- SBCL (download v1.0.13 – 9.8 MB)
- SLIME (download CVS snapshot – 700K) – apparently the SLIME 2.0 release is ancient and not worth using
1. Setup Directories [NO DIFF: skip if you’ve completed the CLisp guide]
Windows XP loves extremely long pathnames like C:\Documents and Settings\Username\Application Data. This is okay if for GUI-driven apps, but in Emacs, you\’re not clicking, you\’re typing, and you want short path names. Also, much (most?) of the open source Common Lisp tools are developed on *nix, so there\’s less impedance mismatch when using stuff off the net if you have a *nix-ish folder structure.
Start with a root folder. In the pathnames in the rest of this guide, I\’ll refer to it as [HOME]. I used C:\home\ to match the *nix convention of having user files be in /home/username/. You also need a username directory – I called mine peter and I\’ll refer to it as [USR]. So in my case, [HOME]/[USR] would be C:\home\peter\.
Emacs NOTE #1: One important point about filenames in Emacs is that they CAN be entered with â€˜/\’, but if you prefer to use â€˜\\’, you have to escape it with another back slash, so in Emacs buffers and files, you would enter â€œC:/home/â€ or â€œC:\\home\\â€ but never â€œC:\home\â€. The trailing slash is also important because it indicates that it\’s a directory. Now that you have chosen your [ROOT] and [USR] values, these are the folders you should setup:
2. Setup Emacs [NO DIFF: skip if you’ve completed the CLisp guide]
Emacs does not need to be â€œinstalledâ€ like most Windows apps – it just runs from its directory. Extract it to [HOME]\bin\. I changed the folder name from emacs-22.2 to just emacs, so my path was c:\home\bin\emacs\. You run emacs by running the file [HOME]\bin\emacs\bin\runemacs.exe.
Emacs settings are stored in a configuration file called â€œ.emacsâ€. On Windows, the default working folder and .emacs location is C:\Documents and Settings\Username\Application Data, but that\’s too painful to type and it\’s a hidden folder so it\’s not even easy to get through with the GUI. To have Emacs work in a different folder, create a file called site-start.el in the emacs\site-lisp folder. In that folder, put the following line (but change the path to match yours):
(setenv â€œHOMEâ€ â€œ[HOME]/[USR]/â€)
(Thanks Nathaniel! This was probably the biggest annoyance of mine that made me put off finishing setup for so long.)
Emacs NOTE #2: Emacs has lots (and lots and lots) of keyboard shortcuts, many more than there are letters in the alphabet. Many of them require multiple keys or a sequence of keys called a â€œchordâ€. The two modifier keys used are Control and Alt (also called Meta). The common way to write chords is to use C- and M- for Control and Meta, so to run the command to close Emacs, you hold down Control and X, then let go, then hold down Control and C. This is written as C-x C-c. Sometimes a chord is followed by another letter or the name of a command. For instance, to undo, you hold Control and x, then let go and hit u. This is written as C-x u. Dashes mean press at the same time, space means let go. Easy! I made a cheat sheet for common commands in Emacs and SLIME.
Now it\’s time to create your .emacs file. Run emacs and hit C-x C-f. This is the find command, which is used to create or open a file. At the prompt â€œFind file: â€œ, type â€œ~/.emacsâ€ (without quotes). Right now just put a ; (that\’s the comment marker in Emacs Lisp files) and save it by hitting C-x C-s. There\’s a world of stuff you can put in a .emacs file, but that\’s too much to bite off now.
3. Install SBCL [DIFF: This section is completely different]
Although the Windows port of SBCL is still experimental, there is a Windows installer (.msi) file for v1.0.13 (highest version as of now is v1.0.17). Just run the installer, and install it to the directory:
Then just finish the install wizard. But you’re not finished yet.
Robert Zubek wrote a post about 2 months ago about how to setup SBCL/Emacs/SLIME on Vista, but it doesn’t work exactly right on Windows XP. If you use the .emacs settings from his post, you get this error when you start SLIME (instead of using the .emacs settings in step 4):
fatal error encountered in SBCL pid XXXX:
can’t find core file at /user/local/lib/sbcl//sbcl.core
Process inferior-lisp exited abnormally with code 1
If you use the settings in step 4, you’ll get a different error message:
Searching for program: no such file or directory, sbcl
If you SBCL looks in the environment variable PATH to find the executable and core file. The default directories are *nixy, so it won’t find your sbcl directory on accident. But why should it look for the directory if you entered it into the install wizard?
Apparently Windows XP doesn’t update system environment variables until the system reboots. So right after you install SBCL, you have the user environment variables PATH and SBCL_Home but SBCL looks in the system variables. I couldn’t find out a way to fix that without rebooting, but the good news is that a reboot solves the problem.
So reboot your computer now.
4. Setup SLIME [DIFF: This section has some differences – links and .emacs setup]
Apparently the SLIME 2.0 is very old; several people recommend ignoring it and going straight to the CVS snapshot, so that’s what I linked to above.
Extract the SLIME folder to [HOME]\bin\emacs\site-lisp. (Here\’s a tip about putting emacs code in site-lisp).
Now in Emacs, open your .emacs file (C-x C-f, ~/.emacs) and enter the following (general SLIME instructions, SBCL specific setup), changing your pathnames as usual. The good news is that because SBCL looks in the environment variables, you don’t need any of the command line parameters in the inferior-lisp-program variable:
(setq inferior-lisp-program â€œsbclâ€)
(add-to-list â€˜load-path â€œ[HOME]/bin/emacs/site-lisp/slime/â€)
Save the .emacs file (C-x C-s), then run the eval-buffer command (M-x eval-buffer). This will run the code that you just entered and tell Emacs how to run SLIME.
Now, you start slime with M-x slime and you\’re ready to go!
NOTE: This is a basic SBCL setup – I’ve found some more advanced setup links that I’ll write guides for later:
- Setup ASDF-Install/SBCL on Windows
- Running SBCL on Windows – this is again for Vista, with the newest (v1.0.16 and v1.0.17) versions of SBCL. It also includes configuring shell commands, etc.
Additional comments at comp.lang.lisp.