Subject: Re: bug#63390: 29.0.90; c-ts-mode fails to recognize functions in xterm.c

From: Yuan Fu <[email-masked]>
Date: Wed, 17 May 2023 23:19:22 -0700

> On May 15, 2023, at 4:13 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Yuan Fu <[email-masked]>
>> Date: Sun, 14 May 2023 22:47:06 -0700
>> Cc: [email-masked]
>> 
>>>> (function_declarator declarator: (identifier)
>>>>  parameters: 
>>>>   (parameter_list (
>>>>    (parameter_declaration
>>>>     type: (struct_specifier struct name: (type_identifier))
>>>>     declarator: (pointer_declarator * declarator: (identifier)))
>>>>    )))
>>>> 
>>>> Same with the next function, x_draw_composite_glyph_string_foreground.
>>>> But the function after that, x_draw_glyphless_glyph_string_foreground,
>>>> is again recognized as function definition.  I wonder if the
>>>> preprocessor conditionals around there have something to do with that.
>> 
>> Ok, so that’s because there are ifdef’s inside the function, which cuts the function into pieces and tree-sitter can’t make out a function_definition, which is what we use to fontify the function name. A function_declarator alone can be used in many places, like in an argument list for function pointers, I think?
> 
> Does this mean that on master movement by defuns will be broken around
> those functions?

Yeah, unfortunately, I’ll try accommodate for it. 

> 
>> I can fix this by fontifying top-level function_declaration, I think a top-level function_declaration should always be a function definition?
> 
> Yes, I think this would be better.
> 
>>>> Btw, function declarations in a header file are recognized as such,
>>>> but the names of the functions there are still correctly fontified.
>> 
>> They are fine because there’s a semicolon in the end, so the function_decalration is wrapped in a declaration node, which we (the fontification rules) recognize.
> 
> Thanks for explaining this.

Should I fix this on emacs-29 or master? Sorry for the delay, I was having some distractions lately ;-)

Yuan