A “presentation”6 in SLIME is a region of text associated with a Lisp object. Right-clicking on the text brings up a menu with operations for the particular object. Some operations, like inspecting, are available for all objects, but the object may also have specialized operations. For instance, pathnames have a dired operation.
More importantly, it is possible to cut and paste presentations (i.e., Lisp objects, not just their printed presentation), using all standard Emacs commands. This way it is possible to cut and paste the results of previous computations in the REPL. This is of particular importance for unreadable objects.
slime-presentations installs presentations in the
REPL, i.e. the results of evaluation commands become presentations. In
this way, presentations generalize the use of the standard Common Lisp
REPL history variables
CL-USER> (find-class 'standard-class) #<STANDARD-CLASS STANDARD-CLASS> CL-USER>
Presentations appear in red color in the buffer. (In this manual, we indicate the presentations like this.) Using standard Emacs commands, the presentation can be copied to a new input in the REPL:
CL-USER> (eql '#<STANDARD-CLASS STANDARD-CLASS> '#<STANDARD-CLASS STANDARD-CLASS>) T
Note that standard evaluation and quoting rules still apply. So if a presentation is a list, it needs to be quoted in an evaluated context to avoid treating it as a function call:
CL-USER> (list (find-class 'standard-class) 2 3 4) (#<STANDARD-CLASS STANDARD-CLASS> 2 3 4) CL-USER> (#<STANDARD-CLASS STANDARD-CLASS> 2 3 4) ; Funcall of #<STANDARD-CLASS STANDARD-CLASS> which is a non-function. ; Evaluation aborted. CL-USER> '(#<STANDARD-CLASS STANDARD-CLASS> 2 3 4) (#<STANDARD-CLASS STANDARD-CLASS> 2 3 4)
When you copy an incomplete presentation or edit the text within a presentation, the presentation changes to plain text, losing the association with a Lisp object. In the buffer, this is indicated by changing the color of the text from red to black. This can be undone.
Presentations are also available in the inspector (all inspectable parts
are presentations) and the debugger (all local variables are
presentations). This makes it possible to evaluate expressions in the
REPL using objects that appear in local variables of some active
debugger frame; this can be more convenient than using
sldb-eval-in-frame. Warning: The presentations that stem from
the inspector and debugger are only valid as long as the corresponding
buffers are open. Using them later can cause errors or confusing
For some Lisp implementations you can also install the package
slime-presentation-streams, which enables presentations on the
*standard-output* stream and similar streams. This means
that not only results
of computations, but also some objects that are printed to the standard
output (as a side-effect of the computation) are associated with
presentations. Currently, all unreadable objects
and pathnames get printed as presentations.
CL-USER> (describe (find-class 'standard-object)) #<STANDARD-CLASS STANDARD-OBJECT> is an instance of #<STANDARD-CLASS STANDARD-CLASS>: The following slots have :INSTANCE allocation: PLIST NIL FLAGS 1 DIRECT-METHODS ((#<STANDARD-METHOD SWANK::ALL-SLOTS-FOR-INSPECTOR (STANDARD-OBJECT T)> ...
Again, this makes it possible to inspect and copy-paste these objects.
In addition to the standard Emacs commands, there are several keyboard commands, a menu-bar menu, and a context menu to operate on presentations. We describe the keyboard commands below; they are also shown in the menu-bar menu.
If point is within a presentation, move point to the beginning of the presentation and mark to the end of the presentation. This makes it possible to copy the presentation.
If point is within a presentation, copy the surrounding presentation to the kill ring.
If point is within a presentation, copy the surrounding presentation to the REPL.
If point is within a presentation, describe the associated object.
If point is within a presentation, inspect the associated object with the SLIME inspector.
Move point to the next presentation in the buffer.
Move point to the previous presentation in the buffer.
Similar operations are also possible from the context menu of every
presentation. Using mouse-3 on a presentation, the context menu
opens and offers various commands. For some objects, specialized
commands are also offered. Users can define additional specialized
commands by defining a method for
Warning: On Lisp implementations without weak hash tables,
all objects associated with presentations are protected from garbage
collection. If your Lisp image grows too large because of that,
use C-c C-v M-o (
slime-clear-presentations) to remove these
associations. You can also use the command C-c M-o
slime-repl-clear-buffer), which both clears the REPL buffer and
removes all associations of objects with presentations.
Warning: Presentations can confuse new users.
CL-USER> (cons 1 2) (1 . 2) CL-USER> (eq '(1 . 2) '(1 . 2)) T
One could have expected
NIL here, because it looks like two
fresh cons cells are compared regarding object identity.
However, in the example the presentation
(1 . 2) was copied twice
to the REPL. Thus
EQ is really invoked with the same object,
namely the cons cell that was returned by the first form entered in the
Presentations are a feature originating
from the Lisp machines. It was possible to define
methods specialized to various devices, e.g. to draw an object to
bitmapped screen or to write some text to a character stream.