tpapp / trivial-project-pathname

A very simple Common Lisp library for resolving pathnames relative to some directory, usually the sources.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IMPORTANT This library is abandonned.

A very simple Common Lisp library for resolving pathnames relative to some directory, usually the sources.

The typical use case looks like this: I am working on, say, some data analysis and I have the following directory structure:

data/where data files are kept
latex/LaTeX sources
lisp/Common Lisp code, including ASDF system definition
plots/plots (potentially generated from Lisp)

I want to be able to write something like

(analyze-data-and-save-plot (project-path "mydata.csv" :data)
                            (project-path "myplot.pdf" :plots))

and have the data read from data/mydata.csv and the plot saved to plots/myplot.pdf.

This is how I would do it using this library:

(project-pathname:define project-path (:asdf "myproject" :up)
  (:data "data")
  (:plots "plots"))

This finds the directory for the .asd file, takes its parent directory, and then defines a function that maps symbols to subdirectories.

Unless otherwise specified, NIL, the default for the optional parameter, would map to the base directory. You don’t even need to use subdirectories, you can just

(project-pathname:define project-path2 (:asdf "myproject"))
;;; and then use
(project-path2 "my-data-file.csv")

See the docstrings for alternatives to :asdf if you have some other way of establishing the base directory (look for :directory, :as-directory and :directory-of).

About

A very simple Common Lisp library for resolving pathnames relative to some directory, usually the sources.


Languages

Language:Common Lisp 100.0%