Connecting Things Together

SBCL and ASDF

The full SBCL package installation automatically installs a current version of ASDF. However, when starting SBCL the ASDF isn't being loaded per default. To be able to compile the systems defined using ASDF, one can simply (require :asdf) inside the SBCL initialization file (~/.sbclrc) or pass the require statement as a command line argument to it.

Emacs and SBCL and ASDF

Emacs core (memory management etc.) is written in C++ and all the high-level features are in Emacs Lisp (it is probably the most widely used piece of software written in Lisp). As it is, without any extensions, it is very well suitable for programming in Emacs Lisp, but not in Common Lisp, and there is no specific protocol to connect the ELisp of Emacs to CL of SBCL.

Emacs uses an initialization script written in ELisp (file extension .el) to define how the software should look like, for setting up special key bindings etc. and, most importantly, which extra packages should be loaded for the particular user.

One of such extension packages is Slime, the Superior Lisp Interaction Mode for Emacs, which is the bridge between ELisp and CL. When Slime is invoked, a number of buffers are created in Emacs. One of them is the *inferior-lisp* buffer which is a comint (command-interpreter-in-a-buffer) wrapper around the SBCL process. Basically, Slime starts an SBCL process and pipes all the inputs from the buffer to the process and some of the SBCL outputs back to the inferior lisp. (Btw, shells like the Emacs internal console Alt-x shell and Alt-x python-shell and some others are also implemented using the same comint mode.) The other buffer that Slime generates for the user is the Slime REPL (Read-Eval-Print Loop), which is similar to the inferior lisp but is more powerful, e.g. one can look inside complex objects that are output in the REPL from function calls using the Slime inspector etc. Using the SBCL process running in the background, Slime can also interactively compile pieces of code from Emacs, jump to the definition of a function etc.

Emacs and ROS

Second important Emacs extension is rosemacs.el which was developed in the ROS community to simplify the process of programming ROS packages. The most basic example usage of the extension would be starting roscore from inside Emacs (the default key binding is Ctrl-x Ctrl-r Ctrl-c). Rosemacs communicates with the ROS ecosystem using OS process calls (i.e. starting a shell process from Emacs Lisp, e.g. starting the command line program roscore when the corresponding key combination is pressed). Rosemacs has nothing to do with Common Lisp.

Emacs and ROS and SBCL and ASDF

And the third useful Emacs library is slime-ros.el which is a Slime plugin (in Emacs vocabulary plugins are called contribs) used to utilize handy features of ROS while developing ROS packages in Common Lisp. The main feature is the ability of ROS to find the paths to the ROS packages on which a particular ROS package is dependent. The CL build system searches for Lidp system definitions through the entries in the ASDF system registry (e.g., *central-registry* variable), so Rosemacs is used for initializing the registry with paths of ROS packages. Those paths are retrieved using the ROS infrastructure such as rospack.