Create small Common Lips projects with cl-project
Quicklisp
Quicklisp is a library manager for Common Lisp. You use it to automatic download, install, and load Common Lisp libraries.
Installing Quicklisp is one of the first things you do after having installed your Common Lisp environment, like SBCL, Clisp, or CCL. See the Quicklisp home page how to install Quicklisp.
Local projects
The Quicklisp installation creates a directory-tree
$HOME/quicklisp/
. Here you find a sub-directory
$HOME/quicklisp/local-projects
for your personal projects.
Configure asdf to discover your local projects
To let asdf discover your local projects, you have to let it know the location of these projects.
For this, we create a small config file under the path
~/.config/common-lisp/source-registry.conf.d
:
mkdir -p ~/.config/common-lisp/source-registry.conf.d
$EDITOR ~/.config/common-lisp/source-registry.conf.d/my-lisp.conf
Add the following line in this conf-file:
(:tree "/home/<username>/quicklisp/local-projects/")
where you replace username with your local username.
Install cl-project
Start your Common Lisp to open the REPL. Next, install cl-project with:
(ql:quickload "cl-project")
Create a new project
Create a new project, using cl-project. You must provide the path for the project, other parameters are optional. Don't forget to load cl-project first.
(ql:quickload "cl-project")
(cl-project:make-project #P"~/quicklisp/local-projects/my-awesome-project")
This will create the sub directory ~/quicklisp/local-projects/my-awesome-project
and fill it with a skeleton:
my-awesome-project/
├── .gitignore
├── README.markdown
├── README.org
├── my-awesome-project.asd
├── src
│ └── main.lisp
└── tests
└── main.lisp
The files are pre-filled with some content, like a few headers in the two README files, and a asdf-setup in the asd-file. Just add the dependencies and you are ready to go.
The main.lisp file has also some lines in it, to define the package and the in-package command.
The .gitignore file is already filled, if you create a git-repo in the my-awesome-project directory, you just have to git add and commit the .gitignore file.
Extra parameters for cl-project
In the above example, we only added the path to the project. You can add more parameters, like:
:version <version-number>
:author your name
:license your-licence
- and so on. See the cl-project documentation.
If you don't want a test directory setup, add :without-tests t
.
Building the project
In Emacs, open the main.lisp file and start SLIME. SLIME will give you a window for your REPL.
Because of your config file in ```~/.config/common-lisp/source-registry.conf.d/''' you can just load your project as a Quicklisp library. In the REPL window, issue the commands:
(ql:quickload "my-awesome-project")
(in-package :my-awesome-project)
Add some code in the main.lisp file.
In the main.lisp buffer, hit ```C-c C-k''' to compile your code. In the REPL-buffer, you can now test your functions, read the values of variables, and so on.
Happy Lisping!
Made with ♥ by a human - Proud member of the 250kb.club.
Most recent pages
All tags
Sitemap
RSS
RSS of Gophersite