bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun


From: Brian Leung
Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior
Date: Tue, 06 Dec 2022 08:41:40 +0000

Thanks for your response!

Theodor Thornhill <theo@thornhill.no> writes:

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.

I don't actually know Java, so my expectations/intuition for what is "right" may be off. But from what I've read about, interfaces should be used to group methods with empty bodies. Body-less forms don't particularly feel like defuns to me, which is why I bring this up. Additionally, interactively using narrow-to-defun in java-ts-mode when point is inside the interface body produces unusual results:

public abstract class Class {
    public static interface Interface {
        void someMethod();
* *
        void otherMethod();
    *}*
}

If you narrow-to-defun with point inside the interface body and not touching either brace (such as between the two methods), you won't be able to capture the entire interface, and instead get just a single-line method. Meanwhile, if point touches the right brace, then narrow-to-defun yields

        void otherMethod();
    }
}

when capturing the entire interface might make more sense.

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.

Yeah, I agree here.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]