It is best to use latest SLIME from Emacs MELPA repository: the packages may be a bit unstable, but you get the latest features.
You can download a portable and multiplatform version of Emacs25 already configured with Slime, SBCL, Quicklisp and Git: Portacle. It's a quick and easy way to get going. If you want to learn how to install everything yourself, read on.
In GNU Emacs (>= 24.5) initialization file (~/.emacs
or ~/.emacs.d/init.el
) add the following:
;; Use Emacs package system
(require 'package)
;; Add MELPA repository
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
;; Reload package list
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; List of packages to install:
(setq package-list
'(magit ; git interface (OPTIONAL)
auto-complete ; auto complete (RECOMMENDED)
auto-complete-pcmp ; programmable completion
idle-highlight-mode ; highlight words in programming buffer (OPTIONAL)
rainbow-delimiters ; highlight parenthesis (OPTIONAL)
ac-slime ; auto-complete for SLIME
slime ; SLIME itself
eval-sexp-fu ; Highlight evaluated form (OPTIONAL)
smartparens ; Help with many parentheses (OPTIONAL)
))
;; Install if are not installed
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
;; Parenthesis - OPTIONAL but recommended
(show-paren-mode t)
(require 'smartparens-config)
(sp-use-paredit-bindings)
(sp-pair "(" ")" :wrap "M-(")
(define-key smartparens-mode-map (kbd "C-<right>") 'sp-forward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-<left>") 'sp-backward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-S-<right>") 'sp-forward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-S-<left>") 'sp-backward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-)") 'sp-forward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-(") 'sp-backward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-}") 'sp-forward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-{") 'sp-backward-barf-sexp)
(sp-pair "(" ")" :wrap "M-(")
(sp-pair "[" "]" :wrap "M-[")
(sp-pair "{" "}" :wrap "M-{")
;; MAIN Slime setup
;; Choose lisp implementation:
;; The first option uses roswell with default sbcl
;; the second option - uses ccl directly
(setq slime-lisp-implementations
'((roswell ("ros" "-L" "sbcl-bin" "run"))
(ccl ("ccl64"
"-K" "utf-8"))))
;; Other settings...
SLIME on its own is OK, but it works better with Quicklisp package manager. To install Quicklisp, follow the instruction on the website (if you use roswell, follow roswell instructions). Once installed, in your lisp invoke:
(ql:quickload :quicklisp-slime-helper)
and add the following lines to Emacs init file:
;; Find where quicklisp is installed to
;; Add your own location if quicklisp is installed somewhere else
(defvar quicklisp-directories
'("~/.roswell/lisp/quicklisp/" ;; default roswell location for quicklisp
"~/quicklisp/") ;; default quicklisp location
"Possible locations of QUICKLISP")
;; Load slime-helper
(let ((continue-p t)
(dirs quicklisp-directories))
(while continue-p
(cond ((null dirs) (message "Cannot find slime-helper.el"))
((file-directory-p (expand-file-name (car dirs)))
(message "Loading slime-helper.el from %s" (car dirs))
(load (expand-file-name "slime-helper.el" (car dirs)))
(setq continue-p nil))
(t (setq dirs (cdr dirs))))))
;; Autocomplete in SLIME
(require 'slime-autoloads)
(slime-setup '(slime-fancy))
;; (require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'slime-repl-mode))
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'slime-repl-mode))
;; Hooks
(add-hook 'lisp-mode-hook (lambda ()
(rainbow-delimiters-mode t)
(smartparens-strict-mode t)
(idle-highlight-mode t)
(auto-complete-mode)))
(add-hook 'slime-mode-hook (lambda ()
(set-up-slime-ac)
(auto-complete-mode)))
(add-hook 'slime-repl-mode-hook (lambda ()
(rainbow-delimiters-mode t)
(smartparens-strict-mode t)
(set-up-slime-ac)
(auto-complete-mode)))
After the restart, GNU Emacs will install and set up all the necessary packages.