GNU bug report logs -
#60655
30.0.50; tree-sitter: `treesit-transpose-sexps' is broken.
Previous Next
Reported by: Mickey Petersen <mickey <at> masteringemacs.org>
Date: Sun, 8 Jan 2023 10:54:01 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 60655 <at> debbugs.gnu.org (full text, mbox):
Mickey Petersen <mickey <at> masteringemacs.org> > The tree-sitter-enabled function, `treesit-transpose-sexps', that is called by transpose-sexps, is broken.
>
> It uses a naive method of sibling adjacency to determine
> transpositions. But it is unfortunately not correct.
>
> Python:
>
>
> def -!-foo():
> pass
>
> Turns into this with `C-M-t':
>
> def ()foo:
> pass
>
> But it ought to be:
>
> foo def():
> pass
>
>
> It's swapping two siblings that are indeed adjacent in the tree, but
> not on screen, which is confusing and a regression from its previous
> behaviour.
>
I can try to make transpose-sexps rely on only swapping "allowed"
node-types? That would be able to keep the new, better function, yet
still disallow these syntax-breaking transposes. What do you think?
> You could make a cogent argument that both approaches are wrong from a
> syntactic perspective, but I think that misses the broader point that
> `C-M-t' now does something errant and unexpected.
I don't really see how "foo def():" is any better at all. We gain some
great improvements with this "naive" method - namely:
if 5 + 5 == 10 then 10 else 100 + 100. If point is on the else the 100
+ 100 wil be swapped by 10, but the old behavior will be broken.
>
> Worse, it's not possible to revert to the old behaviour (see
> bug#60654)
>
>
Right.
Thanks,
Theo
This bug report was last modified 196 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.