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

Bill Clementson's Blog

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

September 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
Aug  Oct

SLIME Refactoring

Thursday, September 27, 2007

SLIME is a great Emacs/CL utility and many people prefer it for developing CL code. However, it has grown quite substantially over the years and some people have discussed the idea of breaking it up into more "manageable" chunks. Also, there has been an ongoing "tension" between those SLIME users who want to add new functionality to SLIME and those who want to keep it slim and trim. Helmut Eller recently made a proposal to split up SLIME into "core" and "contrib" components and, over the past month, he and others have been working to split up the code.

Today, I downloaded the CVS code and had a look at what they've been doing. It works quite well and I feel comfortable with ditching the previous monolithic version of SLIME and using the new CVS code base. However, there are a few changes that one needs to make to their SLIME setup code and the documentation doesn't appear to have been updated yet. So, here's what I had to put in my .emacs file to get it working:

  1. Core SLIME functionality: Added the following lines to use SLIME in Emacs with the CL implementations that I use (I normally use the OpenMCL, SBCL, and ACL CL implementations with SLIME but use the LispWorks IDE with Edi Weitz's STARTER-PACK. OpenMCL is my default implementation, so it's listed first.):
    (add-to-list 'load-path "/path/to/slime")
    (setq slime-lisp-implementations
          `((openmcl ("dppccl"))
    	(sbcl ("sbcl"))
    	(acl ("alisp"))))
    (require 'slime-autoloads)
    (add-hook 'lisp-mode-hook (lambda ()
                                (cond ((not (featurep 'slime))
                                       (require 'slime)
                                       (normal-mode)))))
  2. Contrib functionality: Added the following lines so that certain contrib functionality is loaded after SLIME has been loaded:
    (eval-after-load "slime"
      '(progn
        (add-to-list 'load-path "/path/to/slime/contrib")
        (require 'slime-fancy)
        (require 'slime-banner)
        (require 'slime-asdf)
        (slime-banner-init)
        (slime-asdf-init)
        (setq slime-complete-symbol*-fancy t)
        (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
        (slime-setup)))
    A note about the SLIME contribs that I load: Many "standard" contribs that people use are automatically loaded by the "slime-fancy" contrib (fuzzy-complete is one of them and I use that as my default completer). I'm fond of the SLIME startup animation (slime-banner) and the REPL ASDF load support (slime-asdf) and they aren't included in "slime-fancy", so I load them as well. If you don't want to load any contribs, the only thing you need to have here is:
    (eval-after-load "slime"
      '(progn
        (slime-setup)))
  3. Miscellaneous functionality: Added the following lines so that I have a couple of shortcut keys for starting a SLIME CL connection and switching SLIME buffers:
    ;; Shortcut key for starting a SLIME CL connection
    (global-set-key [f5] 'slime)
    ;; Shortcut key for selecting SLIME buffers (global-set-key [(control f11)] 'slime-selector)
So, some nice things about having the contribs broken out from the main SLIME code base: So, congrats to the SLIME maintainers for improving the overall code quality and the future utility of SLIME by going through this refactoring exercise.

Update-2007-09-28: Tobias Rittweiler mentioned on #lisp that (instead of using the "require" and "init" statements for the contribs as I showed in the example above) it is possible to use "slime-setup" to load and initialize all the contribs. So, for example, to replicate what I had above, one could do:
(eval-after-load "slime"
  '(progn
    (add-to-list 'load-path "/path/to/slime/contrib")
    (slime-setup '(slime-fancy slime-asdf slime-banner))
    (setq slime-complete-symbol*-fancy t)
    (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)))
Much tidier! :-)

emacs Copyright © 2007 by Bill Clementson