A few SLIME tips

SLIME is a highly configurable IDE for Common Lisp. Here are a few tips that you might deem worth trying (to be included in your ~/.emacs configuration).

  1. Get the bleeding edge from CVS and make Emacs aware of it:

    (add-to-list 'load-path "~/opt/slime-cvs")
    (add-to-list 'load-path "~/opt/slime-cvs/contrib")
    (add-to-list 'auto-mode-alist '("\\.asd$" . lisp-mode))
    

    The last line will allow the edition of ASDF definition files in Lisp mode.

  2. Tell Emacs how to auto-load SLIME when needed (if SLIME is installed at all).

    (when (load "slime-autoloads" t)
      (setq slime-auto-connect 'always)
      (slime-setup '(slime-fancy slime-asdf inferior-slime)))
    

    By setting slime-auto-connect to t, the inferior Lisp process will be launched as soon as you try to evaluate something in a Lisp buffer — no need to run SLIME manually.

  3. You can ensure that a bunch of things are done whenever (if ever) SLIME gets loaded.

    (eval-after-load "slime"
      '(progn
        ;; set hyperspec path to the first valid path found
        (some (lambda (path)
                 (let ((path (expand-file-name path)))
                    (when (file-accessible-directory-p path)
                       (setq common-lisp-hyperspec-root path))))
              '("/usr/share/doc/hyperspec-7.0/HyperSpec/"
                "~/Documents/Reference/lisp/HyperSpec-7-0/HyperSpec/"))
    
    
       ;; register info help (dpans2texi)
       (info-lookup-add-help
          :mode 'lisp-mode
          :regexp "[^][()'\" \t\n]+"
          :ignore-case t
          :doc-spec '(("(ansicl)Symbol Index" nil nil nil)))
    
    
       ;; register hooks
       (add-hook 'slime-connected-hook
          (lambda ()
             ;; have OpenMCL load an initialization file
             (when (member ':openmcl (slime-lisp-features))
                (slime-load-file "~/.openmclrc"))))
    
    
       (add-hook 'slime-mode-hook
        (lambda ()
          (set-variable lisp-indent-function 'common-lisp-indent-function)
          (slime-define-key "\r" 'newline-and-indent)
          (slime-define-key [(control ?/)] 'backward-up-list)
          (slime-define-key [(control ?=)] 'down-list)
          (slime-define-key [tab] 'slime-indent-and-complete-symbol)
          (slime-define-key [(control c) tab] 'slime-complete-form)
          (slime-define-key [f13] 'slime-cheat-sheet)))))