This week I continue with bits of emacs puttering during spare bits of time. Each day, I progressively add a bit more to my personal config, picking and choosing pieces of what I want from Doom-Emacs. I haven't gotten to a point where I'm really making my own customizations — but today I had a small realization that delighted me.

As I putter away on my static site generator for this obsidian vault, I have to do the same commands over and over to test as I develop. And while there is no Rust-Repl, developing has become pretty quick. Since I'm still developing in Doom emacs while I build my other config, here's what I currently do:

  1. Make a change in the rust codebase
  2. recompile the program by pressing SPC m b to run cargo build
  3. open my terminal and run rm -rf ~/Sync/notes/_esker/ to remove the previous site that I generated
  4. run target/debug/esker new -d ~/Sync/notes/ to create a new site
  5. run **target/debug/esker build -d ~/Sync/notes/ to buidl the site
  6. inspect how things are looking in a simple http-server for the files.

I try not to introduce any automation into a project until I see I'm doing the same commands again and again. So, after a few separate sessions of working on the program I realized it was time to automate that (and while the current process was pretty fast, it was still getting a bit annoying).

First, I set about creating a makefile that would do each of the individual pieces; then I remembered you can send strings to the shell, and wouldn't it be great to bind a single key command to do steps 1-5?.

So here's my simple solution: I have a make command [^1] that runs steps 1-5, and then I add this to my project directory (and add it to .gitignore):

;;; .bindings.el
 :states '(normal visual) :prefix "SPC"
 ;; top level
 "J" '(:ignore :which-key "Project specific bindings")
 "J j" #'(lambda () (interactive) (shell-command "make wt"))

Now, when I'm developing the project, I evaluate the buffer [^2] above and can then press SPC J j to do… everything for me!

And while this isn't anything particularly interesting, it is a small quality of life improvement that delights me! Things like this also make working with a compiled language so much faster.


[^1]: I also realize that I could just run all the commands directly from emacs, and don't even need a make file.

[^2]: I'm pretty sure I can use a .dir-locals file, although I couldn't quite find a straight answer on how to setup keybindings using it. So, I opted for the simple solution of just evaluating the buffer when I have the project open.