bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68664: 29.1.50; treesit defun commands broken with nested functions


From: Troy Brown
Subject: 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@yahoo.es> wrote:
>
> Troy Brown <brownts@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---





reply via email to

[Prev in Thread] Current Thread [Next in Thread]