How to start with Common Lisp?

SBCL > Quicklisp > Emacs > SLIME > REPL
(If you are curious about what these names mean – read this article)

1. Before you start:
$ sudo apt update

2. Install SBCL:
$ sudo apt install sbcl -y
$ sbcl –version

Optional also the following (I’m using ZSH):
$ ls /usr/bin/sbcl
$ export PATH=”/usr/bin:$PATH”
$ echo ‘export PATH=”/usr/bin:$PATH”‘ >> ~/.zshrc
$ source ~/.zshrc

3. Install Quicklisp:

Download the Quicklisp installer:
$ curl -O https://beta.quicklisp.org/quicklisp.lisp

Run the Quicklisp installer:
$ sbcl –load quicklisp.lisp

Follow the on-screen instructions, usually by typing:
(quicklisp-quickstart:install)

Once installed, add Quicklisp to your SBCL startup by typing:
(ql:add-to-init-file)

4. Install Emacs
$ sudo apt install emacs -y
$ emacs –version

Create the file (if necessary):
$ mkdir -p ~/.emacs.d
$ touch ~/.emacs.d/init.el
Edit the file:
emacs ~/.emacs.d/init.el
Add the SLIME configuration:
Open the ~/.emacs.d/init.el file (create it if it doesn’t exist) and add:
(load (expand-file-name “~/.quicklisp/slime-helper.el”))
(setq inferior-lisp-program “sbcl”)

Then, add this to your “~/.emacs.d/init.el” the following text fragment:
(load (expand-file-name “~/.quicklisp/slime-helper.el”))
(setq inferior-lisp-program “sbcl”)

NOTE: You should replace “sbcl” with path where it is (in my case it is “/usr/bin/sbcl”)
If you don’t know where it is, you can find it easy:
$ which sbcl

5. Install SLIME helper:
$ sbcl –eval ‘(ql:quickload :quicklisp-slime-helper)’ –quit

6. Run SLIME in Emacs
$ emacs
Then: M-x (Alt + x)
Type: slime
Press enter, and a REPL will start;)

SOMETHING WENT WRONG…?
Don’t worry, you can remove everything and try the installation again:

1. Remove Emacs
$ sudo apt remove –purge emacs emacs-common emacs-* -y
2. Delete personal configuration files (if present):
$ rm -rf ~/.emacs.d ~/.emacs
3. Remove SBCL:
$ sudo apt remove –purge sbcl -y
4. Remove Quicklisp:
$ rm -rf ~/quicklisp ~/.quicklisp
5. Remove residual configuration files:
$ sudo apt autoremove –purge -y

Related posts