emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit indentation "blinking"


From: Dmitry Gutov
Subject: Re: treesit indentation "blinking"
Date: Sat, 25 Mar 2023 14:42:50 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

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.

Have you tried using electric-pair-mode, though? I'd hate to make it our
strong recommendation for all ts modes, but it does reduce the odds of
incomplete code a lot.

Maybe you'd hate it

Not really, just a figure of speech.

But not everybody will like it, I suspect.

, but it would at least be consistent with the
setting for electric-indent-mode, which is much more jarring.

See also bug#62412 which is basically the same problem with a recipe.

Yep.



reply via email to

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