Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Emacs/Slime/SBCL to recognize quicklisp packages

I am trying to get Emacs, SLIME and quicklisp to work together properly. I have the following environment set up:

  • Installed Emacs
  • Installed SLIME in Emacs
  • Installed SBCL
  • Installed quicklisp
  • Run (quicklisp-quickstart:install) in SBCL
  • Run (ql:add-to-init-file) in SBCL
  • Run (ql:quickload "quicklisp-slime-helper") in SBCL
  • Installed package cl-csv using (ql:quickload "cl-csv") in SBCL
  • Added (setq inferior-lisp-program "sbcl") to .emacs
  • Added (load (expand-file-name "~/quicklisp/slime-helper.el")) to .emacs
  • Restarted everything

I have a test.lisp file that starts with (ql:quickload "cl-csv") to load the package and use it. When I load the file into Emacs and run SLIME, then try to compile it using slime-compile-and-load-file, I get the error in SBCL that Package CL-CSV does not exist.

What have I missed to get these pieces working together properly?

like image 640
Ana Avatar asked Oct 07 '15 23:10

Ana


1 Answers

If you compile a file which contains a statement

(ql:quickload "cl-csv")

then this call will be compiled, but not executed. That's what a compiler usually does: it compiles, but does not execute. Thus if you use some Lisp package (a namespace) later in the same file - a package which would be introduced in the system cl-csv - then it might not be present, if you have not loaded it before, by loading the system.

There are two typical solutions to this:

  • put the loading command in a file which one compiles (optionally) and/or loads before
  • use EVAL-WHEN with :compile-toplevel, :load-toplevel and :execute

Note that cl-csv is a system, organizing source files. A package is a Lisp namespace for organizing Lisp symbols. A package and a system can have the same name, but they really are two different things.

like image 181
Rainer Joswig Avatar answered Sep 27 '22 23:09

Rainer Joswig