emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: treesit indentation "blinking"


From: João Távora
Subject: Re: treesit indentation "blinking"
Date: Sat, 25 Mar 2023 16:14:15 +0000
User-agent: Gnus/5.13 (Gnus v5.13)

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 25/03/2023 11:05, João Távora wrote:
>> On Thu, Mar 23, 2023 at 9:24 PM Dmitry Gutov <dgutov@yandex.ru> wrote:
>>>
>>> On 23/03/2023 23:10, Daniel Colascione wrote:
>>>> Editing can cause all sorts of transient nonsense in the AST, and it's
>>>> impossible to predict in a general manner what this nonsense might be.
>>>> The wrong kind of bracket can cause the entire rest of the file to be
>>>> parsed as nonsense. This or that error recovery rule isn't going to
>>>> solve the problem: such a strategy is a fragile whack a mole. There
>>>> needs to be some general solution to prevent indentation blinking. This
>>>> blinking makes TS modules unusable for me.
>>>
>>> It seems to me it will only be feasible to support a number of
>>> "incomplete" syntax constructs. Maybe it will constitute a majority of them.
>> I don't think this problem has anything to do with tree-sitter.  It
>> would happen just as well in regular c++-mode if electric-indent-mode
>> were on by default there (but it isn't).
>
> The mode is globally on by default, but indeed the contents of
> electric-indent-chars are much shorter there.
>
>> So it's just the fact that electric-indent-mode is on by default
>> _and_ c-ts-mode.el does this:
>> (setq-local electric-indent-chars (append "{}():;,#"
>> electric-indent-chars))
>> so people are getting what the mode author (and Emacs defaults) ask
>> for:
>> electric indentation doing its thing.
>
> Good point: perhaps either this list should be revisited, or
> predicated (at runtime) somehow on electric-pair-mode being enabled.

At first, I thought this was a good idea.  electric-pair-chars could be
a function returning the characters to use, and c++-ts-mode could set it
to a function that returns the extended set if electric-pair-mode is on.

But OTOH, extra chars in electric-indent-chars is of limited use if
electric-pair-mode is on, because when the buffer is balanced,
newline-inserting commands already do the correct indent.

So, it would probably solve this problem, but not much beyond not
messing with electric-indent-chars at all in the first place.

João




reply via email to

[Prev in Thread] Current Thread [Next in Thread]