Peter Christensen

  • Presentations
  • Contact Me

Reference for the SLIME/Lisp/Emacs Screencast

February 8, 2008 by Peter 17 Comments

Following up on my transcript/review of the UCW “Hello World” screencast, here is my review of Marco Barringer’s SLIME movie. (Description, 150MB .mov, Torrent, watch online). This screencast was more difficult to annotate because:

  1. It was almost 3x as long (55 min vs. 20)
  2. It covered more topics (Linux, Emacs, Lisp, SLIME)

I did find it much more interesting though because it showed off a lot of the cool features in those topics, whereas the UCW screencast was mostly just instructional. Also, I don’t know if I’ll ever use UCW for an app, but I’m already using the LELS stack and plan on using it for a long time to come.

(See what other people have said about it)

Looking back at my UCW reference, I think the format worked for that screencast because it was mostly just straight Lisp code. In the SLIME movie, the Lisp code is the least useful part – it’s just the vehicle for showing off the tools. So there’s a mix of Linux commands (unfortunately omitted because WordPress or Apache or somebody thinks they’re a security problem), Emacs key chords, Emacs Lisp code, and Common Lisp code. I’m leaving out most of the Common Lisp code for the morse code translator to focus on what’s more relevant. Also, I added links to documentation for the features shown. Hopefully this will make it easier to watch the movie and get straight to work on your own projects!


NOTE: In places where a file path is shown, I replaced directories specific to Marco’s user account with “[user]”. You can replace this with your own user-specific path.

Contents:

  • Setting up SLIME, Emacs
  • Working in SLIME
  • Using the SLIME debugger (sldb)
  • Emacs tools for writing Lisp code
  • More debugger demonstration
  • Asdf-install

SETTING UP SLIME, EMACS

0:15 Architecture: SLIME is two parts. An Emacs mode to handle commands, the debugger, all IDE modes, etc, and Swank, a server program that runs in the Lisp environment. Emacs connects with Swank over a typical IP/port protocol, so it can connect to a local or remote Lisp instance. This demo will show connection to a remote Lisp instance (SBCL, in this demo).

NOTE: Robert Goldman points out that this setup is a little dated, and the current setup is simpler. See the links in this comment.

0:25 Recommendation to always work with the latest build of SLIME from CVS. NOTE: This movie was made several years ago – is this still a valid recommendation or is SLIME stable enough to just use the released version without any worries?

EDIT: vanekl from c.l.l says you also need to add this to your .emacs file:

(slime-setup '(slime-fancy slime-asdf))

1:03 Setting up SBCL to be able to load Swank

1:37 Edit (or create) the SBCL initialization file. (The directory he used was /home/[user]/.sbclrc ) Add the following code:

(require :asdf)(push "/home/[user]/systems/" asdf:*central-registry*)

2:53 Create a /home/[user]/systems/ folder and create a link to /home/[user]/slime/swank.asd in that folder

3:08 In the SBCL prompt, load Swank by typing

(asdf:oos 'asdf:load-op :swank) ;oos = operate on system

3:23 Use a secure shell to create a communication link for Slime and the remote Swank process

3:56 Swank will attempt to use second stream for output. This makes things faster and helps avoid odd hangups. It is off for the demo to avoid having an extra port open. To disable it, enter the following in the SBCL prompt:

(setf swank:*use-dedicated-output-stream* nil)

4:37 To start the Swank server, enter this at the SBCL prompt:

(swank:create-swank-server)

EDIT: this command was deprecated in 2006. The new command is:

(swank:create-server)

4:48 Configure your local emacs by creating a slime.el file. This should go in the directory below your .emacs file. For Marco, it was:

~/.emacs.d/mb:slime.el

4:59 Selected contents of Marco’s slime.el file, with comments related to each setting. (Marco’s full slime.el file and his Highly Opinionated Guide to Editing Lisp Code with Emacs including more about his key bindings)

;need to run same version of slime on both machines
(add-to-list 'load-path "/Users/[user]/lisp/slime/") ; local directory, where does emacs find slime
(require 'slime);tell emacs to enter slime mode when editing a lisp file
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))

(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))

(setq inferior-lisp-program "/Users/[user]/bin/[openmcl/sbcl/?]" ;what to run if slime is local

     lisp-indent-function 'common-lisp-indent-function ;as opposed to elisp indentation

     slime-compile-symbol-function 'slime-fuzzy-complete-symbol ;other options - see documentation

     common-lisp-hyperspec-root "file:///Users/[user]/lisp/HyperSpec/" ;

     slime-startup-animation nil)

;translates from emacs buffer to filename on remote machine

(setf slime-translate-to-lisp-filename-function

          (lambda (file-name)
               (subseq file-name (length "/ssh:[userid]:")))

     slime-translate-from-lisp-filename-function

          (lambda (file-name)

               (concat "/[userid]:" file-name)))

7:10 In Emacs, start SLIME and connect to remote Lisp by entering the following key chord:

M-x slime-connect

Enter the IP address and port number and you will then be connected to remote REPL

EDIT: To connect to a local lisp instance, use:

M-x slime

WORKING IN SLIME

8:18 SLIME REPL Presentations
*, **, *** objects returned by previous evaluations

9:25 REPL shortcuts – pressing ‘,’ in the REPL lets you enter commands in the minibuffer. Enter the command ‘help’ to see all available shortcut commands.

10:45 Key chords to find out information about a symbol: (see also Documentation)

C-h k = describe command (general Emacs key chord)
C-c C-d d = Describe symbol
C-c C-d h = Hyperspec lookup

12:25 Package declarations.

(defpackage :morse         ; create a new package
     (:use :common-lisp))  ; include supporting packages
(in-package :morse)   ; this file belongs in the package just created

12:40 Compiling and evaluating code.

C-M-x = slime-eval-defun (slime-eval-toplevel)
C-x C-e = slime-eval-last-expression (evaluates form immediately preceding cursor)

13:45 The SLIME Selector lets you jump to a number of places with a single key. By default it isn’t bound to any key. Enter this in the slime.el file to bind it to F12 (change binding key as you wish):

(define-key global-map (kbd "<f12>") 'slime-selector)

Some SLIME Selector Locations:

? – A help buffer listing all slime-selectors‘s available buffers.
r – The REPL buffer for the current SLIME connection.
d – The most recently activated SLDB buffer for the current connection.
l – The most recently visited lisp-mode source buffer.
s – The *slime-scratch* buffer. See slime-scratch.

15:15 Pressing ‘ ‘ (space) after a typing a function shows the parameter list in the minibuffer.

16:25 Marco does a cool demonstration of Emacs keyboard macros. I have no idea how he did it and I’m not ready to dive into Emacs documentation just yet. Enjoy the link!

EDIT: Reader jeep says:

With standard keybindings, the macro at 16:25 could be:
C-x (
(#\ C-f M-SPC ‘ C-e ‘) C-n C-a
C-x )

i.e.
Start the keyboard macro with C-x (

Then insert the characters (#\
Go forward one character
Get rid of all but one space (M-SPC)
Insert the character ‘
Go to the end of the line
Insert the characters ‘)
Go to the next line and then back to the beginning of the line.
Then close the macro with C-x )

Then C-x e to execute it and e to repeat.

17:05 Demonstration of Emacs sexp navigation. See Marco’s slime.el file for how to bind these functions to keys.

19:35 SLIME Completion in REPL. Press tab in the REPL and a temporary buffer will show information about all possible matches. There are three different kinds of completion. In the screencast, Marco is using fuzzy completion, which can be accessed in two ways:

  • Key Chord C-c M-i
  • Adding this to your slime.el file:
(setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)

USING THE SLIME DEBUGGER

22:20 Welcome to the SLIME debugger buffer (sldb)

22:27 Backtrace and frames. The documentation is more thorough. I’ll list which commands he uses at which time so you can find a demonstration for them.

23:00 Use ‘t’ to toggle details when on a backtrace frame

24:10 In debugger/backtrace frame

v = sldb-show-source
a = sldb-abort; invoke the abort restart

25:04 Navigating through the REPL history

M-n = next command in REPL history
M-p = previous command in REPL history

26:00 Optional declarations – these setting are used to ensure all debugging information is shown for the demo

; make sure all debugging is shown for demo
(declaim (optimize (speed 0) (safety 3) (debug 3)))

EMACS TOOLS FOR WRITING LISP CODE

27:00 Emacs tools for writing Lisp code – I’m not sure if any of these have default bindings or if you have to define them in the slime.el file. I wrote down what he said in the video, and you can refer to his slime.el file for reference on how to setup your own.

27:15 Auto-closing parentheses

27:58 Sexp navigation

C-n = forward sexp (non-standard binding)
C-h = backward sexp (non-standard binding)

28:40 Transpose sexps

C-t = transpose-sexps ; swaps sexp on cursor line with the next one below it

29:10 kill sexp

C-k = kill-sexp ; deletes form immediately after point

29:45 M-[num] ( = wrap [num] close parentheses after next sexp

MORE DEBUGGER DEMONSTRATION

33:35 Recompile file, demonstration of the compiler notes buffer. The form where error is present is underlined (warning = orange, error = red). When there are multiple warnings/errors, you get a tree buffer.

M-n = next note
M-p = previous note
v = view source

35:00 When you’re on a warning and you hit enter, it takes you to the place in the file where the error is

35:45 Debugging methods

C-c C-v h = hyperspec documentation
M-. = jump to source code definition
C-c RET = Macroexpand 1

ASDF-INSTALL

37:42 Using asdf-install to download and configure an external package. At the REPL, type

(require :asdf-install)
(asdf-install:install :split-sequence)

You will get this error “No key found for key…” – unless you have the public key of the library creator. See documentation for more details. Asdf-install will download, unpack, compile, and load source for the package you select.

39:02 Inspecting a package

45:25 Tracing

46:18 Summary of topics covered:

  • repl
  • slime debugger
  • inspecting frames
  • ways to send code from emacs to lisp
  • ways to inspect running image for more info

47:20 Inspecting objects that aren’t printable – current value of that variable in the call stack. This is useful when there’s an error and you don’t know what’s wrong – you can look at actual values

i [when on a frame] = evaluate expression in the stack context of that frame

50:25 Cross reference facility – for instance,you add new parameter to a function and you want to update every call to it

C-c < = slime-list-callers
C-c > = slime-list-callees

53:25 Final thoughts

M-x slime-disconnect = close connection between emacs and SWANK/Lisp

(follow the discussion about this on comp.lang.lisp)

Filed Under: Lisp

Comments

  1. Sean says

    February 11, 2008 at 6:20 pm

    Thanks for taking the time to put this together. It’s a great refresher after being away from SLIME for a while, without having to watch the hour-long video again.

  2. Mark Tran says

    February 11, 2008 at 10:15 pm

    Excellent!

    Though I think the movie is slightly outdated.

    At 4:37, he uses “swank:create-swank-server” which has been removed from swank. “swank:create-server” should be used instead.

    SLIME Changelog, 2006-12-05:

    * swank.lisp (create-swank-server): Removed. Use create-server instead.

  3. Robert Goldman says

    February 12, 2008 at 3:56 pm

    Is it really necessary to put a link to swank.asd in your asdf central registry? I am using CVS-version of slime, and I don’t have any such link. Seems like the emacs side knows how to point lisp at the swank system definition. I believe it’s swank-loader.lisp, loaded by the slime.el code that does the job….

  4. Peter says

    February 12, 2008 at 4:02 pm

    Mark – changed, thanks!

    Robert – you’re right – in the SLIME documentation for Installation and Running it looks like the process is much simpler now. The movie is 2-3 years old and apparently setup is easier now. I changed the article to reflect that. Thanks for the catch!

  5. Ivar Refsdal says

    February 17, 2008 at 4:14 am

    Thanks for giving me a link to this page! 🙂
    Good job.

    The filename translations are also outdated:
    http://common-lisp.net/project/slime/doc/html/Setting-up-pathname-translations.html#Setting-up-pathname-translations

  6. jkndrkn says

    June 21, 2008 at 4:39 pm

    Hey there. I am interested in checking out the SLIME screencast, but it looks like both the .mov and .torrent versions are unavailable. Have they been moved permanently?

  7. Pontus says

    June 22, 2008 at 9:43 am

    I know the movie is old but I would still like to see it. For some reason the links to it doesn’t get me anywhere. Does anybody have an Idea?

  8. Si says

    June 29, 2008 at 4:57 am

    You can find the video here:

    http://www.guba.com/watch/3000054867

    Considering it’s a free video, I would think there is no problem at all downloading it via http://javimoya.com

    It’s a little more compressed than the original, but you won’t notice any difference in quality (unlike a Google video version I saw).

  9. Steffen says

    September 16, 2008 at 3:17 pm

    Hi,

    The link to the mov-file does not work anymore. So does the torrent. Is there an alternative source?

    Thanks for your transcript!

  10. jeep says

    November 22, 2008 at 8:49 pm

    For your information:

    With standard keybindings, the macro at 16:25 could be:
    C-x (
    (#\ C-f M-SPC ‘ C-e ‘) C-n C-a
    C-x )

    i.e.
    Start the keyboard macro with C-x (

    Then insert the characters (#\
    Go forward one character
    Get rid of all but one space (M-SPC)
    Insert the character ‘
    Go to the end of the line
    Insert the characters ‘)
    Go to the next line and then back to the beginning of the line.
    Then close the macro with C-x )

    Then C-x e to execute it and e to repeat.

  11. Bhrgunatha says

    December 9, 2008 at 8:55 pm

    The original quicktime movie is avialable from the internet archive:

    http://www.archive.org/details/UsingtheSLIMELispInteractionModeforEmacs

  12. Seth says

    January 9, 2009 at 6:43 pm

    Thanks! This is very very helpful.

Trackbacks

  1. Tooting My Own Horn » What’s In Peter’s Head says:
    February 12, 2008 at 4:58 pm

    […] spending a (very) long time on the Reference for the SLIME/Lisp/Emacs Screencast and getting lots of good reviews of it, I’ve taken a little pause from writing to actually do […]

  2. Public Beta Open For “Ultimate N00b SLIME/Emacs Cheat Sheet” » What’s In Peter’s Head says:
    February 14, 2008 at 10:54 am

    […] another new Lisper who’s actually getting some use out of my stuff. Aaron Feng wrote up my SLIME movie reference, and he even caught my later reference to my upcoming “Ultimate N00b SLIME/Emacs Cheat […]

  3. Recap of Intro to Lisp Workshop » What’s In Peter’s Head says:
    June 3, 2008 at 12:52 pm

    […] and movies like those from the SICP lectures, LispCast, the SLIME movie, […]

  4. bloggo ergo sum » Blog Archive » A simple weblocks application says:
    February 12, 2009 at 5:41 pm

    […] Hunchentoot webserver. There is a very good Lisp environment screencast by Marco Berringer, and an accompanying reference by Peter Christensen. I highly recommend them for learning more about how to get your Lisp […]

  5. Please recommend a good Slime tutorial or screencast [closed] - Sarkari Job Alert says:
    January 19, 2022 at 8:36 am

    […] http://www.pchristensen.com/blog/articles/reference-for-the-slimelispemacs-screencast/ […]

Leave a Reply

You must be logged in to post a comment.

Categories

  • Blog
  • Book Review
  • Business
  • Clojure
  • Education
  • Emacs
  • Fun
  • iOS
  • Lisp
  • Personal Sprints
  • Pictures
  • Polyphasic
  • Presentations
  • Programming
  • Rails
  • Startups
  • Uncategorized

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in