git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/3] clang-format: align consecutive macro definitions

From
Kyle Lippincott <spectral@google.com>
Date
Oct 14, 2024, 21:12 UTC
Message-ID
<CAO_smVhS8zw_Hk1OrsTg==4spziQOiQtOt+Hg8x-rEQVR+66rw@mail.gmail.com>
In-Reply-To
<1586d5376915a4662c92b8c0881596952c4500bb.1728697428.git.karthik.188@gmail.com>
On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:
Show 7 quoted lines
>
> We generally align consecutive macro definitions for better readability:
>
>   #define OUTPUT_ANNOTATE_COMPAT      (1U<<0)
>   #define OUTPUT_LONG_OBJECT_NAME     (1U<<1)
>   #define OUTPUT_RAW_TIMESTAMP        (1U<<2)
>   #define OUTPUT_PORCELAIN            (1U<<3)

I like this change, thanks. Is there a way of apply clang-format for *only* one rule/aspect? i.e. can we apply *only* this, and preserve every other line? At first glance, I don't see a way of doing it. If there was, I might recommend a whole series just to applying these changes, but with how out of compliance much of the codebase is today, that's not going to be feasible; we'd need to format it in a way that we might not want (the current style), and then fix it, and that seems counterproductive.

Show 32 quoted lines
>
> over
>
>   #define OUTPUT_ANNOTATE_COMPAT (1U<<0)
>   #define OUTPUT_LONG_OBJECT_NAME (1U<<1)
>   #define OUTPUT_RAW_TIMESTAMP (1U<<2)
>   #define OUTPUT_PORCELAIN (1U<<3)
>
> So let's add the rule in clang-format to follow this.
>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
>  .clang-format | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/.clang-format b/.clang-format
> index 66a2360ae5..9547fe1b77 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -32,6 +32,9 @@ AlignConsecutiveAssignments: false
>  # double b = 3.14;
>  AlignConsecutiveDeclarations: false
>
> +# Align consecutive macro definitions.
> +AlignConsecutiveMacros: true
> +
>  # Align escaped newlines as far left as possible
>  # #define A   \
>  #   int aaaa; \
> --
> 2.47.0
>
Previous: Karthik NayakNext: karthik nayak
Message 20 of 34 in “clang-format: fix rules to make the CI job cleaner”
  1. 0/3 clang-format: fix rules to make the CI job cleanerKarthik Nayak, Oct 9, 2024
  2. 1/3 clang-format: don't enforce the column limitKarthik Nayak, Oct 9, 2024
  3. Justin ToblerOct 9, 2024
  4. Junio C HamanoOct 9, 2024
  5. karthik nayakOct 10, 2024
  6. 2/3 clang-format: don't align expressions after linebreaksKarthik Nayak, Oct 9, 2024
  7. 3/3 clang-format: align consecutive macro definitionsKarthik Nayak, Oct 9, 2024
  8. Toon ClaesOct 10, 2024
  9. 0/3 clang-format: fix rules to make the CI job cleanerKarthik Nayak, Oct 12, 2024
  10. 1/3 clang-format: re-adjust line break penaltiesKarthik Nayak, Oct 12, 2024
  11. Toon ClaesOct 14, 2024
  12. Taylor BlauOct 14, 2024
  13. karthik nayakOct 15, 2024
  14. karthik nayakOct 15, 2024
  15. Kyle LippincottOct 14, 2024
  16. karthik nayakOct 15, 2024
  17. Kyle LippincottOct 16, 2024
  18. karthik nayakOct 16, 2024
  19. 2/3 clang-format: align consecutive macro definitionsKarthik Nayak, Oct 12, 2024
  20. Kyle LippincottOct 14, 2024
  21. karthik nayakOct 15, 2024
  22. 3/3 clang-format: don't align expressions after linebreaksKarthik Nayak, Oct 12, 2024
  23. Kyle LippincottOct 14, 2024
  24. karthik nayakOct 15, 2024
  25. 0/2 Subject: clang-format: fix rules to make the CI job cleanerKarthik Nayak, Oct 18, 2024
  26. 1/2 clang-format: re-adjust line break penaltiesKarthik Nayak, Oct 18, 2024
  27. Justin ToblerOct 25, 2024
  28. karthik nayakOct 25, 2024
  29. 2/2 clang-format: align consecutive macro definitionsKarthik Nayak, Oct 18, 2024
  30. Taylor BlauOct 18, 2024
  31. karthik nayakOct 20, 2024
  32. Taylor BlauOct 21, 2024
  33. karthik nayakOct 22, 2024
  34. Taylor BlauOct 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.