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

[PATCH v2 2/3] clang-format: don't align expressions after linebreaks

From
Karthik Nayak <karthik.188@gmail.com>
Date
Oct 10, 2024, 17:59 UTC
Message-ID
<b55d5d2c14142fddad0b5bb84f41dd1c4eb6397a.1728582927.git.karthik.188@gmail.com>
In-Reply-To
<cover.1728582927.git.karthik.188@gmail.com>

We enforce alignment of expressions after linebreaks. Which means for code such as

    return a || b;
it will expect:
   return a ||
          b;

we instead want 'b' to be indent with tabs, which is already done by the 'ContinuationIndentWidth' variable. So let's explicitly set 'AlignOperands' to false.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 .clang-format | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/.clang-format b/.clang-format
index 684ab32d28..d655b08ff6 100644
--- a/.clang-format
+++ b/.clang-format
@@ -42,10 +42,9 @@ AlignConsecutiveDeclarations: false
 #   int cccccccc;
 AlignEscapedNewlines: Left
 
-# Align operands of binary and ternary expressions
-# int aaa = bbbbbbbbbbb +
-#           cccccc;
-AlignOperands: true
+# Don't enforce alignment after linebreaks and instead
+# rely on the ContinuationIndentWidth value.
+AlignOperands: false
 
 # Don't align trailing comments
 # int a; // Comment a
-- 
2.47.0
Previous: Kyle LippincottNext: Karthik Nayak
Message 6 of 7 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 10, 2024
  2. 1/3 clang-format: change column limit to 96 charactersKarthik Nayak, Oct 10, 2024
  3. Kyle LippincottOct 10, 2024
  4. karthik nayakOct 10, 2024
  5. Kyle LippincottOct 10, 2024
  6. 2/3 clang-format: don't align expressions after linebreaksKarthik Nayak, Oct 10, 2024
  7. 3/3 clang-format: align consecutive macro definitionsKarthik Nayak, Oct 10, 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.