[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions
From: |
Yuan Fu |
Subject: |
bug#64442: 29.0.92; treesit-beginning-of-defun fails in DEFUN functions in C |
Date: |
Thu, 10 Aug 2023 14:33:09 -0700 |
> On Aug 10, 2023, at 2:18 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> Cc: 64442@debbugs.gnu.org
>> Date: Sun, 30 Jul 2023 10:10:35 +0300
>> From: Eli Zaretskii <eliz@gnu.org>
>>
>>> From: Yuan Fu <casouri@gmail.com>
>>> Date: Tue, 11 Jul 2023 19:10:01 -0700
>>> Cc: 64442@debbugs.gnu.org
>>>
>>>
>>>
>>>> On Jul 6, 2023, at 11:40 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>>>
>>>>> From: Yuan Fu <casouri@gmail.com>
>>>>> Date: Thu, 6 Jul 2023 23:15:00 -0700
>>>>> Cc: 64442@debbugs.gnu.org
>>>>>
>>>>>> On Jul 4, 2023, at 4:39 AM, Eli Zaretskii <eliz@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
Description: Binary data