4

Having used clang-format to format the buffer when saving, I find this functionality useful.

Are there tools to reformat an Elisp buffer when saving?

Drew
  • 75,699
  • 9
  • 109
  • 225
ideasman42
  • 8,375
  • 1
  • 28
  • 105
  • Here's what my search engine results turned up: https://emacs.stackexchange.com/questions/283/command-that-formats-prettifies-elisp-code and https://www.emacswiki.org/emacs/ElispFormat and https://www.emacswiki.org/emacs/elisp-format.el – Lorem Ipsum Dec 03 '19 at 14:45
  • I'm aware multiple tools for this exist which can probably be configured to format on save, I'm just not sure if any are very useful in practice, I tested `elisp-format` package which heavily indented my code ignoring it's own column width setting. And lispy looks like it can toggle between single/multi-line, but doesn't auto-format unless I missed something. – ideasman42 Dec 03 '19 at 15:37

1 Answers1

2

Since asking this question I've written an auto-formatter that runs on save.

Other elisp formatting tools I found caused a *lot* of right-shift and didn't seem well maintained.

See: elisp-autofmt.

This can be configured to run for some projects and not others. While this runs on save, it first checks for .elisp-autofmt before re-formatting the buffer.


See other auto-formatting tools for reference.

ideasman42
  • 8,375
  • 1
  • 28
  • 105