[graphics/krita] /: Add guidelines about formatting lambdas in Krita's source tree

Wolthera van Hövell null at kde.org
Thu Feb 6 17:07:03 GMT 2025


Git commit 442f669f25383c957225b2199de7946e022e3c5c by Wolthera van Hövell, on behalf of Dmitry Kazakov.
Committed on 06/02/2025 at 16:56.
Pushed by woltherav into branch 'master'.

Add guidelines about formatting lambdas in Krita's source tree

CC:kimageshop at kde.org

M  +7    -0    .clang-format
M  +14   -0    HACKING

https://invent.kde.org/graphics/krita/-/commit/442f669f25383c957225b2199de7946e022e3c5c

diff --git a/.clang-format b/.clang-format
index 0c76379203b..4b870ca86a3 100644
--- a/.clang-format
+++ b/.clang-format
@@ -77,6 +77,10 @@ KeepEmptyLinesAtTheStartOfBlocks: false
 # no namespace indentation to keep indent level low
 NamespaceIndentation: None
 
+# Automatically add a comment with the namespace name at the closing
+# bracket of the namespace
+FixNamespaceComments: true
+
 # we use template< without space.
 SpaceAfterTemplateKeyword: false
 
@@ -89,6 +93,9 @@ ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMA
 # keep lambda formatting multi-line if not empty
 AllowShortLambdasOnASingleLine: Empty
 
+# Align limbdas against their signature lines
+LambdaBodyIndentation: Signature
+
 # We do not want clang-format to put all arguments on a new line
 AllowAllArgumentsOnNextLine: false
 
diff --git a/HACKING b/HACKING
index cdc6cce0a3e..379c5c7b4d9 100644
--- a/HACKING
+++ b/HACKING
@@ -57,6 +57,20 @@ Indentation
     With four spaces. Use the default kdelibs indentation 
     (http://techbase.kde.org/Policies/Kdelibs_Coding_Style)
 
+Indentation of Lambdas
+
+    For indentation of lambdas refer to the `LambdaBodyIndentation: Signature` method used
+    by clang-format, i.e. "align lambda body relative to the lambda signature"
+
+    someMethod(
+        [](SomeReallyLongLambdaSignatureArgument foo) {
+            return;
+        });
+
+    You can use automated "Format Selection" actions of QtCreator and VSCode to format
+    lambdas. They will user the necessary settings from .clang-format file present in
+    the Krita's source tree.
+
 Includes
 
     Avoid as much as possible #includes in header files; use forward declarations



More information about the kimageshop mailing list