all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Troy Brown <brownts@troybrown.dev>
Cc: 68664@debbugs.gnu.org, "Daniel Martín" <mardani29@yahoo.es>
Subject: bug#68664: 29.1.50; treesit defun commands broken with nested functions
Date: Tue, 23 Jan 2024 22:29:40 -0800	[thread overview]
Message-ID: <42732D94-583F-4F4A-804E-76EFAE91B210@gmail.com> (raw)
In-Reply-To: <CABvCZ42LyZaFMx8CJBMpPyrN1gkW5dUJFvwm3DqC0OGzVxHYCA@mail.gmail.com>



> On Jan 23, 2024, at 6:30 AM, Troy Brown <brownts@troybrown.dev> wrote:
> 
> 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.

The behavior is expected. But I can see that it doesn’t match your expectations. The logic behind the current behavior is to first move between siblings in the same level; if there’s no sibling to move across anymore, move to the beginning/end of the immediate parent, and so on.

To get the behavior you want, we would need to add a fourth defun navigation tactic, in addition to the existing three: nested, top-level, and restricted.

If you are interested and able, maybe you can look into adding it to treesit--navigate-thing or treesit-beginning/end-of-defun?

Yuan




  reply	other threads:[~2024-01-24  6:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 23:10 bug#68664: 29.1.50; treesit defun commands broken with nested functions Troy Brown
2024-01-23  0:32 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-23 14:30   ` Troy Brown
2024-01-24  6:29     ` Yuan Fu [this message]
2024-01-24 14:13       ` Troy Brown
2024-01-24 17:25         ` Troy Brown
2024-01-27  4:26           ` Yuan Fu
2024-01-27  7:32             ` Eli Zaretskii
2024-01-28  4:03               ` Yuan Fu
2024-01-28  6:53                 ` Eli Zaretskii
2024-01-28  7:29                   ` Yuan Fu
2024-01-28  7:43                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42732D94-583F-4F4A-804E-76EFAE91B210@gmail.com \
    --to=casouri@gmail.com \
    --cc=68664@debbugs.gnu.org \
    --cc=brownts@troybrown.dev \
    --cc=mardani29@yahoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.