From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brian Leung Newsgroups: gmane.emacs.bugs Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior Date: Tue, 06 Dec 2022 08:41:40 +0000 Message-ID: <87h6y8oq0x.fsf@posteo.net> References: <87lenlnjc1.fsf@posteo.net> <87k035vsph.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37390"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59853@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 10:12:16 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 1p2Tzs-0009We-FD for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 10:12:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2Tzg-00024x-IH; Tue, 06 Dec 2022 04:12: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 1p2Tze-00024j-Cr for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 04:12:02 -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 1p2Tze-0006T0-55 for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 04:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2Tzd-0004u9-WA for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 04:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Brian Leung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 09:12: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.167031790118847 (code B ref 59853); Tue, 06 Dec 2022 09:12:01 +0000 Original-Received: (at 59853) by debbugs.gnu.org; 6 Dec 2022 09:11:41 +0000 Original-Received: from localhost ([127.0.0.1]:41677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2TzJ-0004tv-77 for submit@debbugs.gnu.org; Tue, 06 Dec 2022 04:11:41 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:46915) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2TzH-0004to-8V for 59853@debbugs.gnu.org; Tue, 06 Dec 2022 04:11:40 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BDEE8240106 for <59853@debbugs.gnu.org>; Tue, 6 Dec 2022 10:11:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1670317893; bh=cuJPimDoDQvvJGXbLxf2WrmgApJvvD0oJIghJZbvGUI=; h=From:To:Cc:Subject:Date:From; b=RJyVk2iifNW8OERb1ce6kppE1mjsm2srGFLi+Kgjod02YozKXDPZyz5yXYbBDcfYS FyeGSWkoVN/XDVCd3jFVsQTwlkUJncSimSkGRBdZFjaUysmxe0e5KnBvDYEuSsRaXy EXMh3UFg4WT82VCzZQ9pTVYahKUGS4bR+LBTy0wbUsMi9Vyw45PvP8+uEOW4E+t0gG ulAgZK3qb9GM6h2NWm+f+ddHA/iKmsipd1aOjQVubobnR2NS2rcSbCjWbF/ApCapfg nwZHGRG9UcDvwNthytdr+QlFGZy+uqhta92vOB5qLgAVjtKuNkrSK5ZSBhOHmIofxo ifTPl65udDqOw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NRF5w40rZz6tp2; Tue, 6 Dec 2022 10:11:32 +0100 (CET) In-reply-to: <87k035vsph.fsf@thornhill.no> 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:250094 Archived-At: 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(); > *}* > } 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.