SLIME Features
This is an evolving description of the features available in SLIME. This screenshot (follow link for larger image) shows a visual overview. We'll refer to it in the detailed descriptions:


SLIME Screenshot on OSX

In standard good community spirit, everyone is invited to make corrections and improvements to the text below. When the rate of change dies down a little this page will be converted into a texinfo manual.

Read-Eval-Print-Loop (REPL)

The SLIME Read-Eval-Print-Loop pops up in a buffer called *slime-repl* as soon as Emacs connects to Lisp. The REPL buffer is like the traditional *inferior-lisp* buffer, but with tighter integration between Emacs and Lisp. Parts of the top-level are written in Emacs Lisp, so Emacs always knows where the prompt is and it can tell the difference between return values and printed output. The REPL also uses the SLIME debugger automatically.

You can see the REPL in the top-right quarter of the screenshot (below the debugger). Note that separate pretty colours are used for the prompt, user input, printed output, and the results of expressions you enter.

The *slime-repl* buffer has most of the slime-mode keybindings, plus these additional ones:

  • Return - Either sends the current line to Lisp for evaluation or, if the line isn't complete (unmatched parens), open and indent a new line.
  • Control-Return - Close any unmatched parenthesis and then send the current line to Lisp for evaluation.
  • C-c C-c - Interrupt the Lisp process with SIGINT. This typically signals a condition and pops you into the SLIME debugger. It does not appear to work reliably with multithreaded Lisps due to signaling ambiguity.
  • TAB - Complete the Lisp symbol at point.

Debugger

SLIME has its own custom Emacs-integrated debugger. Any time Lisp is evaluating a request for Emacs the *DEBUGGER-HOOK* is bound such that the Emacs debugger will be used for any errors. When the debugger is triggered an Emacs buffer pops up saying what the error is, which restarts are available, and displaying a part of the backtrace. You can see the debugger in the top-right corner of the screenshot above.

Initially only a single line from the backtrace is shown. You can fetch more blocks of frames just by moving the point down onto --more-- at the end of the buffer.

The debugger remains active until a restart provokes it to return. However, it is possible to use regular SLIME commands from inside the debugger, and any errors in these commands will cause the debugger to be entered recursively.

The following commands invoke restarts:

  • 0 .. 9 - Invoke a restart by number.
  • q - Throw to the top-level.
  • a - Invoke the ABORT restart.
  • c - Invoke the CONTINUE restart.

There are also commands for poking around in the frame at point:

  • v - Show the current frame's source expression in a buffer.
  • t - Toggle verbose display of the frame at point. The verbose version includes all local variables and CATCH tags.
  • l - Show local variables.
  • e - Evaluate an expression from inside a frame.
  • d - Evaluate an expression and display the result in an extra buffer.
  • i - Evaluate an expression and inspect the result.
  • : - Evaluate an expression (in the global environment).
  • D - Disassemble the code of the current frame.
  • r - Restart execution of the frame with the same arguments as it was called originally. (Not supported by all backends.)
  • R - Return a value from the current frame. (Not supported by all backends.)

Motion between frames:

  • n - Move to the next frame.
  • p - Move to the previous frame.
  • M-n - Detail-move to the next frame. This switches the current frame to a one-line summary, then moves to the next frame, displays it verbosely in the backtrace (as with t), and shows the corresponding source expression (as with v).
  • M-p - Detail-move to the previous frame.

Edit Definition

Many Lisps save the source location for functions. SLIME uses this information to find the definition of a specific symbol. You don't need to maintain a separate "tags table" for this feature.

M-.
Jump to the definition of the symbol at point.
M-,
Jump back from a function definition.

SLIME pushes the current position to a stack before jumping to the definition. M-, pops the top element of this stack and jumps to the saved position.

It is recommended that you install the source code of your implementation (you can learn many tricks by reading the source). For CMUCL you should set the target search list in your .cmucl-init.lisp to tell CMUCL where you installed the source, e.g.:

(setf (search-list "target:") '("/opt/cmucl/src/"))

For SBCL you should define the corresponding logical pathname translations, e.g.:

(setf (logical-pathname-translations "SYS") '(("SYS:SRC;**;*.*.*" #P"/opt/sbcl/src/**/*.*") ("SYS:CONTRIB;**;*.*.*" #P"/opt/sbcl/contrib/**/*.*")))

Documentation

SLIME, like ILISP, has a version of Erik Naggum's Common Lisp Hyperspec access package. Out of box, it points to an online version of the HyperSpec. If for some reason you wish to use a locally downloaded copy of the HyperSpec, you can. Place in your .emacs: (setq common-lisp-hyperspec-root "file:/usr/local/lisp/CLHS6/HyperSpec/") replacing the local file URL with the appropriate local file URL of the downloaded and uncompressed HyperSpec for your system. [The package now picks up Map_Sym.txt location automatically, AFAIK?]

[strictly speaking, a wider emacs feature] You may or may not like the built in emacs web browser. If you wish to use an alternative one to read the HyperSpec, then the emacs customisation setting "Browse Url Browser Function" lets you pick which browser to open.

Compilation

SLIME provides commands for compiling files, definitions, buffers, regions, and systems. When compiling files and systems the compiled code is stored in fasl files on disk. When compiling definitions, buffers, or regions the code is only kept in memory and not written to files.

C-c C-c
Compile the current toplevel form.
M-x slime-compile-region
Compile the region.
C-c C-k
Compile the current buffer's file and load the resulting fasl file. The fasl file is only loaded if the compilation was successful.
C-c M-k
Compile (but not load) the current buffer's file.
C-c C-l
Load buffer's file.
M-x slime-load-system
Ask for the name of a system, compile the modified files and load the system.

Compiler Warnings Commands

SLIME collects the warnings generated by the compiler and provides commands to find the corresponding source location and to display the compiler messages. SLIME annotates the source code corresponding to warnings with mouse sensitive overlays. The message for the overlay is displayed in the minibuffer when the mouse pointer is above the overlay.

M-n
Go to and describe the next compiler warning in the buffer.
M-p
Goto the previous form with a compiler note.
M-x slime-list-compiler-notes
Display all compiler warnings of the last compilation in a separate buffer. The warnings in this buffer are clickable and pressing RET highlights the corresponding source form.

Evaluation

Evaluation commands are useful for testing small parts of Lisp programs, without the need to type them into the REPL.

C-c :
Read a single Lisp expression in the minibuffer, evaluate it, and print the value in the echo area (slime-interactive-eval).
C-x C-e
Evaluate the Lisp expression before point, and print the value in the echo area (slime-eval-last-sexp').
C-M-x
Evaluate the toplevel form containing or after point, and print the value in the echo area (slime-eval-defun).
C-c C-p
Evaluate the Lisp expression before point, and pretty-print the value(s) into a new display buffer (slime-pprint-eval-last-expression).
M-x slime-eval-region
Evaluate all the Lisp expressions in the region.
M-x slime-eval-buffer
Evaluate all the Lisp expressions in the buffer.
C-x M-e
Evaluate the Lisp expression before point, print the value in the echo area and display the output buffer (slime-eval-last-expression-display-output).
C-c C-u
Remove the function binding for the symbol at point (slime-undefine-function).

C-c : is the most basic command for evaluating a Lisp expression interactively. Emacs reads the expression as string from the minibuffer and sends it together with the value of slime-buffer-package (the Lisp package associated with the current buffer) to Lisp. Lisp reads the string in the package, evaluates the form and sends the printed result as string back to Emacs and Emacs displays the result in the echo area.

slime-buffer-package is a buffer local variable and contains the name found in the nearest in-package form. If the buffer contains no in-package form, Lisp uses the current package (*package*).

The C-x C-e and C-M-x commands are similar to C-c :, but don't read the expression from the minibuffer. C-x C-e uses the sexp before point and C-M-x the toplevel form after or around point. A toplevel form is a sexp with the opening paren in the first column.

Defvar Hack: C-M-x treats forms starting with defvar specially. The variable is reset, if it is already bound. So C-M-x turns a defvar effectively into a defparameter. C-x C-e does not treat defvar specially.

Tip: slime-complete-symbol can be used to complete the symbol around point. It is bound to M-TAB in Lisp buffers and to TAB in the minibuffer.

Inspector

slime-mode keybindings overview

Here is the summary of keybindings in slime-mode offered by C-h m (describe-mode). A sensible subset of these commands is also available in the *slime-repl* buffer.

SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode).

Commands to compile the current buffer's source file and visually
highlight any resulting compiler notes and warnings:
C-c C-k	- Compile and load the current buffer's file.
C-c M-k	- Compile (but not load) the current buffer's file.
C-c C-c	- Compile the top-level form at point.

Commands for visiting compiler notes:
M-n	- Goto the next form with a compiler note.
M-p	- Goto the previous form with a compiler note.
C-c M-c	- Remove compiler-note annotations in buffer.

Finding definitions:
M-.	- Edit the definition of the function called at point.
M-,	- Pop the definition stack to go back from a definition.

Programming aids:
C-c TAB	- Complete the Lisp symbol at point. (Also M-TAB.)
C-c RET	- Macroexpand once.
C-c M-m	- Macroexpand all.

Cross-referencing (see CMUCL manual):
C-c C-w c	- WHO-CALLS a function.
C-c C-w r	- WHO-REFERENCES a global variable.
C-c C-w s	- WHO-SETS a global variable.
C-c C-w b	- WHO-BINDS a global variable.
C-c C-w m	- WHO-MACROEXPANDS a macro.
C-M-.		- Goto the next reference source location. (Also C-c C-SPC)

Documentation commands:
C-c C-d	- Describe symbol.
C-c C-a	- Apropos search.
C-c M-d	- Disassemble a function.

Evaluation commands:
C-M-x	- Evaluate top-level from containing point.
C-x C-e	- Evaluate sexp before point.
C-c C-p	- Evaluate sexp before point, pretty-print result.

Documentation