The Wayback Machine - https://web.archive.org/web/20080115120245/http://bc.tech.coop:80/blog/070120.html

Bill Clementson's Blog

Bits and pieces (mostly Lisp-related) that I collect from the ether.

January 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Dec  Feb

SLIME Tips and Techniques - Part 1

Saturday, January 20, 2007

I've recently been suffering from "blogger's block". In part because I've been traveling a bit, in part because I've been pretty busy, and in part because (blah, blah, blah - enough excuses already!). So, this is an attempt to get things rolling again.

I use SLIME and Emacs for all of my Lisp programming and really enjoy using this environment. I thought I knew how to use SLIME pretty well; however, I've seen in the past that I can get used to using a tool in a particular way and miss out on some neat functionality. So, I recently decided to re-read the SLIME documentation and re-examine some of my own custom functions for working with Lisp code. In this post, I'll cover some of the "new" functionality that I discovered in SLIME. In future posts, I'll add in some things that I use that others might find useful. Also, if anyone has a SLIME tip/technique that they would like to share, I'd be happy to post it (with proper attribution, of course).

First of all, if you haven't read the SLIME documentation recently, it's worth grabbing the latest CVS version of SLIME and building the documentation. I prefer to read the .info version in Emacs; however, the make script builds PDF and PS versions of the documentation too. The online SLIME manual isn't up-to-date, so if you're going to go to the trouble of reading the manual, you should definitely get the latest and greatest version from CVS.

A function that I never knew existed in SLIME (before re-reading the documentation) is "slime-call-defun". It is bound to "C-c C-y" and it inserts a call to the function defined around point into the REPL. For example, say you are perusing the SLIME source code and happen to be in swank.lisp looking at the function send-repl-results-to-emacs and decide that you want to try it out. Well, you just press C-c C-y and it appears in the REPL. You can then enter some args and give it a whirl. For example:

CL-USER> (swank::send-repl-results-to-emacs '(this is a test))
THIS
IS
A
TEST
(THIS IS A TEST)
CL-USER> 
So, slime-call-defun is not exactly earth-shattering; however, it's another useful SLIME key chord to remember.

Another useful feature I discovered in the manual is Globally redirecting all IO to the REPL. This is quite a useful feature when you're working with code that has multiple threads that write to *standard-output*. I already knew about the technique; however, I didn't know there was a variable in SLIME that you could set for this.

Lastly, I'd like to point out that I discovered some useful variations on commands I already knew about. For example, for some reason, I always seem to use "C-c C-d C-a" when I do an "apropos". That key binding runs "slime-apropos" to search for all "external" symbols whose names match the regular expression that is entered. However, there are two other apropos commands as well:
  1. "C-c C-d C-z" does a "slime-apropos" on all internal AND external symbols whose names match the regular expression that was entered.
  2. "C-c C-d C-p" shows a listing of all the external symbols in a specified package. When called with a prefix argument, the output includes internal symbols.
So, it pays to RTFM sometimes. Even when you think you don't need to! Maybe, ESPECIALLY when you think you don't need to. ;-)

emacs Copyright © 2007 by Bill Clementson