exupero's blog

Clojure scratch files

Last year I wrote about a script I use to start a Babashka nREPL and open Neovim to a temporary Clojure file. That's good enough for quick, relatively trivial experiments, but often investigations require more than a trivial amount of work and produce code I want to refer back to. While my operating system doesn't actually delete temporary files immediately, finding one again, even immediately after using it, was a nuisance. Thus, instead having quickbb use temp files, I've updated it to create a timestamped file in a particular directory:

nvim +'set ft=clojure' $SCRATCH_FILES/$(date +"%Y-%m-%dT%H-%M-%S%z.clj")

My $SCRATCH_FILES folder has been a valuable place to search when I know I've written some code before but can't remember exactly how or why. Timestamping the files allows me to cross-reference code with my work notes, letting me find the concrete implementation of something mentioned in my log, or look up additional context for why I wrote a particular piece of code.

I seem to recall Stuart Holloway talking about an Emacs buffer he has where he drafts Clojure code and which therefore contains the essence of all the Clojure he's written, all in one place and easily searched. If you know where he talks about this, please email me.

If you have a similar setup, or improvements to suggest, let me know.