Hacker News new | ask | show | jobs
by creese 2055 days ago
I've found I can get the same tight feedback loop at least for the times where the code will not compile. I use Cargo mode and an after-save hook so that each save runs `cargo check` and, on success, also runs `cargo fmt`. A nice side effect is that I don't need to care about formatting any more.

  (defun cargo-process-check-sentinel (process event)
    (when (string= "finished\n" event)
      (rust-format-buffer)))

  (defun my-after-save-hook ()
    (when (eq major-mode 'rust-mode)
      (set-process-sentinel (cargo-process-check) 'cargo-process-check-sentinel)))

  (add-hook 'after-save-hook #'my-after-save-hook)