emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit indentation "blinking"


From: Yuan Fu
Subject: Re: treesit indentation "blinking"
Date: Sat, 1 Apr 2023 12:39:15 -0700


> On Mar 30, 2023, at 7:58 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Herman, Géza <geza.herman@gmail.com>
>> Cc: João Távora <joaotavora@gmail.com>,
>> dgutov@yandex.ru, dancol@dancol.org,
>> casouri@gmail.com, theo@thornhill.no, emacs-devel@gnu.org
>> Date: Thu, 30 Mar 2023 12:26:16 +0200
>> 
>> Type this example into a c++-ts-mode buffer (I used "emacs -Q"):
>> 
>> --8<---------------cut here---------------start------------->8---
>> int main() {
>> for (;;) {
>> printf("Hello world\n");
>> }
>> }
>> --8<---------------cut here---------------end--------------->8---
>> 
>> This is how it will be indented as I wrote it here. c++-ts-mode doesn't
>> re-indent anything during typing, even though it had the chance to do
>> that, because electric-indent-mode is enabled by default, and
>> electric-indent-chars contains the necessary characters.
>> 
>> Or, another example. Put the "void foo() { }" part first into a
>> c++-ts-mode buffer, then write the main function:
>> 
>> --8<---------------cut here---------------start------------->8---
>> int main() {
>> int a = 0;
>> for (;;) {
>> printf("Hello!\n");
>> }
>> }
>> 
>> void foo() {
>> }
>> --8<---------------cut here---------------end--------------->8---
>> 
>> Again, c++-ts-mode doesn't indent anything.
>> 
>> If you change the example to contain "void foo();" instead of "void
>> foo() { }", then indenting happens during typing the main function.
>> 
>> If you try adding "int a = 0;" into the first example, then it will be
>> indented at typing the ";". But then for loop is still not get indented,
>> and the buffer will look like this:
>> 
>> --8<---------------cut here---------------start------------->8---
>> int main() {
>>  int a = 0;
>> for (;;) {
>> printf("Hello world\n");
>> }
>> }
>> --8<---------------cut here---------------end--------------->8---
>> 
>> If you start by adding an empty comment, and then write the first
>> example above the empty comment, the buffer will look like this:
>> 
>> --8<---------------cut here---------------start------------->8---
>> int main() {
>>  for (;;) {
>> printf("Hello world\n");
>>  }
>> }
>> 
>> /**/
>> --8<---------------cut here---------------end--------------->8---
> 
> Yuan and Theo, can you please look into these examples?  A simple
> "C-c C-q" fixes the indentation, but the question is why it doesn't
> happen while typing?

I’ll have a look!

Yuan


reply via email to

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