{"thread":{"id":"51232","subject":"[PATCH] clang-format: use git grep to generate the ForEachMacros list","startedAt":"2019-06-03T22:48:33Z","lastAt":"2019-06-06T18:29:53Z","messageCount":4,"participants":["Miguel Ojeda","Johannes Schindelin","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"376628","messageId":"20190603224814.GA15851@gmail.com","threadId":"51232","inReplyTo":null,"subject":"[PATCH] clang-format: use git grep to generate the ForEachMacros list","fromName":"Miguel Ojeda","fromEmail":"miguel.ojeda.sandonis@gmail.com","sentAt":"2019-06-03T22:48:14Z","receivedAt":"2019-06-03T22:48:33Z","isPatch":true,"sender":{"key":"miguel.ojeda.sandonis@gmail.com","avatar":null},"body":"The ForEachMacros list can reasonably be generated grepping\nthe C source code for macros with 'for_each' in their name.\n\nTaken almost verbatim from the .clang-format file in the Linux kernel.\n\nSigned-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>\n---\nWe wrote this for the Linux kernel a while ago, and it has been working\nfine there, so I thought it would be nice to use the same approach here.\nThere are fancier ways of approaching this, of course.\n\n .clang-format | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 41d4cd23fd..c592dda681 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -148,8 +148,21 @@ SpacesInSquareBrackets: false\n Cpp11BracedListStyle: false\n \n # A list of macros that should be interpreted as foreach loops instead of as\n-# function calls.\n-ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut']\n+# function calls. Taken from:\n+#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \\\n+#   | sed \"s,^#define \\([^[:space:]]*for_each[^[:space:]]*\\)(.*$,  - '\\1',\" \\\n+#   | sort | uniq\n+ForEachMacros:\n+  - 'for_each_abbrev'\n+  - 'for_each_builtin'\n+  - 'for_each_string_list_item'\n+  - 'for_each_ut'\n+  - 'for_each_wanted_builtin'\n+  - 'list_for_each'\n+  - 'list_for_each_dir'\n+  - 'list_for_each_prev'\n+  - 'list_for_each_prev_safe'\n+  - 'list_for_each_safe'\n \n # The maximum number of consecutive empty lines to keep.\n MaxEmptyLinesToKeep: 1\n-- \n2.17.1\n\n"},{"id":"376671","messageId":"nycvar.QRO.7.76.6.1906041807140.1775@tvgsbejvaqbjf.bet","threadId":"51232","inReplyTo":"20190603224814.GA15851@gmail.com","subject":"Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-04T16:07:37Z","receivedAt":"2019-06-04T16:07:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Miguel,\n\nOn Tue, 4 Jun 2019, Miguel Ojeda wrote:\n\n> The ForEachMacros list can reasonably be generated grepping\n> the C source code for macros with 'for_each' in their name.\n>\n> Taken almost verbatim from the .clang-format file in the Linux kernel.\n>\n> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>\n> ---\n> We wrote this for the Linux kernel a while ago, and it has been working\n> fine there, so I thought it would be nice to use the same approach here.\n\nMakes sense to me!\n\nThanks,\nJohannes\n\n>  .clang-format | 17 +++++++++++++++--\n>  1 file changed, 15 insertions(+), 2 deletions(-)\n>\n> diff --git a/.clang-format b/.clang-format\n> index 41d4cd23fd..c592dda681 100644\n> --- a/.clang-format\n> +++ b/.clang-format\n> @@ -148,8 +148,21 @@ SpacesInSquareBrackets: false\n>  Cpp11BracedListStyle: false\n>\n>  # A list of macros that should be interpreted as foreach loops instead of as\n> -# function calls.\n> -ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut']\n> +# function calls. Taken from:\n> +#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \\\n> +#   | sed \"s,^#define \\([^[:space:]]*for_each[^[:space:]]*\\)(.*$,  - '\\1',\" \\\n> +#   | sort | uniq\n> +ForEachMacros:\n> +  - 'for_each_abbrev'\n> +  - 'for_each_builtin'\n> +  - 'for_each_string_list_item'\n> +  - 'for_each_ut'\n> +  - 'for_each_wanted_builtin'\n> +  - 'list_for_each'\n> +  - 'list_for_each_dir'\n> +  - 'list_for_each_prev'\n> +  - 'list_for_each_prev_safe'\n> +  - 'list_for_each_safe'\n>\n>  # The maximum number of consecutive empty lines to keep.\n>  MaxEmptyLinesToKeep: 1\n> --\n> 2.17.1\n>\n>\n"},{"id":"376732","messageId":"20190605202019.GA84760@D-10-18-172-221.dhcp4.washington.edu","threadId":"51232","inReplyTo":"20190603224814.GA15851@gmail.com","subject":"Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2019-06-05T20:20:19Z","receivedAt":"2019-06-05T20:20:23Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Miguel,\n\nOn Tue, Jun 04, 2019 at 12:48:14AM +0200, Miguel Ojeda wrote:\n> The ForEachMacros list can reasonably be generated grepping\n> the C source code for macros with 'for_each' in their name.\n>\n> Taken almost verbatim from the .clang-format file in the Linux kernel.\n>\n> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>\n\nThanks for CC-ing me on this. I suspect that it was because I show up\nsomewhere recently in the blame for 'git grep' (I believe I worked on\nadding `-o` about a year ago).\n\nYou 'git grep' usage of course looks correct, so this patch looks good\nto me, too.\n\nThanks,\nTaylor\n"},{"id":"376775","messageId":"CANiq72=9N_VmV=FVLw64Xhn0AGboTbud3be5fVTxapGyxTZ=rA@mail.gmail.com","threadId":"51232","inReplyTo":"20190605202019.GA84760@D-10-18-172-221.dhcp4.washington.edu","subject":"Re: [PATCH] clang-format: use git grep to generate the ForEachMacros list","fromName":"Miguel Ojeda","fromEmail":"miguel.ojeda.sandonis@gmail.com","sentAt":"2019-06-06T18:29:40Z","receivedAt":"2019-06-06T18:29:53Z","isPatch":true,"sender":{"key":"miguel.ojeda.sandonis@gmail.com","avatar":null},"body":"On Wed, Jun 5, 2019 at 10:20 PM Taylor Blau <me@ttaylorr.com> wrote:\n>\n> Hi Miguel,\n>\n> On Tue, Jun 04, 2019 at 12:48:14AM +0200, Miguel Ojeda wrote:\n> > The ForEachMacros list can reasonably be generated grepping\n> > the C source code for macros with 'for_each' in their name.\n> >\n> > Taken almost verbatim from the .clang-format file in the Linux kernel.\n> >\n> > Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>\n>\n> Thanks for CC-ing me on this. I suspect that it was because I show up\n> somewhere recently in the blame for 'git grep' (I believe I worked on\n> adding `-o` about a year ago).\n\nYeah, I just picked a few names that were related to the file form the\nlog, since I was unable to locate a MAINTAINERS file or something like\nthat. :-)\n\nThanks for taking a look -- also to Johannes!\n\nCheers,\nMiguel\n"}]}