* [PATCH] clang-format: use git grep to generate the ForEachMacros list
@ 2019-06-03 22:48 Miguel Ojeda
2019-06-04 16:07 ` Johannes Schindelin
2019-06-05 20:20 ` Taylor Blau
0 siblings, 2 replies; 4+ messages in thread
From: Miguel Ojeda @ 2019-06-03 22:48 UTC (permalink / raw)
To: Git mailing list
Cc: Brandon Williams, Jonathan Nieder, Johannes Schindelin,
Stephan Beyer, Taylor Blau, Patryk Obara
The ForEachMacros list can reasonably be generated grepping
the C source code for macros with 'for_each' in their name.
Taken almost verbatim from the .clang-format file in the Linux kernel.
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
---
We wrote this for the Linux kernel a while ago, and it has been working
fine there, so I thought it would be nice to use the same approach here.
There are fancier ways of approaching this, of course.
.clang-format | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/.clang-format b/.clang-format
index 41d4cd23fd..c592dda681 100644
--- a/.clang-format
+++ b/.clang-format
@@ -148,8 +148,21 @@ SpacesInSquareBrackets: false
Cpp11BracedListStyle: false
# A list of macros that should be interpreted as foreach loops instead of as
-# function calls.
-ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut']
+# function calls. Taken from:
+# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \
+# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
+# | sort | uniq
+ForEachMacros:
+ - 'for_each_abbrev'
+ - 'for_each_builtin'
+ - 'for_each_string_list_item'
+ - 'for_each_ut'
+ - 'for_each_wanted_builtin'
+ - 'list_for_each'
+ - 'list_for_each_dir'
+ - 'list_for_each_prev'
+ - 'list_for_each_prev_safe'
+ - 'list_for_each_safe'
# The maximum number of consecutive empty lines to keep.
MaxEmptyLinesToKeep: 1
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list
2019-06-03 22:48 [PATCH] clang-format: use git grep to generate the ForEachMacros list Miguel Ojeda
@ 2019-06-04 16:07 ` Johannes Schindelin
2019-06-05 20:20 ` Taylor Blau
1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2019-06-04 16:07 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Git mailing list, Brandon Williams, Jonathan Nieder,
Stephan Beyer, Taylor Blau, Patryk Obara
Hi Miguel,
On Tue, 4 Jun 2019, Miguel Ojeda wrote:
> The ForEachMacros list can reasonably be generated grepping
> the C source code for macros with 'for_each' in their name.
>
> Taken almost verbatim from the .clang-format file in the Linux kernel.
>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> ---
> We wrote this for the Linux kernel a while ago, and it has been working
> fine there, so I thought it would be nice to use the same approach here.
Makes sense to me!
Thanks,
Johannes
> .clang-format | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/.clang-format b/.clang-format
> index 41d4cd23fd..c592dda681 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -148,8 +148,21 @@ SpacesInSquareBrackets: false
> Cpp11BracedListStyle: false
>
> # A list of macros that should be interpreted as foreach loops instead of as
> -# function calls.
> -ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut']
> +# function calls. Taken from:
> +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \
> +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
> +# | sort | uniq
> +ForEachMacros:
> + - 'for_each_abbrev'
> + - 'for_each_builtin'
> + - 'for_each_string_list_item'
> + - 'for_each_ut'
> + - 'for_each_wanted_builtin'
> + - 'list_for_each'
> + - 'list_for_each_dir'
> + - 'list_for_each_prev'
> + - 'list_for_each_prev_safe'
> + - 'list_for_each_safe'
>
> # The maximum number of consecutive empty lines to keep.
> MaxEmptyLinesToKeep: 1
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list
2019-06-03 22:48 [PATCH] clang-format: use git grep to generate the ForEachMacros list Miguel Ojeda
2019-06-04 16:07 ` Johannes Schindelin
@ 2019-06-05 20:20 ` Taylor Blau
2019-06-06 18:29 ` Miguel Ojeda
1 sibling, 1 reply; 4+ messages in thread
From: Taylor Blau @ 2019-06-05 20:20 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Git mailing list, Brandon Williams, Jonathan Nieder,
Johannes Schindelin, Stephan Beyer, Taylor Blau, Patryk Obara
Hi Miguel,
On Tue, Jun 04, 2019 at 12:48:14AM +0200, Miguel Ojeda wrote:
> The ForEachMacros list can reasonably be generated grepping
> the C source code for macros with 'for_each' in their name.
>
> Taken almost verbatim from the .clang-format file in the Linux kernel.
>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Thanks for CC-ing me on this. I suspect that it was because I show up
somewhere recently in the blame for 'git grep' (I believe I worked on
adding `-o` about a year ago).
You 'git grep' usage of course looks correct, so this patch looks good
to me, too.
Thanks,
Taylor
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list
2019-06-05 20:20 ` Taylor Blau
@ 2019-06-06 18:29 ` Miguel Ojeda
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2019-06-06 18:29 UTC (permalink / raw)
To: Taylor Blau
Cc: Git mailing list, Brandon Williams, Jonathan Nieder,
Johannes Schindelin, Stephan Beyer, Patryk Obara
On Wed, Jun 5, 2019 at 10:20 PM Taylor Blau <me@ttaylorr.com> wrote:
>
> Hi Miguel,
>
> On Tue, Jun 04, 2019 at 12:48:14AM +0200, Miguel Ojeda wrote:
> > The ForEachMacros list can reasonably be generated grepping
> > the C source code for macros with 'for_each' in their name.
> >
> > Taken almost verbatim from the .clang-format file in the Linux kernel.
> >
> > Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
>
> Thanks for CC-ing me on this. I suspect that it was because I show up
> somewhere recently in the blame for 'git grep' (I believe I worked on
> adding `-o` about a year ago).
Yeah, I just picked a few names that were related to the file form the
log, since I was unable to locate a MAINTAINERS file or something like
that. :-)
Thanks for taking a look -- also to Johannes!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-06 18:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 22:48 [PATCH] clang-format: use git grep to generate the ForEachMacros list Miguel Ojeda
2019-06-04 16:07 ` Johannes Schindelin
2019-06-05 20:20 ` Taylor Blau
2019-06-06 18:29 ` Miguel Ojeda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.