GNU bug report logs -
#64442
29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C
Previous Next
Reported by: Eli Zaretskii <eliz <at> gnu.org>
Date: Mon, 3 Jul 2023 17:14:01 UTC
Severity: normal
Found in version 29.0.92
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #29 received at 64442 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> On Aug 10, 2023, at 2:18 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> Cc: 64442 <at> debbugs.gnu.org
>> Date: Sun, 30 Jul 2023 10:10:35 +0300
>> From: Eli Zaretskii <eliz <at> gnu.org>
>>
>>> From: Yuan Fu <casouri <at> gmail.com>
>>> Date: Tue, 11 Jul 2023 19:10:01 -0700
>>> Cc: 64442 <at> debbugs.gnu.org
>>>
>>>
>>>
>>>> On Jul 6, 2023, at 11:40 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>
>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>> Date: Thu, 6 Jul 2023 23:15:00 -0700
>>>>> Cc: 64442 <at> debbugs.gnu.org
>>>>>
>>>>>> On Jul 4, 2023, at 4:39 AM, Eli Zaretskii <eliz <at> gnu.org> 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 :-(
>>
>> Any progress with this? It would be good to have a solution in Emacs
>> 29.2, if possible.
>
> Ping!
I still don’t have a good solution. But I just realized that we might be able to make a little compromise: what if Emacs recognizes DEFUN, but as two separate parts (the declaration and the body), rather than one? It’s hard to make it recognize DEFUN as a single defun, but making it recognize DEFUN as two parts is easy.
Try this patch and see if you like the behavior. Personally I find it quite alright.
Yuan
[defun-nav.patch (application/octet-stream, attachment)]
This bug report was last modified 1 year and 332 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.