Commit 2e41b805bdf4a6a89bc103f9aeb98ab513193754
1 parent
77e88949
Update TODO with additional notes
Showing
1 changed file
with
38 additions
and
19 deletions
TODO
| @@ -41,37 +41,56 @@ Soon: Break ground on "Document-level work" | @@ -41,37 +41,56 @@ Soon: Break ground on "Document-level work" | ||
| 41 | Code Formatting | 41 | Code Formatting |
| 42 | =============== | 42 | =============== |
| 43 | 43 | ||
| 44 | -Use clang-format-15. | ||
| 45 | - | ||
| 46 | -* Put a .clang-format at the top of the repository -- see below for content. | ||
| 47 | -* Reformat all files: | ||
| 48 | - | ||
| 49 | - for i in **/*.cc **/*.c **/*.h **/*.hh; do | ||
| 50 | - clang-format < $i >| $i.new && mv $i.new $i | ||
| 51 | - done | ||
| 52 | - | ||
| 53 | -* Carefully inspect the diff. There are some places where a comment to | ||
| 54 | - force a line break might be in order. Document use of // line-break | 44 | +Document about code formatting: |
| 55 | 45 | ||
| 46 | +* Use clang-format-15. | ||
| 56 | * Update README-maintainer about formatting. Mention | 47 | * Update README-maintainer about formatting. Mention |
| 57 | 48 | ||
| 58 | // clang-format off | 49 | // clang-format off |
| 59 | // clang-format on | 50 | // clang-format on |
| 60 | 51 | ||
| 61 | - as well as the use of a comment to force a line break. | 52 | + as well as the use of a comment to force a line break. Convention: |
| 53 | + // line-break | ||
| 54 | + | ||
| 55 | +* .dir-locals.el -- most of the time, emacs's formatting agrees with | ||
| 56 | + clang-format. When they differ, clang-format is authoritative. | ||
| 57 | + Significant differences: | ||
| 58 | + * clang-format-15 bug that when | ||
| 59 | + | ||
| 60 | + type function(args) | ||
| 62 | 61 | ||
| 63 | -https://clang.llvm.org/docs/ClangFormatStyleOptions.html | 62 | + is longer than 80 characters, the continuation line rule takes |
| 63 | + precedence over the break after type rule and the function ends | ||
| 64 | + getting intended. (Find an example and report.) | ||
| 65 | + * Emacs doesn't indent breaking strings concatenated with + over | ||
| 66 | + lines but clang-format does. It's clearer with clang-format. To | ||
| 67 | + get emacs and clang-format to agree, parenthesize the expression | ||
| 68 | + that builds the concatenated string. | ||
| 69 | + * With | ||
| 64 | 70 | ||
| 65 | -Remaining work: | 71 | + long_function(long_function( |
| 72 | + args) | ||
| 66 | 73 | ||
| 67 | -* Document .dir-locals.el and how it's close but not perfect | 74 | + clang-format anchors relative to the first function, and emacs |
| 75 | + anchors relative to the second function. Use | ||
| 76 | + | ||
| 77 | + long_function( | ||
| 78 | + // line-break | ||
| 79 | + long_function( | ||
| 80 | + args) | ||
| 81 | + | ||
| 82 | + to resolve. | ||
| 68 | * Consider blame.ignoreRevsFile if it seems to help | 83 | * Consider blame.ignoreRevsFile if it seems to help |
| 69 | -* Add a `make format` similar to `make spell` (or whatever this ends | ||
| 70 | - up being with cmake) | 84 | +* Add a script to format the code. |
| 85 | + | ||
| 86 | + for i in **/*.cc **/*.c **/*.h **/*.hh; do | ||
| 87 | + clang-format < $i >| $i.new && mv $i.new $i | ||
| 88 | + done | ||
| 89 | + | ||
| 71 | * Consider a github action to check formatting. I don't want | 90 | * Consider a github action to check formatting. I don't want |
| 72 | formatting failures to prevent all the tests from being run. | 91 | formatting failures to prevent all the tests from being run. |
| 73 | - Alternatively, add running `make format` as a release preparation | ||
| 74 | - check like `make spell`. | 92 | + Alternatively, add running the format script as a release |
| 93 | + preparation check like running the spell checker. | ||
| 75 | 94 | ||
| 76 | cmake | 95 | cmake |
| 77 | ===== | 96 | ===== |