From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 64442@debbugs.gnu.org
Subject: bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C
Date: Tue, 4 Jul 2023 01:41:22 -0700 [thread overview]
Message-ID: <FA94EF0C-AD32-4A80-B2C8-707C79945715@gmail.com> (raw)
In-Reply-To: <83a5wcncj8.fsf@gnu.org>
> On Jul 3, 2023, at 10:13 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> To reproduce:
>
> emacs -Q
> C-x C-f src/dispnew.c RET
> M-x c-ts-mode RET
> C-u 220 M-g g
> C-M-a
>
> Observe that instead of going to the beginning of
> dump-redisplay-history, the function to which line 220 of dispnew.c
> belongs, point goes to the beginning of the previous function, which
> happens to be add_frame_display_history.
>
> Can we please fix treesit-beginning-of-defun such that it recognizes C
> functions defined via DEFUN?
I’ve tried it when I was fixing fontification for DEFUN, but ultimately gave up. The tree-sitter defun movement functions searches for defun nodes bottom-up, and goes to the beginning or end of that node.
The problem with DEFUN’s is that a DEFUN is really made of two nodes in the parse tree. One for the DEFUN part, one for the body, and there isn’t a parent node that encloses the two.
The defun movement functions are not designed to handle a construct made of two adjacent nodes. They can find a node, go to the beginning/end of it; they can’t find a node, and go to the end of the next node.
It sounds easy to add some hack to handle it, but really isn’t. Defun movement need to support forward/backward to beg/end, that’s four movement types; on top of that you have nested defun’s.
Yuan
next prev parent reply other threads:[~2023-07-04 8:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 17:13 bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C Eli Zaretskii
2023-07-04 8:41 ` Yuan Fu [this message]
2023-07-04 11:39 ` Eli Zaretskii
2023-07-07 6:15 ` Yuan Fu
2023-07-07 6:40 ` Eli Zaretskii
2023-07-12 2:10 ` Yuan Fu
2023-07-30 7:10 ` Eli Zaretskii
2023-08-10 9:18 ` Eli Zaretskii
2023-08-10 21:33 ` Yuan Fu
2023-08-12 14:59 ` Eli Zaretskii
2023-08-14 5:20 ` Yuan Fu
2023-08-14 11:59 ` Eli Zaretskii
2023-08-15 7:30 ` Yuan Fu
2023-08-17 8:18 ` Eli Zaretskii
2023-08-19 22:00 ` Yuan Fu
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=FA94EF0C-AD32-4A80-B2C8-707C79945715@gmail.com \
--to=casouri@gmail.com \
--cc=64442@debbugs.gnu.org \
--cc=eliz@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 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.