elixir-editors / emacs-elixir

Emacs major mode for Elixir
446 stars 94 forks source link

Delete -emacs-elixir-format files when elixir-format is called uninteractively #498

Closed J3RN closed 1 year ago

J3RN commented 1 year ago

Fixes #497

My theory for why these files are left behind when using the hook is the error call in elixir-format--failed-to-format. Per the Emacs documentation:

Error processing normally aborts all or part of the running program and returns to a point that is set up to handle the error.

When elixir-format is called interactively, the error call in elixir-format--failed-to-format function is not invoked, which explains why the files are not left behind in that case.

My fix here was just to wrap the piece that sometimes errors in an unwind-protect and have (delete-file ...) and (kill-buffer ...) as unwind forms.