SLIME, Common Lisp, Conditionally Run Some Code on Startup
Problem: I wanted to do M-x slime-my-project and have slime start up and run some arbitrary setup code (related to the project at hand). Why perform automatable boilerplate, after all.
Exploration: I found slime-lisp-implementations which looked like a good approach. So I set up an entry for my-project, using SBCL and supplying an init-function. However, the init-function runs on the emacs/elisp side, not the CL (common lisp) side. I checked whether common lisp was readily callable from elisp, but didn’t find anything promising – I did find something to evaluate strings holding CL code, but thought there was bound to be a better approach.
Solution: After more insistent search, I happened across a mention of slime-load-file on stackoverflow. This meant I could set up:
(setq slime-lisp-implementations
'((sbcl
("sbcl"))
(my-project
("sbcl")
:init-function
(lambda ()
(slime-load-file "SOME-PATH/my-project-setup.lisp")))))
Which worked well for my purposes. Then later still I discovered that SBCL takes a –load argument, which would probably have worked just as well in the above setup.
Now I can M– M-x slime my-project. Cool.