|
From: Mark W. <ma...@kl...> - 2023-04-22 17:25:23
|
Hi Nick,
On Fri, Apr 21, 2023 at 06:51:42AM +1000, Nicholas Nethercote wrote:
> On Fri, 21 Apr 2023 at 06:02, Mark Wielaard <ma...@kl...> wrote:
> > Sure you can work around it, but I don't think that is a great
> > solution. It requires everyone to make some local changes.
> >
>
> You can send up a .gitconfig for the project, so it'll work automatically
> for everyone.
How? If you can install the .gitconfig automatically that would be
interesting, but I believe you'll always have to install .gitconfig
tweaks by hand.
> > I am not a fan, but also not dead against.
>
> Have you ever worked on a project that uses auto-formatting? Skepticism
> followed by enthusiasm is common. Paul, Julian, and I all have used it on
> other codebases and are now advocates. I'm using it for Cachegrind's Python
> code right now. It makes life easier.
I can see how it would work nicely for new python code. gdb also uses
python black (plus a buildbot checker) to auto-format their python
code. If you like we could add the same to the buildbot for valgrind.
BTW. Trying the various formatters listed in auxprogs/pybuild.sh gives
me (pylint suggests to use a range generator instead of an array, then
black reformates the file to get everything on one line:
diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in
index c76a760be..cba91aec7 100755
--- a/cachegrind/cg_annotate.in
+++ b/cachegrind/cg_annotate.in
@@ -1090,9 +1090,7 @@ def print_annotated_src_files(
# mtimes as if they are all as early as the earliest one.
# Therefore, we warn only if the earliest source file is
# more recent than the cgout file.
- min_ofl_st_mtime_ns = min(
- [os.stat(ofl).st_mtime_ns for ofl in ofls]
- )
+ min_ofl_st_mtime_ns = min(os.stat(ofl).st_mtime_ns for ofl in ofls)
for cgout_filename in args.cgout_filename:
if min_ofl_st_mtime_ns > os.stat(cgout_filename).st_mtime_ns:
> Personally I am happy with emacs M-x indent-region on the code I edit.
> > There is a .dir-locals.el in git which catches some (but certainly not
> > all) formatting things.
> >
>
> What about people who don't use emacs?
:) That sound like the start of a joke... I assume other editors have
something similar to M-X ident-region. But have no experience with
that. I just mentioned it to show that I do have a little experience
with formatters and do like valgrind having a .dir-locals.el. So if
the .clang-format gives the same kind of experience to others then
that is nice.
Cheers,
Mark
|