GNU bug report logs - #68664
29.1.50; treesit defun commands broken with nested functions

Previous Next

Package: emacs;

Reported by: Troy Brown <brownts <at> troybrown.dev>

Date: Mon, 22 Jan 2024 23:12:02 UTC

Severity: normal

Found in version 29.1.50

Full log


Message #11 received at 68664 <at> debbugs.gnu.org (full text, mbox):

From: Troy Brown <brownts <at> troybrown.dev>
To: Daniel Martín <mardani29 <at> yahoo.es>
Cc: 68664 <at> debbugs.gnu.org
Subject: Re: bug#68664: 29.1.50;
 treesit defun commands broken with nested functions
Date: Tue, 23 Jan 2024 09:30:49 -0500
On Mon, Jan 22, 2024 at 7:32 PM Daniel Martín <mardani29 <at> yahoo.es> wrote:
>
> Troy Brown <brownts <at> troybrown.dev> writes:
>
> > I've noticed that "defun" related treesit commands do not appear to work
> > correctly when nested functions are involved.  I've seen this behavior
> > in multiple languages and believe the problem is an issue in the
> > treesit.el library.
>
> Customize the treesit-defun-tactic variable to 'top-level to ignore
> nested defuns in navigation commands.

But I don't want it to just go to the top-level, I want it to respect
the current
nesting level.  If I insert yet another level in the example, and
point is within
the second level of nesting, I want it to move to the beginning and end of that
nested function (i.e., "secondLevel" in the sample below when point is on the
call to innerFunction).  As mentioned in my original email, python-mode does
respect the nesting level correctly, but python-ts-mode, and other "ts" modes
that support nesting, don't respect it.

--8<---------------cut here---------------start------------->8---
# -*- mode: python-ts -*-

def outerFunction(text):
    text = text

    def secondLevel(text):
        print(text)

        def innerFunction(text):
            print(text)

        innerFunction()

        def innerFunction2(text):
            print(text)

        innerFunction2()

    secondLevel()

--8<---------------cut here---------------end--------------->8---




This bug report was last modified 1 year and 142 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.