Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start programming with SLIME and Steel Bank Common Lisp on Windows 7 x64?

I'd very much like to start using these tools, but it seems I'm not smart enough :-(

I've spent hours reading docs, moving folders around and editing config files, but I still cannot start Emacs ...

like image 286
user1563526 Avatar asked Dec 20 '22 17:12

user1563526


1 Answers

Although it took quite some time to figure everything out, I was able to successfully install Steel Bank Common Lisp (SBCL), GNU Emacs, and SLIME onto a Windows 7 64-bit system. Here are the steps I took:

  1. Install Steel Bank Common Lisp. I downloaded it from the SBCL site by clicking the box which intersects "Windows" and "AMD64." It should take you to a Sourceforge page which automatically starts downloading the link. This should download the binary.msi file and not the tar.gx file. (I've learned the hard way that tar.gz files are a pain to deal with on a Windows system.) After downloading the file, clicking it should start an install wizard which should take you through the installation process step-by-step.

    At the time of writing, the SBCL version for 64-bit Windows is 1.1.17, and according to the SBCL website it is a port in progress instead of being fully supported. If you prefer, I imagine you could also download the more stable 1.1.12 version for 32-bit Windows by clicking the box to the left; however, I have yet to run into any serious problems using the 1.1.17 64-bit version of SBCL.

  2. Install GNU Emacs. This can be downloaded from the Emacs mirror site. (I was going to link it for you, but I am limited to posting only two links and I need to save a link for later.) Click the tar.xz file (not the tar.gz file) for the most recent version of Emacs, which will then download a zip file to your computer; at the time of writing, the most recent Emacs version is 24.3. Once downloaded, open the files with WinZip or a similar program and extract the entire contents of the zip file into a folder of your choice on your computer (preferably one that is fairly close path-wise to the C drive and someplace easy for you to remember). You can extract files in WinZip by clicking the "extract" button at the very top of the program; this should create a new folder on your computer with all the individual Emacs files contained inside of it. (Make sure you don't have any individual files selected while clicking the extract button, since WinZip will only extract the file you've selected in that particular case.) Once the files have been extracted, simply click the runemacs.exe file in the bin folder (or the emacs.exe file if you prefer to use the console instead of a GUI) and the program should successfully install.

    Before extracting the entire zip file, it may be beneficial to read the README and README.W32 files contained in the zip download to glean more information, but Emacs should install successfully if the steps above are followed closely. After installation, it will help you greatly to go through the Emacs tutorial included with the program. You can either click the tutorial link that is presented when you first open Emacs, or you can hit [Control-h] then [t] while in Emacs to load the tutorial.

  3. Install SLIME. SLIME can be downloaded from its GitHub page, or you can click the "latest release" link at the main SLIME site; at the time of writing, the latest SLIME release is version 2.5. Again, be sure to click the source code zip button instead of the tar.gz button. Similar to installing Emacs, this will download a zip file, and you can then use WinZip to extract the entire contents of the file to a location of your choice on your computer. However, this time, make sure to extract SLIME into a path location* that does not contain folders with spaces in their name (that is, do not extract SLIME to "C:\Program Files" or "C:\Shared Folder\Programs" or something similar). This will become important in the next step, when we configure Emacs to run SLIME.

    *A path location is simply the list of folders you have to go through to get to a program. For example, a document on your computer may have the path "C:\Users\YourName\MyDocuments\document-title.doc". When choosing a location for SLIME, in addition to avoiding folders with spaces in the name, try to install SLIME to a folder fairly close to the C drive, since you'll have to remember and write out the path location for SLIME in the next step.

  4. Setup SLIME in Emacs. At this point, you should have all the necessary programs successfully installed on your computer. The last step, which tends to be the hardest, is modifying your .emacs file so you can use SLIME with Emacs. (This page explains how to manipulate the .emacs file exceptionally well and also contains generally useful information you'll want to know if you plan on using Emacs on a regular basis.) You can find/create the .emacs file by running Emacs and hitting [Control-x] followed by [Control-f]. This should open a find file command in the bottom buffer; after the colon, type "~/.emacs" (without the quotes), press return/enter, and it should open your .emacs file. At this point, copy the exact text from below into your .emacs file word for word:

    (add-to-list 'load-path "C:\\wherever-you-installed-SLIME\\slime-2.5")
    (require 'slime)
    (add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
    (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
    (setq inferior-lisp-program "sbcl")

    Replace "C:\\wherever-you-installed-SLIME\\slime-2.5" with whatever path location and name you have for your SLIME folder.

    When you are done writing this into the .emacs file, save the file by either using the File-Save options from the menu or by hitting [Control-x] followed by [Control-s]. If a save-as prompt comes up, be sure to name the file .emacs and save it under "C:\Users\YourName\AppData\Roaming\.emacs". (At least, this is where my Windows 7 system automatically saves the .emacs file. If your computer saves it somewhere else, you can search the C drive for the location of the .emacs file if necessary.) Make sure there is only one instance of the .emacs file; if there are multiple copies of the .emacs file, the Emacs program will not necessarily recognize the configuration you just set up.

    Once you have saved the .emacs file with the above code written in it, close out the Emacs program and re-open it. Once reopened, type [Alt-x] followed by [slime] (it will appear as "M-x slime" at the bottom) and hit enter/return. Voila: Emacs should be running SLIME at this point. Congrats, you just installed Emacs with SLIME running SBCL on a Windows 64-bit system!

    Remember when I said not to choose any folders with spaces in the name when extracting SLIME? It has to do with this step; if you choose a folder with a space (such as C:\\Program Files\\slime-2.5), the .emacs file will view it as "C:\\Program" with "Files\\slime-2.5" interpreted as additional information instead of the whole path location. If for some reason you had to extract the SLIME zip file to a folder with a space in the name, there are ways around this issue, but it unnecessarily complicates the process; I find it easiest simply to avoid spaces in the SLIME path location. Also be sure to use double backslashes instead of single backslashes when writing out the path location in the .emacs file, or you will run into problems. (I learned this the hard way.)

If you have any remaining questions, feel free to send me a message via email.

like image 168
dubosec Avatar answered Dec 27 '22 10:12

dubosec