[cmake-developers] Code style auto-formatting
Daniel Pfeifer
daniel at pfeifer-mail.de
Mon May 9 13:48:16 EDT 2016
On Mon, May 9, 2016 at 11:14 AM, Brad King <brad.king at kitware.com> wrote:
> On 05/02/2016 10:08 AM, Brad King wrote:
>> Next I'll look at the style updates themselves.
>
> I've made some more preparatory commits:
>
> Isolate formatted streaming blocks with clang-format off/on
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64b55203
>
> Move comments off of class access specifier lines
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=85425a3e
>
> Help clang-format wrap after braces on long initializer lists
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afca3735
>
> Remove `//------...` horizontal separator comments
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ac18d40
>
> These changes improve the formatting output in some local
> experiments.
>
> With the earlier changes to the #include order we no longer need
> to use any custom `IncludeCategories`.
>
> Here is the `.clang-format` file I'd like to use:
>
> ---
> # This configuration requires clang-format 3.8 or higher.
> BasedOnStyle: Mozilla
> AlignOperands: false
> AllowShortFunctionsOnASingleLine: Inline
> AlwaysBreakAfterReturnType: None
> AlwaysBreakAfterDefinitionReturnType: None
> ColumnLimit: 79
> IndentCaseLabels: false
> Standard: Cpp03
> ...
>
"AllowShortFunctionsOnASingleLine: Inline" is default in the Mozilla
preset. This line can be removed.
What is your rationale for "IndentCaseLabels: false"? I find that
indenting them increases readability when switch statements use
hanging braces. If the opening "{" is on a separate line, indenting
the labels does not improve readability that much.
What is the rationale for "ColumnLimit: 79"? To make a line fit on old
school terminals, 80 should be OK. To make a diff or an email response
fit on old school terminals, two extra spaces are reserved. That leads
to a column limit of 78. Where does 79 come from?
More information about the cmake-developers
mailing list