I've started to write a package and excessive use of the interactive eval-* functions has become a pain point for me.

After I make a change re-evaluating entire file or package is almost always appropriate. eval-buffer is usually sufficient and usually what I run.

Since I'm an emacser with the C-x C-s Tourette-esque tic eval'ing the buffer would be something I'd like to happen automatically on save. I'm writing elisp, but I can imagine other circumstances where the same workflow would be useful. Eval'ing the entire project (i.e. (require 'my-package)) would often also be sufficient in cases that the package is in load-path.

I've started to use .dir-locals.el files in these projects which add a buffer-local after-save-hook:

   (eval add-hook 'before-save-hook 'eval-buffer nil t)))

What would be a better way to accommodate this sort of workflow / What other ways have people implemented this workflow?

I'm wishing there's something in the realm of zero-configuration "Do what I mean" to figure out / track which projects/directories/files I want eval'd on save and do it. I happen to use projectile, but am still curious about broader possibilities which may or may not be usable with projectile.

A few thoughts:

  • If you're hitting C-x C-s constantly, surely auto-eval-on-save is a really bad idea? You want to eval when the code is good, not just whenever an instinctive habit kicks in. – phils May 17 '16 at 21:53
  • 1
    @phils Not a concern. My code is always correct. Backspace and delete are remapped as additional modifiers. – ebpa May 17 '16 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.