SLIME Tips
This page is for collecting tips for avoiding problems with and making the best use of SLIME, the Emacs-based Lisp development environment

  • No REPL by default: Slime no longer gives you a REPL by default, as you can use slime without a REPL. To specify that you want one (see file NEWS):
    (slime-setup '(slime-repl))
    
  • Connecting automatically: Making slime connect to your lisp automatically when you open a lisp file.
    (defun cliki:start-slime ()
      (unless (slime-connected-p)
        (save-excursion (slime))))

    (add-hook 'slime-mode-hook 'cliki:start-slime)

  • Multiple sessions: By using C-u M-x slime you are given the option of starting additional Lisp processes and connecting to them, resulting in multiple REPL buffers. The lisp-mode buffers will use the most recently opened connection, unless you cycle to another with M-x slime-cycle-connection
  • CLISP: When using SLIME with CLISP, be sure to invoke the Lisp process (using C-u M-x slime) as "clisp -K full" to include the full linking set. The default base linking set does not include the REGEXP module, upon which SLIME depends. Failure to use a linking set including the REGEXP module causes SLIME to complain about the missing REGEXP package.

    Alternatively, you can set inferior-lisp-program in your .emacs file to the correct executable and args:

    (setq inferior-lisp-program "clisp -K full")
    
  • FAIRLY-STABLE: Sometimes the current version of SLIME in CVS is broken. If your copy doesn't work, it's recommended that you update to the FAIRLY-STABLE CVS tag. The CVS incantation is:
    cvs update -r FAIRLY-STABLE .
    
    Generally speaking the FAIRLY-STABLE tag is set immediately before some dangerous changes are being made. Thus during periods of general stability it may be quite out-of-date and less featureful than the current version.
  • Cygwin: . Starting an inferior lisp in Windows NT Emacs and using Cygwin (e.g., starting the CLisp that comes with Cygwin) may produce errors of this sort:
    ...A file with name /c/cygwin/usr/share/emacs/site-lisp/slime/swank-loader does not exist...
    
    One easy fix is to mount the Windows volume under the Cygwin root:
    mkdir /c
    touch /c/NOT_MOUNTED
    mount C:\\ /c
    
  • Indentation: If your emacs indents Common Lisp code in Emacs Lisp style (i.e. "if" has the then-form and else-form in different columns), add something like this to your ~/.emacs:

    (add-hook 'lisp-mode-hook
              (defun my-lisp-mode-hook ()
                (set (make-local-variable 'lisp-indent-function)
                     'common-lisp-indent-function)))
    

    Alternatively, try adding the following in your ~/.emacs:

    (slime-setup)
    
  • Styled SLDB: If you're feeling artistic you can use M-x customize-group slime-debugger to make the debugger pretty.
  • CL-SDL: If you are experiencing nasty freezes and errors with CL-SDL OpenGL programs and Nvidia proprietary binary linux opengl drivers with SLIME on CMUCL, place (defparameter swank:*communication-style* :spawn) in ~/.swank.lisp to switch away from the :SIGIO SWANK communication method to avoid hairy signal handling problems.

  • Unicode: If pain results when you try entering nice Unicode symbols, try something like the following your .emacs:

    (set-language-environment "UTF-8")
    (setq slime-net-coding-system 'utf-8-unix)
    

    (This is taken from a blog entry, where he goes on to say: A Unicode aware Lisp implementation such as Clisp or SBCL and Emacs version 21.4 or greater. I won't go into setting those up here, but in Gentoo you'll need to be sure SBCL is emerged with the "unicode" USE flag, and Emacs with the "leim" use flag and some tweaking to the ebuild.)

  • Restoring clobbered user keybindings: In its default configuration, slime clobbers the keybinding C-c x which is supposed to be reserved for the user according to official guidelines. You can workaround this, by adding the following snippet to your .emacs file:
    (defun slime-sanitize-bindings ()
      "Removes SLIME's keybinding on C-c x"
      (cond ((boundp 'slime-mode-map)
             (define-key slime-mode-map (kbd "C-c x") nil)
             (message "slime keybinding C-c x has been sanitized"))
            ('t (message "slime keybindings not sanitized"))))
    (add-hook 'slime-mode-hook 'slime-sanitize-bindings)
    
  • Tramp connection to another computer: You can use tramp to edit lisp files on a remote server. When you tell slime to compile-and-load or go to definition slime will automatically translate the filename between the workstation and the lisp server. This is setup with the slime-create-filename-translator function. For an example of all you can do with this, see http://paste.lisp.org/display/17592


Can anyone say whether it's possible to use SLIME in conjunction with attachtty? In particular, I'm wanting to connect to a Linux box running CMUCL/detachtty from my Mac running OS X. attachtty from the command line works fine, but that's not terribly useful. :-) Trying to use SLIME just specifying inferior-lisp-mode as the attachtty command line results in numerous errors which appear to be from SLIME trying to load its files (locally in /Users/me/whatever) on the Linux box (obviously they aren't there).

Actually, you don't even need detachtty. But still I prefer to use it, so that I can attach back to it if something breaks even the swank server (e.g. entering the debugger). You have to add something like the following to your application:

(swank:create-server)

Then you can use SLIME's slime-connect command.