From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72263: 31.0.50; Wrong indentation c++-ts-mode Date: Wed, 31 Jul 2024 23:09:53 +0200 Message-ID: <266A7254-4449-4F6A-A69F-D98C6DF8CC2E@aol.com> References: <87cyn3vequ.fsf.ref@aol.com> <87cyn3vequ.fsf@aol.com> <86h6ce53pw.fsf@gnu.org> Reply-To: Ergus Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=----0HKC2A1FCVLEN4AVDSP7U02CLPY9CK Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39577"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72263@debbugs.gnu.org To: Yuan Fu , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 31 23:11:08 2024 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 1sZGbE-000A5Y-3t for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 31 Jul 2024 23:11:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGay-0002Pe-31; Wed, 31 Jul 2024 17:10:53 -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 1sZGas-00023g-RY for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 17:10:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGas-00024M-4z for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 17:10:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=WZ6/kCqFmDZ6s59TyyYG0lJaGfNzN059lymjCYT51Zs=; b=gsZxwTWNOSg5tYu0nYlJN6rr8es7HQK852m+eehyuT7m71jGZ1MxXuKn3q/mHtPF78rsMsh5na/LzdVy+iu6Ir/8QyLT0TlMfxqKEJnDtB+hIbebBio6SpbfYm9Um8CAJ+XZYP5L29yyb4oyUj8zRjzjqOhcGEmis6vpmt0y2HTKw9VSEJXtJvt1UVU+tm9tEuGAk6yd25D4wdluSOYSi2gtrpfRgZ5uyubbgkcFdvNc+HQiYp5CEjn4B83QwUAxwn7YuIlVQjf8zBYuwdrF9CispOKM9jHQJOBodZhObZjBeLcxB2lrS7iSu8M5r/Jd6Wv/CU9ePYGbZEJ1AWCeaA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sZGb7-0003rF-T0 for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 17:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jul 2024 21:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72263 X-GNU-PR-Package: emacs Original-Received: via spool by 72263-submit@debbugs.gnu.org id=B72263.172246022914792 (code B ref 72263); Wed, 31 Jul 2024 21:11:01 +0000 Original-Received: (at 72263) by debbugs.gnu.org; 31 Jul 2024 21:10:29 +0000 Original-Received: from localhost ([127.0.0.1]:50368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sZGab-0003qV-AD for submit@debbugs.gnu.org; Wed, 31 Jul 2024 17:10:29 -0400 Original-Received: from sonic304-10.consmr.mail.bf2.yahoo.com ([74.6.128.33]:33518) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sZGaZ-0003qE-9i for 72263@debbugs.gnu.org; Wed, 31 Jul 2024 17:10:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1722460205; bh=WZ6/kCqFmDZ6s59TyyYG0lJaGfNzN059lymjCYT51Zs=; h=Date:From:To:CC:Subject:In-Reply-To:References:From:Subject:Reply-To; b=cTXAHlf/xhECUMGM/sgZe2Lcdqp6QoNCGDJpJ74JG2VNPrOnhn37oKhFvwb4pH7gD+T85vAzeWmtyi18Y1Ei1W4I/sQQYnquTdw6bQdpsUdz8oO+v+dqza16DhBX63gRHqVd4+Ubh0g7wkB5ooT3vsZqhhZ0dXx+nluKYqRxE4d9iCtUCFnG7yzyzjfWmWyDrNqWtlUKGNjN/4rZCVTur+8fxuPaVvV1vppjj9gfQEWgkzXuf8X+/hISQg0bcxDF4ifxxi5rnDdjwPqgnrIHtfr5P5U9f9QUzAZqHN6xuekZbSWyD8A0JOOHiIe6UnDqRIzlkzDjCg9H1BqI94g+1w== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1722460205; bh=zBTaHu0ipwrMMw7D1FjTasf4tbVkkBTKxpOJKhLR0ha=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=ZqHAV76bgzQPsDDs3G5QtjdtuxABsDpvadI/TX/Z3pmJfzQX40gIc+HflaZUgYJgyzLaZpdVcbwKmbJpSP0KnsjCQyfB1GlAJZto8ExQGl1K/iFDHYn8PWCDu0+9QhPT3CGygMDn5c6Am0CeHiwSn8Z2H+Uz28YsA4inJ7jRjyTvJKIE8/eFm3vV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3e-6674-4e26-8992-c292db734ff4 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Wed, 31 Jul 2024 21:10:05 +0000 Original-Received: by hermes--production-ir2-6664f499fc-stbn9 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6bac416d24bbab92fcdcc17847980a0c; Wed, 31 Jul 2024 21:10:00 +0000 (UTC) In-Reply-To: X-Mailer: WebService/1.1.22544 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol 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:289591 Archived-At: ------0HKC2A1FCVLEN4AVDSP7U02CLPY9CK Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi again Yuan: I found another indentation issue in if-else conditions without parenthesis: if (pid =3D=3D 0) print "hello from the child" else print "hello from the parent" The else is not indented properly: This is the explore output: (translation_unit (if_statement if condition:=20 (parenthesized_expression ( (binary_expression left: (identifier) operator: =3D=3D right: (number_= literal)) )) consequence:=20 (expression_statement (concatenated_string (identifier) (string_literal " (string_content) ") (identifier) (identifier) (string_literal " (string_content) ")) ;))) Best, Ergus On July 25, 2024 9:53:16 AM GMT+02:00, Yuan Fu wrote= : > > >> On Jul 25, 2024, at 12:29=E2=80=AFAM, Eli Zaretskii wr= ote: >>=20 >>> Date: Wed, 24 Jul 2024 02:02:33 +0200 >>> From: Ergus via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>>=20 >>> When using c++-ts-mode there is an indentation issue apparently relate= d >>> with namespaces+templates=2E >>>=20 >>> c-ts-mode-indent-style 'linux (but with 'gnu also happens) >>>=20 >>> ``` >>> namespace A { >>>=20 >>> T myfunction1(const char *fname) >>> { >>> } >>>=20 >>> template >>> T myfunction2(const char *fname) >>> { >>> } >>>=20 >>> } >>> ``` >>>=20 >>> The myfunction2 may be indented as expected, but it is not=2E >>>=20 >>> The explorer shows: >>>=20 >>> ``` >>> (translation_unit >>> (namespace_definition namespace name: (namespace_identifier) >>> body:=20 >>> (declaration_list { >>> (function_definition type: (primitive_type) >>> declarator:=20 >>> (function_declarator declarator: (identifier) >>> parameters:=20 >>> (parameter_list ( >>> (parameter_declaration >>> (type_qualifier const) >>> type: (primitive_type) >>> declarator: (pointer_declarator * declarator: (identifier))) >>> ))) >>> body: (compound_statement { })) >>> (template_declaration template >>> parameters:=20 >>> (template_parameter_list < >>> (type_parameter_declaration class (type_identifier)) >>>> ) >>> (function_definition type: (type_identifier) >>> declarator:=20 >>> (function_declarator declarator: (identifier) >>> parameters:=20 >>> (parameter_list ( >>> (parameter_declaration >>> (type_qualifier const) >>> type: (primitive_type) >>> declarator: (pointer_declarator * declarator: (identifier))) >>> ))) >>> body: (compound_statement { }))) >>> }))) >>> ``` >>=20 >> Yuan, can you take a look, please? > >Yeah let me take a look=2E > >Yuan --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E ------0HKC2A1FCVLEN4AVDSP7U02CLPY9CK Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi again Yuan:

I found an= other indentation issue in if-else conditions without
parenthesis:
if (pid =3D=3D 0)
=C2=A0=C2=A0 print "hello from the child"
=C2=A0= =C2=A0 else
=C2=A0=C2=A0 print "hello from the parent"


The el= se is not indented properly:

This is the explore output:

(tra= nslation_unit
(if_statement if
=C2=A0 condition:
=C2=A0=C2=A0 (p= arenthesized_expression (
=C2=A0=C2=A0=C2=A0 (binary_expression left: (i= dentifier) operator: =3D=3D right: (number_literal))
=C2=A0=C2=A0=C2=A0 = ))
=C2=A0 consequence:
=C2=A0=C2=A0 (expression_statement
=C2=A0= =C2=A0=C2=A0 (concatenated_string (identifier)
=C2=A0=C2=A0=C2=A0=C2=A0 = (string_literal " (string_content) ")
=C2=A0=C2=A0=C2=A0=C2=A0 (identifi= er) (identifier)
=C2=A0=C2=A0=C2=A0=C2=A0 (string_literal " (string_cont= ent) "))
=C2=A0=C2=A0=C2=A0 ;)))


Best,
Ergus

=
On July 25, 2024 9:53:16 A= M GMT+02:00, Yuan Fu <casouri@gmail=2Ecom> wrote:


On Jul 25, 2024, at 12:29=E2= =80=AFAM, Eli Zaretskii <eliz@gnu=2Eorg> wrote:

Date: Wed, 24 Ju= l 2024 02:02:33 +0200
From: Ergus via "Bug reports for GNU Emacs,
th= e Swiss army knife of text editors" <bug-gnu-emacs@gnu=2Eorg>

= When using c++-ts-mode there is an indentation issue apparently related
= with namespaces+templates=2E

c-ts-mode-indent-style 'linux (but with= 'gnu also happens)

```
namespace A {

T myfunction1(const = char *fname)
{
}

template <class T>
T myfunction2(con= st char *fname)
{
}

}
```

The myfunction2 may be ind= ented as expected, but it is not=2E

The explorer shows:

```(translation_unit
(namespace_definition namespace name: (namespace_ide= ntifier)
body:
(declaration_list {
(function_definition typ= e: (primitive_type)
declarator:
(function_declarator declar= ator: (identifier)
parameters:
(parameter_list (
(parameter= _declaration
(type_qualifier const)
type: (primitive_type)
decl= arator: (pointer_declarator * declarator: (identifier)))
)))
body= : (compound_statement { }))
(template_declaration template
par= ameters:
(template_parameter_list <
(type_parameter_de= claration class (type_identifier))
)
(function_definition type: (type_identifier)
declarator: (function_declarator declarator: (identifier)
parameters:
(pa= rameter_list (
(parameter_declaration
(type_qualifier const)
= type: (primitive_type)
declarator: (pointer_declarator * declarator: (= identifier)))
)))
body: (compound_statement { })))
})))```

Yuan, can you take a look= , please?

Yeah let me take a lo= ok=2E

Yuan
--
Sent from my Android device with K-9 Mail=2E = Please excuse my brevity=2E
------0HKC2A1FCVLEN4AVDSP7U02CLPY9CK--