From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior Date: Tue, 06 Dec 2022 11:36:31 +0100 Message-ID: <875yeox1hs.fsf@thornhill.no> References: <87lenlnjc1.fsf@posteo.net> <87k035vsph.fsf@thornhill.no> <87h6y8oq0x.fsf@posteo.net> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30147"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 59853@debbugs.gnu.org To: Brian Leung Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 11:37:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2VKA-0007aB-U0 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 11:37:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2VJw-0006QG-5w; Tue, 06 Dec 2022 05:37:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2VJu-0006Pm-Mq for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 05:37:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2VJu-0004Kk-EU for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 05:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2VJt-0005i3-SV for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 05:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59853 X-GNU-PR-Package: emacs Original-Received: via spool by 59853-submit@debbugs.gnu.org id=B59853.167032299621936 (code B ref 59853); Tue, 06 Dec 2022 10:37:01 +0000 Original-Received: (at 59853) by debbugs.gnu.org; 6 Dec 2022 10:36:36 +0000 Original-Received: from localhost ([127.0.0.1]:42071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2VJU-0005hk-3Z for submit@debbugs.gnu.org; Tue, 06 Dec 2022 05:36:36 -0500 Original-Received: from out-156.mta0.migadu.com ([91.218.175.156]:19269) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2VJR-0005he-Lv for 59853@debbugs.gnu.org; Tue, 06 Dec 2022 05:36:34 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670322992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6FJo1nKUChCrrMWrt/xSA5IDTbiJk9OwrQ8RoBw7sto=; b=k5wKulz29uvH+a75Rl7pFp2RY3Q2YOMVIqc6I53INPmmQwEk1ZJDY8ofGFULGEF89FjBOp t0HmxxrUZsXkTkAcxrdKfm6c2zINwplbL/Wz0F+YRGDwkH4r4rVDtTAVUqeSXIN+3V5lNR KB7emrn0x66n2EnlymniHRTeQN3BDsAjxVc1A6XqpFlH0TpA/GGgZwyZp84yuFE7uvIlsD h6uxsojGUIa2GMwKYpsRHGpf+C6eUuyXA7tIbOn1r5IMk0qBCSqJsV0xPwuo9bUAe5KN5l TmOSYvtypE+qckw7E7vscFGVQztJ5LfTinnXaL5fnnIaKB1OY/lkXM5mmoDxIQ== In-Reply-To: <87h6y8oq0x.fsf@posteo.net> X-Migadu-Flow: FLOW_OUT X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250097 Archived-At: Brian Leung writes: > Thanks for your response! > > Theodor Thornhill 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