Slime Tips

Little known features of Slime.

2 notes &

Exporting symbols, part 2

Earlier I wrote about exporting symbols, now there’s a few new options.

slime-export-symbol-representation-auto default value T.

Automatically determines which exporting style to use, : or #:, based on already exported symbols in the defpackage form. If both or neither are used, the default described in the previous post is applied.

 slime-export-save-file, default value NIL.

Automatically save the file in which the defpackage form is residing after an export operation.

I often export something, and since the file is in the background, I forget to save it and it breaks the next recompile, or I even forget to commit it. 

P.S. It appears that there was a bug when slime-export-symbol-representation-auto was set to T, it used “:” prefix by default, it’s now fixed in CVS, and should be included in the next Quicklisp update.

0 notes &

Smarter M-.

In the latest CVS M-. became slightly more convenient.
It’s now able to find definitions of symbols whose names are prefixed with punctuation, for example, some lisps produces warnings


In FOO: Undeclared free variable X


And pressing M-. on FOO tried to find “FOO:" before, now it sees that there’s no symbol named "FOO:”, it tries to find “FOO”.

This is controlled by two new variables, which can be customized in ~/.swank.lisp

*find-definitions-right-trim*, default value “,:.”
*find-definitions-left-trim*, default value “#:”.

All those are arguments to cl:string-x-trim.

With the default value for left-trim it’s now possible to use M-. on
#: symbols in package definitions.

0 notes &

How to use ~/.swank.lisp

For some people it’s not obvious how to use ~/.swank.lisp to configure swank (the CL part of Slime).
First, it’s better to have (in-package :swank) at the beginning.
Then, instead of using SETF, it’s better to use DEFVAR or DEFPARAMETER, because ~/.swank.lisp is loaded before the contrib modules (in which some variables are defined) and SETF will produce a warning (like in the previous tip) or may not work at all.

1 note &

Object slots ordering in the inspector

When inspecting an object inspector provides two options on how to sort and group the slots. By default it lists all the slots alphabetically. The other option is to list them in the way they are defined. It can also group the slots by the direct class they’re defined in. Slots can be sorted or unsorted when you grouped by classes as well.
Inspector provides two check-boxes to change the ordering at run-time

 Group slots by inheritance [X]
 Sort slots alphabetically  [ ]


The default values of those can be set in ~/.swank.lisp

*inspector-slots-default-order* to either :unsorted or :sorted. (:sorted by default)
and
*inspector-slots-default-grouping* to :all or :inheritance. (:all by default)

I set *inspector-slots-default-order* to :unsorted, and then it shows all the slots in the order they’re defined in the source code (implementation or MOP can reorder them, but that usually doesn’t happen).

1 note &

Reloading Slime without restarting Emacs

After updating Slime it’s usually needed to restart Emacs so that the changes take effect, but restarting Emacs is quite inconvenient. After adding the following code into .emacs, M-x slime-reload will reload all the Emacs Lisp parts (CL side should be restarted with ,restart short-cut in the REPL).

(defun load-slime ()
  ;; here should be placed all the usual configuration code.
  ;; like loading contribs and setting variables
  (slime-setup '(slime-fancy ...)))

(load-slime)

(defun slime-reload ()
  (interactive)
  (mapc 'load-library
        (reverse (remove-if-not
                  (lambda (feature) (string-prefix-p "slime" feature))
                  (mapcar 'symbol-name features))))
  (setq slime-protocol-version (slime-changelog-date))

  (load-slime))

0 notes &

Failed FASLs

When doing C-c C-k and COMPILE-FILE returns failure-p, slime asks whether to load the resulting fasl, although the compilation process failed.
The default action can be controlled by slime-load-failed-fasl variable, it accepts the following values:
never don’t load the fasl
always load the fasl
ask ask the user (default).


I have it set to always.

1 note &

Keeping FASLs away

C-c C-k by default puts FASLs in the same directory as the .lisp file, which may be not very nice.

(setq slime-compile-file-options '(:fasl-directory "/tmp/slime-fasls/"))


will place fasls into “/tmp/slime-fasls/”.
I also have

(make-directory "/tmp/slime-fasls/" t)

in my .emacs to make sure the directory exists (/tmp gets cleaned on each reboot).

2 notes &

Monitoring and controlling threads

M-x slime-list-threads (you can also access it through slime-selector shortcut t) will list running threads by their names, and their statuses.


The thread on the current line can be killed with k, or if there’s a lot of threads to kill, several lines can be selected and k will kill all the threads in the selected region.


g will update the thread list, but when you have a lot of threads starting and stopping it may be too cumbersome to always press g, so there’s a variable slime-threads-update-interval, when set to a number X the thread list will be automatically updated each X seconds, a reasonable value would be 0.5.

0 notes &

Inspector navigation

A couple of inspector commands:
l  go back to the previous inspected object.
n  go forward.
g  reinspect current object (g is generally used for updating things throughout Emacs).