clang-format

6 views
Skip to first unread message

Elliott Hughes

unread,
Aug 12, 2018, 3:27:13 PM8/12/18
to evergre...@googlegroups.com
for those who aren't reading all the checkin comments -- is there even a way to get them mailed to you from github? -- note that although i didn't _say_ so, i did actually finish the "clang-format on save" stuff the other week. there's a new option in the preferences dialog.

note also that clang-format supports C/C++/Java/JavaScript/Objective-C/Protobuf, not just C/C++.

i'm enjoying it greatly for stuff i'm just dicking about with at home, but haven't turned it on at work or for the jessies.org projects because i only implemented it with file scope, so unless you submit a "reformat the world" change (which upsets the history) any real change you make is lost in a sea of reformatting (because realistically you're a lot further from canonical style than you think you are).

we could add clang-format-diff (https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting) support to checkintool. (this is effectively what i have at work via a presubmit hook.)

i've also wondered how well clang-format --lines= would work as an indenter if we called it to reformat just the previous+current+next line each time enter is hit. (would potentially let us move closer to the original "we rely on external tools to do most things" style, though i think we'd still need enough intelligence to choose a reasonable scope. it's a pity we can't tell clang-format "reformat the logical line that contains the physical line N")

or there's the easy cop-out option of a command to clang-format the selection, but i suspect that the act of selection would be annoying enough that i'd never use it.

--

Martin Dorey

unread,
Sep 28, 2018, 10:13:30 PM9/28/18
to Evergreen Users
I'd hoped to get away with this:


I think that would have gone under the radar but it wasn't enough, so I did:


I fear Elliott will notice that, so I'll ask forgiveness now.

--
You received this message because you are subscribed to the Google Groups "evergreen-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to evergreen-use...@googlegroups.com.
To post to this group, send email to evergre...@googlegroups.com.
Visit this group at https://groups.google.com/group/evergreen-users.
For more options, visit https://groups.google.com/d/optout.

Elliott Hughes

unread,
Oct 6, 2018, 10:11:59 PM10/6/18
to evergre...@googlegroups.com
unless i'm missing something, i don't _think_ i care? i'll always have a new enough clang-format anyway, without specifying an explicit version, and this might mean it works for folks stuck in the past?

Martin Dorey

unread,
Oct 7, 2018, 7:24:30 PM10/7/18
to Evergreen Users
> i don't _think_ i care?

It won't actively hurt you but your effort to make clang-format work for others might not work, even if they're living in the present.

> this might mean it works for folks stuck in the past?

This keeps it installable for folks stuck in the past, but it doesn't help the clang-format invocation to work.  The clang-format-3.8 package, for example, doesn't install anything called clang-format, which is what our code seems to invoke.

Elliott Hughes

unread,
Oct 8, 2018, 12:53:59 AM10/8/18
to evergre...@googlegroups.com
On Sun, Oct 7, 2018 at 4:24 PM Martin Dorey <marti...@gmail.com> wrote:
> i don't _think_ i care?

It won't actively hurt you but your effort to make clang-format work for others might not work, even if they're living in the present.

> this might mean it works for folks stuck in the past?

This keeps it installable for folks stuck in the past, but it doesn't help the clang-format invocation to work.  The clang-format-3.8 package, for example, doesn't install anything called clang-format, which is what our code seems to invoke.

huh. i didn't actually look that far. i saw https://packages.debian.org/search?keywords=clang-format and inferred "oh, clang-format means 3.8 on stretch and 6.0 on buster/side and 7.0 on experimental".


i think `clang-format` itself is just a symlink on debian/ubuntu...

t520:~$ ls -l /usr/bin/clang-format
lrwxrwxrwx 1 root root 16 May 16 09:07 /usr/bin/clang-format -> clang-format-6.0

hopefully at some point i'll have the time to write proper clangd support and give the rest of you some more motivation. (though i have to say that just `clang-format` has changed the way i work... i basically ignore formatting now and just let it fix itself when i save. obviously this doesn't work as well for non-new code.)

Martin Dorey

unread,
Oct 8, 2018, 1:05:10 AM10/8/18
to evergre...@googlegroups.com
martind@swiftboat:~$ dpkg --status clang-format-3.8 | grep Status
Status: install ok installed
martind@swiftboat:~$ clang-format
-bash: clang-format: command not found
martind@swiftboat:~$

I'm sure there's a binary in there but installing the package doesn't create the symlink, not in the old version.  In Stretch, I imagine the symlink is in:


I'm sure this automatic formatting is great.  I might even get around to creating my own symlink to try it.
Reply all
Reply to author
Forward
0 new messages