Up and running with Emacs, sbcl, and SLIME

While I normally program in Python, a part of me wants to quickly hack some lisp code every now and then. Especially during those long minutes when my automated tests are running.

I realized that long neglect had left me without a working lisp setup. Here is how I got it up and running again.

Step 1: Get rid of system lisp and slime

The version of sbcl and SLIME in my Ubuntu system is not recent enough for my liking. So I get rid of them:

$ sudo apt-get -y remove sbcl slime common-lisp-controller
$ sudo apt-get -y autoremove # get rid of packages we don't need anymore
$ sudo rm -rf /var/cache/common-lisp-controller

Step 2: Install common requirements

cd ~/
sudo apt-get update
sudo apt-get -y install emacs22
sudo apt-get -y install cvs
sudo apt-get -y install git-core
sudo apt-get -y install darcs
sudo apt-get -y install subversion
sudo apt-get -y install build-essential
sudo apt-get -y install autoconf
sudo apt-get -y install curl
sudo apt-get -y install sbcl
sudo apt-get -y install texinfo
sudo apt-get -y install tetex-bin
sudo apt-get -y install xloadimage

Step 3: Get clbuild

$ mkdir lisp
$ cd lisp
# for fresh install of clbuild
$ darcs get http://common-lisp.net/project/clbuild/clbuild
$ cd clbuild
# Or, to update existing clbuild
$ cd clbuild
$ darcs pull

Step 4: Get latest SBCL

$ ./clbuild update sbcl
$ cd source/sbcl
$ sh make.sh
$ cd doc/manual
$ make
$ cd ../..
$ echo > ~/.sbclrc
(require :asdf)
(push "/home/parijat/lisp/clbuild/systems/" asdf:*central-registry*)

Step 5: Setup SLIME

$ ./clbuild update slime

Now, we need to add this slime configuration to our .emacs file:

(push "/home/parijat/lisp/clbuild/source/slime" load-path)
;; Common Lisp Mode
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'auto-mode-alist '("\\.lisp$" . lisp-mode))
(add-to-list 'auto-mode-alist '("\\.cl$" . lisp-mode))
(add-to-list 'auto-mode-alist '("\\.asd$" . lisp-mode))
(require 'slime)
(eval-after-load "slime"
    (setq slime-complete-symbol*-fancy t
          slime-complete-symbol-function 'slime-fuzzy-complete-symbol
          slime-when-complete-filename-expand t
          slime-truncate-lines nil
          slime-autodoc-use-multiline-p t)
    (slime-setup '(slime-fancy slime-asdf))
    (define-key slime-repl-mode-map (kbd "C-c ;")
    (define-key slime-repl-mode-map (kbd "C-c M-;")
    (define-key slime-mode-map (kbd "C-c ;")
    (define-key slime-mode-map (kbd "C-c M-;")
    (define-key slime-mode-map (kbd "RET") 'newline-and-indent)
    (define-key slime-mode-map (kbd "C-j") 'newline)))
(add-hook 'lisp-mode-hook (lambda ()
                           (cond ((not (featurep 'slime))
                                  (require 'slime)
                           (indent-tabs-mode nil)
                           (pair-mode t)))

Note: pair-mode is a nice package for inserting balanced parentheses, quotes, braces and square-brackets, etc., which I installed earlier by hand.

Now we can launch emacs, and start slime with “M-x slime”.


For some reason, after doing the above, slime would still not start. Doing a “M-x slime” would throw me into the sbcl debugger with the error message that sbcl could not find “/usr/share/common-lisp/systems/slime/swank-loader.lisp”, or something like that (I could be wrong about the exact path). After much head-scratching (and grepping my ~/lisp directory), I figured out I had to change the emacs customization variable slime-backend. This can be done by doing “M-x customize-group RET slime-lisp RET” and changing the value of “Slime Backend” to simply “swank-loader.lisp” (the file should be in the same directory as “slime.el”). We can also give an absolute path to the file. I found that the value of this variable was set wrongly (an artifact of using apt-get installed slime, I guess) and hence sbcl was not able to load the correct file.

Post a comment or leave a trackback: Trackback URL.


  • Steve Knight  On November 14, 2008 at 4:56 pm

    Useful, thanks. I’ve recently decided to move closer to the head, so to speak and was looking for this info.

    By-the-way, your step 1 removes sbcl but step 2 adds it back again. Therefore you don’t really need to do step 1!! It turns out that you can’t build SBCL without already having a lisp installed so perhaps step 1 should be step 6?

  • Phil  On November 18, 2008 at 6:11 pm

    I get the following when i run sh make.sh…

    //building cross-compiler, and doing first genesis
    make-host-1.sh: 31: sbcl: not found
    Command exited with non-zero status 1

  • Phil  On November 18, 2008 at 7:07 pm

    For some reason SBCL dit not install with apt-get -y install…it downloaded the packages but the actual install seemed not to have happened..i re ran apt-get install sbcl and it just unpacked and installed ok. Then I used “clbuild compile-implementation sbcl” instead of make. According to the guys at lisp.irc its the better way.

    Thought I would just share it with you.

  • Jim  On March 16, 2009 at 2:40 pm

    Thanks for this! I had the exact same problem with an incorrect path to swank-loader.lisp in emacs… After much head-scratching and googling, you saved the day.

  • devendra  On December 20, 2009 at 10:40 pm

    there is no .emacs file in my ~/ and when I create one. emacs directly starts from slime . there is no need to do M-x slime. How can I use it by M-x ?

    • parijatmishra  On December 21, 2009 at 10:58 am

      Your .emacs should have:

      (require 'slime)

      but NOT (IIRC):


      When you call ‘M-x slime’, it calls ‘slime-start’. Unfortunately, I don’t have a working setup right now to verify.


  • By Recent Links Tagged With "texinfo" - JabberTags on January 5, 2009 at 5:49 am

    […] public links >> texinfo Up and running with Emacs, sbcl, and SLIME Saved by olaparent on Sun 21-12-2008 New GNU stuff April 2008 Saved by jorgejiro on Sat […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: