From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Date: Sat, 25 Mar 2023 10:28:15 +0000 Message-ID: References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22722"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 62412@debbugs.gnu.org, geza.herman@gmail.com To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 25 13:16:11 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pg2oc-0005dD-NV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Mar 2023 13:16:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pg2oY-0005Wz-PR; Sat, 25 Mar 2023 08:16:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pg2oV-0005Ps-0T for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 08:16:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pg2oU-0002Xy-DO for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 08:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pg2oU-0004bx-7q for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 08:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Mar 2023 12:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62412 X-GNU-PR-Package: emacs Original-Received: via spool by 62412-submit@debbugs.gnu.org id=B62412.167974654417692 (code B ref 62412); Sat, 25 Mar 2023 12:16:02 +0000 Original-Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 12:15:44 +0000 Original-Received: from localhost ([127.0.0.1]:41965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2oC-0004bI-7j for submit@debbugs.gnu.org; Sat, 25 Mar 2023 08:15:44 -0400 Original-Received: from mail-yw1-f177.google.com ([209.85.128.177]:45933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2oB-0004b6-14 for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 08:15:43 -0400 Original-Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5418d54d77bso82493357b3.12 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 05:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679746528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bnxwTkZUUCUNhEWUcEbTql2RNVxvvUkXqh+koemogyk=; b=La63dptjhG1gGBQPKkwOt/9punGRHjvukly8q0wPfhjex2Gv9uBV+0YyKIjwVLVM32 u/+YxkPjrI1ocOtawEtgshkHoL7rgtXHvFCUb+iEOYh+Kfl6FHjSxGfspbdSfKNR1nyf p7C2t2AXcB3YrBfZJLDGZrexdlHY7bvetcNpzn1aLYAgq4tWP49AfRVa35R88n9cjbQJ TyAJx0HQO2VC+MyNEF1hPaDygNMgahWHLs6RXLppmHk31eYTcMH8OpjHcFeE+zLre2E6 NKeTjD6wc9pdD4Jzqw3/4VEaGQMAzQY8tHPSk1S4IJDbGWCeeqqZ9JaXxjS4g7IXLAor q7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679746528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bnxwTkZUUCUNhEWUcEbTql2RNVxvvUkXqh+koemogyk=; b=d+6+34M89sedhdM+xSjBNI1vcIFhrE0aQT9Zb2bKNI1J53hFYdHzETxir/vmBUazFt eBXUbtQbyIZhwEhg7En8WM4Ems8MUyCblrnKwVWDzxSJui1k8FvjWlPfsWBR9GVNj7V+ IsNEST6ux0yU+znvYtzUsDVSKlYIBmrdB+w2P/HNlbAWrATB0DMqKY2VKuFYCrYRMkJ1 gpt0kima8JBFsXct+VkYXvdRgli4g6LLZ6JwfsbK2mpc9NBxsKrwMNPGhZHYo2+Mq3Rs w0au+qBjTmu98o8mmUpMW7FxfbN/eTSxzLNDa8luAudAmCB/JRT5G3I8kTrqfWpFmWCE y19w== X-Gm-Message-State: AAQBX9c+vp2cMsdhgDbaIY4MhnNtXuBLNV4dhmoJTqj4Fhj43TmgqQOP jW7DcuGR7XI9+eGp7NVKdB7cBZzdOmMXO8mNjSLltdIy X-Google-Smtp-Source: AK7set8xqaggWA15Ay5Ac2f3J+Vsj2250GqkIPwygO6ibN8i3csLmpvcCBRSRshTDwXtgRfjUzmL8Jxt1byIkyBlqzk= X-Received: by 2002:a54:4716:0:b0:384:1e6a:bf10 with SMTP id k22-20020a544716000000b003841e6abf10mr1258528oik.5.1679739984065; Sat, 25 Mar 2023 03:26:24 -0700 (PDT) In-Reply-To: <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258547 Archived-At: On Sat, Mar 25, 2023 at 10:19=E2=80=AFAM Theodor Thornhill wrote: > > > > On 25 March 2023 09:53:31 CET, "Jo=C3=A3o T=C3=A1vora" wrote: > >On Fri, Mar 24, 2023 at 10:02=E2=80=AFPM Theodor Thornhill via Bug repor= ts for > >GNU Emacs, the Swiss army knife of text editors > > wrote: > >e about the original purpose for this rule, CC=E2=80=99ing 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 wo= uld advise people to use electric-pairs-mode (if that's the correct name, o= n 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=C3=A3o > > 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 o= ften when the closing paren or bracket is inserted, as it is much simpler t= o 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=C3=A3o