GNU bug report logs - #60197
30.0.50; beginning-of-defun broken after new treesit impl

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Mon, 19 Dec 2022 10:14:01 UTC

Severity: normal

Found in version 30.0.50

Fixed in version 29.1

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 60197 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 60197 <at> debbugs.gnu.org
Subject: Re: bug#60197: 30.0.50; beginning-of-defun broken after new treesit 
 impl
Date: Thu, 22 Dec 2022 00:51:33 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> Yuan Fu <casouri <at> gmail.com> writes:
>
>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>
>>> On 21 December 2022 07:50:04 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>
>>>>Yuan Fu <casouri <at> gmail.com> writes:
>>>>
>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>
>>>>>> Hi, Yuan!
>>>>>>
>>>>>> It seems 'prog-fill-reindent-defun' is broken after the latest changes
>>>>>> to treesit-beginning-of-defun.  The culprit is that we now use remap
>>>>>> instead of setting the beginning-of-defun-function.  What is the
>>>>>> reasoning behind that change?  Can't we just rely on the variable
>>>>>> beginning-of-defun-function?
>>>>>
>>>>> Not really, end-of-defun uses beginning/end-of-defun-function in a way
>>>>> that’s incompatible with nested defuns[1]. So if we want to support
>>>>> navigation nested defuns reliably we need to remap the commands instead.
>>>>> In the future (ie emacs 30), we can extend the current
>>>>> beginning/end-of-defun to support nested defuns, then we don’t need to
>>>>> remap the commands anymore.
>>>>
>>>>I see the problem now... Many other functions uses
>>>>beginning/end-of-defun. I didn’t thought about that initially :-(
>>>>
>>>>But I don’t want to make big changes to beg/end-of-deun, hmmm.
>>>>
>>>>Yuan
>>>
>>>
>>> I think you can set the functions and remap, right? Maybe you can
>>> force the beginning-of-defun-function variant to choose the smallest
>>> scope as a default? Or just follow the same tactic the user set?
>>
>> Maybe, we can have beg-of-defun-function respect treesit-defun-tactic,
>> and end-of-defun-function simply jump to the end of the defun at point,
>> and remap the commands as we do now. I’ll experiment with that and see
>> if it works well.
>
> Sure!  Do you mean some treesit-specific code inside of
> beginning-of-defun, or just making treesit-beginning-of-defun callable
> non-interactively?

I played around, and it seems the best we can do is to simply setting
the b/e-of-defun-function. That’s also what cc-mode does. If cc-mode
does that for 20 years and no one complained, I think we are pretty
safe. Though we should still improve end-of-defun in Emacs 30.

So I did that :-)

Yuan




This bug report was last modified 2 years and 134 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.