public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: Proposal: format GDB Python files with black
Date: Sat, 08 May 2021 10:00:31 -0600	[thread overview]
Message-ID: <87lf8p9pwg.fsf@tromey.com> (raw)
In-Reply-To: <a2621b82-48a4-9e4e-836b-9989c2c6b7a5@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Mon, 26 Apr 2021 11:55:21 -0400")

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> A few people I talked to about this and I have good experience
Simon> with the tool black to auto-format Python code.

Inspired by this, I took another look at clang-format.  If we could use
this, I think it would be a decent productivity improvement, because it
would mean contributors would no longer need to worry about the minutiae
of the GNU style.  We could also stop reviewing this.

My github has my current hacks, on the t/clang-format branch.  This
branch just has .clang-format, I didn't reformat the sources.  I'm using
clang-format 10.0.1.

I managed to tweak the penalty values in the format to avoid the
bin-packing problem I was seeing previously.  I haven't extensively
tested this (I usually only reformat gdb_bfd.c and look at it, since it
exercised several bugs before...), so I recommend that others play with
it a bit.

I did see a few issues, though perhaps they are minor.

1. It removes all the Control-L page breaks from the source.
   I know these often confuse newcomers, so maybe it's fine.
   I feel that Someone out there will cheer this :)

2. clang-format can't handle GNU-style goto label out-denting.
   There's a clang-format bug on this topic
   https://bugs.llvm.org/show_bug.cgi?id=24118

3. In gdb if we have a large 'if' condition that consists of expression
   chained with "&&" or "||", we often put each sub-condition on its own
   line.  clang-format packs them instead, and I didn't see a way to
   counteract this.

4. Gettext invocations like _("text") have a space added, like _ ("text").
   I didn't see a way to change this.

Another possible problem is that, unlike with 'black', ensuring that
everyone has the same version is a pain.

Maybe we could live with these?  Let me know what you think.
I can continue my experiments if this seems worthwhile.

Tom

  parent reply	other threads:[~2021-05-08 16:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 15:55 Simon Marchi
2021-04-26 16:21 ` Andrew Burgess
2021-04-26 17:25   ` Simon Marchi
2021-04-26 17:50     ` Andrew Burgess
2021-04-26 18:08       ` Simon Marchi
2021-04-27  7:54         ` Andrew Burgess
2021-04-27 13:21           ` Simon Marchi
2021-04-26 17:42   ` Tom Tromey
2021-04-26 17:34 ` Paul Koning
2021-04-26 17:44   ` Simon Marchi
2021-04-26 17:48     ` Simon Marchi
2021-04-26 17:39 ` Tom Tromey
2021-04-30 16:26   ` Joel Brobecker
2021-04-26 22:40 ` Lancelot SIX
2021-04-30 17:04   ` Tom Tromey
2021-04-30 17:14     ` Simon Marchi
2021-05-01  6:42       ` Joel Brobecker
2021-04-30 17:21 ` Luis Machado
2021-05-08 16:00 ` Tom Tromey [this message]
2021-05-11  2:55   ` Simon Marchi
2021-05-11  2:57     ` Using clang-format Simon Marchi
2021-05-11 13:31       ` Marco Barisione
2021-05-11 13:44         ` Simon Marchi
2021-05-11 20:40       ` Tom Tromey
2021-05-13 17:13         ` Simon Marchi
2021-05-11 11:38     ` Proposal: format GDB Python files with black Luis Machado
2021-05-11 13:49       ` Simon Marchi
2021-05-11 14:23         ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lf8p9pwg.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).