On 3 July 2017 at 11:26, Jean-Marc Lasgouttes <lasgout...@lyx.org> wrote:

> Since we are approaching major release, I think it is a good time to do
> some mechanical clean-ups. The idea is that it is better to do it now
> instead of at the beginning of a cycle in order to ease backporting of
> patches to stable.
>

I posted what's below in a different thread, but it's better of here:

-----
If we're open to doing to some cleanup of the code I strongly suggest we
use a tool called 'clang-format' to automatically take care of code
formatting. I've introduced this tool at my work and it's _really_ nice to
not have to care about the formatting in most cases.  Tonight I'll create a
"format" file, ".clang-format", that attempts to replicate the formatting
style of the typical LyX code. If that goes well we can then discuss if it
makes sense to use/apply clang-format to the LyX source code. It might well
be that it results in too many changes for us to want to apply them.

Note: I have seen there's a config file for uncrustify in the repository,
but I got some error messages when trying to run uncrustify on the LyX
code.  Running clang-format on the LyX code works fine though. The
difficult part is tailoring the formatting rules to the current formatting
style to minimise the number of changes, and to avoid tedious discussions
about how the code ought to be formatted.

In case you're interested in clang-format, there's plenty of information
online. Chandler Carruth who leads the C++, Clang, and LLVM teams at
Google has a nice talk that includes a live demo of using clang-format in
this video: https://www.youtube.com/watch?v=cX_GhJ6BuWI. The demo starts as
about 29 minutes, but I'd suggest looking from 23 minutes. Fun detail:
Chandler references TeX and the issue of where to break lines, clang-format
needs to do something similar to the source code.
-----

Expanding on the above.
- IMHO it's really nice to use clang-format
- Now (before release) would be a good time to start using clang-format
- It has integrations for various IDEs and editors, but can also be run
from the command line.
- It's some work to start using it
  - Trying to replicate the "nominal" formatting style that the old code
uses.
     I will make an attempt here tonight.
  - Realising that a lot of the old code didn't actually use your nominal
formatting style.

And something really important.  I think Scott, as release manager, has
absolute power to veto the use of clang-format before a release. Or to
limit the extent to which it is used. Especially if a never-ending
discussion on code formatting starts...

Cheers,
Christian

Reply via email to