From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Newsgroups: gmane.emacs.bugs Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Date: Sat, 25 Mar 2023 11:26:04 +0100 Message-ID: References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3030"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Cc: Yuan Fu , 62412@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 25 19:39:27 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 1pg8nX-0000Ql-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Mar 2023 19:39:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pg8nB-0004l9-Hu; Sat, 25 Mar 2023 14:39:05 -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 1pg8n9-0004kr-Ju for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 14:39:03 -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 1pg8n9-0003r7-Aw for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 14:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pg8n8-00016t-Bl for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 14:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Mar 2023 18:39: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.16797694844171 (code B ref 62412); Sat, 25 Mar 2023 18:39:02 +0000 Original-Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 18:38:04 +0000 Original-Received: from localhost ([127.0.0.1]:43484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg8mB-00015B-Rz for submit@debbugs.gnu.org; Sat, 25 Mar 2023 14:38:04 -0400 Original-Received: from mail-lj1-f171.google.com ([209.85.208.171]:42751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg8mA-00014d-0T for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 14:38:02 -0400 Original-Received: by mail-lj1-f171.google.com with SMTP id x20so4952646ljq.9 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 11:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679769476; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Hfyrfe2nrTYd9tJ/Gz1MV+VN2gXxTg10MyUWBW2Rcw0=; b=qslVMevh82nlmshnYyrL6I2iEmyyshhED2/3vs3IQExKVLw4IZ8lAt+V2CSJhKjhJV jf/lbZ6Smz0Uczzn6KCzamc81pMFYuvxCEgjVUuHWFsv0hyI2uFRe+QGLEFIJDOgO7ha O8mWMX/nSAbJGI77hXlY9w0soQ6QxaIEFByf/ej4NgyliplZRM5we7oK6J4lKNMt+iMY Vcb5cwwIsCjpvLCdoM/PzMuetH5sOVq2XJreo3FB0J6eK+xAX5qe3pd5dCzDhmfEQqc5 B8ZV5k6YLPrPcBMMeWTqAxLvxbfFmxvLZ+8bmhDrmkzLPJRXjK+/qJdKOEOkINMdwjzz V67Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679769476; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hfyrfe2nrTYd9tJ/Gz1MV+VN2gXxTg10MyUWBW2Rcw0=; b=1QDORpn54dGS2lSSRTdsgQMkBht2JEFw5EhYQxfP/lxYXNQF4jC0hSFwr8M/3jdjIM zI9PdRLONy6i919Mb+P3nnfz9AWG6L5XyU6FspUKA7luV6ttluOK0DNgF7pqdvB+/Sye URfbknYyexD6ifMSox7CKgmjKYj88xxV1b178Sf8p0fhn1u+1ElgWY//INPx2+smzjKk sJzLQ7gh/k+QSYcBf+j1TIQ7PJmsOlxZBJ8g6k2y/5PEmRRx7qZZUJ9BMkK3gLZmqRjI 1TznLHdtidL+qTIVM59XCX+kV8r/DRCYY2OOsMH95CWFQGdkHwOuHbnXPNQovzbd+ceI GRyg== X-Gm-Message-State: AAQBX9dXstAKPD8o+fUBMBKWSZBjoxt/VYXD3yDZrOhSmQmjoTnRLtQE +oNxctFoIVANauzWaROqr9c3zDQlu4w= X-Google-Smtp-Source: AKy350YU3SRl1H0U7mkTKpp8/NDSvbQkKNU8lEDEkbFQ54t6WrdnxaEIadGtLDXzV0R8X0plULPF8A== X-Received: by 2002:a17:906:284c:b0:931:99b5:5a23 with SMTP id s12-20020a170906284c00b0093199b55a23mr5567276ejc.44.1679739966438; Sat, 25 Mar 2023 03:26:06 -0700 (PDT) Original-Received: from [192.168.8.4] (netacc-gpn-204-88-167.pool.yettel.hu. [5.204.88.167]) by smtp.gmail.com with ESMTPSA id gz4-20020a170907a04400b0090e0a4e1bacsm11528537ejc.159.2023.03.25.03.26.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Mar 2023 03:26:06 -0700 (PDT) Content-Language: sv-FI In-Reply-To: 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:258614 Archived-At: That's the difference. c++-ts-mode appends "{}():;,#" to electric-indent-chars, while c++-mode doesn't do this. Nevertheless, I think that the calculated intendation should be a correct number. Even if the user turns off electric-indent-mode, but dedices to call re-indenting manually for a half-written for loop, emacs should re-intent the line properly. At least, this specific example works OK with c++-mode. (note that I understand that this problem is not trivial, tree sitter/emacs may get confused if the buffer cannot be properly parsed) On 3/25/23 09:53, João Távora 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 > 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