Installing CLISP, Emacs, and SLIME on Windows XP

May 16th, 2008 | by Peter |

Until this week, I had been putting off setting up a CL/Emacs/SLIME environment from scratch ever since I had trouble getting ASDF to work with Lispbox. Every time I tried, I ran into some will-sapping problem like needing to find a good Windows program for .tar.gz files, or finding the command line flags to get CLISP to run right, or figuring out the best way to setup a folder structure that matches the Unix folders used by most Lispers. Every time I fixed one problem, I ran into another. For someone out there trying to do a setup like this, there are lots of good resources, but they are either incomplete or outdated.

For instance, the Common Lisp Cookbook has a very thorough page on Setting Up an IDE with Emacs on Windows or Max OSX, but as far as I can tell, it’s from 2004 or earlier because it doesn’t mention SBCL or SLIME, two of the most popular pieces of CL development software today. Or when you run into a specific problem, it’s usually not too hard to find an answer, but it might not match the setup you’re using. That’s why I had to quit using Lispbox, because no one had any clue how it was configured, especially not on Windows. n00bs didn’t know the answers and the wizards had a traditional setup.

Here are some of the variables that contribute to the combinatorial explosion of configuration, in order or pain caused:

  • Operating system: Linux (many flavors), Mac, Windows, Cygwin
  • CL implementation: most common are SBCL, CMUCL, Allegro, LispWorks, CLISP
  • CL implementation version (I ran into a problem here)
  • SLIME version (stable 2.0 release or CVS snapshot)
  • Emacs version (I didn’t run across any problems with this)
  • I almost forgot, now there’s Cusp/Eclipse if you don’t want to use Emacs/SLIME, but right now Cusp is only tested on SBCL.

Maybe someday someone will try out all of those combinations and report, but for today, I did exactly one: Windows XP, CLISP 2.44, SLIME CVS, and Emacs 22.2 Why CLISP? After reading lots of internet, I came to the conclusion that (aside from the commercial CLs), CLISP is the best implementation for Windows users. The knocks against it are that it’s slow because it’s byte-code compiled, it doesn’t have threads, and on some points, it’s ideologically different from CL and other implementations.

Well, the performance isn’t a big concern for me (plus as I went to press, 2.45 was released with experimental JIT compilation), the threads also aren’t a big deal right now, and I think the differences will help me be aware of the considerations for writing portable code. Also regarding the SBCL windows port, it’s still considered experimental (currently v1.013 for Windows) but people are saying it’s stable and everything works except the threads. There’s even an msi installer for the Windows version. One of my next projects will be to dive into the SBCL documentation and mailing lists to get a better feel for it.

As far as the philosophy behind this (and future) setup guides, I want them to be a) thorough and b) instructive. Instructive? If you just want to take my word for everything, that’s fine, but I want you to know where I got my info from, so I’ve tried to include links to references for each step. On to the setup guide!

0. Files to Download

If you want to get started on downloading the setup files, here are the links:

1. Setup Directories

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:

  • [HOME]\[USR]\
  • [HOME]\[USR]\site\
  • [HOME]\[USR]\docs\
  • [HOME]\[USR]\lisp\
  • [HOME]\[USR]\info\
  • [HOME]\bin\

2. Setup Emacs

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 CLISP

This is easy if you download the install package (that’s the one I linked to). Run the installer and choose [HOME]\bin\clisp\ as the install directory. That’s it!

4. Setup SLIME

CLISP changed recently (around version 2.44 - not sure exactly) and broke compatibility with the SLIME 2.0 release. This was fixed in development and the CVS snapshot works. If you try to use the 2.0 release, you’ll get an error that looks like this:

INTERN(”FRAME-UP-1″): #<PACKAGE SYSTEM> is locked

So use the CVS snapshot (which I linked to) and you should be fine.

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, CLISP specific parameters), changing your pathnames as usual:

(setq inferior-lisp-program “[HOME]/bin/clisp/full/lisp.exe
-B [HOME]/bin/clisp/full
-M [HOME]/bin/clisp/full/lispinit.mem
-ansi -q”)
(add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/”)
(require ’slime)
(slime-setup)

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!

————————————–

I hope this works for you - I ran through it on another computer and it worked the first time, so if you use exactly these parts you should be OK. Please let me know if you run into problems so I can incorporate the fix into my doc. Many thanks to everyone who I linked to, since they did the coding, testing, and writeups that I used to get here. More resources to come - tell me what you’d like to see. If it’s something I was planning on doing anyway, I’ll move it up my queue.

The next guide will probably be setting up your built-in documentation (Hyperspec, etc).

  1. 22 Responses to “Installing CLISP, Emacs, and SLIME on Windows XP”

  2. By corporate drone on May 17, 2008 | Reply

    Excellent guide. Thanks! I believe that there are many who develop for Windows that would like to use Lisp for creating domain specific languages. If basic installation is too difficult people will just use an alternative that offers better platform support. There are now many functional alternatives to Lisp that fill the same space.

  3. By Peter on May 17, 2008 | Reply

    Thanks, drone. While this isn’t an easy install by Windows standards, it is debugged and predictable. I tried to be thorough enough that anyone could get through in on the first try.

  4. By #6 on May 17, 2008 | Reply

    Interesting article. Also, an astounding waste of time, like putting functioning arms and legs on a piece of dog feces. If you’re doing hardcore software development or computer science using CLISP, why would you ever do it on an XP machine? The mind boggles.

    A quicker method.

    Download and install VMware
    Download and install some unix on the VMware installation
    Install CLISP and SLIME and EMACS on the VMware unix. If you do this on Ubuntu, one command line will do this.

    But windows isn’t for serious tasks.

  5. By Peter on May 17, 2008 | Reply

    Thanks, troll. VMware is a good tip, one that I started to pursue but found to be a hassle. As much as you (and many of your species) dislike Windows, it has the big benefit that hundreds of millions of people know how to use it! Learning Lisp and Emacs is a challenge enough; having to learn *nix at the same time is too much to bother with.

    I wrote this for Windows because that’s where the people are.

  6. By Зарт on May 17, 2008 | Reply

    Patch:

    2,3c2,3
    < -B c:/[HOME]/bin/clisp/full
    -B [HOME]/bin/clisp/full
    > -M [HOME]/bin/clisp/full/lispinit.mem
    5c5
    (add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/”)

    , where “[HOME]” could be “c:/home”.

  7. By w-g on May 17, 2008 | Reply

    The 2.0 SLIME release is really ancient. Get the CVS version with the FAIRLY-STABLE tag:

    export CVSROOT=:pserver:anonymous@common-lisp.net:/project/slime/cvsroot

    cvs login

    _(The password is `anonymous’)_

    cvs checkout -rFAIRLY-STABLE slime

  8. By Зарт on May 17, 2008 | Reply

    2,3c2,3
    < -B c:/[HOME]/bin/clisp/full
    < -M c:/[HOME]/bin/clisp/full/lispinit.mem

    > -B [HOME]/bin/clisp/full
    > -M [HOME]/bin/clisp/full/lispinit.mem
    5c5
    < (add-to-list ‘load-path “[HOME]/emacs/site-lisp/slime/”)

    > (add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/”)

  9. By jon on May 18, 2008 | Reply

    Use clbuild

  10. By Dave on May 19, 2008 | Reply

    Thanks for this - I had only just started to look for information on how to get SLIME working properly on Windows when I found your post right at the top of comp.lang.lisp - you have saved me much googling and frustration! Good lisp implementations on Windows are few and far between unless you’re prepared to pay through the nose for one of the commercial versions, so it’s great to have this information out there.

    And #6 - excellent trolling. Suggesting the installation of a entire operating system just to get one application running made me smile.

  11. By Joe on May 29, 2008 | Reply

    Thank you very much for your excellent guide! I’ve been trying to get Emacs, CLisp and Slime to work together under Windows (not using LispBox) for some time now — with mounting frustration. Your explanation was crystal clear, and most importantly, it worked the first time.

    And like Dave, I too thought #6’s suggestion was entertaining. You are right: Windows is where the people are.

  12. By Alex on May 29, 2008 | Reply

    Excellent! I’ve been stuck for ages by the incompatibility issue between CLISP 2.45 and Slime. Thanks!

  13. By fincomus on Jun 4, 2008 | Reply

    Thanks a lot. Very helpfull.

  14. By waterbreath on Jun 6, 2008 | Reply

    I searched my brains out for something like this about a year ago.

    (BTW “will-sapping” is a great term for this kind of masochistic activity that I always seem to have to slog through when I deal with F/OSS software. I really wish this weren’t the case, but it’s the simple truth.)

    The pain and suffering I endured in trying to get this suite of tools (although with CLISP instead of SBCL) set up and stable in Windows XP is exactly what turned me off of actually following through in my quest to learn and start using LISP. The real stinger is that I actually managed to get it all working smoothly, but by the time I did, I just had no motivation left to actually sink my teeth into the language itself…. And so it all sits installed yet ignored.

    At any rate, thanks so much for the guide. I honestly hope to use it someday. But even if I never do, please appreciate my heartfelt thanks on behalf of all the people who really shouldn’t have to suffer through what I did.

    If LISP ever begins to descend from its snob-status and actually approach the mainstream, it will be people like you that will make it happen.

  15. By Peter on Jun 6, 2008 | Reply

    waterbreath - I’m glad you like it and I’m sorry I didn’t get it to you a year ago! One nice thing about F/OSS is that it does tend to get easier to setup, you just have to either be a year behind on versions or stick to very mature products.

    Also, you should keep writing your blog! I loved the piece on Identity Crisis in Computer Science Education and some of the other ones I looked at were good as well. Lots of people are having a similar identity crisis about their career and education (myself included) and prospective students and programmers could use the kind of well thought out, articulate arguments that you’ve demonstrated you can write.

    Everyone Else: Go read waterbreath’s blog at Turbulent Intellect, read his good stuff, comment on it, and encourage him to write more!

  16. By allen on Jun 6, 2008 | Reply

    Great job!thank u!
    I follow your post,and it works.But there is still a problem,i can’t load slime-scratch buffer!
    After entering M-x slime-scratch ,emacs says no match ,and nothing happens. I don’t know why.

  17. By grg on Jun 25, 2008 | Reply

    Sorry for the noob question, but I get this message in the mini-buffer when I enter ‘M-x slime’: “Searching for program: no such file or directory, lisp”

    I’m certain it’s a case of user error, probably with the syntax.

    Question 1: in add-to-list, is it `load-path or ‘load-path (back tic or apostrophe)?

    Question 2: same thing in require for `slime/’slime

    Question 3: Can I use “~/bin/…” instead of “C:\Document and Settings\[USERNAME]\…”? I’ve tried it both ways with the same result.

  18. By Peter on Jun 25, 2008 | Reply

    grg: for 1&2, those are apostrophes, not back quotes. Back quotes are used in CL for list construction, usually in macros, while apostrophes are used very often for symbol names (that is in both CL and Emacs Lisp).

    As far as the directories, I’ve found only pain when using the Windows default directories. Setting [HOME] as C:\home and following the directory layout in Step 1 is worth the extra effort.

    Good luck!

  19. By grg on Jun 25, 2008 | Reply

    Thanks, Peter. I’ll try switching it to “c:\home” I’d prefer that, as I’m more accustomed to ‘nix environments, though like many/most people I have to use Windows at work.

    I was just trying to “let Windows be Windows” and use the default home directory. I guess I could always just try to set it up in under cygwin if Windows keeps being difficult.

    Thanks, again. I appreciate it.

  20. By Peter on Jun 26, 2008 | Reply

    grg: Letting Windows be Windows is usually a good idea since it fights back if you try to corner it. Sometimes you have to put your foot down though.

    I heard lots of horror stories about using Cygwin versions of Emacs and CLisp together, and I just didn’t want to deal with it. The web was silent about native Emacs and CLisp, so I decided to try out and found it wasn’t too bad at all.

  21. By Bruce Lambert on Jun 26, 2008 | Reply

    Peter,

    Many thanks for this very useful and well-put-together page. I have installed emacs+slime+clisp many times, and each time it is a time consuming adventure. Like yo uI oftne put it off until I absolutely have to do it. Your page made it much easier this time around. Again thanks.

    -bruce

  1. 2 Trackback(s)

  2. May 25, 2008: Setting Up and Using Emacs InfoMode » What’s In Peter’s Head
  3. May 30, 2008: Installing SBCL, Emacs, and SLIME on Windows XP » What’s In Peter’s Head

Post a Comment