GNU bug report logs - #59686
30.0.50; tree-sitter indentation in some loops and conditional statements is wrong

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Bruce Stephens <bruce.stephens@HIDDEN>; merged with #60398, #60496; dated Tue, 29 Nov 2022 18:42:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 15 Jan 2023 09:24:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 15 04:24:00 2023
Received: from localhost ([127.0.0.1]:56104 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pGzFA-0003WB-EZ
	for submit <at> debbugs.gnu.org; Sun, 15 Jan 2023 04:24:00 -0500
Received: from mail-pl1-f177.google.com ([209.85.214.177]:43528)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>)
 id 1pGzF6-0003Ve-AQ; Sun, 15 Jan 2023 04:23:57 -0500
Received: by mail-pl1-f177.google.com with SMTP id d3so27501315plr.10;
 Sun, 15 Jan 2023 01:23:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=XUt8CmYvOAqndeajKxKqQoDiBG9HvdpRha5qDKw258Y=;
 b=LoNdkXnWInZWOyUSiz9jjvlDLEaJI3YYhz7Jh16SHWnG2iaCy8LdiHzCefShUrzPtf
 V2njRovqGxh7ga4S1GxfJ6ToEjUWAEAcKm8tnMGk3Kn+FgBT+slDFLNYgYvdLW2NF+c7
 yYw7BbeVTbJE0K+aKj9SFTaytXg5J0yNXIed+hfhqQJzV4vrQ5YjYjXNInFmmXz17Pb7
 wtMt9i96h1DVk8iUiflVT91DbsPCEbbQNDpEkFF+t6zUgKtcennOnMKgiRgO+/9ERkRF
 3Q88CiqWDPmWEnxCLSq3vm4zORjiLpuGXX97Oid2fJ6AufrXh3x43I2PVZWVBwkuaccL
 4xbA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=XUt8CmYvOAqndeajKxKqQoDiBG9HvdpRha5qDKw258Y=;
 b=PMmMqMDFpaY9hsPOWH+iwobxQA0wXuBaqGReLQDyPcPVkn7UaRCKhf1B04nL/CvTXK
 kwZkUSiEknF5mLYuBluNBWVVwLDGfNzMIaSKMnm6LI+7+pFkUboVpkejF8YlM7IrJ15/
 FfzyUwfRty4CeiN/xxF1jJ8bcZWetrmvpsj1UgmklYYRtJ6KXUy9897CQkDmq76Yt9Kw
 zoiUzC/5lgID8lQ5/i0o+2f6k/ptLr9clsL855xV9ymeoMToH4/1v+OrzmGsIhq9zwvb
 RPvLezy0VCaxz+YqktSHW6G+axhXXdssVABvNXRiOcPocxU1Eq83AWLlx8ZAR5lvSe3r
 B/FA==
X-Gm-Message-State: AFqh2krQ5HTS0IFdrtUx2mSem/LbM+D/T7TFljzjWkDnBhL38woeNjVS
 jax9YxPengPTEytxbo4DW3A=
X-Google-Smtp-Source: AMrXdXv4DdrCUVMRZOCYDhE3ISRLMoEjW9CDGEUHknY+YlApmPtWuCis4TKAOt89Z6S7Jy91pxybaw==
X-Received: by 2002:a17:903:1d2:b0:194:7aae:f272 with SMTP id
 e18-20020a17090301d200b001947aaef272mr7630081plh.30.1673774629138; 
 Sun, 15 Jan 2023 01:23:49 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 ik9-20020a170902ab0900b00183c67844aesm17081200plb.22.2023.01.15.01.23.48
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 15 Jan 2023 01:23:48 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60496: 29.0.60; c-ts-mode: Broken indentation with linux 
 style conditionals
Message-Id: <14D85B96-4968-45D9-8296-819E440F01C3@HIDDEN>
Date: Sun, 15 Jan 2023 01:23:45 -0800
To: Theodor Thornhill <theo@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, eliz@HIDDEN, 60496 <at> debbugs.gnu.org,
 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Yuan Fu <casouri@HIDDEN> writes:

>> On Dec 3, 2022, at 3:08 AM, Theodor Thornhill <theo@HIDDEN> =
wrote:
>>=20
>>=20
>>=20
>> On 3 December 2022 11:48:34 CET, Yuan Fu <casouri@HIDDEN> wrote:
>>>=20
>>> Theodor Thornhill <theo@HIDDEN> writes:
>>>=20
>>>> Bruce Stephens <bruce.stephens@HIDDEN> writes:
>>>>=20
>>>>> On 02/12/2022 08:39, Eli Zaretskii wrote:
>>>>>=20
>>>>>> FWIW, this is an unusual style, so I see no catastrophe if it is =
not 110%
>>>>>> according to expectations.  Users can easily fix that by tweaking =
their BOLs
>>>>>> where important.
>>>>>=20
>>>>>=20
>>>>> The example I gave would be unusual, I think, but I'd argue that =
the
>>>>> situations where I saw the problem are quite natural.
>>>>>=20
>>>>> For example,
>>>>>=20
>>>>>                 } else if ( MYSTRCMP (attname, =
SOME_PREFIX_X400ADDRESS) ||
>>>>>                             MYSTRCMP (attname, SOME_PREFIX_X400) ) =
{
>>>>>                     FOO_ptr orp =3D foo_std2foo (val);
>>>>>=20
>>>>> or a function declaration with several arguments with types that =
are
>>>>> rather long.
>>>>>=20
>>>>> I agree it's not a critical bug but if there's no appropriate =
general
>>>>> fix it would be helpful to have some guidance for users to resolve =
our
>>>>> specific cases.
>>>>=20
>>>> This is the case I was thinking of.  In the for-loop a =
grand-parent-bol
>>>> on compound_statement rule would match the 'for' keyword, so the
>>>> indentation will be correct, but this one will not, IIRC.  I plan =
to dig
>>>> into this some more soon, but motivation left me a little on that =
issue.
>>>> Maybe we could make a preset like:
>>>>=20
>>>> ```
>>>> (seq
>>>> (parent-is "compound_statement") parent (parent-is "for_statement") =
bol)
>>>> ```
>>>>=20
>>>>=20
>>>> In other words, make other presets execute sequentially, move =
point,
>>>> check again, and if all are true, pick indent offset.  Or allow =
multiple
>>>> captures, like so:
>>>>=20
>>>> ```
>>>> (for_statement @offset-anchor
>>>>  body: (compound_statement (_) @to-indent))
>>>> ```
>>>>=20
>>>> Here the @to-indent capture would get the new indent level based on
>>>> treesit-node-start of for_statement.
>>>>=20
>>>> What do you think, Yuan?
>>>=20
>>> I think we can just test for the grandparent, there is an
>>> (undocumented) matcher n-p-gp which matches parent and grandparent.
>>>=20
>>> Yuan
>>=20
>> Yeah I know, but that doesn't work in every case we see this =
behavior.
>
> I see, but at least it fixes common cases that I can think of right =
now, namely if, for, while. What are some other cases?

I just pushed a change (189d976dbae) that I think fixes this kind of
problems. Instead of trying to figure out the right anchor, we simply
count the number of {} blocks between the node at point and the root
node, and use that number (multiplied by c-ts-mode-indent-offset) as the
indentation.

If you think about it, both

for (a;b;c)
{
  |
}

and

for (a;
     b;
     c)
{
  |    =20
}

are one block-level deep.  So multi-line conditions is not an issue
anymore.

And

int main()
{
  if ()
    {
      |
    }
}

is 2 block-level deep, etc.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.
Merged 59686 60398 60496. Request was from Yuan Fu <casouri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Merged 59686 60496. Request was from Yuan Fu <casouri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 3 Dec 2022 11:19:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 03 06:19:58 2022
Received: from localhost ([127.0.0.1]:51585 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p1QYn-0008Ai-UU
	for submit <at> debbugs.gnu.org; Sat, 03 Dec 2022 06:19:58 -0500
Received: from mail-pg1-f182.google.com ([209.85.215.182]:45707)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p1QYi-0008Aa-TX
 for 59686 <at> debbugs.gnu.org; Sat, 03 Dec 2022 06:19:56 -0500
Received: by mail-pg1-f182.google.com with SMTP id r18so6439328pgr.12
 for <59686 <at> debbugs.gnu.org>; Sat, 03 Dec 2022 03:19:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=4NjYztyLW9VszXoMt45vMju+KI4vYzF66AczmQQ1MYc=;
 b=XVLgqKdfiV6L/aaJzsmBgZFLpHC7aVkr5UKaO3otaiyDiN+hfKNDTZmeFydNzl1onZ
 Rk4BB2PfzPYftRvV5FytywSL/e8gZE9aUkDdprI/fc2A2YqUmOUaV6EZVgj3+DZNiOfI
 gzonH/aFcFXQUNaYdvGC1YbsiVf1nYKFIeusU7L5AUuknOW89KHvySUpIKuKNsaGYQci
 3gMo69kIMiBOWGRVYCb45effgZ1O4rN9V1Y7T7Wy25cPGbnPqgMd46/AO7OJCgbYuyH5
 kpeWi4cTRMym90ddewTtUyj6BnaFAbbv90bf3rHAf/FpKhN0KWVuAvOe2NcyGDDw0Yx9
 9bLg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=4NjYztyLW9VszXoMt45vMju+KI4vYzF66AczmQQ1MYc=;
 b=rO1BySgeArPFviEhadxzJyBmAdXuaMA1cNWnY30NNRlJAlVnMOe5bAlevkCN2REC3e
 XOTGXBRemiMj5fvcswYOqgC9KWMnMp41DzctKPuFlPniDw+TP6tGPDhwZoh5tEDp1gcx
 z9nZTwPt10jm10+rOubiybpGKTmJOcTaAzAWhdQd2vb9HyIRDvoA70vZ9tg6z1+/bSZe
 /R6yOsNSDTWCxjpGruk1r1o1uFiIEx5lK40NLMIMKQ0St4l/4yXITfEE4TTZUpEDZ6Q4
 elABmfUNGT35ztV4hB7Wjx+FEIW4kuYAp5KaJMjnOKlp1aKBKFb6pyqOW7uvTwJzmKhE
 mNFw==
X-Gm-Message-State: ANoB5pl0xmDiTTg7uin8PsIRYuk2nDdZ0ykvApHaKVkR2wks7hxVQlya
 02105gAfV78NP+9DNiZne94=
X-Google-Smtp-Source: AA0mqf4WC4DaMhPGXw41by7PlKVxfeCFLZYiC/FUDG8tOH+fFypswe2BJH2xSLbLMCIsIutLesmxFQ==
X-Received: by 2002:a63:5146:0:b0:477:86c1:640f with SMTP id
 r6-20020a635146000000b0047786c1640fmr49508770pgl.231.1670066386879; 
 Sat, 03 Dec 2022 03:19:46 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 e1-20020a621e01000000b0057621a437d7sm4583487pfe.116.2022.12.03.03.19.45
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 03 Dec 2022 03:19:46 -0800 (PST)
Content-Type: text/plain;
	charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and 
 conditional statements is wrong
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <CF60B970-885B-4935-8BF7-B4E6D121EBF4@HIDDEN>
Date: Sat, 3 Dec 2022 03:19:45 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <2DADEBEF-A7CD-45C6-9B2B-1B766D14788E@HIDDEN>
References: <F75E7056-3D82-4B45-B11D-137BD87E290A@HIDDEN>
 <CF60B970-885B-4935-8BF7-B4E6D121EBF4@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, Eli Zaretskii <eliz@HIDDEN>,
 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



> On Dec 3, 2022, at 3:08 AM, Theodor Thornhill <theo@HIDDEN> =
wrote:
>=20
>=20
>=20
> On 3 December 2022 11:48:34 CET, Yuan Fu <casouri@HIDDEN> wrote:
>>=20
>> Theodor Thornhill <theo@HIDDEN> writes:
>>=20
>>> Bruce Stephens <bruce.stephens@HIDDEN> writes:
>>>=20
>>>> On 02/12/2022 08:39, Eli Zaretskii wrote:
>>>>=20
>>>>> FWIW, this is an unusual style, so I see no catastrophe if it is =
not 110%
>>>>> according to expectations.  Users can easily fix that by tweaking =
their BOLs
>>>>> where important.
>>>>=20
>>>>=20
>>>> The example I gave would be unusual, I think, but I'd argue that =
the
>>>> situations where I saw the problem are quite natural.
>>>>=20
>>>> For example,
>>>>=20
>>>>                 } else if ( MYSTRCMP (attname, =
SOME_PREFIX_X400ADDRESS) ||
>>>>                             MYSTRCMP (attname, SOME_PREFIX_X400) ) =
{
>>>>                     FOO_ptr orp =3D foo_std2foo (val);
>>>>=20
>>>> or a function declaration with several arguments with types that =
are
>>>> rather long.
>>>>=20
>>>> I agree it's not a critical bug but if there's no appropriate =
general
>>>> fix it would be helpful to have some guidance for users to resolve =
our
>>>> specific cases.
>>>=20
>>> This is the case I was thinking of.  In the for-loop a =
grand-parent-bol
>>> on compound_statement rule would match the 'for' keyword, so the
>>> indentation will be correct, but this one will not, IIRC.  I plan to =
dig
>>> into this some more soon, but motivation left me a little on that =
issue.
>>> Maybe we could make a preset like:
>>>=20
>>> ```
>>> (seq
>>> (parent-is "compound_statement") parent (parent-is "for_statement") =
bol)
>>> ```
>>>=20
>>>=20
>>> In other words, make other presets execute sequentially, move point,
>>> check again, and if all are true, pick indent offset.  Or allow =
multiple
>>> captures, like so:
>>>=20
>>> ```
>>> (for_statement @offset-anchor
>>>  body: (compound_statement (_) @to-indent))
>>> ```
>>>=20
>>> Here the @to-indent capture would get the new indent level based on
>>> treesit-node-start of for_statement.
>>>=20
>>> What do you think, Yuan?
>>=20
>> I think we can just test for the grandparent, there is an
>> (undocumented) matcher n-p-gp which matches parent and grandparent.
>>=20
>> Yuan
>=20
> Yeah I know, but that doesn't work in every case we see this behavior.

I see, but at least it fixes common cases that I can think of right now, =
namely if, for, while. What are some other cases?

Yuan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 3 Dec 2022 11:09:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 03 06:09:42 2022
Received: from localhost ([127.0.0.1]:51580 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p1QOr-000860-NF
	for submit <at> debbugs.gnu.org; Sat, 03 Dec 2022 06:09:42 -0500
Received: from out-18.mta0.migadu.com ([91.218.175.18]:37127)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1p1QOp-00085u-VV
 for 59686 <at> debbugs.gnu.org; Sat, 03 Dec 2022 06:09:40 -0500
Date: Sat, 03 Dec 2022 12:08:59 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1670065778;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=3crI0PuhEwOb2adRJsEri4TJhJQ5E/Ri3eIHqu0g3AM=;
 b=Lkwx1WwwH69xLLdxjlHd6TxiSPXgj3JzkS7egcGeQCzxwDXjVAmnnxtZUlzIp7xIZ/hOUv
 fkzFluYXM3yMZp/eqwV5jKIeGNLHEr94V1OuYnuuzfABFJqn57xuVscHAZTp9l9GiQtl59
 NE9gVjBj0v+ZGYJCzi5R4GewDYTtoRu9D36vVwkIynagJjmJ5hTuXByKqDAuQYzb/rx6/X
 h4CwjuunwLNgDtqHwzAacmAlb/KxgC9wWtxfM3vloODzqpf2n+L0Jx2NHOBy2jhn1g6X7e
 xyGU6ayxxLvD+GnC80+5xi50vkCnt4YRHQJqZwH2Fy262CG/UxwpKXk+TUNjVA==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
Subject: =?US-ASCII?Q?Re=3A_bug=2359686=3A_30=2E0=2E50=3B_?=
 =?US-ASCII?Q?tree-sitter_indentation_i?=
 =?US-ASCII?Q?n_some_loops_and__conditional_statements_is_wrong?=
In-Reply-To: <F75E7056-3D82-4B45-B11D-137BD87E290A@HIDDEN>
References: <F75E7056-3D82-4B45-B11D-137BD87E290A@HIDDEN>
Message-ID: <CF60B970-885B-4935-8BF7-B4E6D121EBF4@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, Eli Zaretskii <eliz@HIDDEN>,
 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 3 December 2022 11:48:34 CET, Yuan Fu <casouri@gmail=2Ecom> wrote:
>
>Theodor Thornhill <theo@thornhill=2Eno> writes:
>
>> Bruce Stephens <bruce=2Estephens@isode=2Ecom> writes:
>>
>>> On 02/12/2022 08:39, Eli Zaretskii wrote:
>>>
>>>> FWIW, this is an unusual style, so I see no catastrophe if it is not =
110%
>>>> according to expectations=2E  Users can easily fix that by tweaking t=
heir BOLs
>>>> where important=2E
>>>
>>>
>>> The example I gave would be unusual, I think, but I'd argue that the
>>> situations where I saw the problem are quite natural=2E
>>>
>>> For example,
>>>
>>>                  } else if ( MYSTRCMP (attname, SOME_PREFIX_X400ADDRES=
S) ||
>>>                              MYSTRCMP (attname, SOME_PREFIX_X400) ) {
>>>                      FOO_ptr orp =3D foo_std2foo (val);
>>>
>>> or a function declaration with several arguments with types that are
>>> rather long=2E
>>>
>>> I agree it's not a critical bug but if there's no appropriate general
>>> fix it would be helpful to have some guidance for users to resolve our
>>> specific cases=2E
>>
>> This is the case I was thinking of=2E  In the for-loop a grand-parent-b=
ol
>> on compound_statement rule would match the 'for' keyword, so the
>> indentation will be correct, but this one will not, IIRC=2E  I plan to =
dig
>> into this some more soon, but motivation left me a little on that issue=
=2E
>> Maybe we could make a preset like:
>>
>> ```
>> (seq
>>  (parent-is "compound_statement") parent (parent-is "for_statement") bo=
l)
>> ```
>>
>>
>> In other words, make other presets execute sequentially, move point,
>> check again, and if all are true, pick indent offset=2E  Or allow multi=
ple
>> captures, like so:
>>
>> ```
>> (for_statement @offset-anchor
>>   body: (compound_statement (_) @to-indent))
>> ```
>>
>> Here the @to-indent capture would get the new indent level based on
>> treesit-node-start of for_statement=2E
>>
>> What do you think, Yuan?
>
>I think we can just test for the grandparent, there is an
>(undocumented) matcher n-p-gp which matches parent and grandparent=2E
>
>Yuan

Yeah I know, but that doesn't work in every case we see this behavior=2E




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 3 Dec 2022 10:48:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 03 05:48:45 2022
Received: from localhost ([127.0.0.1]:51562 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p1Q4a-0007vH-MM
	for submit <at> debbugs.gnu.org; Sat, 03 Dec 2022 05:48:45 -0500
Received: from mail-pj1-f45.google.com ([209.85.216.45]:41514)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p1Q4Y-0007vB-Px
 for 59686 <at> debbugs.gnu.org; Sat, 03 Dec 2022 05:48:43 -0500
Received: by mail-pj1-f45.google.com with SMTP id
 w15-20020a17090a380f00b0021873113cb4so7313679pjb.0
 for <59686 <at> debbugs.gnu.org>; Sat, 03 Dec 2022 02:48:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=m/ouI0A6hYaCxA8eEvt7q6Dx1AcJNkzUnYu1A06D714=;
 b=ab3L+TFX8nh+3ebOyCb0h9l+nzQXTrDm7Yty89ro9Karg095TI+pltDpXWn1Eii2Jj
 SFNiAbRTlCc5ZwquiZIRnhyl0u6pAFuj78e8sWsuUuA0NTyZRJtVteL8Fz0yv3L14Fcc
 CUxa+aJW3dxxnOIGQ1hTz8+0dB6Zek5DylM7xJW9XGM+Bl8xZ5vsF4KQkRCm6bAwbwTr
 uPAy+p12zPSu6NcruJckUW8meohL0UzdjPy/f4xTaw/WWTKIVdR3OtjwsqTMOR4X/KQK
 yhZRkP3zaTdR/n3fNV5U9U7JAARzsr197+urg1a0tD2DXrAA9dfwUHvu8pBw5CdwTUAK
 Wt9w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=m/ouI0A6hYaCxA8eEvt7q6Dx1AcJNkzUnYu1A06D714=;
 b=z7f7jU501jOhEj6k+j17KWqfrj6azIbgNSjTorBkLoosNvGrNe7Y8jTQc/fkynqAXc
 hL9NqOvaeX1U8uvG1eolglAv6E6jWY6t1U2vmyrzv1s1KlKEZvfnWlpzZC26HABYH0JH
 3X8ya4XmuU2y4UWzFic+T12Q3uZbTsPo5Vgz5W5qt2ARgqKhHp6JSSQMNdLVWV9Y4HJY
 O1d9sKYbDVO9fWG/MQlN68DUbTSmzDUU0aFz1u+t6y+DNrXHH1/9mReZpdA7VJ/q7tn9
 2NcZTxMJReAmIlzWGTMiXXtBj7BczbE7ECfojDPGZVGvAytDjTLiZgNgN1BxwL9Q8Tcj
 M0Ag==
X-Gm-Message-State: ANoB5pnHfdvTf9TrynYXNLsuaQLug1lvwMn5Y/tuQMf5U8avHKINw5C/
 S7Zrf58oi1SKfK5aEOrm2tQ=
X-Google-Smtp-Source: AA0mqf7iebrJIGic7u0JLGecy+7O7vFt9dOC98WYlOF/m6jydfeS2nbLo/xZrLgWIILOer7gMS9BcA==
X-Received: by 2002:a17:90a:94c3:b0:219:e20:9bf7 with SMTP id
 j3-20020a17090a94c300b002190e209bf7mr41142760pjw.61.1670064517030; 
 Sat, 03 Dec 2022 02:48:37 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 t68-20020a625f47000000b0056bbd286cf4sm6486920pfb.167.2022.12.03.02.48.36
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 03 Dec 2022 02:48:36 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and 
 conditional statements is wrong
Message-Id: <F75E7056-3D82-4B45-B11D-137BD87E290A@HIDDEN>
Date: Sat, 3 Dec 2022 02:48:34 -0800
To: Theodor Thornhill <theo@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, Eli Zaretskii <eliz@HIDDEN>,
 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Theodor Thornhill <theo@HIDDEN> writes:

> Bruce Stephens <bruce.stephens@HIDDEN> writes:
>
>> On 02/12/2022 08:39, Eli Zaretskii wrote:
>>
>>> FWIW, this is an unusual style, so I see no catastrophe if it is not =
110%
>>> according to expectations.  Users can easily fix that by tweaking =
their BOLs
>>> where important.
>>
>>
>> The example I gave would be unusual, I think, but I'd argue that the
>> situations where I saw the problem are quite natural.
>>
>> For example,
>>
>>                  } else if ( MYSTRCMP (attname, =
SOME_PREFIX_X400ADDRESS) ||
>>                              MYSTRCMP (attname, SOME_PREFIX_X400) ) {
>>                      FOO_ptr orp =3D foo_std2foo (val);
>>
>> or a function declaration with several arguments with types that are
>> rather long.
>>
>> I agree it's not a critical bug but if there's no appropriate general
>> fix it would be helpful to have some guidance for users to resolve =
our
>> specific cases.
>
> This is the case I was thinking of.  In the for-loop a =
grand-parent-bol
> on compound_statement rule would match the 'for' keyword, so the
> indentation will be correct, but this one will not, IIRC.  I plan to =
dig
> into this some more soon, but motivation left me a little on that =
issue.
> Maybe we could make a preset like:
>
> ```
> (seq
>  (parent-is "compound_statement") parent (parent-is "for_statement") =
bol)
> ```
>
>
> In other words, make other presets execute sequentially, move point,
> check again, and if all are true, pick indent offset.  Or allow =
multiple
> captures, like so:
>
> ```
> (for_statement @offset-anchor
>   body: (compound_statement (_) @to-indent))
> ```
>
> Here the @to-indent capture would get the new indent level based on
> treesit-node-start of for_statement.
>
> What do you think, Yuan?

I think we can just test for the grandparent, there is an
(undocumented) matcher n-p-gp which matches parent and grandparent.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 11:51:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 06:51:23 2022
Received: from localhost ([127.0.0.1]:46236 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p14Ze-0008Iu-I7
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 06:51:22 -0500
Received: from out-70.mta0.migadu.com ([91.218.175.70]:28824)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1p14Zc-0008Io-Fc
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 06:51:21 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1669981876;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=O3jATdpKi1dmxkHcgjwA4Oc+8TohaUyGziDsu2afyJs=;
 b=h1f5MvxxmOgFJXbpeiLS6RinpCZTJmbcB9VHifbHiCqssUVxdfkkUzB36Lvo1znbdfkq2m
 829Dnvpa6nudXbF2WyqYB5GHwkez9aZw0CudrshqwnVLupgFt5bFCFVDuPrKZw7ZMAWACF
 mtY09zJuTnyYMa3bTFI4DA64n/oQxmftpea9jPrV0z91Dk1908VJQZh48y5VGxusvuLT2S
 jE+G8serjdfwfURVF6y+GPE9ICgPY+QxkMF5DTSkxBVEfGS00EWlr0zV57qVJ+IQwAJNVn
 fBlUz1YEX29++il1zdpNVsxrdR+04y8VDdRH2uw+CQlKIlz7g/hu6hd5UuxkUw==
From: Theodor Thornhill <theo@HIDDEN>
To: Bruce Stephens <bruce.stephens@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and
 conditional statements is wrong
In-Reply-To: <86268d17-402f-6ae3-9ed7-100a2591e04d@HIDDEN>
References: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
 <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
 <83v8mufbd2.fsf@HIDDEN> <86268d17-402f-6ae3-9ed7-100a2591e04d@HIDDEN>
Date: Fri, 02 Dec 2022 12:51:14 +0100
Message-ID: <87v8munhvx.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: casouri@HIDDEN, 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Bruce Stephens <bruce.stephens@HIDDEN> writes:

> On 02/12/2022 08:39, Eli Zaretskii wrote:
>
>> FWIW, this is an unusual style, so I see no catastrophe if it is not 110%
>> according to expectations.  Users can easily fix that by tweaking their =
BOLs
>> where important.
>
>
> The example I gave would be unusual, I think, but I'd argue that the=20
> situations where I saw the problem are quite natural.
>
> For example,
>
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 } else if ( MYSTRCMP (attname, SOME_PREFIX_X400ADDRESS) =
||
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 MYSTRCMP (attname, SOME_PREFIX_X400) ) {
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FOO_ptr orp =3D foo_std2foo (val=
);
>
> or a function declaration with several arguments with types that are=20
> rather long.
>
> I agree it's not a critical bug but if there's no appropriate general=20
> fix it would be helpful to have some guidance for users to resolve our=20
> specific cases.

This is the case I was thinking of.  In the for-loop a grand-parent-bol
on compound_statement rule would match the 'for' keyword, so the
indentation will be correct, but this one will not, IIRC.  I plan to dig
into this some more soon, but motivation left me a little on that issue.
Maybe we could make a preset like:

```
(seq
 (parent-is "compound_statement") parent (parent-is "for_statement") bol)
```

In other words, make other presets execute sequentially, move point,
check again, and if all are true, pick indent offset.  Or allow multiple
captures, like so:

```
(for_statement @offset-anchor
  body: (compound_statement (_) @to-indent))
```

Here the @to-indent capture would get the new indent level based on
treesit-node-start of for_statement.

What do you think, Yuan?

Theo





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 10:46:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 05:46:48 2022
Received: from localhost ([127.0.0.1]:45941 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p13ZA-0007Y5-4h
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 05:46:48 -0500
Received: from waldorf.isode.com ([62.232.206.188]:61953)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruce.stephens@HIDDEN>) id 1p13Z4-0007Xp-OJ
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 05:46:46 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1669977996;
 d=isode.com; s=june2016; i=@isode.com;
 bh=N75Ckl6bCrzeyAWGxsoYN60nNBfHBLktXyqiILqafnM=;
 h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:
 In-Reply-To:References:Content-Type:Content-Transfer-Encoding:
 Content-ID:Content-Description;
 b=CoN4HP4HMKaEBwHJIYgre0YPKhdxhQZaRWOlauxYkBu6hlFvMHJl4BTR+8qbnLc2rRV3Ut
 Ax/lufdEm+0x2DRbs8BqPVu3Dw3DYtiwSO4wg6+Gye97WHRWwvEvF0pXOimOjfg0jb0stp
 yfLRLmGTa8CyJlrM4m/cRry44nw82XQ=;
Received: from [192.168.1.65] (84.230.200.146.dyn.plus.net [146.200.230.84]) 
 by waldorf.isode.com (submission channel) via TCP with ESMTPSA 
 id <Y4nXigBS6HM7@HIDDEN>; Fri, 2 Dec 2022 10:46:36 +0000
Message-ID: <86268d17-402f-6ae3-9ed7-100a2591e04d@HIDDEN>
Date: Fri, 2 Dec 2022 10:46:34 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
 Gecko/20100101 Thunderbird/102.5.0
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and
 conditional statements is wrong
To: Eli Zaretskii <eliz@HIDDEN>, Theodor Thornhill <theo@HIDDEN>
References: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
 <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
 <83v8mufbd2.fsf@HIDDEN>
From: Bruce Stephens <bruce.stephens@HIDDEN>
In-Reply-To: <83v8mufbd2.fsf@HIDDEN>
MIME-Version: 1.0
Content-Language: en-GB
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-transfer-encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: casouri@HIDDEN, 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 02/12/2022 08:39, Eli Zaretskii wrote:

> FWIW, this is an unusual style, so I see no catastrophe if it is not 110%
> according to expectations.  Users can easily fix that by tweaking their BO=
Ls
> where important.


The example I gave would be unusual, I think, but I'd argue that the=20
situations where I saw the problem are quite natural.

For example,

 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 } else if ( MYSTRCMP (attname, SOME_PREFIX_X400ADDRESS) ||
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 MYSTRCMP (attname, SOME_PREFIX_X400) ) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FOO_ptr orp =3D foo_std2foo (val);

or a function declaration with several arguments with types that are=20
rather long.

I agree it's not a critical bug but if there's no appropriate general=20
fix it would be helpful to have some guidance for users to resolve our=20
specific cases.






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 09:20:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 04:20:46 2022
Received: from localhost ([127.0.0.1]:45549 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p12Du-0004VK-7B
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 04:20:46 -0500
Received: from out2.migadu.com ([188.165.223.204]:44204)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1p12Dr-0004VD-3h
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 04:20:44 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and
 conditional statements is wrong
In-Reply-To: <83v8mufbd2.fsf@HIDDEN>
References: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
 <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
 <83v8mufbd2.fsf@HIDDEN>
Date: Fri, 02 Dec 2022 10:20:39 +0100
Message-ID: <87y1rqnouw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, casouri@HIDDEN, 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Cc: 59686 <at> debbugs.gnu.org
>> Date: Fri, 02 Dec 2022 06:42:03 +0100
>> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>=20
>> >> // -*- c-ts -*-
>> >> int main() {
>> >>    for (int i=3D0; i<10; ++i) {
>> >>      foo(i);
>> >>    }
>> >>
>> >>    for (int i=3D0;
>> >>           i<10;
>> >>           ++i) {
>> >>             foo(i);
>> >>           }
>> >> }
>> >
>> >I see, that=E2=80=99s because the indent rule finds the BOL of the line=
 where
>> >the "{" is on, and indents from there.  Theo, WDYT? Does indent style=20
>> >fix this, or we should change the indent rules?
>> >
>> >Yuan
>>=20
>> I've seen this issue myself, and have tried several combinations to fix =
it. It is trivial to fix this particular case, but because compound_stateme=
nt is used everywhere problems will pop up other places. The fix here would=
 be some grand-parent-bol function, but if my memory serves that would mess=
 up the else in an if else. I'm happy to see this fixed, but just remember =
that it's not _super_ trivial.
>>=20
>> Other languages exhibit similar issues, but with other constructs.
>
> FWIW, this is an unusual style, so I see no catastrophe if it is not 110%
> according to expectations.  Users can easily fix that by tweaking their B=
OLs
> where important.

Yeah, that was my reasoning as well.  I think we should come up with
some preset that can do this, but maybe when we know even more about how
to deal with similar edge cases?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 08:39:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 03:39:54 2022
Received: from localhost ([127.0.0.1]:45364 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p11aM-0003tC-JO
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 03:39:54 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34880)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1p11aK-0003su-Un
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 03:39:53 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p11aF-0006WI-1c; Fri, 02 Dec 2022 03:39:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=qY0HqIGSmv6J95PCnZ8gKcYa+mFL+oR+PaFi1XXose8=; b=G0H3xWtmVd9dcO439rcd
 2SsSlXY58SXsKUcsVuV+dqYBB2drsRmX8n9sWRVa1SsP0H5I8nkpr6B+yIPy8lcPFG9VUdObMU7zi
 PNs2cUBqmbbAo7GOfYI6qiebShbuUOkWVygkqb0vY/WPGrn+RNL8IjHGduDygo5GEVgMIan8DygZ5
 ++SJvMUmf7Uyib4uHeaoOszZHeWWghgDk7W5KOIThGjv3taMaxe0EFNwoRQGqJB7R0tau5+HUtGvr
 /eS2JrVNYVZ99r4ASKl6Prt+5G0BAbEgsZXeBsbaLMcDujfmNxOy5QEARH18GxZ7hQ/4emRkFm9+f
 jSk171P/SFHpcg==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1p11aD-0004yV-WE; Fri, 02 Dec 2022 03:39:46 -0500
Date: Fri, 02 Dec 2022 10:39:21 +0200
Message-Id: <83v8mufbd2.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
 (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#59686: 30.0.50;
 tree-sitter indentation in some loops and conditional statements is
 wrong
References: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
 <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59686
Cc: bruce.stephens@HIDDEN, casouri@HIDDEN, 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 59686 <at> debbugs.gnu.org
> Date: Fri, 02 Dec 2022 06:42:03 +0100
> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> >> // -*- c-ts -*-
> >> int main() {
> >>    for (int i=0; i<10; ++i) {
> >>      foo(i);
> >>    }
> >>
> >>    for (int i=0;
> >>           i<10;
> >>           ++i) {
> >>             foo(i);
> >>           }
> >> }
> >
> >I see, that’s because the indent rule finds the BOL of the line where
> >the "{" is on, and indents from there.  Theo, WDYT? Does indent style 
> >fix this, or we should change the indent rules?
> >
> >Yuan
> 
> I've seen this issue myself, and have tried several combinations to fix it. It is trivial to fix this particular case, but because compound_statement is used everywhere problems will pop up other places. The fix here would be some grand-parent-bol function, but if my memory serves that would mess up the else in an if else. I'm happy to see this fixed, but just remember that it's not _super_ trivial.
> 
> Other languages exhibit similar issues, but with other constructs.

FWIW, this is an unusual style, so I see no catastrophe if it is not 110%
according to expectations.  Users can easily fix that by tweaking their BOLs
where important.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 05:42:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 00:42:42 2022
Received: from localhost ([127.0.0.1]:44305 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p0yos-0001hH-7w
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 00:42:42 -0500
Received: from out-205.mta0.migadu.com ([91.218.175.205]:56905)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1p0yom-0001hB-G0
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 00:42:40 -0500
Date: Fri, 02 Dec 2022 06:42:03 +0100
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>, bruce.stephens@HIDDEN
Subject: =?US-ASCII?Q?Re=3A_bug=2359686=3A_30=2E0=2E50=3B_?=
 =?US-ASCII?Q?tree-sitter_indentation_i?=
 =?US-ASCII?Q?n_some_loops_and__conditional_statements_is_wrong?=
In-Reply-To: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
References: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
Message-ID: <A0CA40DB-15DA-4E01-8B68-98C923A9AE10@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 2 December 2022 06:13:42 CET, Yuan Fu <casouri@gmail=2Ecom> wrote:
>
>Bruce Stephens <bruce=2Estephens@isode=2Ecom> writes:
>
>> With the following file I would expect foo(i) to be indented to just tw=
o
>> indents (like the first one), but they are not=2E Similarly for many ot=
her
>> compound statements where the opening spans more than one line=2E
>>
>> // -*- c-ts -*-
>> int main() {
>>    for (int i=3D0; i<10; ++i) {
>>      foo(i);
>>    }
>>
>>    for (int i=3D0;
>>           i<10;
>>           ++i) {
>>             foo(i);
>>           }
>> }
>
>I see, that=E2=80=99s because the indent rule finds the BOL of the line w=
here
>the "{" is on, and indents from there=2E  Theo, WDYT? Does indent style=
=20
>fix this, or we should change the indent rules?
>
>Yuan

I've seen this issue myself, and have tried several combinations to fix it=
=2E It is trivial to fix this particular case, but because compound_stateme=
nt is used everywhere problems will pop up other places=2E The fix here wou=
ld be some grand-parent-bol function, but if my memory serves that would me=
ss up the else in an if else=2E I'm happy to see this fixed, but just remem=
ber that it's not _super_ trivial=2E

Other languages exhibit similar issues, but with other constructs=2E

Lastly, I _did_ fix most of these, but that required using query as the ma=
tcher in simple-indent-rules, which made indenting slower, and I needed one=
 rule for almost every construct in a language=2E

I'm sure she fix can be simple, but I'm a little blind to it right now=2E =
My eyes are bleeding tree-sitter nodes at the moment, so I might not see cl=
early :P




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at 59686 <at> debbugs.gnu.org:


Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 05:13:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 02 00:13:53 2022
Received: from localhost ([127.0.0.1]:44130 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p0yMy-0007VT-MW
	for submit <at> debbugs.gnu.org; Fri, 02 Dec 2022 00:13:52 -0500
Received: from mail-pj1-f43.google.com ([209.85.216.43]:44766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p0yMv-0007VA-Ti
 for 59686 <at> debbugs.gnu.org; Fri, 02 Dec 2022 00:13:50 -0500
Received: by mail-pj1-f43.google.com with SMTP id
 3-20020a17090a098300b00219041dcbe9so4149775pjo.3
 for <59686 <at> debbugs.gnu.org>; Thu, 01 Dec 2022 21:13:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=y0L3V3fYm0cdlTE0IbzPCNH3dxPq4zVNj36zUTADYi8=;
 b=UM14ZXZcyRB+c5qdLj+nsgtTyDshqx1KHxCDjDv2SuxPWHeBHPeZHB4WTY2sq/vQxF
 Hxxfgycss0Z12Uv5alJnQBpNtzBofpifKFn8TR8YQE5zXPxQbG0M+a0aT6UjMOMLRjOm
 AhSTGFJYhkpOnb/VyicEs9mA2saPTBb9KPE2b2sw4pcIXZfQTiv5I9SsqfhH/gyD8Ztp
 X3CSGEo27Nd4W8gKVRw0cr0acQwARWnW0TXWZSbwTRxaOIOcp6AYIQ/eV5IVvh/1m916
 vAIYjHKXY00aB9QiJeEooWBsFJ2kcknf1lM7r40jQgGXCAtqFxgkfRKjaYIXO9pU8FB6
 KvZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=y0L3V3fYm0cdlTE0IbzPCNH3dxPq4zVNj36zUTADYi8=;
 b=1K0CdRPQet+jO+N0V3ugyDXNivaOmCBUomnif+iw+aqe/CFnD15/pa76FSNdg/CaCZ
 MPUcSjAYvp5DENvh4t93cH0RdziABpgQJwzIxBZfE0FFvfkGKdO5V24lDQ9zIr35NQIf
 k4z8UIDEptDpQHoaz9to3xmaHluU1ohKtfsqaIZkJs8jmemOyiILUQcWhXhZCrUBem/L
 FUBiboXyGWj4Xb3uhHejaMi4oLCMRXCCPVRmjI7UVsIvShJSuqqXhmuMiV6f+kBdl1pC
 CNwlzg3KAK46jYRtIYeWeYP2OWdNIR18ADKYpwCS6oVkMTz26k2hxuN/9FAhHZ5qQzWt
 H8sQ==
X-Gm-Message-State: ANoB5pnRxl9+0zuBLqRnx4MZ8S9CQhZ3fUdywkRDi7bTmg5JMMW8Sxrn
 14ArdC/4YJMPinSHGEf8RAs=
X-Google-Smtp-Source: AA0mqf4UAHftQbZ58dWx1c8QwbPHtab8z+lfz1o7Qu3mgW2DeH2NpHt4AhAF3YjwMDsPASf5M7QOBg==
X-Received: by 2002:a17:90a:710b:b0:218:725:c820 with SMTP id
 h11-20020a17090a710b00b002180725c820mr74330195pjk.170.1669958024214; 
 Thu, 01 Dec 2022 21:13:44 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 i17-20020a170902c95100b00189847cd4acsm4618986pla.237.2022.12.01.21.13.43
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 01 Dec 2022 21:13:43 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and 
 conditional statements is wrong
Message-Id: <9F4F5716-F492-479A-869F-94D8A9391285@HIDDEN>
Date: Thu, 1 Dec 2022 21:13:42 -0800
To: bruce.stephens@HIDDEN
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59686
Cc: Theodor Thornhill <theo@HIDDEN>, 59686 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Bruce Stephens <bruce.stephens@HIDDEN> writes:

> With the following file I would expect foo(i) to be indented to just =
two
> indents (like the first one), but they are not. Similarly for many =
other
> compound statements where the opening spans more than one line.
>
> // -*- c-ts -*-
> int main() {
>    for (int i=3D0; i<10; ++i) {
>      foo(i);
>    }
>
>    for (int i=3D0;
>           i<10;
>           ++i) {
>             foo(i);
>           }
> }

I see, that=E2=80=99s because the indent rule finds the BOL of the line =
where
the "{" is on, and indents from there.  Theo, WDYT? Does indent style=20
fix this, or we should change the indent rules?

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Nov 2022 18:41:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 29 13:41:39 2022
Received: from localhost ([127.0.0.1]:55623 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p05Y3-0005TQ-I6
	for submit <at> debbugs.gnu.org; Tue, 29 Nov 2022 13:41:39 -0500
Received: from lists.gnu.org ([209.51.188.17]:50858)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruce.stephens@HIDDEN>) id 1p05Xz-0005TJ-9X
 for submit <at> debbugs.gnu.org; Tue, 29 Nov 2022 13:41:38 -0500
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 <bruce.stephens@HIDDEN>)
 id 1p05Xy-0007Qj-Im
 for bug-gnu-emacs@HIDDEN; Tue, 29 Nov 2022 13:41:34 -0500
Received: from statler.isode.com ([62.232.206.189])
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bruce.stephens@HIDDEN>) id 1p05Xw-0003rb-PY
 for bug-gnu-emacs@HIDDEN; Tue, 29 Nov 2022 13:41:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1669747288;
 d=isode.com; s=june2016; i=@isode.com;
 bh=OyaEOHNDpZw2XSAuwDq5IYT0ll4Z3ttKU76Olzwclm8=;
 h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:
 In-Reply-To:References:Content-Type:Content-Transfer-Encoding:
 Content-ID:Content-Description;
 b=VZ9YLiKt/exqQHPzo6Vf1jvnI6tE9Kpuju/EsXjEuY3PzKCPZUb0XQMSNx26hlQfd1lIX/
 LbdXGBhh67AFUOc3fWSmSxK16GIJl/gMMkhWgoPJGKvAA/BmZKb8ij7aQVAcobFUvGo8ap
 EMACIZ27m04fio9GK53X1cMAzJxCas4=;
Received: from [192.168.1.65] (84.230.200.146.dyn.plus.net [146.200.230.84]) 
 by statler.isode.com (submission channel) via TCP with ESMTPSA 
 id <Y4ZSVwAPgW2X@HIDDEN> for <bug-gnu-emacs@HIDDEN>;
 Tue, 29 Nov 2022 18:41:28 +0000
Message-ID: <ff6f80b5-d94a-1d5e-b47c-1c8d8ecc5506@HIDDEN>
Date: Tue, 29 Nov 2022 18:41:27 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
 Gecko/20100101 Thunderbird/102.5.0
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; tree-sitter indentation in some loops and conditional
 statements is wrong
From: Bruce Stephens <bruce.stephens@HIDDEN>
MIME-Version: 1.0
Content-Language: en-GB
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-transfer-encoding: quoted-printable
Received-SPF: pass client-ip=62.232.206.189;
 envelope-from=bruce.stephens@HIDDEN; helo=statler.isode.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


With the following file I would expect foo(i) to be indented to just two
indents (like the first one), but they are not. Similarly for many other
compound statements where the opening spans more than one line.

// -*- c-ts -*-
int main() {
 =C2=A0=C2=A0 for (int i=3D0; i<10; ++i) {
 =C2=A0=C2=A0=C2=A0=C2=A0 foo(i);
 =C2=A0=C2=A0 }

 =C2=A0=C2=A0 for (int i=3D0;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i<10;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ++i) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 foo(i);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
}



In GNU Emacs 30.0.50 (build 1, x86_64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.6 (Build 21G115)) of 2022-11-29 built on
Bruces-MacBook-Pro.local
Repository revision: e90c21e6fb35d1c844c49d96f0b62c5fe55bb203
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description: macOS 12.6

Configured using:
'configure --with-native-compilation=3Daot --with-tree-sitter'

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

Important settings:
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix

Major mode: C

Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp comp-cstr
warnings icons subr-x rx cl-macs gv cl-extra help-mode bytecomp
byte-compile c-ts-mode treesit cl-seq cl-loaddefs cl-lib rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads kqueue cocoa ns lcms2 multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 81423 9034)
(symbols 48 7273 0)
(strings 32 20423 1742)
(string-bytes 1 634204)
(vectors 16 17092)
(vector-slots 8 341908 8957)
(floats 8 32 58)
(intervals 56 242 0)
(buffers 992 12))





Acknowledgement sent to Bruce Stephens <bruce.stephens@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#59686; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 15 Jan 2023 09:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.