all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: Yuan Fu <casouri@gmail.com>,
	62412@debbugs.gnu.org, geza.herman@gmail.com
Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter
Date: Sat, 25 Mar 2023 10:28:15 +0000	[thread overview]
Message-ID: <CALDnm50v=_z4BadXUN1vnvFXwJnGm7hP=Rs2N5T8i2g95yNDcg@mail.gmail.com> (raw)
In-Reply-To: <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no>

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





  reply	other threads:[~2023-03-25 10:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 20:43 bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Herman, Geza
2023-03-24 18:17 ` Yuan Fu
2023-03-24 20:04   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-25  8:53     ` João Távora
2023-03-25 10:19       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-25 10:28         ` João Távora [this message]
2023-03-25 10:26       ` Herman, Géza
2023-03-25 11:43         ` João Távora
2023-03-25 13:48           ` Herman, Géza
2023-03-25 16:23             ` João Távora
2023-03-25 17:41               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12  0:03                 ` Stefan Kangas
2023-03-25 17:47               ` Herman, Géza
2023-03-25 17:53                 ` João Távora
2023-03-26 13:54           ` Herman, Géza
2023-03-26 13:25     ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALDnm50v=_z4BadXUN1vnvFXwJnGm7hP=Rs2N5T8i2g95yNDcg@mail.gmail.com' \
    --to=joaotavora@gmail.com \
    --cc=62412@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=geza.herman@gmail.com \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.