Search code examples
common-lispsbcl

How to permanently save a macro in LISP (sbcl)


Lets say i define a macro

(defmacro foo(x)
    (print x))

Now i want to be able to always load this macro in all my lisp files in future where should i save this macro?


Solution

  • Every CL implementation has an init file it calls on start. For SBCL that is ~/.sbclrc. Usually also quicklisp has some setup code in there if you installed quicklisp.

    So you could add a line:

    (load #P"path/to/your/macro/file.lisp")
    

    And it'll get loaded each time you start SBCL.