Set up a Lisp environment
Quicklisp
I'm more or less following Zach Beane's blog articlehere and using clbuild2 to manage SBCL. The quicklisp site is here.
If this is a new machine, install sbcl from the
package manager (sudo apt-get insall sbcl). Start with a
fresh .sbclrc file:
cd
mv .sbclrc .sbclrc-last
;; -*-Lisp-*-
(require 'asdf)
|
Get quicklisp set up
mkdir quicklisp && cd quicklisp
curl -O http://beta.quicklisp.org/quicklisp.lisp
|
Start up sbcl and load quicklisp. Then do
(quicklisp-quickstart:install)
(ql:add-to-init-file)
|
Use it to load some packages:
(ql:quickload "cl-ppcre")
(ql:quickload "cl-who")
(ql:quickload "vecto")
(ql:quickload "uffi")
(ql:quickload "ieee-floats")
(ql:quickload "hunchentoot")
(ql:quickload "drakma")
|
Don't forget to add my repository to the search path:
mkdir -p ~/.config/common-lisp/source-registry.conf.d
nano ~/.config/common-lisp/source-registry.conf.d/projects.conf
|
Add this line to the file:
(:tree (:home "src/lisp"))
|
And run this in sbcl:
(asdf:initialize-source-registry)
|
Note: when a package export list gets screwed up the best way to fix it is call delete-package.
Load Slime from quicklisp:
(ql:quickload "quicklisp-slime-helper")
|
It tells you what to add to .emacs:
(load (expand-file-name "~/quicklisp/slime-helper.el"))
(require 'slime)
(setq inhibit-splash-screen t)
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(slime-setup '(slime-fancy slime-tramp slime-asdf))
(slime-require :swank-listener-hooks)
|
I'm only using it to get the latest SBCL right now.
git clone git://gitorious.org/clbuild2/clbuild2.git
cd clbuild2
./clbuild install-from-upstream sbcl
|
Set options up in
"customize-target-features.lisp". At a minimum make sure threads is
turned on. Look at
~/clbuild2/source/sbcl/base-target-features.lisp-expr for the
options. Here's what mine currently looks like when I'm through:
(lambda (list)
(flet ((enable (x) (pushnew x list))
(disable (x) (setf list (remove x list))))
#+nil (enable :sb-show)
(enable :sb-after-xc-core)
(enable :sb-doc)
(enable :sb-unicode)
(enable :sb-source-locations)
;; #+nil (disable :sb-doc)
list))
|
Build SBCL from within its source directory:
sh make.sh
su
sh install.sh
|
If I'm on a machine where I want sbcl documentation,
I follow the instructions sbcl gives at the end of the
build before doing the install:
cd doc/manual
make (requires LaTeX installation to build manuals)
cd ../../
sudo bash install.sh
|
Finish .sbclrc with the following
;;; If a fasl was stale, try to recompile and load (once).
(defmethod asdf:perform :around ((o asdf:load-op)
(c asdf:cl-source-file))
(handler-case (call-next-method o c)
;; If a fasl was stale, try to recompile and load (once). ;
(sb-ext:invalid-fasl ()
(asdf:perform (make-instance 'asdf:compile-op) c)
(call-next-method))))
;;; Use this to enable shebang style scripts like this:
;;;
;; #!/usr/bin/sbcl --noinform
;; (write-line :Hello, World:)
;;
;;; If the first user-processable command-line argument is a filename,
;;; disable the debugger, load the file handling shebang-line and quit.
(let ((script (and (second *posix-argv*)
(probe-file (second *posix-argv*)))))
(when script
;; Handle shebang-line ;
(set-dispatch-macro-character ## #!
(lambda (stream char arg)
(declare (ignore char arg))
(read-line stream)))
;; Disable debugger ;
(setf *invoke-debugger-hook*
(lambda (condition hook)
(declare (ignore hook))
;; Uncomment to get backtraces on errors ;
;; (sb-debug:backtrace 20) ;
(format *error-output* :Error: ~A~%: condition)
(quit)))
;; Load the script file and quit ;
(load script)
(quit)))
|
Try the new sbcl. Then start emacs and try slime. Everything should work.
Notes:
- Might also need fortran for
cl-blapack. sudo aptitude search fortran to find the
latest version.
sudo aptitude install libblas-dev liblapack-dev
|
- If using a 64-bit Linux, this might be a backport,
so set up the link in /usr/lib/ by hand:
cd /usr/lib
sudo ln -s i386-linux-gnu/libgfortran.so.3 .
|
- Now I can load org.middleangle.cl-blapack which is needed for lisp-matrix (along with ffa, etc).
(ql:quickload "org.middleangle.cl-blapack")
(ql:quickload "lisp-matrix"
|
- If buildling a hunchentoot project on this machine, make sure the reference to swank is accurate:
(load (merge-pathnames
"quicklisp/dists/quicklisp/software/slime-20110829-cvs/swank-loader.lisp"
(user-homedir-pathname)))
|
|