GNU bug report logs -
#62825
29.0.90; c-ts-mode doesn't recognize DEFUN functions
Previous Next
Full log
View this message in rfc822 format
> Date: Fri, 14 Apr 2023 09:44:22 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> Evaluating '(treesit-defun-at-point)' inside a function defined via
> the DEFUN macro yields nil, when the buffer is under c-ts-mode. This
> gets in the way of significant functionalities, like
> c-ts-mode-indent-defun and generating ChangeLog-style log entries
> using "C-x 4 a" and the likes.
>
> To reproduce, visit any of the Emacs C source files, like treesit.c,
> with c-ts-mode, move point to a function defined via DEFUN, and type
> "C-x 4 a". The resulting ChangeLog entry will have the file name, but
> not the expected function name in parentheses.
>
> Please fix this ASAP, this is a bad regression for those, like myself,
> who want to use c-ts-mode.
Using treesit-explore-mode I see that c-ts-mode regards DEFUN
functions as a sequence of 2 expression_statement nodes. Here's the
tree corresponding to the DEFUN macro call:
(expression_statement
(call_expression
function:
(call_expression function: (identifier) <<<<<<<<<<<<<<<<<<<
arguments:
(argument_list (
(string_literal " ")
, (identifier) , (identifier) , (number_literal) , (number_literal) ,
(number_literal)
, (identifier)
(ERROR :)
(comment) )))
arguments:
(argument_list ( (identifier)
(ERROR (identifier))
, (identifier)
(ERROR (identifier))
)))
;)
The identifier node on the line indicated with "<<<<<" is "DEFUN", so
maybe we can recognize this. The body of the DEFUN is another
compound_statement node, following the DEFUN's node.
This bug report was last modified 2 years and 62 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.