From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#59853: 30.0.50; tree-sitter modes have unexpected beginning-of-defun behavior Date: Sat, 7 Jan 2023 15:12:13 -0800 Message-ID: References: <87lenlnjc1.fsf@posteo.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13551"; mail-complaints-to="usenet@ciao.gmane.io" Cc: leungbk@posteo.net, 59853@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 08 00:13:16 2023 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 1pEINI-0003L6-Sf for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Jan 2023 00:13:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEIN7-00057t-VA; Sat, 07 Jan 2023 18:13:08 -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 1pEIN4-00057X-Nz for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:13: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 1pEIN4-0001V6-Az for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEIN4-0007Qt-3W for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:13:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87lenlnjc1.fsf@posteo.net> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Jan 2023 23:13:02 +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.167313314128493 (code B ref 59853); Sat, 07 Jan 2023 23:13:02 +0000 Original-Received: (at 59853) by debbugs.gnu.org; 7 Jan 2023 23:12:21 +0000 Original-Received: from localhost ([127.0.0.1]:59216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIMP-0007PU-FL for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:12:21 -0500 Original-Received: from mail-pj1-f45.google.com ([209.85.216.45]:42780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIMO-0007PH-7E for 59853@debbugs.gnu.org; Sat, 07 Jan 2023 18:12:20 -0500 Original-Received: by mail-pj1-f45.google.com with SMTP id z9-20020a17090a468900b00226b6e7aeeaso5550928pjf.1 for <59853@debbugs.gnu.org>; Sat, 07 Jan 2023 15:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=WlgvYknCHZpeh4ciuLPDawytdkoeyQaBsUvgJO7HMx0=; b=MUrLo9adUZbs1GzL+Fu6cQ4eGzMDSi89j9B73GDV8hWW1hcX0Sv9JgfQA2kSIXbLnZ vIHK43f86YMhQSX6bmTFewMtuPdnsLW6kIVn49/wPrMg45oTkcfjDLnJ+7/MDQkqg+ZC C6vlEQSqOavWGvqp1z+IBE3ytjCzxCu6fuGCu+JXC2aqidJu4YJ5enGY8sr9+V6L2O3T ZkhC7GFel9ocxlekBWZoi/DrX38WBN/rJMJSOABfeuOVYC7BH8PrTZOHRtBWFFEpNrEk S1qvogZBWk0FnIJWcQN/phrWGHiK0nwcCHKTKZJrMqwfGRKqh1BZZnkZwp7y28KpD68L BlaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlgvYknCHZpeh4ciuLPDawytdkoeyQaBsUvgJO7HMx0=; b=wdTJp0Qw2hJPUks/X7qWKEHHoY8SAkAxd0mHbYuradH42ugnPcNE9OM9qm3cdD/CeG gbQpplmrBio3TT+lgYAdro8Hs9fiyXYn5wCFr/9+siKRjNWxAOZ8RkBddlvWkTOjmrRe 4fxgFzYtwFYzKJkBSdYxzDXQqTZ7xPh2XGrYphPuSZpKjJ4Cv3rcccsmBydrgkqTrZT0 xlHozdfYg7mwKu/YUhu6scdqUCY0tSFkWG6t7zk9nNoHjBUZsme+vDci4FWLbQUQYUk7 FaMSA3ixqNNr0DHO1PHxynuI9jZc/iqVXAc2o1CpWwhsvPz2y/289cG4LaC2nd4nTsfn S4AQ== X-Gm-Message-State: AFqh2kqz09ofdQuZKw6G4NBo2wPnnqdgyEQ48+Q2wo0R57d23P6IJVg6 uheMqlGhZQ2VotbkHHAAuSo= X-Google-Smtp-Source: AMrXdXvSsQqA2GeoglbBsHxuMuWAJFNZ8NzflTggXf7jw+NP3476KrpRXRXEbudOGUM69XT9lzdmDw== X-Received: by 2002:a05:6a20:1bd9:b0:ad:efda:5e5d with SMTP id cv25-20020a056a201bd900b000adefda5e5dmr61678396pzb.61.1673133134633; Sat, 07 Jan 2023 15:12:14 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id u7-20020a17090341c700b00186e34524e3sm3239472ple.136.2023.01.07.15.12.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2023 15:12:14 -0800 (PST) X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:252839 Archived-At: Yuan Fu writes: > Yuan Fu writes: > >> Theodor Thornhill writes: >> >>> Brian Leung writes: >>> >>>> Theodor Thornhill writes: >>>> >>>>>> 2. When point is anywhere in the first line of the class=20 >>>>>> declaration, mark-defun highlights "void otherMethod()",=20 >>>>>> instead=20 >>>>>> of the entire class declaration. >>>>> >>>>> Yeah, I think I've fixed this in a patch I just submitted. >>>> >>>> Which commit are you referring to? >>>> >>> >>> I believe it was the one I included as a patch here. >>> >>>>>> 3a. When point is at the [*] in between someMethod and=20 >>>>>> otherMethod, narrow-to-defun captures "void otherMethod()". I=20 >>>>>> feel=20 >>>>>> that since the methods inside the interface declaration have no=20= >>>>>> bodies, it makes more sense to capture the entire interface=20 >>>>>> definition if point is at [*]. >>>>> >>>>> Maybe, but I don't believe this is wrong either. >>>> >>>> Let me rephrase my request. Consider the following example: >>>> >>>>> class Cow implements Animal { >>>>> public void animalSound() { >>>>> // The body of animalSound() is provided here >>>>> System.out.println("The cow says: moo"); >>>>> } >>>>> >>>>> [*] >>>>> >>>>> public void sleep() { >>>>> // The body of sleep() is provided here >>>>> System.out.println("Zzz"); >>>>> } >>>>> } >>>> >>>> Both the methods have bodies. If point is at the [*], I would like=20= >>>> for narrow-to-defun to capture the entire class declaration, since=20= >>>> point is not really contained in either method. (For this=20 >>>> particular example, java-mode presently agrees with java-ts-mode.) >>>> >>>> Is there a clean way of ensuring that, when point lies between=20 >>>> (and is not contained in) those two methods, point is not treated=20= >>>> as if it were in one of those methods' tree-sitter nodes? > > That=E2=80=99s hard to do with the current narrow-to-defun, we can add = a > new version that is aware of nested defuns and remap narrow-to-defun = to > it in tree-sitter modes. In the future we can improve stock > narrow-to-defun to support nested defuns. > > Yuan Defun navigatio is largely fixed now, so I=E2=80=99m closing this. For narrow-to-defun to completely work we need to improve beginning/end-of-defun to support nested defuns. Yuan