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

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

bug#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions


From: Yuan Fu
Subject: bug#62825: 29.0.90; c-ts-mode doesn't recognize DEFUN functions
Date: Fri, 14 Apr 2023 13:19:41 -0700


> On Apr 13, 2023, at 11:59 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Date: Fri, 14 Apr 2023 09:44:22 +0300
>> From: Eli Zaretskii <eliz@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.

Ok, I fixed indent-defund and add-log. Because a DEFUN is made of two nodes in 
the parse tree rather than one, it’s a bit hard to incorporate it into the 
normal treesit-defun-at-point, etc, functions. And we probably have to fix 
DEFUN case-by-case.

Yuan






reply via email to

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