emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit indentation "blinking"


From: Eli Zaretskii
Subject: Re: treesit indentation "blinking"
Date: Thu, 30 Mar 2023 16:39:04 +0300

> 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
> 
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > [...]  Which is better indeed, but
> > what c++-ts-mode does is not a catastrophe, either.
> 
> Maybe it's not a catastrophe, but it's far from behaving well.
> 
> 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---
> 
> Can you reproduce these? These happen both with emacs-29 and
> several-day-old master with the latest tree-sitter-cpp (but it also
> happens with a ~1 month-old tree-sitter-cpp).

Thanks for the examples, but how are they related to the issue at
hand?  We are discussing the possibly adverse effects that
electric-indent-mode and the customization of electric-indent-chars by
c-ts-base-mode might have on user experience while typing C/C++ code.
Are you saying that removing the customization of
electric-indent-chars by c-ts-base-mode solves the problems you
mention?  If not, then I think your examples should go into a separate
bug report, which should be investigated separately.



reply via email to

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