Skip to content

Latest commit

 

History

History
158 lines (130 loc) · 7.8 KB

ome-common-lisp.org

File metadata and controls

158 lines (130 loc) · 7.8 KB

Oh My Emacs Common Lisp

This is part of oh-my-emacs.

This file contains some settings for Common Lisp.

Prerequisites

PackageWindowsUbuntu/Debian/MintArchLinuxFedoraMac OS XMandatory?
SBCLsbclYes
Clozure CL[web]No
CLISPclispNo

Note:

  • SBCL or Clozure CL or CLISP as a Common Lisp implementation. I recommend SBCL since it has good performance, and is easy to install via package manager.

El-get packages

StatusDescription
slimeRequiredOne of the most amazing packages for Emacs.
ac-slimeRequiredAC backend for slime.

Common Lisp

SLIME is the Superior Lisp Interaction Mode for Emacs, here’re some features and tips. Believe me, SLIME in Emacs is a subversive developing environment for Common Lisp, it is the ultimate solution for languages with a REPL. SLIME is the bridge between an Editor(here, Emacs for example, vim users have a slimv which is a fork of SLIME to vim) and a running Common Lisp environment. It makes your workflow so smooth and enjoyable that you will miss it so much when working with other REPL languages such as Python/Ruby/JavaScript[1], etc.

Some good resources about SLIME:

Besides, wiht do a really good job to list many valuable links for learning common lisp.

To use SLIME, you must install an Lisp Implementation, just like if you want to do C programming, you must install a C compiler such as GCC. Here I recommend SBCL for you. You can get it by sudo apt-get install sbcl in Ubuntu/Mint/Debian.

LispWorks provides a comprehensive documentation for Common Lisp called hyperspec, which integrates quite well with SLIME through slime-documentation-lookup. You can get by sudo apt-get install hyperspec in Ubuntu/Mint/Debian. To use hyperspec in ubuntu/mint, you can: sudo apt-get install hyperspec, which also set proper common-lisp-hyperspec-root for you. On other Linux distributions, maybe you need to set it manually to tell SLIME where to find the hyperspec document.

You can also get CLTL by sudo apt-get install cltl, which is the defacto standard for Common Lisp before the ANSI standard.

Oh-my-emacs also configure emacs-w3m as the default documentation browser for SLIME.

Oh-my-emacs integrates ac-slime for instant in-buffer completion, and should be self-adapted to your system, by which I mean, it will use an available lisp implementation by finding it using executable-find instead of specifying a fixed file path like /usr/bin/sbcl.

Enough stuff, enjoy your Common Lisp journey with Emacs and SLIME.

(defun ome-slime-setup ()
  ;; Define multiple lisp backends
  ;; see http://nklein.com/2010/05/getting-started-with-clojureemacsslime/
  (defmacro defslime-start (name lisp-impl)
    `(when (executable-find (symbol-name ,lisp-impl))
       (defun ,name ()
         (interactive)
         (let ((slime-default-lisp ,lisp-impl))
           (slime)))))

  (setq slime-lisp-implementations
        `((sbcl (,(executable-find "sbcl")) :coding-system utf-8-unix)
          (ccl (,(executable-find "ccl")))
          (ccl64 (,(executable-find "ccl64")))
          (clisp (,(executable-find "clisp")))))

  (defslime-start slime-sbcl 'sbcl)
  (defslime-start slime-ccl 'ccl)
  (defslime-start slime-ccl64 'ccl64)
  (defslime-start slime-clisp 'clisp)

  ;; If you use ubuntu/mint, then "sudo apt-get install hyperspec" will set
  ;; this for you in a file like "/etc/emacs/site-start.d/60hyperspec.el"
  ;; (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/")

  ;; Open SBCL rc file in lisp-mode
  (add-to-list 'auto-mode-alist '("\\.sbclrc$" . lisp-mode))

  (global-set-key (kbd "C-c s") 'slime-selector)
  (setq slime-net-coding-system 'utf-8-unix)
  (setq slime-complete-symbol*-fancy t)
  (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
  (setq inferior-lisp-program
        (or (executable-find "sbcl")
            (executable-find "ccl")
            (executable-find "ccl64")
            (executable-find "clisp")))
  (slime-setup '(slime-fancy
                 slime-indentation
                 slime-banner
                 slime-highlight-edits)))

(defun ome-ac-slime-setup ()
  (add-hook 'slime-mode-hook
            (lambda ()
              (set-up-slime-ac t)))     ; use slime-fuzzy-complete-symbol
  (add-hook 'slime-repl-mode-hook
            (lambda ()
              (set-up-slime-ac t)))
  (eval-after-load "auto-complete"
    '(add-to-list 'ac-modes 'slime-repl-mode)))

(when (or (executable-find "sbcl")
          (executable-find "ccl")
          (executable-find "ccl64")
          (executable-find "clisp"))
  (ome-install 'slime)
  (ome-install 'ac-slime))

Todos

  • Integrate redshank?
  • Find a method to rebase the source tree of various CL implementations, which is useful for slime-edit-definition.

[1] swank-js, swankr