Installing Babel on macOS

These instructions assume you have already installed the dependencies and you have downloaded Babel on your computer. Follow these additional steps to configure your macOS computer for Babel development:

  • Install a Common Lisp implementation. Babel supports LispWorks, Clozure Common Lisp (CCL) and Steel Bank Common Lisp (SBCL). Both CCL and SBCL are freely available and can be installed via Homebrew. When you are a novel Lisp user, we recommend installing CCL.
;; to install ccl
brew install clozure-cl

;; to install sbcl
brew install sbcl
  • Install Emacs using Homebrew
brew install --cask emacs
  • Read and follow the Homebrew caveats to link Emacs to your /Applications folder.

  • Use git clone to get the latest version of Slime. We will assume Slime is placed in your home directory, but you can place this anywhere you want.

git clone https://github.com/slime/slime.git
  • For configuring Emacs, use a text editor to create a plain text file called .emacs (without extension). This file must be placed in your home directory. Copy the contents below in your .emacs file. Replace <SLIME> by the path to the Slime directory on your machine and <LISP> by the path to the Lisp installation on your machine. You can find the latter by running which sbcl or which ccl in the Terminal.
;;; -*- emacs-lisp -*-
(custom-set-variables
 '(show-paren-mode t)
 '(size-indication-mode t)
 '(tool-bar-mode nil)
 '(transient-mark-mode t)
 '(column-number-mode t)
 '(indent-tabs-mode nil)
 '(make-backup-files nil))

(set-face-foreground 'font-lock-string-face "navy")

(setq mouse-wheel-scroll-amount '(1 ((shift) .1)))
(setq mac-allow-anti-aliasing t)

;; Make sure gnuplot and dot are found. Add /usr/local/bin to the path
(setenv "LANG" "en_US.UTF-8")
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))

;; path to slime (ADAPT <SLIME>)
(add-to-list 'load-path "<SLIME>")

(require 'slime)
(slime-setup '(slime-repl slime-autodoc slime-fancy-inspector))

;; path to lisp implementations (ADAPT <LISP>)
(setq inferior-lisp-program "<LISP>")

(command-execute 'slime)
  • Download and install Quicklisp. This can be done by running the following commands in the Terminal from your home directory:
curl -O https://beta.quicklisp.org/quicklisp.lisp

;; using ccl
ccl -n -l quicklisp.lisp -e '(quicklisp-quickstart:install)(ccl:quit)' -b

;; using sbcl
sbcl --no-sysinit --no-userinit --load quicklisp.lisp \
     --eval '(quicklisp-quickstart:install)' \
     --quit
  • [SBCL only] To ensure that Quicklisp and Babel are loaded whenever you start SBCL, you can create a file called .sbclrc in your home directory. Add the following to this file (filling in the correct path to your Babel folder):
;;; loading Babel
(load "/path/to/Babel/libraries/asdf")
(load "/path/to/Babel/init-babel")

;;; loading quicklisp
(load "~/quicklisp/setup.lisp")
  • [CCL only] To ensure that Quicklisp and Babel are loaded whenever you start CCL, you can create or edit a file called .ccl-init.lisp in your home directory. Add the following to this file (filling in the correct path to your Babel folder):
;;; loading Quicklisp
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

;;; loading Babel
(load "/path/to/Babel/libraries/asdf")
(load "/path/to/Babel/init-babel")
  • Now, when you open Emacs, it should automatically start up a Lisp session, load Babel and print the following message:
* Initializing BABEL.
  The BABEL path is: /path/to/Babel
  • To test your Babel installation, run the following commands. The test consists in opening a PDF file with a diagram and displaying a window with a sinus function.
;;; for ccl
ccl -l /path/to/Babel/test-babel-installation.lisp -e '(ccl:quit)' -b

;;; for sbcl
sbcl --load "/path/to/Babel/test-babel-installation.lisp" --quit