diff options
| author | Ellis KenyĆ <elken@users.noreply.github.com> | 2022-09-14 03:05:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-13 19:05:22 -0700 |
| commit | 9101a3380cb1a86e8bb78d80e716266b0a484c67 (patch) | |
| tree | f9bc07a958f466c341368f53695841048ed3a49d | |
| parent | e01ced3ac985eabd51dad348d04974cefa778625 (diff) | |
Assume filename correctly (#128)
Fixes #108
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | apheleia.el | 10 | ||||
| -rwxr-xr-x | test/formatters/apheleia-ft.el | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e89f92..e3addcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ The format is based on [Keep a Changelog]. correctly; it throws an error. It doesn't make sense to attempt to format if we can't find the correct formatter, so instead formatting is only attempted when the formatter is found. [#126] +* clang-format doesn't handle filenames correctly by default. Support + for guessing the flags from first the file name then the major mode + in the case of a temporary buffer was added in [#128] ### Formatters * [elm-format](https://github.com/avh4/elm-format) for Elm ([#100]). @@ -56,6 +59,7 @@ The format is based on [Keep a Changelog]. [#123]: https://github.com/radian-software/apheleia/issues/123 [#124]: https://github.com/radian-software/apheleia/issues/124 [#125]: https://github.com/radian-software/apheleia/pull/125 +[#126]: https://github.com/radian-software/apheleia/pull/126 [#127]: https://github.com/radian-software/apheleia/pull/127 [#128]: https://github.com/radian-software/apheleia/pull/128 diff --git a/apheleia.el b/apheleia.el index f9dbcc5..09cafa9 100644 --- a/apheleia.el +++ b/apheleia.el @@ -925,7 +925,15 @@ being run, for diagnostic purposes." '((bean-format . ("bean-format")) (black . ("black" "-")) (brittany . ("brittany")) - (clang-format . ("clang-format")) + (clang-format . ("clang-format" + "-assume-filename" + (or (buffer-file-name) + (cdr (assoc major-mode + '((c-mode . ".c") + (c++-mode . ".cpp") + (cuda-mode . ".cu") + (protobuf-mode . ".proto")))) + ".c"))) (dart-format . ("dart" "format")) (elm-format . ("elm-format" "--yes" "--stdin")) (fish-indent . ("fish_indent")) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index db2422b..b560441 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -271,7 +271,9 @@ environment variable, defaulting to all formatters." in-temp-file) (`output out-temp-file) - (_ arg))) + ((guard (stringp arg)) + arg) + (_ (eval arg)))) command)) (setq command (delq 'npx command)) (setq stdout-buffer (get-buffer-create |
