Subject: bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C

From: Yuan Fu <[email-masked]>
Date: Tue, 11 Jul 2023 19:10:01 -0700

> On Jul 6, 2023, at 11:40 PM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Yuan Fu <[email-masked]>
>> Date: Thu, 6 Jul 2023 23:15:00 -0700
>> Cc: [email-masked]
>> 
>>> On Jul 4, 2023, at 4:39 AM, Eli Zaretskii <[email-masked]> wrote:
>>> 
>>> Why cannot we look for a top-level expression_statement node which is
>>> a call_expression whose function identifier is "DEFUN" and whose
>>> position is between the place where C-M-a was invoked and the place
>>> where it does find a defun?
>> 
>> It’s gonna be ugly, but I can take a jab at it this weekend. I’m thinking of a wrapper function that tries to detect DEFUN before falling back to the ordinary tree-sitter defun movement function.
> 
> Thanks.  let's see how ugly it is before deciding whether it's worth it.
> 
>>> DEFUN's cannot be nested, so we don't need to consider that.
>> 
>> Yeah, in general C sources don’t have nested defuns, only C++ ones do.
> 
> No, I meant the use of DEFUN macros in Emacs cannot be nested.

Just an update. I didn’t forget about this, but it’s more harder than I thought and I’m still working on it :-(

Yuan