SavchenkoValeriy/emacs-clang-format-plus

Only perform formatting when there is a .clang-format file?

Closed this issue · 1 comments

Thanks for writing this package!

Earlier this summer I looked for an Emacs mode that runs clang-format automatically but couldn't find one, so I wrote my own: https://github.com/jrosdahl/auto-clang-format. The main, and only, feature of my package (except for defining a minor mode) is that it only runs clang-format-buffer when there is a .clang-format file in the directory tree. The reason is that I want to be able to activate the mode unconditionally in e.g. c-mode-common-hook but only have it take effect in projects that have defined a format style. Adding .dir-locals.el files to the different projects does not feel like a very tasty solution to me (and it might not even be possible).

I submitted my package for inclusion in MELPA (melpa/melpa#6383), but I then happened to find your package so I hope that it would be possible to collaborate on this instead of maintaining my own package (although I like my package name more since it enables auto-formatting 🙂).

So, would you accept a pull request that adds the above mentioned behavior? If so, would you prefer it to be opt-in or opt-out? (Or if you want to implement it yourself, that would also be perfectly fine by me.)

Thank you for the detailed description :-) I think that is a good default behavior to have, so opt-in is good.
Collaboration on this package is very much appreciated, I received a couple of good feature ideas in the emacs subreddit and I’ll create issues for them, so we can work on those!