From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Brian Leung <leungbk@posteo.net>
Cc: casouri@gmail.com, 59853@debbugs.gnu.org
Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior
Date: Tue, 06 Dec 2022 11:36:31 +0100 [thread overview]
Message-ID: <875yeox1hs.fsf@thornhill.no> (raw)
In-Reply-To: <87h6y8oq0x.fsf@posteo.net>
Brian Leung <leungbk@posteo.net> writes:
> 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();
>> *}*
>> }
Not sure I can reproduce this. I made two files:
```
package Foo;
import some.thing;
interface Foo {
void foo();
}
````
```
package Foo;
import some.thing;
public abstract class Fooo {
public static interface Foo {
void foo();
}
}
```
In the first one, when point is on the 'f' of 'foo()' I get narrowed to
that line. If I'm at column 0 of the same line, I see the whole
interface, but not the package declaration or import statement. That
seems correct to me. Also I see similar results on the other file.
What am I missing?
>>> 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.
Great! This sounds like a different bug report though.
Theo
next prev parent reply other threads:[~2022-12-06 10:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 6:21 bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior Brian Leung
2022-12-06 8:31 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-06 8:41 ` Brian Leung
2022-12-06 10:36 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-07 9:51 ` Brian Leung
2022-12-07 11:33 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-09 3:35 ` Brian Leung
2022-12-09 15:59 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-07 19:34 ` Yuan Fu
2022-12-21 5:24 ` Yuan Fu
2022-12-21 5:28 ` Yuan Fu
2022-12-22 8:59 ` Yuan Fu
2023-01-07 23:12 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875yeox1hs.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=59853@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=leungbk@posteo.net \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.