GNU bug report logs - #59853
30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior

Previous Next

Package: emacs;

Reported by: Brian Leung <leungbk <at> posteo.net>

Date: Tue, 6 Dec 2022 06:22:02 UTC

Severity: normal

Found in version 30.0.50

Fixed in version 29.1

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: Brian Leung <leungbk <at> posteo.net>
Cc: 59853 <at> debbugs.gnu.org
Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior
Date: Tue, 06 Dec 2022 09:31:38 +0100
Hi Brian and thanks for the report!

Brian Leung <leungbk <at> posteo.net> writes:

> Given the following Java file:
>
> public abstract class Class {
>     public static interface Interface {
>         void someMethod();
>
>         void [o]therMethod();
>     }
> }
>
> If point is at the "o" in otherMethod, pressing C-M-a in java-ts-mode
> moves point to the beginning of that line. However, in java-mode, point
> moves to the beginning of Interface's declaration.
>

I see.  To me this looks like java-ts-mode is "correct", in that the
next step "outwards" is to the method start itself.  The point is in
fact inside the method still, IIUC.  


> In the following Python file:
>
> def outer():
>     def inner(i):
>         return i
>
>     [r]eturn 42
>
> If point is at the "r" in the outer return statement, pressing C-M-a in
> python-ts-mode moves point to the beginning of the line where the
> function "inner" is declared. However, in python-mode, point moves to
> the beginning of the line where "outer" is declared.
>

In this case I think python-mode is correct, becase the 'inner' function
is a sibling to the return statement, and it would make sense to go
directly to outer.

> This discrepancy in behavior makes it harder to use narrow-to-defun effectively.
>

Yeah, I understand.  Do you agree on my points above?  I just want to
make the problem clear to me :-)

Theo




This bug report was last modified 2 years and 139 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.