[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter
From: |
João Távora |
Subject: |
bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter |
Date: |
Sat, 25 Mar 2023 10:28:15 +0000 |
On Sat, Mar 25, 2023 at 10:19 AM Theodor Thornhill <theo@thornhill.no> wrote:
>
>
>
> On 25 March 2023 09:53:31 CET, "João Távora" <joaotavora@gmail.com> wrote:
> >On Fri, Mar 24, 2023 at 10:02 PM Theodor Thornhill via Bug reports for
> >GNU Emacs, the Swiss army knife of text editors
> ><bug-gnu-emacs@gnu.org> wrote:
> >e about the original purpose for this rule, CC’ing Theo.
> >> >
> >> >Yuan
> >> I'll look more deeply into the cause of this, but the rule is covering
> >> some preproc directives iirc.
> >>
> >> Unfortunately tree-sitter behaves better when auto pairs is used. I would
> >> advise people to use electric-pairs-mode (if that's the correct name, on
> >> mobile now) to avoid these sorts of issues.
> >
> >electric-pair-mode, it's not on by default.
> >
> >But, for some reason, electric-indent-mode _is_ on by default,
> >at least in c++-ts-mode.
> >
> >So this has nothing to do with tree-sitter IMO, it's just
> >electric-pair-mode doing its thing.
> >
> >Why is it on by default? A fair number of users don't like
> >this electricity, or prefer to have it toned down. At least
> >this has been the argument for not turning on electric-pair-mode
> >by default, which is a much less jarring mode IMO, and one which
> >would solve these problems.
> >
> >João
>
> Yeah, maybe! But I was under the impression that indentation was electric by
> default in most modes, but I may be mistaken.
>
> The reason I mentioned electric-pair-mode is that the parser fails less often
> when the closing paren or bracket is inserted, as it is much simpler to have
> a functional ast.
Sure. I wrote electric-pair-mode and that's exactly the point.
electric-indent-mode is on by default, but many modes just
use the default value for electric-indent-chars, which only
contains a newline, and so they aren't affected by this problem.
In c++-ts-mode, you gave electric-indent-chars a richer value,
including characters such as '}', ':' and ';'. This is not
unreasonable, but, as you've discovered, only really goes together
well with electric-pair-mode.
João
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Herman, Geza, 2023/03/23
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Yuan Fu, 2023/03/24
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Theodor Thornhill, 2023/03/24
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Herman, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, João Távora, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Herman, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, João Távora, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Theodor Thornhill, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Herman, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, João Távora, 2023/03/25
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Herman, 2023/03/26
- bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter, Daniel Martín, 2023/03/26