From: Troy Brown <brownts@troybrown.dev>
To: 68664@debbugs.gnu.org
Subject: bug#68664: 29.1.50; treesit defun commands broken with nested functions
Date: Mon, 22 Jan 2024 18:10:34 -0500 [thread overview]
Message-ID: <CABvCZ40GYDir=MNfQYDfnnhPjMbP_nJxgQXO-PRbxk5ip4yG_g@mail.gmail.com> (raw)
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.
According to the Emacs manual section "Moving by Defuns", the
beginning/end-of-defun commands should "... find the beginning and end
of the innermost defun around point". I don't see this behavior with
the corresponding treesit-beginning-of-defun and treesit-end-of-defun
commands. The following example uses python-ts-mode to demonstrate the
issue.
--8<---------------cut here---------------start------------->8---
# -*- mode: python-ts -*-
def outerFunction(text):
text = text
def innerFunction(text):
print(text)
innerFunction()
def innerFunction2(text):
print(text)
innerFunction2()
--8<---------------cut here---------------end--------------->8---
To reproduce the issue, place point on line 9 (i.e., the call to
"innerFunction"). When point is at this location, I've noticed
incorrect behavior for the following commands:
M-x treesit-beginning-of-defun RET
Moves point to the beginning of the "innerFunction" function (line 6)
instead of the beginning of the "outerFunction" function (line 3).
M-x treesit-end-of-defun RET
Moves point to the end of "innerFunction2" function (line 13) instead of
the end of the "outerFunction" function (line 15).
For comparison, the buffer can be switched to python-mode and the above
repeated with the non-treesit versions of these commands to demonstrate
that the regular python-mode does work as expected.
next reply other threads:[~2024-01-22 23:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 23:10 Troy Brown [this message]
2024-01-23 0:32 ` bug#68664: 29.1.50; treesit defun commands broken with nested functions 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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABvCZ40GYDir=MNfQYDfnnhPjMbP_nJxgQXO-PRbxk5ip4yG_g@mail.gmail.com' \
--to=brownts@troybrown.dev \
--cc=68664@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).