GNU bug report logs - #74386
Tree-sitter javascript indentation

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: Marius Kjeldahl <marius.kjeldahl@HIDDEN>; dated Sat, 16 Nov 2024 23:28:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 74386) by debbugs.gnu.org; 5 Jan 2025 11:33:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 05 06:33:20 2025
Received: from localhost ([127.0.0.1]:60163 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tUOsi-0005D7-Fe
	for submit <at> debbugs.gnu.org; Sun, 05 Jan 2025 06:33:20 -0500
Received: from mx.kolabnow.com ([212.103.80.154]:36596)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1tUOsg-0005Ct-Um
 for 74386 <at> debbugs.gnu.org; Sun, 05 Jan 2025 06:33:19 -0500
Received: from localhost (unknown [127.0.0.1])
 by mx.kolabnow.com (Postfix) with ESMTP id 1DAE53004C6B;
 Sun,  5 Jan 2025 12:33:13 +0100 (CET)
Authentication-Results: ext-mx-out013.mykolab.com (amavis);
 dkim=pass (2048-bit key) reason="pass (just generated, assumed good)"
 header.d=kolabnow.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h=
 content-transfer-encoding:content-type:content-type:mime-version
 :message-id:date:date:references:in-reply-to:subject:subject
 :from:from:received:received:received; s=dkim20240523; t=
 1736076792; x=1737891193; bh=Gm1ygRgHDm+DFB8Z62yrPsH1PGKGLTcf0Ud
 YgB8ihSU=; b=BGsG+tqqkp8m0CXto6BVDeku4L9OUnUTX4DpA5FeQoV0fWQVyk4
 gBT+aKyAP/d4zdQcP4A+JUYCzSlrHUD/fxNqhoMlnztrzt5AIvTajqZSIQXA7l5T
 il6c6h8oyRnSGqBWqCMuAKIJuFRg1Wk+kYamwRoF/B5P5aBAFU+gL4KCRJy0So/A
 eTu1CvS/sFY2Du9f4Qb8cGySlYgwJc92ONdotaumvaKts10d/T2AVlhxInHkqrFs
 6DPlNLyre7IGna++DrdzD8o+Qfhwb7reigmycInego5XEHS+5Qf8DIq+QOVGIiZe
 dgKr9mC9gVwELS9izuTC5XmVOvEXTMqvnpg==
X-Virus-Scanned: amavis at mykolab.com
X-Spam-Flag: NO
X-Spam-Score: -1
X-Spam-Level: 
X-Spam-Status: No, score=-1 tagged_above=-10 required=5 tests=[ALL_TRUSTED=-1]
 autolearn=ham autolearn_force=no
Received: from mx.kolabnow.com ([127.0.0.1])
 by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024)
 with ESMTP id Q5fO0JH2Cc_a; Sun,  5 Jan 2025 12:33:12 +0100 (CET)
Received: from int-mx009.mykolab.com (unknown [10.9.13.9])
 by mx.kolabnow.com (Postfix) with ESMTPS id 61F7A3004C69;
 Sun,  5 Jan 2025 12:33:11 +0100 (CET)
Received: from ext-subm010.mykolab.com (unknown [10.9.6.10])
 by int-mx009.mykolab.com (Postfix) with ESMTPS id 07F522125AB8;
 Sun,  5 Jan 2025 12:33:11 +0100 (CET)
From: Theodor Thornhill <theo@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>, Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#74386: Tree-sitter javascript indentation
In-Reply-To: <057D3C98-8503-4C6F-80F1-B54BAFE624BF@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
 <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
 <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
 <F907FCE3-82DA-4F2D-8825-B476AB81A135@HIDDEN>
 <cb45b90e-cc66-4b3f-895b-d96f641bb9dd@HIDDEN>
 <057D3C98-8503-4C6F-80F1-B54BAFE624BF@HIDDEN>
Date: Sun, 05 Jan 2025 12:33:10 +0100
Message-ID: <87ed1hv6kp.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: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 marius.kjeldahl@HIDDEN
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 (-)


>>> I=E2=80=99ve already used it to rewrite c-ts-mode indent rules and it=
=E2=80=99s been a success; this baseline + override approach has been very =
helpful. c-ts-mode still has a lot of indent rules because of things like p=
reproc directive, etc, but it=E2=80=99s much more manageable than before.
>>> I don=E2=80=99t know how much it would help modes that has simpler inde=
nt rules. Go-ts-mode and rust-ts-mode only has a handful of indent rules, m=
aybe they don=E2=80=99t really need this baseline rule. OTOH Lua and Ruby h=
as more involved indent rules, maybe they can benefit and reduce the number=
 of rules they need to define.
>>=20
>> Ruby has different delimiters (do...end or def...end or etc), and the cu=
rlies don't do exactly the same job that they do in C. So I'm not sure how =
feasible it is. A half of the function would be a fit, though.
>
> Right, so I think it=E2=80=99ll still be more helpful than not.
>
> Yuan

I think I like what's suggested here - I'll see if I can make something
like this work in java-ts-mode, which has a standing bug just like the
one mentioned in this report.

Thanks!

Theo




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

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


Received: (at 74386) by debbugs.gnu.org; 13 Dec 2024 05:36:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 13 00:36:11 2024
Received: from localhost ([127.0.0.1]:41250 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLyLR-000086-JK
	for submit <at> debbugs.gnu.org; Fri, 13 Dec 2024 00:36:11 -0500
Received: from mail-pf1-f182.google.com ([209.85.210.182]:49399)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tLyL5-00006z-D7
 for 74386 <at> debbugs.gnu.org; Fri, 13 Dec 2024 00:36:08 -0500
Received: by mail-pf1-f182.google.com with SMTP id
 d2e1a72fcca58-728e1799d95so1596535b3a.2
 for <74386 <at> debbugs.gnu.org>; Thu, 12 Dec 2024 21:35:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1734068081; x=1734672881; darn=debbugs.gnu.org;
 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=BBLCEKd6zv4urA9VNb1Lt2TDCoIyu4v26ReFfy2EjUU=;
 b=P1+C4SQpu6LWFPoQfstWCUBpSuiPqE7VzklLiYgboBfd1OKrj0nplJSAcdIkT1Eq4p
 G8ITENq9vB0pGNPX8p+4/B2Yqq9ww4hv0HF5QlLFQI9rx6n0ta0uT8JPI5Kwqta28BCq
 2tnEiT9tVfB+UrKVqfEjSQdPhgtqnQh4JS7WtWzDsZpNQ63A12tzRf29DUz5lu3RooEP
 /PDKoiiNEcP3TfUonHMe1XB7XGlLjpKQnfRCR+daSoxTT4KzsZv657pfs2SLdb/0z7hm
 jCpurfBnd/G+34kDmlNORLt6GfcT8F7Nt6EvbPIIfqRP1GDZtHKBz7QKvdsPycLz1QR4
 7fvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734068081; x=1734672881;
 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=BBLCEKd6zv4urA9VNb1Lt2TDCoIyu4v26ReFfy2EjUU=;
 b=Rs9qrUbZkzaXwR/PdfWAWUOQf+GUvQw9nfig+ThbAs+9c0lfosQhGLvrZbJSVYSNq7
 hY4/L4TVR556p3s3QlEu7Aoym5Xpd/HMRaDMtfgiaJ1hVFalPVIkEW/VPa7z4JsIZeNL
 smmDK8SQJ+ZaMEYiy0Tycuxy7V6GpcR9LGXLdqjIACI8XKDLP7zPs4aW/vzVKxYBH8Zx
 0gEgv/hX+LEstDBUphIduAceOBvJiHEbx9pwmAtCcmwQe6yOnfVxUECbTc0vv9hmTjJa
 ItEPv3rMJL5UgrFd1DkZ42OLlROL2phIQFNrZnXgQwd/0Fcy8W6zhxQWnYCv6U4VVGlc
 Wvcw==
X-Forwarded-Encrypted: i=1;
 AJvYcCUdFirBBpQYlLk2+whuXHl5atEEPMi1ZBxPfZ2yC41SJsE+2TJTcPtgWMu2QM4iHd/hqCgVYw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YzgWvgfE9gG6JDBE9zlDjzeU3EutjxB8fheSC0xrFGYt7+PRfqu
 czboa4cV4bFM14szCPMgJ9mMoDgEen0gWTPDcA6X38uICI+lQjhI
X-Gm-Gg: ASbGncs9pUnAK1/ERnHh+4+gYrl2Mb9Oc0tYhJQX5BuenQAGTezeqoo/47M5MP79+ni
 wQ1NvBWqgf5p13AEEhWQo8hdAh7GuAkqol73kG0gtNvb0rJvfm1lKAjVJFnkn+AnNdTJw7RzEkS
 xh0WZ9V1rctBD25QuZhP8gPXuFusDWVstgKdpkJBDlEiMyPSfPD/ND8YBmVj87ecB/Qv2seOw/d
 9N4I0by5H9jmHwocT2+6X7+pik09Cc1AOmg5+n83Fihl5PvNb0OJl0urXYCwZrhYyndNxL2su13
 4h7x
X-Google-Smtp-Source: AGHT+IHtCtWUEQ8GUkzFnfxQOs9BJE3A8zf2qLnb9A6Q6y++KJIYvCYO8PuneVdQbdX1sLZ+CAOrwQ==
X-Received: by 2002:a05:6a21:2d8c:b0:1db:e40d:5f89 with SMTP id
 adf61e73a8af0-1e1dfde7031mr1989097637.28.1734068081392; 
 Thu, 12 Dec 2024 21:34:41 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:1591:1a19:416c:1925])
 by smtp.gmail.com with ESMTPSA id
 d2e1a72fcca58-725d36e66e1sm10349455b3a.178.2024.12.12.21.34.40
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 12 Dec 2024 21:34:40 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <cb45b90e-cc66-4b3f-895b-d96f641bb9dd@HIDDEN>
Date: Thu, 12 Dec 2024 21:34:29 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <057D3C98-8503-4C6F-80F1-B54BAFE624BF@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
 <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
 <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
 <F907FCE3-82DA-4F2D-8825-B476AB81A135@HIDDEN>
 <cb45b90e-cc66-4b3f-895b-d96f641bb9dd@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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: -0.3 (/)



> On Dec 12, 2024, at 7:34=E2=80=AFPM, Dmitry Gutov <dmitry@HIDDEN> =
wrote:
>=20
> On 12/12/2024 07:28, Yuan Fu wrote:
>=20
>>> What would be our next step in this? Replacing all 'parent-bol' =
anchors with 'standalone-parent' across most ts modes?
>> Speaking of next step, I recently added another handy tool for =
languages with C-like syntax: c-ts-common-baseline-indent-rule. I =
figured out an indent logic that can work on all C-like languages and =
covers a wide range of cases. This one rule can give you all theses =
indentation:
>=20
> Looks pretty great. I guess it depends on the grammars being to an =
extent compatible, right?

Yes, but most C-like language should be compatible. The rule relies on =
the grammar to put brackets like =E2=80=9C(=E2=80=9C =E2=80=9C[=E2=80=9C =
=E2=80=9C{=E2=80=9C as the first child node and last child node of the =
contract that contains them, which is what grammars naturally do. (The =
only exception I found is the for statement in C.) Beyond that, the rule =
takes advantage of how parse tress are usually structured: when the =
previous line is a sibling node of the current lines, usually you want =
to align the two lines; and when you indent, the indent anchor is =
usually the "standalone-parent=E2=80=9D.=20

>=20
>> 1. Statements align to their previous sibling:
>>     int main() {
>>       int a =3D 1;
>>       int b =3D 2; <-- Align to prev line=E2=80=99s sibling.
>>     }
>> 2. Indents one level for blocks: function, if, for, struct, etc.
>>     int main() {
>>       return 0;   <-- Indent one level.
>>       {           <-- Align to prev line=E2=80=99s sibling.
>>         return 1; <-- Indent one level.
>>       }
>>     }
>> 3. Elements in parenthesis and brackets:
>>     return [1, 2, 3,
>>             4, 5, 6]; <-- Align to first sibling.
>>     return [
>>       1, 2, 3,  <-- Indent one level (option 1).
>>       4, 5, 6,  <-- Align to prev line=E2=80=99s sibling.
>>     ];
>>     return [
>>             1, 2, 3,  <-- Align to opening bracket (option 2).
>>             4, 5, 6,  <-- Align to prev line=E2=80=99s sibling.
>>            ];         <-- Align to opening bracket.
>>     for (int i =3D 0;
>>          i < 10; <-- Align to first sibling.
>>          i++) {  <-- Align to prev line=E2=80=99s sibling.
>>       continue;
>>     }
>> 4. Statement expressions indent one level when it=E2=80=99s broken =
into two
>>    lines:
>>     int main() {
>>       int var
>>         =3D 1287;  <-- Indent one level.
>>       int var =3D
>>         1287;    <-- Indent one level.
>>     }
>=20
> Should there be an example with a method call starting on a new line, =
line in the arrow literal example (for JS) that we discussed?

Yes, once we add that.

>=20
>> Then a C-like language=E2=80=99s major mode only need to add special =
cases over the baseline indent rule. And if we add the configurable =
heuristic for standalone-parent, the baseline indent rules would make =
use of it.
>=20
> Sounds good.
>=20
>> I brought it up because if we=E2=80=99re going to do some renovations =
to indent rules, might as well make use of =
c-ts-common-baseline-indent-rule, and we probably don=E2=80=99t even =
need to replace parent-box with standalone-parent, because the baseline =
indent rule would cover most cases.
>=20
> I'm now sure how safe that is - my point was that for each of the =
languages it'd be great to have somebody motivated go over the main =
syntactic cases and see that the behavior is still reasonable. But we =
can also make the switch and wait for reports.

I agree, sweeping change in unfamiliar packages maintained by other =
people is obviously a no-go. I=E2=80=99m thinking of the maintainers =
making the change should they see the baseline-indent-rule beneficial. =
(Same goes to standalone-parent, I=E2=80=99d much rather the maintainers =
take that call even it=E2=80=99s a smaller change.)

For immediate next step we can just apply the standalone-parent patch, =
and use it in js. And we make baseline-indent rule support the =
standalone-parent customization, and let major mode maintainers know of =
both. What they want to do is up to them.

>=20
>> I=E2=80=99ve already used it to rewrite c-ts-mode indent rules and =
it=E2=80=99s been a success; this baseline + override approach has been =
very helpful. c-ts-mode still has a lot of indent rules because of =
things like preproc directive, etc, but it=E2=80=99s much more =
manageable than before.
>> I don=E2=80=99t know how much it would help modes that has simpler =
indent rules. Go-ts-mode and rust-ts-mode only has a handful of indent =
rules, maybe they don=E2=80=99t really need this baseline rule. OTOH Lua =
and Ruby has more involved indent rules, maybe they can benefit and =
reduce the number of rules they need to define.
>=20
> Ruby has different delimiters (do...end or def...end or etc), and the =
curlies don't do exactly the same job that they do in C. So I'm not sure =
how feasible it is. A half of the function would be a fit, though.

Right, so I think it=E2=80=99ll still be more helpful than not.

Yuan=




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

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


Received: (at 74386) by debbugs.gnu.org; 13 Dec 2024 03:34:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 12 22:34:27 2024
Received: from localhost ([127.0.0.1]:41119 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLwRa-0002n2-A9
	for submit <at> debbugs.gnu.org; Thu, 12 Dec 2024 22:34:26 -0500
Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]:37985)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tLwRT-0002mf-Tz
 for 74386 <at> debbugs.gnu.org; Thu, 12 Dec 2024 22:34:19 -0500
Received: from phl-compute-11.internal (phl-compute-11.phl.internal
 [10.202.2.51])
 by mailfout.stl.internal (Postfix) with ESMTP id 27B4A1140136;
 Thu, 12 Dec 2024 22:34:10 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162])
 by phl-compute-11.internal (MEProxy); Thu, 12 Dec 2024 22:34:10 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm3; t=1734060850;
 x=1734147250; bh=ItSaQM8W9HwgIouWyXSAy5OlgQbDTDd8vbbTMCWLqN8=; b=
 fOXSaKIfbrDZMhUcV8Nh2hb/l6laU/Oq549/Z/MNkZNQDF1dU41Z2wvrC550NctL
 O3/pNyRC8ep2hrOow0wIrTozxN5C3mpmGmOUbXx3XCCOqrhjJnnzwVYL6JJQy4Nd
 wgBYxd8jUZXE4hvUGym8DcTALNWiFVy9XbuKptYe0LIl3S0sptrmc73PBjuSocrU
 Wvlph5xKFyGaIrSYpMUL+BkNizGrjT+X1jM1YAkyXwkyxlFQeEfShicdrWCtgw62
 xxOyqrtHOedzqUomXQrkZLoy2/wg+q8sWW2nKmk/sUa3NvGrCNzwOF+NS+7/Nhr4
 sZM67IRABkrYn6YykSxuvQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734060850; x=
 1734147250; bh=ItSaQM8W9HwgIouWyXSAy5OlgQbDTDd8vbbTMCWLqN8=; b=l
 +7uvI4DaXH50tvDMbYgcUuZ4EH2jHloNOnOyU09kb59DG/z3bAIoBsmuZMMLNjWS
 qm3sv8e8qjBQ/XxHzeHDLKI7RNsayExpK4VbicOd8/dhscSxu6VXsBtI9gR0IolB
 YI+tZW8J8kFvGQQfjyT9E7QT+4GZNmC7JajifaBkLCpqrmvOg/neDbEP5zd30+Ve
 cPkOMgThu0CRB2XbFtARL80daDQf5UuRK0WNf9ci5fbq0lWrPN5rFqdhbSliT+pg
 QN9l/DUkjGiCJGlQhhc0Xc95vcTPy8jSEk4YKh1iIaFLUYkPlh9z0RYfV7Ns9JUK
 SGHQ656xePNSulXy/BsYg==
X-ME-Sender: <xms:MatbZ6VXgXKF2_PcdHhyv77RO2yjfm4hP9xAvSfhMYkHdW6hsNe_qA>
 <xme:MatbZ2mr4h-hKVU2SoaUBN5Ugeds3fEvXXMO7BfDWPp4nRbXglr2G9VY59Te1o_l_
 B56xYaUCVG1JT1gUf4>
X-ME-Received: <xmr:MatbZ-apr0O7fAkogBqWXrTxO2A3xQOmR5hBZuMYMLnXEY_Mt1Xz0Xo_m_WOoUJ2Ro72>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrkeeigdeitdcutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
 tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth
 hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpeegleefteekgffhvdfhtdegveevveetteegteevgeet
 tdehhfdukeetheffueekkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptggrshhouhhrihesghhmrghilh
 drtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehthhgv
 ohesthhhohhrnhhhihhllhdrnhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgsh
 drghhnuhdrohhrghdprhgtphhtthhopehmrghrihhushdrkhhjvghluggrhhhlsehgmhgr
 ihhlrdgtohhm
X-ME-Proxy: <xmx:MatbZxVnW_19jCWplxH1-RbcjJB1zWEJkfbWA1hDXWgm8aQXEiGz3w>
 <xmx:MatbZ0mGJ3hGrxck7fnYUb5ABnGg6MR6ynlv5_DuSsoH2fkUZrRWzg>
 <xmx:MatbZ2dfrEWvmM4ClFfCOO2ahNLC0EEEhyHdLmCICPqVnVj2ZWW1kg>
 <xmx:MatbZ2G6rD93Or_YoPtgiOFp4ot168Kl5IGWGYBKlaiOLikxZHEa9Q>
 <xmx:MatbZzs8b-AvL8hbX-1J3vlK97EhG89nmlDMJXn_GczKjDKTRpLHkAZ->
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 12 Dec 2024 22:34:08 -0500 (EST)
Message-ID: <cb45b90e-cc66-4b3f-895b-d96f641bb9dd@HIDDEN>
Date: Fri, 13 Dec 2024 05:34:02 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Yuan Fu <casouri@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
 <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
 <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
 <F907FCE3-82DA-4F2D-8825-B476AB81A135@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <F907FCE3-82DA-4F2D-8825-B476AB81A135@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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 12/12/2024 07:28, Yuan Fu wrote:

>> What would be our next step in this? Replacing all 'parent-bol' anchors with 'standalone-parent' across most ts modes?
> 
> Speaking of next step, I recently added another handy tool for languages with C-like syntax: c-ts-common-baseline-indent-rule. I figured out an indent logic that can work on all C-like languages and covers a wide range of cases. This one rule can give you all theses indentation:

Looks pretty great. I guess it depends on the grammars being to an 
extent compatible, right?

> 1. Statements align to their previous sibling:
> 
>      int main() {
>        int a = 1;
>        int b = 2; <-- Align to prev line’s sibling.
>      }
> 
> 2. Indents one level for blocks: function, if, for, struct, etc.
> 
>      int main() {
>        return 0;   <-- Indent one level.
>        {           <-- Align to prev line’s sibling.
>          return 1; <-- Indent one level.
>        }
>      }
> 
> 3. Elements in parenthesis and brackets:
> 
>      return [1, 2, 3,
>              4, 5, 6]; <-- Align to first sibling.
> 
>      return [
>        1, 2, 3,  <-- Indent one level (option 1).
>        4, 5, 6,  <-- Align to prev line’s sibling.
>      ];
> 
>      return [
>              1, 2, 3,  <-- Align to opening bracket (option 2).
>              4, 5, 6,  <-- Align to prev line’s sibling.
>             ];         <-- Align to opening bracket.
> 
>      for (int i = 0;
>           i < 10; <-- Align to first sibling.
>           i++) {  <-- Align to prev line’s sibling.
>        continue;
>      }
> 
> 4. Statement expressions indent one level when it’s broken into two
>     lines:
> 
>      int main() {
>        int var
>          = 1287;  <-- Indent one level.
>        int var =
>          1287;    <-- Indent one level.
>      }

Should there be an example with a method call starting on a new line, 
line in the arrow literal example (for JS) that we discussed?

> Then a C-like language’s major mode only need to add special cases over the baseline indent rule. And if we add the configurable heuristic for standalone-parent, the baseline indent rules would make use of it.

Sounds good.

> I brought it up because if we’re going to do some renovations to indent rules, might as well make use of c-ts-common-baseline-indent-rule, and we probably don’t even need to replace parent-box with standalone-parent, because the baseline indent rule would cover most cases.

I'm now sure how safe that is - my point was that for each of the 
languages it'd be great to have somebody motivated go over the main 
syntactic cases and see that the behavior is still reasonable. But we 
can also make the switch and wait for reports.

> I’ve already used it to rewrite c-ts-mode indent rules and it’s been a success; this baseline + override approach has been very helpful. c-ts-mode still has a lot of indent rules because of things like preproc directive, etc, but it’s much more manageable than before.
> 
> I don’t know how much it would help modes that has simpler indent rules. Go-ts-mode and rust-ts-mode only has a handful of indent rules, maybe they don’t really need this baseline rule. OTOH Lua and Ruby has more involved indent rules, maybe they can benefit and reduce the number of rules they need to define.

Ruby has different delimiters (do...end or def...end or etc), and the 
curlies don't do exactly the same job that they do in C. So I'm not sure 
how feasible it is. A half of the function would be a fit, though.




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

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


Received: (at 74386) by debbugs.gnu.org; 12 Dec 2024 05:30:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 12 00:30:20 2024
Received: from localhost ([127.0.0.1]:37244 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLbmF-0002pd-CW
	for submit <at> debbugs.gnu.org; Thu, 12 Dec 2024 00:30:19 -0500
Received: from mail-pg1-f176.google.com ([209.85.215.176]:55559)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tLbmD-0002ir-2A
 for 74386 <at> debbugs.gnu.org; Thu, 12 Dec 2024 00:30:18 -0500
Received: by mail-pg1-f176.google.com with SMTP id
 41be03b00d2f7-7f46d5d1ad5so182342a12.3
 for <74386 <at> debbugs.gnu.org>; Wed, 11 Dec 2024 21:30:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1733981351; x=1734586151; darn=debbugs.gnu.org;
 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=y1muzZElkitfuyDvzTKjQ7Jo+zVBE7LLjxAviLivzOg=;
 b=P+4OCrkiNu8VFfRt7omn95nONnqTLKvuLtIXrxuEGKrTZ0FujeKuzcP/bnd0/eyccy
 RC0THFx8fr+JtQCdD+Vs90YS+0DsGjln/yQ8YbRT1F9CRwYgV6XdClEOPIfRbKKaqDcJ
 wvc6BWnJuLaVT/HwyzKRHIotDtd7cOsgGfJ6YraFqjzjPYx9muH+iAlUH0uDuuWSx1JR
 WnThd9BmJaaCqsTkFGBK4WG617Agk7Ng+CehkuMUBVLlzMG89n5681jSvc3obl2icWVq
 39BYQogrReR0MR258hT1j6rHeJLUqrTxrfYUVcznn0DhvvlsyYCyNgkcZ0nkEnbBX9iV
 f8GQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733981351; x=1734586151;
 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=y1muzZElkitfuyDvzTKjQ7Jo+zVBE7LLjxAviLivzOg=;
 b=kWyhDLGdfyzdCP2U9DPIyGYQT7UhR21Juvf3sz2ARDojjogsTl6aUA/dDFM9kXCYD5
 /G0Chwb2PaIbuhhY00cvvpSFaS20FadWTGyex/G107h3cJtfYQr6qkHddUCwuScfSJfS
 Woh5nOC+bEm4oTO4qUOxPs17OCpNPnsNy0dQo4BGGP5RvvbTXQ5Y/yW0xc+q+QrCMOwq
 TQ8CjGVwn046lNP4D2stW33Md340cCgHhKLU6MWqPitl7QCSpeo7uoT/bBDf0tXADIXA
 5fnN9klJYZ6ESEO8qA+PvVQgV7opZs5Y3QN3H51bXXN7JLOOs/CAwdnhZnrH4GJ/J7nN
 6Fqw==
X-Forwarded-Encrypted: i=1;
 AJvYcCWPF4UeALgEM8otH2meoTz9K0gYTfmFoJbXtXQyRpgY9snHueTJTOkqedI/RGVaGU0t+PhawQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yx635GjWo3kU6Ne1qykQN22oqnAVkzeAyn55tITqQqVYM+FOtqI
 5aEjn+aR9qox1TBDaRxnG99MmlepteRRc03FypbohJXohkuhrMMD
X-Gm-Gg: ASbGncv82PV+Y2IjU3gzG3cKI+Vy/yE+4HfDGhxW8j/3c+RgBEbRtWJhlIMcVcCSXN9
 T53YT0QGiTdUvrjfO1SKPYxU1l7CkbRPWQkKwAnSJ7Z+l0wKt6583VDCTAn7w9IDH3Z6wS3k/MZ
 VAEBDRz5FTLaE4pE1lt0OtwYOjGNMnnpZayUX5PL/lrLFjk3/LRgk7sJDWQoqdvOxCcRbF5KoFX
 x2zZ9/kpdS1E4P0Pm2WiToPr5Q6n8QkL3WMPvp/rUQrVTfUi1eU4k9WzTE6wY9XIUEBZdLusKRk
 Q2zH
X-Google-Smtp-Source: AGHT+IHDGeUWw+1+WBRtT0NmrXh31qhtp2mSRxNQKhOsMS97lliKbS4JK/Ts3KTEKwzo3kgk1SSZnQ==
X-Received: by 2002:a05:6a21:9988:b0:1e1:ae9a:6311 with SMTP id
 adf61e73a8af0-1e1cea5705cmr2954392637.4.1733981351073; 
 Wed, 11 Dec 2024 21:29:11 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:e40f:e83b:f0f0:1e5e])
 by smtp.gmail.com with ESMTPSA id
 41be03b00d2f7-7fd55eb21e9sm5021428a12.84.2024.12.11.21.29.09
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 11 Dec 2024 21:29:10 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
Date: Wed, 11 Dec 2024 21:28:58 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <F907FCE3-82DA-4F2D-8825-B476AB81A135@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
 <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
 <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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: -0.3 (/)



> On Dec 11, 2024, at 7:20=E2=80=AFPM, Dmitry Gutov <dmitry@HIDDEN> =
wrote:
>=20
> On 11/12/2024 08:18, Yuan Fu wrote:
>>>> Maybe not by hardcoding this in inside the 'standalone-parent' =
matcher, but writing this in the indentation rules? Different languages =
might have differing ASTs for such construct.
>>>>=20
>>>> Or if you meant to do a text search, a period might start a method =
call, but it could also continue a "range" literal in some other =
language, or some struct initializer (I think?) in C/C++. Also, some =
languages allow (and style guides suggest) to have the previous at the =
end of the line, then followed by newline and then the method name.
>>> Not hard-coded, but customizable, like this:
>>>=20
>>> Yuan
>>>=20
>>> <standalone-predicate-poc.patch>
>> Circling back on this. WDYT? I think this would benefit all =
=E2=80=9Cmodern=E2=80=9D languages with chaining method calls.
>=20
> It's an interesting suggestion - and the docstring is very readable.
>=20
> I'd be great to see how it works with some existing modes' indentation =
code - e.g. to try to rewrite any of the rules in ruby-ts-mode (do we =
have any other ts mode with as many options affecting indentation?).
>=20
> OT2H the use of 'standalone-parent' is optional, and it's combined =
with a matcher anyway, so it's good even if it covers like 80% of the =
cases.
>=20
> What would be our next step in this? Replacing all 'parent-bol' =
anchors with 'standalone-parent' across most ts modes?

Speaking of next step, I recently added another handy tool for languages =
with C-like syntax: c-ts-common-baseline-indent-rule. I figured out an =
indent logic that can work on all C-like languages and covers a wide =
range of cases. This one rule can give you all theses indentation:

1. Statements align to their previous sibling:

    int main() {
      int a =3D 1;
      int b =3D 2; <-- Align to prev line=E2=80=99s sibling.
    }

2. Indents one level for blocks: function, if, for, struct, etc.

    int main() {
      return 0;   <-- Indent one level.
      {           <-- Align to prev line=E2=80=99s sibling.
        return 1; <-- Indent one level.
      }
    }

3. Elements in parenthesis and brackets:

    return [1, 2, 3,
            4, 5, 6]; <-- Align to first sibling.

    return [
      1, 2, 3,  <-- Indent one level (option 1).
      4, 5, 6,  <-- Align to prev line=E2=80=99s sibling.
    ];

    return [
            1, 2, 3,  <-- Align to opening bracket (option 2).
            4, 5, 6,  <-- Align to prev line=E2=80=99s sibling.
           ];         <-- Align to opening bracket.

    for (int i =3D 0;
         i < 10; <-- Align to first sibling.
         i++) {  <-- Align to prev line=E2=80=99s sibling.
      continue;
    }

4. Statement expressions indent one level when it=E2=80=99s broken into =
two
   lines:

    int main() {
      int var
        =3D 1287;  <-- Indent one level.
      int var =3D
        1287;    <-- Indent one level.
    }

Then a C-like language=E2=80=99s major mode only need to add special =
cases over the baseline indent rule. And if we add the configurable =
heuristic for standalone-parent, the baseline indent rules would make =
use of it.

I brought it up because if we=E2=80=99re going to do some renovations to =
indent rules, might as well make use of =
c-ts-common-baseline-indent-rule, and we probably don=E2=80=99t even =
need to replace parent-box with standalone-parent, because the baseline =
indent rule would cover most cases.=20

I=E2=80=99ve already used it to rewrite c-ts-mode indent rules and =
it=E2=80=99s been a success; this baseline + override approach has been =
very helpful. c-ts-mode still has a lot of indent rules because of =
things like preproc directive, etc, but it=E2=80=99s much more =
manageable than before.

I don=E2=80=99t know how much it would help modes that has simpler =
indent rules. Go-ts-mode and rust-ts-mode only has a handful of indent =
rules, maybe they don=E2=80=99t really need this baseline rule. OTOH Lua =
and Ruby has more involved indent rules, maybe they can benefit and =
reduce the number of rules they need to define.

Yuan=




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

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


Received: (at 74386) by debbugs.gnu.org; 12 Dec 2024 03:20:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 11 22:20:37 2024
Received: from localhost ([127.0.0.1]:37086 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLZkj-0003N4-1I
	for submit <at> debbugs.gnu.org; Wed, 11 Dec 2024 22:20:37 -0500
Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]:53965)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tLZkd-0003Lw-SQ
 for 74386 <at> debbugs.gnu.org; Wed, 11 Dec 2024 22:20:35 -0500
Received: from phl-compute-11.internal (phl-compute-11.phl.internal
 [10.202.2.51])
 by mailfout.stl.internal (Postfix) with ESMTP id C08CB1140178;
 Wed, 11 Dec 2024 22:20:23 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162])
 by phl-compute-11.internal (MEProxy); Wed, 11 Dec 2024 22:20:23 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm3; t=1733973623;
 x=1734060023; bh=md168JSaS1g08BYf5/AguIE8eABFGq86zuNs1O8FJBk=; b=
 kb3WYc2jj28kc172egX4DYxwebvZ5dppqFmnTNWH2K0f1vda5QZXCC2eRu3z8ZBc
 KGxW94lWQqmohmnTdRkX4WfB9HT/gPnMvvblY0Yisnz8a2y2UQZO7pilsvTjJqs0
 Xa0B7+ra8gk0BEuOfiOuKNRjmPg8a3K7AeqVXxW4n5H52XfA/qO8FejenP96F5eu
 36WEjvlWvQEaC0Y2oumyGjBy2SkPGerN/aAAWTO1dRlfhFW4xJAqlEb5LWlHyIgx
 HOvhV66s8jpfpThzx2uwZ2DOInzrNs57CHkMQpv6eM7bMZPxOceNLylhrgjiAVEF
 IaXunXI87RR27MUuFgDKvQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733973623; x=
 1734060023; bh=md168JSaS1g08BYf5/AguIE8eABFGq86zuNs1O8FJBk=; b=E
 9zb3ALPGezUfWsOPPadb0hy1W75XyTxb89r78uNtckL5Ec4CXc8iHSA4PKgrwAvN
 nNPmI1CHq9ReZdK3vKIkHC8JDUqAhVRpYU9scFVBsUV41oPyqmgflkkw4iXFvlVd
 MIp0xN0ExS5MCepdWh6yI1qCGNtukdVxk6Q0KV2Jz3u9PfLtsGI3KVS1Jdx/4yX/
 H8JY46NvYgvALB/Su2dkTFNUBg1rDz8BwQFch57w6AIwz7Hf9K/gmD2edRJCyTYl
 jAXZDIPTODwC09V9eI1jOc6KyZVvqZ5FO91gMriixbT6gIgVaxOy2bquk6b3XiEv
 +gKP/zYnXD2C7KMTWVUtA==
X-ME-Sender: <xms:d1ZaZ_NaS4LGACLKwd76OJn7HHdfglhUinpBhVnhAtzb2P0gv06Ecw>
 <xme:d1ZaZ58nxgdqvmzSK3R9y0O_ba3e4hK7ovRCTkKA0Hvq3-BmJsR63vLxggMIuZVwK
 7AxSOczZdmWHKLT6co>
X-ME-Received: <xmr:d1ZaZ-QQ7LbgBwZsEYV_EyAyl-94kNuT0IwFEwqWwdEXU7GJqLLbN1D-vc4fXQFVx_3I>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrkeefgddtudcutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
 tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth
 hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpeegleefteekgffhvdfhtdegveevveetteegteevgeet
 tdehhfdukeetheffueekkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptggrshhouhhrihesghhmrghilh
 drtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehthhgv
 ohesthhhohhrnhhhihhllhdrnhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgsh
 drghhnuhdrohhrghdprhgtphhtthhopehmrghrihhushdrkhhjvghluggrhhhlsehgmhgr
 ihhlrdgtohhm
X-ME-Proxy: <xmx:d1ZaZzt1w4iSil-K8uZLB2sW11A5xz34Si3-gbyRUqREZ_jokS06Rw>
 <xmx:d1ZaZ3ewM0_GHDbcFKccvdbJ4hI_8ppcM4w_Wm6yGit3q4BaEpG05Q>
 <xmx:d1ZaZ_2oJ4qT40snxCeXbVXTYZIoFDJLDKaAT0mjX2nidhYQOE521g>
 <xmx:d1ZaZz_TjxYvu60_knK6qfqNZAGQPYfjj7psWQbZFI8zI_Ekf3eJ0g>
 <xmx:d1ZaZ4HRKIO09jJhpVck5UqoW0efhMddB2AR4EOlgeRsPEsUV2GM3XIV>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed,
 11 Dec 2024 22:20:20 -0500 (EST)
Message-ID: <bf499bbc-4937-4f92-886b-3fb384514c33@HIDDEN>
Date: Thu, 12 Dec 2024 05:20:18 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Yuan Fu <casouri@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
 <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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 11/12/2024 08:18, Yuan Fu wrote:
>>> Maybe not by hardcoding this in inside the 'standalone-parent' matcher, but writing this in the indentation rules? Different languages might have differing ASTs for such construct.
>>>
>>> Or if you meant to do a text search, a period might start a method call, but it could also continue a "range" literal in some other language, or some struct initializer (I think?) in C/C++. Also, some languages allow (and style guides suggest) to have the previous at the end of the line, then followed by newline and then the method name.
>> Not hard-coded, but customizable, like this:
>>
>> Yuan
>>
>> <standalone-predicate-poc.patch>
> Circling back on this. WDYT? I think this would benefit all “modern” languages with chaining method calls.

It's an interesting suggestion - and the docstring is very readable.

I'd be great to see how it works with some existing modes' indentation 
code - e.g. to try to rewrite any of the rules in ruby-ts-mode (do we 
have any other ts mode with as many options affecting indentation?).

OT2H the use of 'standalone-parent' is optional, and it's combined with 
a matcher anyway, so it's good even if it covers like 80% of the cases.

What would be our next step in this? Replacing all 'parent-bol' anchors 
with 'standalone-parent' across most ts modes?




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

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


Received: (at 74386) by debbugs.gnu.org; 11 Dec 2024 06:19:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 11 01:19:42 2024
Received: from localhost ([127.0.0.1]:60824 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLG4T-0006Qu-HU
	for submit <at> debbugs.gnu.org; Wed, 11 Dec 2024 01:19:41 -0500
Received: from mail-pg1-f171.google.com ([209.85.215.171]:61781)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tLG4Q-0006Qd-5V
 for 74386 <at> debbugs.gnu.org; Wed, 11 Dec 2024 01:19:40 -0500
Received: by mail-pg1-f171.google.com with SMTP id
 41be03b00d2f7-7fd581c2bf4so1583547a12.3
 for <74386 <at> debbugs.gnu.org>; Tue, 10 Dec 2024 22:19:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1733897912; x=1734502712; darn=debbugs.gnu.org;
 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=TInk021ROFIya7/d9Yv5VBHWceSQcV/ymxuePmepqLw=;
 b=J6ctC4L9t2paobWhrjWyyMXuAVRn3IH5+m9jWqfadxCOaHn5HjdrFhWEF5dWOwfkaW
 nc2oN6kjqwM+Aj8KvMvPTeZjdIy8qI5WE+EIMKdawMQIHFApAy5yBLb9KHVaapN/Dxr/
 WD36z9X4ZraJZ15v0ZGO4KnA9huxmopMW452JXAxb/LXYQQj14Bun5nxnHSFz0FBfjyu
 9cq0hhGDIatBH5Gonzfn8fgnnPZDbwuck7/rglDwAcchnsUU0RNsxYexDnDQc1NB3EDV
 gXT7928uX9+tG4xX0+WG4kHQWOyXALG31r5a02GWEVeBSeX6Oc8qIGfiRUq+mZRGk3Ah
 gOhw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733897912; x=1734502712;
 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=TInk021ROFIya7/d9Yv5VBHWceSQcV/ymxuePmepqLw=;
 b=u3vB3dL/0WC8HVSUAd0ews+2wnB44R4CJ3cLUfhFnRsIM5b8C8h9HcM3OBv+N5m81A
 wncbBDfuZ1kmak8lXnAXbNKYQSw7njfpaGlc4DjrNMT94MfJcM63KjOGOajaiZxO8347
 Nf6/yMpx78pmD2vO0jpKK30oy/yFtLmIVIoW3CYRyqckyPbmBWxUgBGYWRWdCGqdFoUn
 TMVzwzXs1Va/1tn6Ft/WtTLhNeMs7CGCtMWTm4GIaEIrw6eUll9wruhCzq0tmkSaT/tX
 HklQT59WJ0HBE+zp2d4FgSunoP8t4rzL3SFxMpbh6kVmFvr4dGLO9lCbCRgN3AHBliwh
 pAdA==
X-Forwarded-Encrypted: i=1;
 AJvYcCV8JWmcj8EnY5NuphmeCvydvFn6GBMECkoLW2fETW3A1/qJXMorrPTaQvx29ifwXdj7WRHckw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YyFHJtOP41ydkQFvQ40Fie/stV4pTzVuDFiSvlx0xmjG5smu4h1
 EaqpxOPRLvVRnJLjdNDLjc11tiGclKz+1pJFfbFEfb8I+IlwYKzY
X-Gm-Gg: ASbGncuGML/8iq36I1hsf/XFBu9YjmPGsENir64w7cXRJm8j8STrBdh+rjdS3j2Qvtd
 fOZcVF0XxCETMryU3fWVKOoqemNqs2wLytrM22063sMy0BTiwqTMrKdixWbJLPqSL3Op3gqUa4D
 Tax3KsXLnWd/pfyUKQhDshF4PCGB8TTgCRYvyU06yqYqOQr/HdJEnukzE/0tJklptAqiK+Yr7yv
 zkro9I6EhoaE63bVQ9ZRYI91hBXvWeXyTcPdtfE4NmqPlaf7ERp3SQhNfklFFwRwm5Me1N3kOfd
 3w==
X-Google-Smtp-Source: AGHT+IHc7axPuiH+IWvhITe29E0bOf1G2fzVDaoBqjB1Xv+UyjUGZ2+nCGYkEFsWpNmiIZkr/tAbVQ==
X-Received: by 2002:a17:90b:5204:b0:2ea:61de:38f7 with SMTP id
 98e67ed59e1d1-2f12802ccd0mr2950958a91.29.1733897912269; 
 Tue, 10 Dec 2024 22:18:32 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:f90e:3b71:6ee2:6197])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2f12fcd4917sm227872a91.38.2024.12.10.22.18.31
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 10 Dec 2024 22:18:31 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
Date: Tue, 10 Dec 2024 22:18:20 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <C8322A63-40E0-4BE1-B799-5B8D0FF9E261@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
 <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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: -0.3 (/)



> On Dec 1, 2024, at 6:31=E2=80=AFPM, Yuan Fu <casouri@HIDDEN> wrote:
>=20
>=20
>=20
>> On Dec 1, 2024, at 2:33=E2=80=AFPM, Dmitry Gutov <dmitry@HIDDEN> =
wrote:
>>=20
>> On 01/12/2024 21:10, Yuan Fu wrote:
>>> Ah, I see. That=E2=80=99s a good point, and I definitely prefer the =
indentation result of parent-bol here. The one produced by =
standalone-parent is just wrong. What we can do is make =
standalone-parent ignore =E2=80=9C.=E2=80=9D when checking for =
=E2=80=9Cstandaloneness=E2=80=9D. And perhaps make it configurable so =
it=E2=80=99s enabled only for modes that this waiver makes sense (C-like =
languages excluding C and C++).
>>=20
>> Maybe not by hardcoding this in inside the 'standalone-parent' =
matcher, but writing this in the indentation rules? Different languages =
might have differing ASTs for such construct.
>>=20
>> Or if you meant to do a text search, a period might start a method =
call, but it could also continue a "range" literal in some other =
language, or some struct initializer (I think?) in C/C++. Also, some =
languages allow (and style guides suggest) to have the previous at the =
end of the line, then followed by newline and then the method name.
>=20
> Not hard-coded, but customizable, like this:
>=20
> Yuan
>=20
> <standalone-predicate-poc.patch>

Circling back on this. WDYT? I think this would benefit all =E2=80=9Cmoder=
n=E2=80=9D languages with chaining method calls.

Yuan=




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

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


Received: (at 74386) by debbugs.gnu.org; 2 Dec 2024 02:32:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 21:32:23 2024
Received: from localhost ([127.0.0.1]:53698 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHwEZ-0008MI-GE
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2024 21:32:23 -0500
Received: from mail-pl1-f170.google.com ([209.85.214.170]:50464)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tHwEW-0008M3-P5
 for 74386 <at> debbugs.gnu.org; Sun, 01 Dec 2024 21:32:22 -0500
Received: by mail-pl1-f170.google.com with SMTP id
 d9443c01a7336-21200c749bfso30425725ad.1
 for <74386 <at> debbugs.gnu.org>; Sun, 01 Dec 2024 18:32:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1733106675; x=1733711475; darn=debbugs.gnu.org;
 h=references:to:cc:in-reply-to:date:subject:mime-version:message-id
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=RL1O9VPXXseprmRnQHuj3yu8LsvtrC/tx4AxQhshjgA=;
 b=MAf17q1aztMiACFFjAP/kjkq2kBr78rzEXlJyYBNnV87btAhBby43MaQ7gaueLzJfQ
 SnlKVk8nYD43JDR4UDGMcR2aE24XvYgW1KoPKGPrF3istITfhkNr+vpzqT8MscHyEPVP
 M5PHlIKz1sTY2XBq0O6ZPjkhV+Uf64FiTyBdoKL+2a/ZCSJMLz7/xvVhXah6L5d/ggoU
 hGBu/z4Qy7egMgveOB8gLuP1ammZOwLhQ9uNSKFt+yuD5unUWbtGhh6LkvQVe6sUYCoT
 hkfcsfjmh5OFxrZsYFlvEiQWrj2V+kfTp4LJr5gaB5sjs+BArlT/cfZJFnku7PmanYbx
 Lnzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733106675; x=1733711475;
 h=references:to:cc:in-reply-to:date:subject:mime-version:message-id
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=RL1O9VPXXseprmRnQHuj3yu8LsvtrC/tx4AxQhshjgA=;
 b=rMjEYpLtuLzxXX9s8iI1ooPidLjb3uX+PMyWXWsZri9M+eB27Gt4lMHqTekpvYezEh
 FHKFAJ4TlFW/PElqSfzzXw6cLKzY11ML8lEhhlc9cSdPL6b/SHbIv3fTksN4DedMTU49
 +eUZndeE1owkR/FDWfWUGNyNceSijYvEmLhmsiHHFcUlAU89GlwYFpOVIgOyDnUjjYYo
 ko0mlVVoL8JwELO7I4InTzs+Zg8Z+b4oMFFHofcN+Fl++eIKctV9J2fo2Ru3R1E9WpN0
 dYBvJMy6hpdwJNco6od9N20Z1hltlyFlwQnMg7ZJDy7f0zsYlZXuWa+wxFugMT4XqDll
 e/+w==
X-Forwarded-Encrypted: i=1;
 AJvYcCV1a0HfWVALVmFFKbgcSU2Ag0y1hn3lkE4ssHVJnAe4Eh/fiJFaNMhkbYV9r8iuQZp/yMNBaw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yz3n3/Zj4MMtZp/vWAJ/Z7sskRzxJyDU+wqxYu4p/lT0f/uVrHh
 6wqiMh3EQTzpE8XzDDZlUaLm1/8YHSMDgXHMjrQSJinYWffaZdiL
X-Gm-Gg: ASbGncvW1DZA9LrIXzmoVZBS1oZ3uV9Xt2SiblNHT5d9IUuJAQsZAzg6TaroyghlZb4
 AowfsGQX97B0g8QmsdJvnvFxOsoTjseTTo9TE9ekHp8eBJ+sV/K/R6e5XrE4vIfzyhN8oCUTY7A
 QaD+x39oWDlfX1Y2qhA82PZzSeGxeF9ihMP0PxoxYJi8tKmoGrxUKKAGAOSPQ+Oyj4Vkz9X+a0d
 vi3KqCYR633tmHwVfGVmh5SF0Y9f9iS3WxORP/oVzsO5n2hZDpxe95525LaDnhzr3z8Spz+DQ==
X-Google-Smtp-Source: AGHT+IGFSB1kTM9bdlE9OTcENf6he7ywDi3bySGVZkD4grz7UqWeYS72O4t7ECv8aMCCEeNzrWv+JQ==
X-Received: by 2002:a17:902:e549:b0:215:5637:447 with SMTP id
 d9443c01a7336-2155637073amr106422995ad.51.1733106674991; 
 Sun, 01 Dec 2024 18:31:14 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:71b7:718f:7faa:8436])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-21544fd9b4dsm45703415ad.223.2024.12.01.18.31.13
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 01 Dec 2024 18:31:14 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Message-Id: <8A7428E6-50EE-4783-82FF-3A62C4756C56@HIDDEN>
Content-Type: multipart/mixed;
 boundary="Apple-Mail=_94AE5EBC-C795-4E1C-9FBF-A773A0606255"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
Date: Sun, 1 Dec 2024 18:31:02 -0800
In-Reply-To: <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
 <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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: -0.3 (/)


--Apple-Mail=_94AE5EBC-C795-4E1C-9FBF-A773A0606255
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On Dec 1, 2024, at 2:33=E2=80=AFPM, Dmitry Gutov <dmitry@HIDDEN> =
wrote:
>=20
> On 01/12/2024 21:10, Yuan Fu wrote:
>> Ah, I see. That=E2=80=99s a good point, and I definitely prefer the =
indentation result of parent-bol here. The one produced by =
standalone-parent is just wrong. What we can do is make =
standalone-parent ignore =E2=80=9C.=E2=80=9D when checking for =
=E2=80=9Cstandaloneness=E2=80=9D. And perhaps make it configurable so =
it=E2=80=99s enabled only for modes that this waiver makes sense (C-like =
languages excluding C and C++).
>=20
> Maybe not by hardcoding this in inside the 'standalone-parent' =
matcher, but writing this in the indentation rules? Different languages =
might have differing ASTs for such construct.
>=20
> Or if you meant to do a text search, a period might start a method =
call, but it could also continue a "range" literal in some other =
language, or some struct initializer (I think?) in C/C++. Also, some =
languages allow (and style guides suggest) to have the previous at the =
end of the line, then followed by newline and then the method name.

Not hard-coded, but customizable, like this:

Yuan


--Apple-Mail=_94AE5EBC-C795-4E1C-9FBF-A773A0606255
Content-Disposition: attachment;
	filename=standalone-predicate-poc.patch
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="standalone-predicate-poc.patch"
Content-Transfer-Encoding: quoted-printable

=46rom=20301e8a55a14f61258c505a48a973379ac3156079=20Mon=20Sep=2017=20=
00:00:00=202001=0AFrom:=20Yuan=20Fu=20<casouri@HIDDEN>=0ADate:=20Sun,=20=
1=20Dec=202024=2018:26:40=20-0800=0ASubject:=20[PATCH]=20Standalone=20=
predicate=20POC=0A=0A---=0A=20lisp/treesit.el=20|=2037=20=
+++++++++++++++++++++++++++++++++++--=0A=201=20file=20changed,=2035=20=
insertions(+),=202=20deletions(-)=0A=0Adiff=20--git=20a/lisp/treesit.el=20=
b/lisp/treesit.el=0Aindex=202acb46ab105..513f58eeffd=20100644=0A---=20=
a/lisp/treesit.el=0A+++=20b/lisp/treesit.el=0A@@=20-1597,6=20+1597,37=20=
@@=20treesit--indent-prev-line-node=0A=20=20=20=20=20=20=20=
(back-to-indentation)=0A=20=20=20=20=20=20=20=
(treesit--indent-largest-node-at=20(point)))))=0A=20=0A+(defvar=20=
treesit-simple-indent-standalone-predicate=20nil=0A+=20=20"Function=20=
used=20to=20determine=20if=20a=20node=20is=20\"standalone\".=0A+=0A=
+\"Standalone\"=20means=20the=20node=20starts=20on=20a=20new=20line.=20=20=
For=20example,=20if=20we=0A+look=20at=20the=20opening=20bracket,=20then=20=
it's=20standalone=20in=20this=20case:=0A+=0A+=20=20=20=20{=20=20=20=20=20=
=20=20=20=20=20=20=20<--=20Standalone.=0A+=20=20=20=20=20=20return=201;=0A=
+=20=20=20=20}=0A+=0A+but=20not=20in=20this=20case:=0A+=0A+=20=20=20=20=
if=20(true)=20{=20=20<--=20Not=20standalone.=0A+=20=20=20=20=20=20return=20=
1;=0A+=20=20=20=20}=0A+=0A+The=20value=20of=20this=20variable=20affects=20=
the=20`standalone-parent'=20indent=20preset=0A+for=20=
treesit-simple-indent.=20=20If=20the=20value=20is=20nil,=20the=20=
standlone=20condition=0A+is=20as=20described.=20=20Some=20major=20mode=20=
might=20want=20to=20relax=20the=20condition=20a=0A+little=20bit,=20so=20=
that=20it=20ignores=20some=20punctuation=20like=20\".\".=20=20For=0A=
+example,=20a=20Javascript=20mode=20might=20want=20to=20consider=20the=20=
method=20call=20below=0A+to=20be=20standalone=20too:=0A+=0A+=20=20=20=20=
obj=0A+=20=20=20=20.method(()=20=3D>=20{=20=20=20<--=20Consider=20=
\".method\"=20to=20be=20standalone,=0A+=20=20=20=20=20=20return=201;=20=20=
=20=20=20=20=20<--=20so=20this=20line=20anchors=20on=20\".method\".=0A+=20=
=20=20=20});=0A+=0A+The=20value=20should=20be=20a=20function=20that=20=
takes=20a=20node,=20and=20return=20t=20if=20it's=0A+standalone.")=0A+=0A=20=
(defvar=20treesit-simple-indent-presets=0A=20=20=20(list=20(cons=20=
'match=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(lambda=0A@@=20=
-1736,8=20+1767,10=20@@=20treesit-simple-indent-presets=0A=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20(catch=20'term=0A=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(while=20parent=0A=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(goto-char=20=
(treesit-node-start=20parent))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20(when=20(looking-back=20(rx=20bol=20(*=20=
whitespace))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
(line-beginning-position))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20(when=20(if=20(null=20=
treesit-simple-indent-standalone-predicate)=0A+=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
(looking-back=20(rx=20bol=20(*=20whitespace))=0A+=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20(line-beginning-position))=0A+=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20(funcall=20parent))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20(throw=20'term=20(point)))=0A=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20parent=20=
(treesit-node-parent=20parent)))))))=0A=20=20=20=20=20=20=20=20=20(cons=20=
'prev-sibling=20(lambda=20(node=20parent=20bol=20&rest=20_)=0A--=20=0A=
2.39.5=20(Apple=20Git-151)=0A=0A=

--Apple-Mail=_94AE5EBC-C795-4E1C-9FBF-A773A0606255--




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

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


Received: (at 74386) by debbugs.gnu.org; 1 Dec 2024 22:33:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 17:33:36 2024
Received: from localhost ([127.0.0.1]:53385 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHsVT-0004c9-RU
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2024 17:33:36 -0500
Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]:51595)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tHsVR-0004bq-4L
 for 74386 <at> debbugs.gnu.org; Sun, 01 Dec 2024 17:33:34 -0500
Received: from phl-compute-06.internal (phl-compute-06.phl.internal
 [10.202.2.46])
 by mailfout.stl.internal (Postfix) with ESMTP id B6818114006E;
 Sun,  1 Dec 2024 17:33:27 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-06.internal (MEProxy); Sun, 01 Dec 2024 17:33:27 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm3; t=1733092407;
 x=1733178807; bh=8vCmCqcbc9lXBeuohG9B5QtqaNCg462je9HRQHBE/7E=; b=
 EnBaVXG29hv8288ybLWLkSFTdQkxu1x9A40zjvV43aJzx9dzE2IjbhkAx32iPobb
 sneBVxfiLt9JAg1HedDSfCuxgGfbb5zGnwFw3b8OFIfGtwqmowaxQAOBfZuC+gPE
 vfYbnrIZu5Ot/cmpeaOm4tK69bRMior/hKgTBwKuKFds2/OgIWhTX8+mLn1fgsDk
 TuhsvtXz+ccqJQRsnxdWqift2UsrnaUawcH1AApgvJfLijzksdnriIqez0bABkQC
 wXGZGjldFACecN+YPa1EwGxyVYVoUqp+NU5XBfC0Nrg60tv6ylwEd3rG6GoK2/I7
 gaunFCiohE8JdMtE+54f7A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733092407; x=
 1733178807; bh=8vCmCqcbc9lXBeuohG9B5QtqaNCg462je9HRQHBE/7E=; b=x
 s+YmEZ1NkkYPDMr2eykBxw3GypANA1vVz64Ww5YnGj/pRJ7rJMCwWas8v+01GLgn
 8udcmGnDEmRxnzr4RP7oVxqhABXYR9BCDbCE9fIS73Lr/UzatQbF1PauXR8XfKiX
 yvbOH1PctBXYel69EAITH/vxtzL5HwRwsN0XFgyLQjoT80PrPL0scQ0e4uI03wwW
 xfsnJ74rcPz5SWYuHC5dTjqp6BZpWFJDhoHqGcQjT+pFJ1bjPtQVIwHjUP0nLGbI
 EkoaTqMbdwh4e4sXHBfBxJJa+zcGIQMvbwstDG10QS/PkGyfOzQLDXceeqzpLf6w
 unBsQdA4frMAPt9IEVxUA==
X-ME-Sender: <xms:N-RMZ2SIhFO4kRgjtIBMilehMhoasI52sNF9CWP_ojkxUJXWY78RHA>
 <xme:N-RMZ7wGHl6bB9UiXHIjtIRt7-sspiJxZsxDpxZp9jt_XxlBdG3KQ_iFfp3LykVN4
 6ehH0Og_iNLW7INsPY>
X-ME-Received: <xmr:N-RMZz0ehkHmcZy-RPioMR1sTtalbEOnxo8TD-36fDcda6buaYz42riJFUQs4goSUC5L>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrheejgdduiedtucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
 rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh
 htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej
 necuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdrug
 gvvheqnecuggftrfgrthhtvghrnhepgeelfeetkefghfdvhfdtgeevveevteetgeetveeg
 tedthefhudekteehffeukeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe
 hmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthho
 peehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegtrghsohhurhhisehgmhgrih
 hlrdgtohhmpdhrtghpthhtohepvghlihiisehgnhhurdhorhhgpdhrtghpthhtohepthhh
 vghosehthhhorhhnhhhilhhlrdhnohdprhgtphhtthhopeejgeefkeeiseguvggssghugh
 hsrdhgnhhurdhorhhgpdhrtghpthhtohepmhgrrhhiuhhsrdhkjhgvlhgurghhlhesghhm
 rghilhdrtghomh
X-ME-Proxy: <xmx:N-RMZyAaZXDHvtByykKRPDVp_94cEnAOd0Jm_FI-vP21PdrT-Bz7JQ>
 <xmx:N-RMZ_ijSMKc-QRZMrLSY-BDnaBFWTRDqZsQrtLXz27-pwqDm1AzEw>
 <xmx:N-RMZ-o8xbWFLd-M__xdoNjx4uMHm-Uy__X2WUdoh8ARJNBHePRQdw>
 <xmx:N-RMZyi9CiCKV-z6eS_JggOhSl91Ml57zC4dYps_GR5Lflo8llXtTg>
 <xmx:N-RMZ1ZxK1mkQez5-5IFmxTFJh9JvQ5rR6mgB0U6X-DM27YwXtrZa7FB>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 1 Dec 2024 17:33:25 -0500 (EST)
Message-ID: <a82074c0-f8e7-4bb2-b2a6-20716b586a8f@HIDDEN>
Date: Mon, 2 Dec 2024 00:33:23 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Yuan Fu <casouri@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
 <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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 01/12/2024 21:10, Yuan Fu wrote:
> Ah, I see. That’s a good point, and I definitely prefer the indentation result of parent-bol here. The one produced by standalone-parent is just wrong. What we can do is make standalone-parent ignore “.” when checking for “standaloneness”. And perhaps make it configurable so it’s enabled only for modes that this waiver makes sense (C-like languages excluding C and C++).

Maybe not by hardcoding this in inside the 'standalone-parent' matcher, 
but writing this in the indentation rules? Different languages might 
have differing ASTs for such construct.

Or if you meant to do a text search, a period might start a method call, 
but it could also continue a "range" literal in some other language, or 
some struct initializer (I think?) in C/C++. Also, some languages allow 
(and style guides suggest) to have the previous at the end of the line, 
then followed by newline and then the method name.




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

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


Received: (at 74386) by debbugs.gnu.org; 1 Dec 2024 19:11:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 14:11:29 2024
Received: from localhost ([127.0.0.1]:53100 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHpLt-0002sI-7e
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2024 14:11:29 -0500
Received: from mail-pg1-f181.google.com ([209.85.215.181]:55511)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tHpLr-0002s9-Hm
 for 74386 <at> debbugs.gnu.org; Sun, 01 Dec 2024 14:11:28 -0500
Received: by mail-pg1-f181.google.com with SMTP id
 41be03b00d2f7-7fcc00285a9so658250a12.2
 for <74386 <at> debbugs.gnu.org>; Sun, 01 Dec 2024 11:11:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1733080226; x=1733685026; darn=debbugs.gnu.org;
 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=Qv6Xnv1CcqrcGnKXYPF3pIehy7vtHnl96OvltCGSPEU=;
 b=Ke+cYkYXuUx/DDycnAK+CGyziQkalZ9esvMPeHqRT6OYhNYcgJ3IkgmdGgPUiuD8Uv
 WJHMubKZhOd/yJI5+IODRPMthvTSEaqmFo7BaxvCW0l40ECb1AnKTkJE1Q1NYBuxSIi0
 Rc2URfnIdDmowRDOYlNBBMOfrxOf7qU57oQ44z2MTikOsPIe1E+AmqzF2JrGtuE2YhKt
 sZe9cKwDamYLo5OJdWCN1VRfSgeo4/bQBomhGpWu1WGwQlB2UFb6QvQqz2T7HniFi4l+
 /KQ3iBiDpYnMB5lm6IwsM/YiN8nrHQsigsJtxgvHJbnuPM4YPxS9FwnTniatp0M8HImm
 GiaA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733080226; x=1733685026;
 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=Qv6Xnv1CcqrcGnKXYPF3pIehy7vtHnl96OvltCGSPEU=;
 b=cKSSZVfVtZE/jp35oaT9zN39mC+vdYdmS7w+APcaTkURsMq4vyYhuIhprSHrDV1gAA
 6RV/ByupDwr0brK5CUtAXgzwnkC14jUvgOxZs+GXUxl8T1Dp4vOSSo+700M0hU75OQaZ
 x+ki4gSl3dmk96eemrMMgYBsMdwA5fJR2ejALHWZGbMUsIgY9yltuqbH0umRtFxkOYzj
 DgF+z4n2jBV3AgvqEQfEnL6ihgaW0grakQVFaYECp51Q05C9uKWOvakHWGneKhV3/Zcu
 AKshiEJY/YM4umKHYQqj7hbahuGRLeFmRRKj6H+x9P6GLPfXboU4M9bi0bYm5XWld+l0
 pMQQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCVgzo/dMAJt0y8gpC26EFhMY+rjQrmXgjfrcFfUvdEN9Yu+6phzNlBXexX4Ovs+SCsbmRshPg==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YxnyMf+YROb1kI1nr7oUchKEzRY8az30vnjM9NLf5gsyJiw9MbY
 RX8si2jgunjv5+7BChMPZCaxw2cMeIv4k/lDABkfYQj4/ADT1od6
X-Gm-Gg: ASbGncui9eKpV10uL/cF0DdCCMyLA8PqqhcUdiIcTRjxR3k5QgM2Gv0AIcnSuYz0zoP
 c0GXJWl1vRSssKMnqmv+1UnikqwMa8ESIoTak+OAZp52OSpAp+Kype8x1TpZ6soBndE/hS386L6
 +YQDSga3ISpXJshct1LlRyanNoXn8DSkWMpIKm5oBT/TL8Ron4+6jCghHLDmxW64hDqeKBMBwCC
 p496Bqx+1SB/i0canOE/vwCeqboE+vw7rjReRlNkhXZMV9cG/sYHIAVIHKGcpf3s2lIEtXw9g==
X-Google-Smtp-Source: AGHT+IFo2DZlfqkw++lqZRO9BvWPwCsSpboCPUhBh+1EzP//Ajem4BKLabbW9VUrsAQG/2YVMX1nBA==
X-Received: by 2002:a05:6a20:12c3:b0:1db:efab:390c with SMTP id
 adf61e73a8af0-1e0e0b5a079mr33957271637.35.1733080226464; 
 Sun, 01 Dec 2024 11:10:26 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:71b7:718f:7faa:8436])
 by smtp.gmail.com with ESMTPSA id
 d2e1a72fcca58-72541814291sm7153329b3a.142.2024.12.01.11.10.25
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 01 Dec 2024 11:10:25 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
Date: Sun, 1 Dec 2024 11:10:14 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <35B61F44-C551-44DB-A334-A893991BC799@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
 <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>, marius.kjeldahl@HIDDEN
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: -0.3 (/)



> On Dec 1, 2024, at 5:11=E2=80=AFAM, Dmitry Gutov <dmitry@HIDDEN> =
wrote:
>=20
> On 01/12/2024 07:23, Yuan Fu wrote:
>>>> For more experimenting, also check out 'M-x treesit-explore-mode'.
>>>>=20
>>>> And here's how to immediately find out which indentation rule was =
used:
>>>>=20
>>>>   (setq treesit--indent-verbose t)
>>> Theo, please chime in.  Should Dmitry install his changes?
>> The standalone-parent anchor is designed specifically to solve the =
bug described here, and changing parent-bol to standalone-parent is very =
safe. So IMO we can merge this (either to emacs-30 or master).
>=20
> Thanks for your answer.
>=20
> What I was wondering, is whether we might need some user option(s) to =
switch back to parent-bol instead of standalone-parent for some =
constructs, and whether we should replace more uses of parent-bol with =
standaline-parent, and if so, which ones.
>=20
> Also see the example of the indentation change with that patch =
(switching from one fairly popular indentation style to one slightly =
less popular - AFAIK).

Ah, I see. That=E2=80=99s a good point, and I definitely prefer the =
indentation result of parent-bol here. The one produced by =
standalone-parent is just wrong. What we can do is make =
standalone-parent ignore =E2=80=9C.=E2=80=9D when checking for =
=E2=80=9Cstandaloneness=E2=80=9D. And perhaps make it configurable so =
it=E2=80=99s enabled only for modes that this waiver makes sense (C-like =
languages excluding C and C++).

Yuan





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

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


Received: (at 74386) by debbugs.gnu.org; 1 Dec 2024 13:11:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 08:11:50 2024
Received: from localhost ([127.0.0.1]:50684 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHjjp-00006A-Pl
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2024 08:11:50 -0500
Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]:36833)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tHjjn-00005s-Ed
 for 74386 <at> debbugs.gnu.org; Sun, 01 Dec 2024 08:11:48 -0500
Received: from phl-compute-08.internal (phl-compute-08.phl.internal
 [10.202.2.48])
 by mailfout.stl.internal (Postfix) with ESMTP id BACB711400B1;
 Sun,  1 Dec 2024 08:11:41 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162])
 by phl-compute-08.internal (MEProxy); Sun, 01 Dec 2024 08:11:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm3; t=1733058701;
 x=1733145101; bh=kLtmxYOMZJSO1tIPcn6pvO9fcodGp79tFlrgLwyrlzg=; b=
 fSrxKw2hG4dZuYxJ6YqNNdT/ZUW/DmsyF1E95tuPpjMK5DRWt57+PZ3naEP28CLe
 QVHYOH/fq580EA8Xp1Xn+lPLaRo0wMGi4LGM4L6Ya8Tpz2FG/2Fv12IatRwwdlvF
 MxPHmKSh0nq9A0KqAX3poNsCP7sgLPJd3DE/fpWFqSNujcNlX2NF+C3Te+rxTWLk
 pFmScbduP058lUmpUzcutout8HDcc774jX1h8aN+ReA9wtv0l2dw3feeoO++0p98
 1ypv6+m15xEOp13U8plV2sMPHa05errkGbEn3fzq5PrmxOAEFbFPGliwzwbf4a27
 +fFwUmP8dCIsZnUI6QuBxQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733058701; x=
 1733145101; bh=kLtmxYOMZJSO1tIPcn6pvO9fcodGp79tFlrgLwyrlzg=; b=v
 0d6tzQ/hSUXT9Dlbm9dZiJqtSr2Kp6ZZ0bBCluDrXR596QcoAy4+BBx5AZw1co58
 Gux9VriZ4xRUCbLTiNnUPSdnF89jJaKfmUvY66D+NQdrUua/aYlk45Qr/TR0czm4
 zXzqJb/vQ7pwnhINGfHNW0YcLfl7UiywEwg9D4SDwO0ehNNmMiO49GWaS/MbfUmF
 D0HhkQnpKB26KjXgcGK83//vrZYEVFq9LeZ/NsXmkjb3PtncGXQapZyarXlmG5uc
 TNGJWMoDntm5r6AB0186OXPljq6GrDHNxRqcOEkroTMPa+O7Lhx8/vv8wE4B5Cai
 n4hmQ7aqj1iZ8MeXIr2kQ==
X-ME-Sender: <xms:jWBMZzwBC9cGKgk-weF-jcT-ZSIJ2KqLJisXcWtGhYl9jtOQUftHMw>
 <xme:jWBMZ7SKEeaulmK5rRv8iJG3n4JR2CVbgASmywbLegc0_YiHpLRGSsbqM3j3-E4Fb
 5tRWKj8pBAi2HfLkL4>
X-ME-Received: <xmr:jWBMZ9UeZqXGLbXTeON_EXrPRP-HQDQCo_Pt0iRK2P6yWfXl93h1Fht4WiaKzJX5h6ri>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrheejgdegkecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
 tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth
 hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedt
 vddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptggrshhouhhrihesghhmrghilh
 drtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehthhgv
 ohesthhhohhrnhhhihhllhdrnhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgsh
 drghhnuhdrohhrghdprhgtphhtthhopehmrghrihhushdrkhhjvghluggrhhhlsehgmhgr
 ihhlrdgtohhm
X-ME-Proxy: <xmx:jWBMZ9jqbZO6_mRJufXAI21UKXgqAIzVsKAeqrOF5JPLGPnTRUOV5g>
 <xmx:jWBMZ1DSLpJcYPTzrclq9GL-0BFdcSHxyIhi8tLMFFniN-62-bXDzQ>
 <xmx:jWBMZ2IIihHu-Oaio65YW_CHgijSOHDYbyxo1ZkWuACO2K4FPTc4mA>
 <xmx:jWBMZ0AvQ6RechlkCrgFZg9LpH2h2afKGFeM78_scsGiA5Qa_2jX8Q>
 <xmx:jWBMZ30ta2rFK-JJdbSlUSsl_2VxdE-FXfEDLAXagCbvU1ARci-To61N>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 1 Dec 2024 08:11:39 -0500 (EST)
Message-ID: <deabc799-ef26-42b3-9043-763f247f0760@HIDDEN>
Date: Sun, 1 Dec 2024 15:11:36 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Yuan Fu <casouri@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
 <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, theo@HIDDEN, marius.kjeldahl@HIDDEN
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 01/12/2024 07:23, Yuan Fu wrote:
>>> For more experimenting, also check out 'M-x treesit-explore-mode'.
>>>
>>> And here's how to immediately find out which indentation rule was used:
>>>
>>>    (setq treesit--indent-verbose t)
>> Theo, please chime in.  Should Dmitry install his changes?
> The standalone-parent anchor is designed specifically to solve the bug described here, and changing parent-bol to standalone-parent is very safe. So IMO we can merge this (either to emacs-30 or master).

Thanks for your answer.

What I was wondering, is whether we might need some user option(s) to 
switch back to parent-bol instead of standalone-parent for some 
constructs, and whether we should replace more uses of parent-bol with 
standaline-parent, and if so, which ones.

Also see the example of the indentation change with that patch 
(switching from one fairly popular indentation style to one slightly 
less popular - AFAIK).




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

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


Received: (at 74386) by debbugs.gnu.org; 1 Dec 2024 05:24:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 00:24:41 2024
Received: from localhost ([127.0.0.1]:49876 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHcRl-0000xH-3a
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2024 00:24:41 -0500
Received: from mail-pj1-f41.google.com ([209.85.216.41]:61476)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1tHcRi-0000x6-Iv
 for 74386 <at> debbugs.gnu.org; Sun, 01 Dec 2024 00:24:39 -0500
Received: by mail-pj1-f41.google.com with SMTP id
 98e67ed59e1d1-2ee8647dbb9so492682a91.2
 for <74386 <at> debbugs.gnu.org>; Sat, 30 Nov 2024 21:24:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1733030617; x=1733635417; darn=debbugs.gnu.org;
 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=V5k8lUkW1yMcs3vVhiINA5082mkyUUSQDVPpYTVEk+A=;
 b=ZvN7X1uHe6arVCjuOJeTk83opJEhFbk5jByyGoui27ufoYyRCT3KysGGNViNWtKj2Q
 wdtD/evXfppiHCsk3B1ofoVMlfBV2eJ7MftJBoB5+VN1wouTqubdlkhtBV/HllixQIUn
 RJ+4Js/Md6Ca/H0Y2f13w+iykhpoaiqQLs8REG8SYoV1gMMLFcV8d4TmU4LvOLl/dzVe
 5Hry0HXYHcegardzb7BJYDXKEmuwmXOJZ0Rn3hlyVAb3eJQhltOMYUrV9WQ0ecB2pYgH
 tFC1ikjTMaYDCl0ijJL/g48Cjr9PL6cBcguOsELqBq1FndQIBvXGOnnZ/wyqS522nl1H
 i3cQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733030617; x=1733635417;
 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=V5k8lUkW1yMcs3vVhiINA5082mkyUUSQDVPpYTVEk+A=;
 b=XjgWv3g8Jex8HkxDzEhHKOQCi3cI3BQUMsGl4esilLWazM/9eQTURPiGM8oVpETmzJ
 C4csRERNTH2MWx/yBtyeGiUVdi6cBb8V2kIJILGWS8JJWb/AU0jIZyvEV727yGftlYP4
 KD7ZPKNgs3HFyD2riqMf80TUW+2ucvp/LVADGCuuTwjOJAHO213gnOiJ3sqnkyJMuVl+
 XUfslmBEX+5zNxTieWBRO3IHC89g8DyTu/mv8phHTHm52tf8mN2RFcy+gdFre3OhVMoD
 s/AktFbEu7Hm1zNRdzn9oUICbC4GaLm2HC+fhkrCrJboJdD5FB90GlKawYsm6xVBybGc
 qhpA==
X-Forwarded-Encrypted: i=1;
 AJvYcCWEQqgKjrYYymQttPWjn6V8ZnYz0yuRpnLwO0x6nZiKbRW4tI7L/aOhtXA5KICbz9yqrGsuSQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YzUehgQtn+B8wXtVqLJBy5+f8C2WPNVK1hA2+KkOkMB017WuRgR
 /jcxtSOI565rLuh6lxQYE3le/0XzPI/+9uzUJtw463FpZQW7aQ6s
X-Gm-Gg: ASbGncvRBLfCi9QVXnJMBCzgHs4OVmJRIl4eSne1LX047Cd6FcKmGlRE6B8Qt8PVBeA
 oamO7E1QAEdEcypzmPachpjT3kq1OayXc4XA4g1RYtO7h7UzPy96tpqP+8/WkPz+Udq70Zada8q
 BWnbwk6Pf3CcacltLAB4no3UQSfdkGzV2XIGfSnGt9djDeuCzlkL+NCKqbilqlud7MJ+BlE7JrQ
 muN7jwsmfnT6iX9P2jjuYV8Q87sFE2qmhw82D1+EV/go5VJmDYM1Jem1C3zdTAvdROS4OmIAw==
X-Google-Smtp-Source: AGHT+IFLp+LnCV7+5/POngOnoyFAmxD/b8U4XO6K2RshS9hp/oLcPn0Nue0qGcG/8HeD2NBGJT8HnQ==
X-Received: by 2002:a17:90b:2fd0:b0:2ee:48bf:7dc3 with SMTP id
 98e67ed59e1d1-2ee48bf7f80mr15944635a91.15.1733030617430; 
 Sat, 30 Nov 2024 21:23:37 -0800 (PST)
Received: from smtpclient.apple ([2601:646:8f81:6120:71b7:718f:7faa:8436])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2ee5a8a7f5csm3819609a91.14.2024.11.30.21.23.34
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 30 Nov 2024 21:23:36 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\))
Subject: Re: bug#74386: Tree-sitter javascript indentation
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <86r06t82gl.fsf@HIDDEN>
Date: Sat, 30 Nov 2024 21:23:22 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> <86r06t82gl.fsf@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: Apple Mail (2.3776.700.51)
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: Dmitry Gutov <dmitry@HIDDEN>, theo@HIDDEN,
 marius.kjeldahl@HIDDEN, 74386 <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: -0.3 (/)



> On Nov 30, 2024, at 2:01=E2=80=AFAM, Eli Zaretskii <eliz@HIDDEN> =
wrote:
>=20
>> Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
>> Date: Mon, 18 Nov 2024 17:29:18 +0200
>> From: Dmitry Gutov <dmitry@HIDDEN>
>>=20
>> On 18/11/2024 10:35, Marius Kjeldahl wrote:
>>> Can confirm your patch solves both the variants I showed. This will
>>> also help me to dig into and understand more of what is going on, =
and
>>> allows me to experiment more with my preferences (and tree-sitter in
>>> general). So thank you very much.
>>=20
>> Great!
>>=20
>> For more experimenting, also check out 'M-x treesit-explore-mode'.
>>=20
>> And here's how to immediately find out which indentation rule was =
used:
>>=20
>>   (setq treesit--indent-verbose t)
>=20
> Theo, please chime in.  Should Dmitry install his changes?

The standalone-parent anchor is designed specifically to solve the bug =
described here, and changing parent-bol to standalone-parent is very =
safe. So IMO we can merge this (either to emacs-30 or master).

Yuan=




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

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


Received: (at 74386) by debbugs.gnu.org; 30 Nov 2024 10:01:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 30 05:01:58 2024
Received: from localhost ([127.0.0.1]:45515 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tHKIY-0007Bl-0i
	for submit <at> debbugs.gnu.org; Sat, 30 Nov 2024 05:01:58 -0500
Received: from eggs.gnu.org ([209.51.188.92]:48678)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1tHKIV-0007BS-Ml
 for 74386 <at> debbugs.gnu.org; Sat, 30 Nov 2024 05:01:56 -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 1tHKIP-0001XY-OD; Sat, 30 Nov 2024 05:01:49 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=9hUk3egopn4GsLYOOIJrFEOzWtwgH8g3/BG5xK3NrQA=; b=YleRFh3HP5nT
 T1mSSUgVzEj847o835P2QgHcZeYCzlr1lWh65PH8L4PZSk7GoqaV9RBXwtaxj8wDbvwxcLU0yIWLR
 R5CVvtNZS9LIr6B8TcW8O1db3nOY+M1Lr8Ii5fF9BlsO9lpjb2BN9o3IHCufNWgFnes0vJncb2EJb
 vjDRSVEHoDHjk+yvFf7EnGtR1d0CrgE/UlrKb0YgknNRhPsCLKANLfuaidyzq86+z78Fdo/3hEy8w
 iaV12osF1murZa39WZjfXr8ss2ILriCKAEO6tmMhDLbeewzBwQNYVSgpEXnKMUdt0lnlTCrD5v8Xa
 CjtAUPFW63UTyfsNZlgFZw==;
Date: Sat, 30 Nov 2024 12:01:46 +0200
Message-Id: <86r06t82gl.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>, theo@HIDDEN
In-Reply-To: <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN> (message from
 Dmitry Gutov on Mon, 18 Nov 2024 17:29:18 +0200)
Subject: Re: bug#74386: Tree-sitter javascript indentation
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
 <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, marius.kjeldahl@HIDDEN
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.6 (--)

> Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
> Date: Mon, 18 Nov 2024 17:29:18 +0200
> From: Dmitry Gutov <dmitry@HIDDEN>
> 
> On 18/11/2024 10:35, Marius Kjeldahl wrote:
> > Can confirm your patch solves both the variants I showed. This will
> > also help me to dig into and understand more of what is going on, and
> > allows me to experiment more with my preferences (and tree-sitter in
> > general). So thank you very much.
> 
> Great!
> 
> For more experimenting, also check out 'M-x treesit-explore-mode'.
> 
> And here's how to immediately find out which indentation rule was used:
> 
>    (setq treesit--indent-verbose t)

Theo, please chime in.  Should Dmitry install his changes?




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

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


Received: (at 74386) by debbugs.gnu.org; 18 Nov 2024 15:29:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 18 10:29:29 2024
Received: from localhost ([127.0.0.1]:34864 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tD3gu-0008Nw-VY
	for submit <at> debbugs.gnu.org; Mon, 18 Nov 2024 10:29:29 -0500
Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]:39563)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tD3gt-0008Nj-93
 for 74386 <at> debbugs.gnu.org; Mon, 18 Nov 2024 10:29:28 -0500
Received: from phl-compute-04.internal (phl-compute-04.phl.internal
 [10.202.2.44])
 by mailfout.phl.internal (Postfix) with ESMTP id AF97C1380095;
 Mon, 18 Nov 2024 10:29:21 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162])
 by phl-compute-04.internal (MEProxy); Mon, 18 Nov 2024 10:29:21 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm2; t=1731943761;
 x=1732030161; bh=6Mkm9jgIRiKVpJn7rR1r0C+V4DberRZB/3Mspp8XBL8=; b=
 OXsoOXAm+hKhvDcN+hZGk+URoasbNnGaWYDdsdW2xrYd2qtvZAGT2C59yrG45HhR
 M/Ap7SzO6xfgC+SgYBbrUSYWfzDD7XtkFimJZ6xwJtRW5GT7jC5BiVGpt13Hd8HT
 /Nm3PL4f7QpbeNX3MgF51HlkzhD2xwyOk1rJIqqUr6qoFE1G1xK7TQseDL6S35US
 nAHPlycMcIfz4/Hdka1TowF7MMFcEOgo6P90s3zGg96/tj1LWi5u+q0xOt7xBfYi
 wdn9telJ4ukAPtI/Dfb1vEeU3jExJ3Wd9cjyZWrLaG3huVcfGekKZmAPJPaqzMOL
 CEi/nR0yoszbfr0Y8u/Lmg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1731943761; x=
 1732030161; bh=6Mkm9jgIRiKVpJn7rR1r0C+V4DberRZB/3Mspp8XBL8=; b=P
 C4Eq+r5VaK11SuipPIbCTXF1RUsu4u+yLnzWPs9BJDdM9u6a544RkNAaaySZ2SJO
 hpxrYYKyMH08CJZgDv/hO/sHjV0OMa9O8d2uh2xjFP62NTnUwnLbaoqAGcjDCV2G
 qaIVHpLaGpdEmb4kQNP2wmdRUkglbBDRi6zmT8CsC23MrOiUnOBL8S9WyVVdNw2F
 4ASc4O9Y1HpVMHvOZ0FEaln9hc3ABMO3dQ4Q6vNmPKPTUjH07gN0ZgXRqS79qPTf
 fobwzTN7mV6xg/xxp+/2bYY8SYevG9sacn48VcGAsCz1st1k7i2tFFlKqDKc1qgw
 y4S3c4iuXLQpc6YU34XGw==
X-ME-Sender: <xms:UV07Z1gvK1STbaI-8niTKVxp4lZOKoGfQy0kjUF3WrfMAWb7lYbUvg>
 <xme:UV07Z6BUAuCDr1C0REnJUZzFvsrZzJKsQdW2o8DxluYFjdEn9nAhZavUMeD0MzwVR
 PIqqFLoxxz8-W01Jqk>
X-ME-Received: <xmr:UV07Z1Eg5jMwEJlpeBtinAoICt7U-Qi_lN5AEBw4BIRl1FpGrIi7xVJwNzmR2KKl1BnS>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfedtgdejiecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
 tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth
 hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedt
 vddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 fedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhgrrhhiuhhsrdhkjhgvlhgurg
 hhlhesghhmrghilhdrtghomhdprhgtphhtthhopehthhgvohesthhhohhrnhhhihhllhdr
 nhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgshdrghhnuhdrohhrgh
X-ME-Proxy: <xmx:UV07Z6T0kyf-kZTt-WNB0UCZHgnQAsOJtzuYZ76fqAO0xXjvQvx7ug>
 <xmx:UV07ZyxGPsOgc-Ld6YQ-6eqzhkGot0etKHYaKKRZLMJN8clNFnNBXg>
 <xmx:UV07Zw4FBm7ddVNWbQP3BDSYPUC2s_AtjUZAqXZ9jdEE-Lp8SY2DDQ>
 <xmx:UV07Z3xMoICZJqJoxwHeAmnfIKHyAsaf8gj7ly1K30PcPuA9ynV41Q>
 <xmx:UV07Z2--mD5Mc1F6CXIM_f92OqKGuPvMr9eOdYvl-BnQg9pQPlo4PIjq>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 18 Nov 2024 10:29:20 -0500 (EST)
Message-ID: <389b6090-6ae9-433a-85cc-a2d2eb84751f@HIDDEN>
Date: Mon, 18 Nov 2024 17:29:18 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
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.7 (-)

On 18/11/2024 10:35, Marius Kjeldahl wrote:
> Can confirm your patch solves both the variants I showed. This will
> also help me to dig into and understand more of what is going on, and
> allows me to experiment more with my preferences (and tree-sitter in
> general). So thank you very much.

Great!

For more experimenting, also check out 'M-x treesit-explore-mode'.

And here's how to immediately find out which indentation rule was used:

   (setq treesit--indent-verbose t)




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

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


Received: (at 74386) by debbugs.gnu.org; 18 Nov 2024 08:37:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 18 03:37:01 2024
Received: from localhost ([127.0.0.1]:59836 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCxFk-0005Gb-OE
	for submit <at> debbugs.gnu.org; Mon, 18 Nov 2024 03:37:01 -0500
Received: from mail-oo1-f48.google.com ([209.85.161.48]:50251)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <marius.kjeldahl@HIDDEN>) id 1tCxFi-0005GL-8c
 for 74386 <at> debbugs.gnu.org; Mon, 18 Nov 2024 03:37:00 -0500
Received: by mail-oo1-f48.google.com with SMTP id
 006d021491bc7-5ebc9bda8c8so561123eaf.0
 for <74386 <at> debbugs.gnu.org>; Mon, 18 Nov 2024 00:36:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1731918952; x=1732523752; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=qmFj1gkFSRQKaCvjv/2gQgQWBgS/VctP4ixI68F6vwo=;
 b=klvqL6RPyaFYGSLZlThUycZIazwyf24ZNBqNtXluteZF52aipgJcARP9ukDZY4H/DR
 dGt8K8tfRA1X03kleUhcm2+9Y2k8u8n27L4vwuE6yzhb3wTiofZEVWHPDb3C8gON9p1s
 yuUxmO7dclOjM8ZkG7PcC23ecPyXpx1AMIjSKzjT63b6lOF+mC4gnw0jF4t6qTQx8Fwq
 GQ15miMAy7lLnwOhb2pU0Mrn4VkVOQukaLsX4TziR4PFh1Dy3OKPLVt4ADIGdZqsDGUD
 1BAcYKXVrnEfEHUD/5nAcfURzCmu/JqvNjor+cnMkHyGSbHxEtq9hV/6TrsIM0i4X9Gb
 kDBg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1731918952; x=1732523752;
 h=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=qmFj1gkFSRQKaCvjv/2gQgQWBgS/VctP4ixI68F6vwo=;
 b=uMgUO4rrxjN4ZEYZYXLZKPv3fg+bJUdzLxbxZkrPUu4r+svk4rJa25UYJFENIzDOeZ
 2jBEnL7ObD2qqSOfFid+aUHMahxTEcFKK5NnvJxamQm0+Ti/Uagv3Q3CAY7p7tE3cCM8
 mlpdNiWuEB59RwaxmPcw6Fw/Bc0t1+6VHkYdjKZ53dTjQ9f2QmyZeq2UJrjhp7YqiUwX
 E4e1e9SE2jG4a5TkYebCaIZhR/lal4WorA0J9GuYwlYtOuuV89C6iO5ledL2AVbunz9m
 BkYrI/QWFTU+hLv24g7i/OdBCAoCUiELR4sPB3ZijldC3BnwvNFXMaURE/qGlu3XkJWq
 vvhg==
X-Forwarded-Encrypted: i=1;
 AJvYcCUjd7nhkXOocjBtC0MM5fHSqsvfRjer7gf/SbUUSeS0LNr+uuzW6Xb2n6k5fhMxJl7o+VA8Ng==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YwUAcOMWYqgOulMe3aIAhP3DLniGNEaYD02jqLtzLpAtGFfu4ui
 ZRh32BmK/IDJ1jdR55RmKWhyLXHUFMalFJyl+17JHF1TQbdJu5wZTOjvs6XqCThIwjZ3DMcMKtC
 0nOseeawGgwx6Jr3kLRwmAQN1L6Y=
X-Google-Smtp-Source: AGHT+IHcAe0op6sHC1zLPrTYOb6o0hYwR58cwSikl8rSXMhH+def4BkfIpOsCr354iXYw546SJkiWEFmHvAiErWzr68=
X-Received: by 2002:a05:6870:de15:b0:259:88b4:976 with SMTP id
 586e51a60fabf-2962e0d1ed4mr8203483fac.43.1731918952243; Mon, 18 Nov 2024
 00:35:52 -0800 (PST)
MIME-Version: 1.0
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
In-Reply-To: <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
From: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
Date: Mon, 18 Nov 2024 09:35:41 +0100
Message-ID: <CAHdMyCK5VP3kj1ZsM1mUyfuTja_a+GZm+rgV=zswpYKTShUZTQ@HIDDEN>
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Dmitry Gutov <dmitry@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
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 (-)

Can confirm your patch solves both the variants I showed. This will
also help me to dig into and understand more of what is going on, and
allows me to experiment more with my preferences (and tree-sitter in
general). So thank you very much.

When I get a clue, or when someone with a clue comes up with it, a
patch which make these things configurable with easy settings would
probably be. a good idea (instead of diving into "tree-sitter
internals").

Thanks,

Marius K.

On Sun, 17 Nov 2024 at 23:12, Dmitry Gutov <dmitry@HIDDEN> wrote:
>
> On 17/11/2024 21:21, Marius Kjeldahl wrote:
> > Great, thanks.
> >
> > Here are two examples (fingers crossed):
> >
> > function a(b,
> >    c) {
> > ....d();
> >
> > and
> >
> > if (clause1
> >    && clause2) {
> > ....callSomeFunc();
> >
> > Notice in both cases the four dots "...." representing spaces used for
> > indentation. I would like only two dots (two spaces) for those
> > specific examples.
>
> Thank you, these two examples should be handled by the patch below.
>
> It's a change which could affect a fair amount of other examples too -
> for example
>
> Foobar
>    .find()
>    .catch((err) => {
>      return 2;
>    })
>    .then((num) => {
>      console.log(num);
>    });
>
> turns into
>
> Foobar
>    .find()
>    .catch((err) => {
>    return 2;
> })
>    .then((num) => {
>    console.log(num);
> });
>
>
> I'm not 100% sure if that's good or bad (maybe worse compatibility with
> js-mode, that we could say), so it would be useful to go through a bunch
> of other examples and decide whether what we had is a bug, or these
> should be supported as different styles, or etc.
>
> Cc'ing the original author of js-ts-mode, Theodor, for consultation.
>
> BTW, to try out such a patch you need to apply it, evaluate the defvar
> form (C-M-x, for example), and then re-enable the major mode in a given
> buffer (M-x js-ts-mode).
>
> diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
> index f74b8ab1c46..17a9509dd45 100644
> --- a/lisp/progmodes/js.el
> +++ b/lisp/progmodes/js.el
> @@ -3453,7 +3453,7 @@ js--treesit-indent-rules
>     (let ((switch-case (rx "switch_" (or "case" "default"))))
>       `((javascript
>          ((parent-is "program") parent-bol 0)
> -       ((node-is "}") parent-bol 0)
> +       ((node-is "}") standalone-parent 0)
>          ((node-is ")") parent-bol 0)
>          ((node-is "]") parent-bol 0)
>          ((node-is ">") parent-bol 0)
> @@ -3466,7 +3466,7 @@ js--treesit-indent-rules
>          ;; "{" on the newline.
>          ((node-is "statement_block") parent-bol js-indent-level)
>          ((parent-is "named_imports") parent-bol js-indent-level)
> -       ((parent-is "statement_block") parent-bol js-indent-level)
> +       ((parent-is "statement_block") standalone-parent js-indent-level)
>          ((parent-is "variable_declarator") parent-bol js-indent-level)
>          ((parent-is "arguments") parent-bol js-indent-level)
>          ((parent-is "array") parent-bol js-indent-level)
> @@ -3481,7 +3481,6 @@ js--treesit-indent-rules
>          ((parent-is "binary_expression") parent-bol js-indent-level)
>          ((parent-is "class_body") parent-bol js-indent-level)
>          ((parent-is ,switch-case) parent-bol js-indent-level)
> -       ((parent-is "statement_block") parent-bol js-indent-level)
>          ((match "while" "do_statement") parent-bol 0)
>          ((match "else" "if_statement") parent-bol 0)
>          ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do")
> "_statement")
>




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

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


Received: (at 74386) by debbugs.gnu.org; 17 Nov 2024 22:41:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 17:41:45 2024
Received: from localhost ([127.0.0.1]:59012 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCnxh-0002tL-Jr
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:41:45 -0500
Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]:54971)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tCnxe-0002t6-RG
 for 74386 <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:41:43 -0500
Received: from phl-compute-01.internal (phl-compute-01.phl.internal
 [10.202.2.41])
 by mailfout.phl.internal (Postfix) with ESMTP id 4D06C13805DA;
 Sun, 17 Nov 2024 17:41:37 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-01.internal (MEProxy); Sun, 17 Nov 2024 17:41:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm2; t=1731883297;
 x=1731969697; bh=eix4+wEgJtYN7pO9LZQshczyXBUkSxfGBwB0oSltnUQ=; b=
 k6g5JqsCyHh5HO5hTSS6oJOu1ZQXUbGQ2pLs2qH0Ru32PTEaCDA+m4aJX77XtTaX
 TNptYjDJLpj5BUVVzRxAXWomglyarDR7YN3AfcfgFfYpiDGtMv5DBI5/Q64FmKrK
 42cI/M13F4QamGCN62F5w12ozdHkl/RY7B+GqnqCh+LMOQSJF1844s5VH+TQGd44
 +CFcwZy6704mA4xDsGlCaq7zYrRRw44lBAD4MfWJVeAbV/uvz8AzE+sx3Fkpw/O8
 9F1XmWUjMz7r8HSjNdkwIYRZJEbPPc0jbsPWAx5FdSjUYaDWWerc3yqqNTqiwDJg
 pWhEG1kYUIKzRrzVhLreWA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1731883297; x=
 1731969697; bh=eix4+wEgJtYN7pO9LZQshczyXBUkSxfGBwB0oSltnUQ=; b=Z
 NQUtXIdSz9AGAVuyPi52vll/GAegT+wyMnsb9xSeGvbJ/Hg3uGskQcn7Hz2dnmDA
 1EjWOpW3Tj1w+Z5Gz5+yAX71SwMWZ0gQKBxab6H0PT/akJFN6jnUqP2yz8VNeiZm
 KIR6Chz0t1nqyL2dl6n7Hz4wEfjvW1upaR4MMztwLOcrhBzSORlut9+lUOy0QErM
 zyHH35gyKNtjvP6Z66P8Af/gjB8hmcg31a+iYRezLXELblm0vh4yGv8XwwpfCjQ3
 snFqIeGGAcOkn1IoO+pStGmIy+65nm08zIGMbe6f2c0b1ryauUUXDfhQk6D0xzU7
 9ut+IngjhWp9Aqe8ZjOtA==
X-ME-Sender: <xms:IHE6ZwDkotBhNShGW2P4Tg9UFAZFEpjMIqbawr82ys97N7KSrQUFvQ>
 <xme:IHE6ZygwKaYRzheWJV2KSWPRP_9KBf-VVNKzlu9tHeUs3RUijCs6CiyC2tMa4jDmA
 0GT5BEbBL0M6Agx96Q>
X-ME-Received: <xmr:IHE6ZznJDc2LkBXK3CKdUwt-j-s3jYK7nJouhivbFAsWboP0GLzJRAZYTcs19Es9lIfj>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdelgddtvdcutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
 tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth
 hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedt
 vddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 fedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhgrrhhiuhhsrdhkjhgvlhgurg
 hhlhesghhmrghilhdrtghomhdprhgtphhtthhopehthhgvohesthhhohhrnhhhihhllhdr
 nhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgshdrghhnuhdrohhrgh
X-ME-Proxy: <xmx:IHE6Z2xPF-WotiX469Bfk_THFcwx6Va0n1hO4DdAhM_5YRy0o_zhKg>
 <xmx:IHE6Z1SdG5iCHxSmpgtYNy2u72rMvuDUyquBsiCI_hrkWVrQkCVwcg>
 <xmx:IHE6ZxYRcvXVz49TWfhgtjuoRxqITlMfTIkUFAqC3eaNXwGy5iQsXQ>
 <xmx:IHE6Z-Sb0ENlTr_10ezBwvQeUr_oEizmW9Cj3al-42zSJBBULbbw0w>
 <xmx:IXE6Z3dDJ4S6GlE_a-GwGwcNlihFy89qbqljuLK1DHlcHhBLgVn6i1mP>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 17 Nov 2024 17:41:35 -0500 (EST)
Message-ID: <5a84df05-be96-45b7-949c-4bafa3fd2025@HIDDEN>
Date: Mon, 18 Nov 2024 00:41:34 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
 <CAHdMyCKTcrf45+b=YjGA_5Fppf83+B6mt-MmJtHnDHy=Ta8SyA@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <CAHdMyCKTcrf45+b=YjGA_5Fppf83+B6mt-MmJtHnDHy=Ta8SyA@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
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.7 (-)

On 18/11/2024 00:21, Marius Kjeldahl wrote:
> Sounds good, will try. I'm not sure I like you other examples much, so
> customizability for these things would be preferable.

These particular cases could also be distinguished using custom logic, 
or even using a separate query.

But we might still want to allow customizing them separately (or not?) - 
and check other examples as well.




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

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


Received: (at 74386) by debbugs.gnu.org; 17 Nov 2024 22:22:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 17:22:32 2024
Received: from localhost ([127.0.0.1]:58986 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCnf6-000200-8l
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:22:32 -0500
Received: from mail-oa1-f47.google.com ([209.85.160.47]:57713)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <marius.kjeldahl@HIDDEN>) id 1tCnf4-0001zn-C5
 for 74386 <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:22:31 -0500
Received: by mail-oa1-f47.google.com with SMTP id
 586e51a60fabf-29066daf9e2so1722074fac.3
 for <74386 <at> debbugs.gnu.org>; Sun, 17 Nov 2024 14:22:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1731882084; x=1732486884; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=oz7PMhXDtit7P1Kb7Qlh3jrDR6MU4Oh+BReLjhMpnOM=;
 b=I4RFeY5EoF+qYbW1oHHTN4QzvRmEN58Bg3+9qLFGToLBfWlJJPlfnD8psobdKQpYQg
 F2JzwGO8wCgfE8kxU3/punYacDz1QnKtrA++SBN4jFxyu+NWhrXfTm9pepbeRYMWwJ1r
 xE+DFtCnKBumXor1s+iMYtpjhzecHqZfORUSBj6MKOxEqgV96kPRyf+HzO3w8gsb9f3c
 rxjSuLVwM8Yq15fIAX2BWAakSlFrbtINuR5N4N96hT01mFrRjalgogNEOTaY8EfO+C70
 cW2foRGlcXawcAD0vy9RafInlWTMgEzN2RfB/uGEnWO4qnFidzH+T8zPpQU+dgVf/xel
 AFBQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1731882084; x=1732486884;
 h=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=oz7PMhXDtit7P1Kb7Qlh3jrDR6MU4Oh+BReLjhMpnOM=;
 b=cmemvtf4sNtFSpI9mFbqEqThY95eebrc3BFYIqldEubSCiGl7NTu6cjzQQY8LBnTK2
 lQqBwORzY6nggDhAxDGcjiph5GzO0qF28PFbsF/kCE7iUV2N3gK9pnIqEwdld9N2Dp/U
 TusxbOeH4hQuJLtv7lES5KdItGTVM/I+qWIQPS1bhVYlKS6pnbZORcKuFon8l67tzUsx
 LXVnn3ZdNRqBrTVzSpIa2WSxEGtJ01DLPoRsgwuOmdV2QKEG7Gp2GdeFnxxAkOBE7m1+
 4DW1TbT3ilTqG4yu+ZVVGJ6k+1x3n94EMuTbhZ922Ew8vWk6oqajpe45igO2qXD4rTTH
 f5Jw==
X-Forwarded-Encrypted: i=1;
 AJvYcCUlUbt3QMRs/v30PrdVmV7pFZrmSNoIVwZzX1z4GuWb7dgoifXjDy06d5yb6vlEbPdUlQFbeA==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YzgCcMID1ojsyi/ep7K7lu581am2jF3iAUBmvOmNDV78IwBF215
 WSdT/i3awqgj3nR0+9Ea3LqLHdrgXzLAor8F582MPunKecok9gYGgt7FlZ3m+7umti94vC5bHtF
 r5Y33p6IgMg7DZRHdUQ/EBYf2N9U=
X-Google-Smtp-Source: AGHT+IHQYUj/Mj3BgFxOh46m+T1ymgagbWQy2+LAtzT/vj4his9qTKZZvgBtH5/bg6S0Cyh0z681n3+PSwK2UpF1Bsk=
X-Received: by 2002:a05:6870:414f:b0:288:570d:8fe8 with SMTP id
 586e51a60fabf-2962dc91b7amr7386706fac.3.1731882084583; Sun, 17 Nov 2024
 14:21:24 -0800 (PST)
MIME-Version: 1.0
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
 <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
In-Reply-To: <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
From: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
Date: Sun, 17 Nov 2024 23:21:13 +0100
Message-ID: <CAHdMyCKTcrf45+b=YjGA_5Fppf83+B6mt-MmJtHnDHy=Ta8SyA@HIDDEN>
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Dmitry Gutov <dmitry@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
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.7 (-)

Sounds good, will try. I'm not sure I like you other examples much, so
customizability for these things would be preferable.

Thanks,

Marius K.

On Sun, 17 Nov 2024 at 23:12, Dmitry Gutov <dmitry@HIDDEN> wrote:
>
> On 17/11/2024 21:21, Marius Kjeldahl wrote:
> > Great, thanks.
> >
> > Here are two examples (fingers crossed):
> >
> > function a(b,
> >    c) {
> > ....d();
> >
> > and
> >
> > if (clause1
> >    && clause2) {
> > ....callSomeFunc();
> >
> > Notice in both cases the four dots "...." representing spaces used for
> > indentation. I would like only two dots (two spaces) for those
> > specific examples.
>
> Thank you, these two examples should be handled by the patch below.
>
> It's a change which could affect a fair amount of other examples too -
> for example
>
> Foobar
>    .find()
>    .catch((err) => {
>      return 2;
>    })
>    .then((num) => {
>      console.log(num);
>    });
>
> turns into
>
> Foobar
>    .find()
>    .catch((err) => {
>    return 2;
> })
>    .then((num) => {
>    console.log(num);
> });
>
>
> I'm not 100% sure if that's good or bad (maybe worse compatibility with
> js-mode, that we could say), so it would be useful to go through a bunch
> of other examples and decide whether what we had is a bug, or these
> should be supported as different styles, or etc.
>
> Cc'ing the original author of js-ts-mode, Theodor, for consultation.
>
> BTW, to try out such a patch you need to apply it, evaluate the defvar
> form (C-M-x, for example), and then re-enable the major mode in a given
> buffer (M-x js-ts-mode).
>
> diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
> index f74b8ab1c46..17a9509dd45 100644
> --- a/lisp/progmodes/js.el
> +++ b/lisp/progmodes/js.el
> @@ -3453,7 +3453,7 @@ js--treesit-indent-rules
>     (let ((switch-case (rx "switch_" (or "case" "default"))))
>       `((javascript
>          ((parent-is "program") parent-bol 0)
> -       ((node-is "}") parent-bol 0)
> +       ((node-is "}") standalone-parent 0)
>          ((node-is ")") parent-bol 0)
>          ((node-is "]") parent-bol 0)
>          ((node-is ">") parent-bol 0)
> @@ -3466,7 +3466,7 @@ js--treesit-indent-rules
>          ;; "{" on the newline.
>          ((node-is "statement_block") parent-bol js-indent-level)
>          ((parent-is "named_imports") parent-bol js-indent-level)
> -       ((parent-is "statement_block") parent-bol js-indent-level)
> +       ((parent-is "statement_block") standalone-parent js-indent-level)
>          ((parent-is "variable_declarator") parent-bol js-indent-level)
>          ((parent-is "arguments") parent-bol js-indent-level)
>          ((parent-is "array") parent-bol js-indent-level)
> @@ -3481,7 +3481,6 @@ js--treesit-indent-rules
>          ((parent-is "binary_expression") parent-bol js-indent-level)
>          ((parent-is "class_body") parent-bol js-indent-level)
>          ((parent-is ,switch-case) parent-bol js-indent-level)
> -       ((parent-is "statement_block") parent-bol js-indent-level)
>          ((match "while" "do_statement") parent-bol 0)
>          ((match "else" "if_statement") parent-bol 0)
>          ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do")
> "_statement")
>




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

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


Received: (at 74386) by debbugs.gnu.org; 17 Nov 2024 22:13:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 17:13:07 2024
Received: from localhost ([127.0.0.1]:58964 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCnVw-0001XO-3O
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:13:07 -0500
Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]:46299)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tCnVu-0001Ws-Fj
 for 74386 <at> debbugs.gnu.org; Sun, 17 Nov 2024 17:13:03 -0500
Received: from phl-compute-02.internal (phl-compute-02.phl.internal
 [10.202.2.42])
 by mailfhigh.phl.internal (Postfix) with ESMTP id 57BF51140127;
 Sun, 17 Nov 2024 17:12:57 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-02.internal (MEProxy); Sun, 17 Nov 2024 17:12:57 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm2; t=1731881577;
 x=1731967977; bh=ybNscExyFc9ogbR+OOjJLgYplx09TmQ4svd5owh+icI=; b=
 GbS8079cuPFoVZkzYDPnDNwtZBhJ28HNDgRhVEazUXa7KzyLA8utbnL6l30GAsPm
 qpp16f5bt6MlAFKD/gIJYAk8sH/n460Rl7ZcbZQL5dLpe51cYCQ3PzBVOq4sywW8
 U9N11yraBSXlnXaQ2bFauT/e5Z9B8ORTDb/pLpfQ6NjPGNRGEIT0I7jq5jY9chLK
 wu+dAIbEaDxH1H1clc+jH4TOs7PKSVjCVNG99+LXL5Al+wam4ZItKngf69NRIncI
 GRHhHmmBRH2m2r3avGOfrAmHOSZphiz1WXt+AtYEoqlqOMtoZS0LXTfk9r6hku69
 PzM2J2hV0bRxRRynDaKfFw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1731881577; x=
 1731967977; bh=ybNscExyFc9ogbR+OOjJLgYplx09TmQ4svd5owh+icI=; b=Z
 HweQFgY3moyJDyrFFPFL5DvBQ2+JLjpFkKg8SxPtowEjHeMWYCSiFnTIqyWRdJ8j
 r+ADwk+FYaWTGXB5azLVhkJ/9sT1VWcMJChEvSNbUd1s3s1tt10Z2pnxGWttqSYx
 FDjQcF2PXud5mJJ4vxJ1f+xfPnyde3l0QV0SW/GcWZLLOHEP76zjHs6PR7COvMw9
 oTUe8MXp+72cnFgaCZFkVJ1QJ5j27tOkdFIdJoGWtrDzpZg7x6dpJP/8F8FMsk6y
 OsKifQTnfanob4Lnkd6xTy9NC/o6cbjxg5kSTYaSgszvBCP5kXqJQemrNoORH76k
 1ZWALiyA2b5FDJNBgFSgQ==
X-ME-Sender: <xms:aWo6ZxlFw-Dr9z2VQQt-ABJLfKDXJw9XWaOqYt2iu44MibU_DH0cAA>
 <xme:aWo6Z839Osz79_4MZ3-UcskPmEnzkQx3_gbQQGgQQIupKWXDb-GKBL97FhQZEvnx1
 DvkODzlrrn0gmatkHQ>
X-ME-Received: <xmr:aWo6Z3qWgKu_ilMF4TAfMn1vw2v49zDAwb6FMVVb78cp5SO8MSXVjxvHdcThlG7gKkS0>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdekgdduheejucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
 rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh
 htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdej
 necuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdrug
 gvvheqnecuggftrfgrthhtvghrnhepteduleejgeehtefgheegjeekueehvdevieekueef
 tddvtdevfefhvdevgedujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe
 hmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthho
 peefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehmrghrihhushdrkhhjvghlug
 grhhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhhvghosehthhhorhhnhhhilhhl
 rdhnohdprhgtphhtthhopeejgeefkeeiseguvggssghughhsrdhgnhhurdhorhhg
X-ME-Proxy: <xmx:aWo6ZxkaTVa-YynR4E08P8hzfz7xoY1jcsFU1_lBShBiVkcR4orA9g>
 <xmx:aWo6Z_1Wlv0-6kFo8G3zne7cHTq3FkvfylTpVCOrAwKS4AKlNHRyAg>
 <xmx:aWo6Zwv0TCMLJ81IQUnGEghvjZZKUyqqPB2os84gjgmK-tLFxkHh6A>
 <xmx:aWo6ZzVcxyHnsvZPbvVm0J5p-Y0mmqv8rQm3aGmRvBxLvYYQjFTHJg>
 <xmx:aWo6ZwywvVhd0f22A7hFugIIN9hBHUfsE0iI2XB4AkcLfgAQ7CJsP_5I>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 17 Nov 2024 17:12:56 -0500 (EST)
Message-ID: <2ce8c98e-c399-46f1-a930-04f27a3d56dd@HIDDEN>
Date: Mon, 18 Nov 2024 00:12:54 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Marius Kjeldahl <marius.kjeldahl@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
 <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <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.7 (-)

On 17/11/2024 21:21, Marius Kjeldahl wrote:
> Great, thanks.
> 
> Here are two examples (fingers crossed):
> 
> function a(b,
>    c) {
> ....d();
> 
> and
> 
> if (clause1
>    && clause2) {
> ....callSomeFunc();
> 
> Notice in both cases the four dots "...." representing spaces used for
> indentation. I would like only two dots (two spaces) for those
> specific examples.

Thank you, these two examples should be handled by the patch below.

It's a change which could affect a fair amount of other examples too - 
for example

Foobar
   .find()
   .catch((err) => {
     return 2;
   })
   .then((num) => {
     console.log(num);
   });

turns into

Foobar
   .find()
   .catch((err) => {
   return 2;
})
   .then((num) => {
   console.log(num);
});


I'm not 100% sure if that's good or bad (maybe worse compatibility with 
js-mode, that we could say), so it would be useful to go through a bunch 
of other examples and decide whether what we had is a bug, or these 
should be supported as different styles, or etc.

Cc'ing the original author of js-ts-mode, Theodor, for consultation.

BTW, to try out such a patch you need to apply it, evaluate the defvar 
form (C-M-x, for example), and then re-enable the major mode in a given 
buffer (M-x js-ts-mode).

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f74b8ab1c46..17a9509dd45 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3453,7 +3453,7 @@ js--treesit-indent-rules
    (let ((switch-case (rx "switch_" (or "case" "default"))))
      `((javascript
         ((parent-is "program") parent-bol 0)
-       ((node-is "}") parent-bol 0)
+       ((node-is "}") standalone-parent 0)
         ((node-is ")") parent-bol 0)
         ((node-is "]") parent-bol 0)
         ((node-is ">") parent-bol 0)
@@ -3466,7 +3466,7 @@ js--treesit-indent-rules
         ;; "{" on the newline.
         ((node-is "statement_block") parent-bol js-indent-level)
         ((parent-is "named_imports") parent-bol js-indent-level)
-       ((parent-is "statement_block") parent-bol js-indent-level)
+       ((parent-is "statement_block") standalone-parent js-indent-level)
         ((parent-is "variable_declarator") parent-bol js-indent-level)
         ((parent-is "arguments") parent-bol js-indent-level)
         ((parent-is "array") parent-bol js-indent-level)
@@ -3481,7 +3481,6 @@ js--treesit-indent-rules
         ((parent-is "binary_expression") parent-bol js-indent-level)
         ((parent-is "class_body") parent-bol js-indent-level)
         ((parent-is ,switch-case) parent-bol js-indent-level)
-       ((parent-is "statement_block") parent-bol js-indent-level)
         ((match "while" "do_statement") parent-bol 0)
         ((match "else" "if_statement") parent-bol 0)
         ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") 
"_statement")





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

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


Received: (at 74386) by debbugs.gnu.org; 17 Nov 2024 19:22:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 14:22:56 2024
Received: from localhost ([127.0.0.1]:58663 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCkrH-0001vh-QL
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 14:22:56 -0500
Received: from mail-oa1-f53.google.com ([209.85.160.53]:61751)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <marius.kjeldahl@HIDDEN>) id 1tCkrF-0001vN-RT
 for 74386 <at> debbugs.gnu.org; Sun, 17 Nov 2024 14:22:54 -0500
Received: by mail-oa1-f53.google.com with SMTP id
 586e51a60fabf-29692ad4b42so14064fac.3
 for <74386 <at> debbugs.gnu.org>; Sun, 17 Nov 2024 11:22:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1731871308; x=1732476108; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=jquOEaP/gD8E4Tvw5Dr79rfAEcLDAocQ4b1b3BwajSY=;
 b=W+r4vQV1h42MwJOvZ18NE6QD6L1cO4ueVzYask2AdnzS/io6GdCsjfalogG8fnH6OG
 RaAYN2tHBmIrLMIj+Dboe3dPFPsgLKXs3e+Uj5DSGyOdbNnGmYdHlsS7232h2KlVzZRr
 gMvl/CZ0/sW6Bu2nkmbWuLTKiwLsJaW9YR/oSt5Vw5PYK3muwpyGMKRiMci2Ml4JsJWj
 Rfen8G+uCtLBojiI5jMysMX8q4j0JZSZzD6Z4a3MLoCrGmm7ntTgqnU4nMWxJWrOdIX7
 fZgupGlMUEMZ4fpyCEzj6wGv/se3ojez1PXTpSijqoQqyfDI0cDC1cluZWYL1nQX/kjz
 qpTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1731871308; x=1732476108;
 h=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=jquOEaP/gD8E4Tvw5Dr79rfAEcLDAocQ4b1b3BwajSY=;
 b=a4JwFZuG4agxCR/V4w2v06KNqQ+5wuekM3sYHYp7kL+fMDBTGTfTf6JvFy7FSrPkpI
 jTxGD8mmblanBJ7TKrUb4Qpu28PKZf6dq9ychAOLLWFvyFniKIEQlIQHPrp3gM1Br+Qr
 dzQVLsV0/WK/LfV6LfrLxh80MUqJQSu1eUJjJ4Ctz1bAQf0i3Qhx867dMdwkUB5vaoE4
 yCILVbS0VorpOKV0MzwAWuMfG7acxUdDWtBvlEjxF6PTKNa97wJpKgp2/riJvfnaf8Ni
 rb3zVB0ghR3zihmnCnhMmHPYr+k3/qdMlZ5bdItZfXHSsWjkeb6yf1JmC+IYMX5yVHep
 cGBg==
X-Gm-Message-State: AOJu0Yz/Pf/xahR0p760kUwoba5DcgsNOirtPQa1gtpkD0ACtY2Eekjg
 z2X/UT7/KKYI0LYYt9A+26aNaTYUVvXlD/9HriNyieEvtQMGRUWz4nBrkoCjvOuhr5hMaw/A4RB
 oB2fXXfDEH2N64pdZ5zXM5rPBhLM=
X-Google-Smtp-Source: AGHT+IGmGGh6nw3hKMbpbn2SK//oiAaHO36BRln68OmnKlChoJpHh+sGyQr2XAUqp//coB3YO6Ts6jD+4SYsUYyZexM=
X-Received: by 2002:a05:6870:96a2:b0:277:f301:40d5 with SMTP id
 586e51a60fabf-2962dfeea2fmr6795566fac.31.1731871308129; Sun, 17 Nov 2024
 11:21:48 -0800 (PST)
MIME-Version: 1.0
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
 <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
In-Reply-To: <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
From: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
Date: Sun, 17 Nov 2024 20:21:37 +0100
Message-ID: <CAHdMyCLdyVqiqDbnd=b51FHp8T3nDc++4QVq4ALbQCWUQuMHbQ@HIDDEN>
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Dmitry Gutov <dmitry@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74386
Cc: 74386 <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 (-)

Great, thanks.

Here are two examples (fingers crossed):

function a(b,
  c) {
....d();

and

if (clause1
  && clause2) {
....callSomeFunc();

Notice in both cases the four dots "...." representing spaces used for
indentation. I would like only two dots (two spaces) for those
specific examples.

Thanks,

Marius K.

On Sun, 17 Nov 2024 at 20:18, Dmitry Gutov <dmitry@HIDDEN> wrote:
>
> Hi!
>
> On 17/11/2024 01:26, Marius Kjeldahl wrote:
> > When using js-ts-mode, after multiline function parameter lists, or
> > multiline if clauses, Emacs typically adds two spaces indentation
> > after where the previous line ends. But because that line is already
> > indented, the effective indentation becomes four spaces (compare to
> > where the function definition or if clause starts). I would like this
> > to be only two. This is most likely a preference, but still.
> >
> > I haven't been able to figure out if it is possible to customize Emacs
> > to do what I want. Or even learn where I can dig in and figure out
> > what I need to change to accomplish it. I've tried a reddit group and
> > also posted an issue on the tree-sitter github repo. But was told the
> > correct place to report it is as an Emacs bug.
> >
> > So any pointers or suggestion?
>
> It would help if you also give specific examples of code where incorrect
> indentation occurs. People can guess, but they might not guess all the
> cases you want.
>
> Just paste the code inside email, assuming monospaced text.
>
> (And to clarify how this mailing list works: please use "reply all", so
> that the bug# email address is retained in To:).




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

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


Received: (at 74386) by debbugs.gnu.org; 17 Nov 2024 19:18:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 14:18:57 2024
Received: from localhost ([127.0.0.1]:58655 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCknR-0001iw-53
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 14:18:57 -0500
Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]:38493)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1tCknO-0001if-A3
 for 74386 <at> debbugs.gnu.org; Sun, 17 Nov 2024 14:18:55 -0500
Received: from phl-compute-02.internal (phl-compute-02.phl.internal
 [10.202.2.42])
 by mailfout.phl.internal (Postfix) with ESMTP id CE9C41380439;
 Sun, 17 Nov 2024 14:18:48 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-02.internal (MEProxy); Sun, 17 Nov 2024 14:18:48 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :content-transfer-encoding:content-type:content-type:date:date
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm2; t=1731871128;
 x=1731957528; bh=Q9t5uuQFphikoxdyF1feLrCsSUobcDbPfoKbFX1YNIA=; b=
 damZLopVEY/sN4RtMosyes8ool41NU7zkbpPd+zVuDWYetmj9prkLxMvso3JrV+r
 /PrbNHojrWh9VjpsVJQIV5WE7xfTWfU6EufEUfgZHLNhZ8TJ64Q6pEHGX6FK87JG
 ro3Hk6qN3kTzMwdb0RT4P+sHgXT2C16iOKvynxt82YYb/iLcPg3YGwJJs0ggMq1J
 FmkEd+6UEV/DUbVwTDaz74vkCkLKQQQjSRYvJ0baku9vyYOt5fbr0GziUXuwYdPM
 tXxsqKW7EOM9dbCaEzBDp7SH0WB670ASjpbhuHGUxV1dHb7cDUgF3hrW9X665Kzz
 Ih5gg+QkZiaGzekqFrQYog==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :content-type:date:date:feedback-id:feedback-id:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender
 :x-me-sender:x-sasl-enc; s=fm3; t=1731871128; x=1731957528; bh=Q
 9t5uuQFphikoxdyF1feLrCsSUobcDbPfoKbFX1YNIA=; b=CPpN+R9CpfUXAOHR+
 2hWyHnn+aICHKvDAgzTGkG+vzkjX6Zh8tODOUhqu8Tl5BHMzRCwccURXSQ1y4Yse
 QM1B5/Ik2FIdikjjH5kpOFPaM1LaZLoLXdk/CYcCZRUR/mjMa75zYQgixhkhwNj1
 gJnKieGK4imgg/XkeAA+sI+afK0bCVrbw50xpsMt+kcUo4/C8C6sh173L0n3dKe1
 DDVEwtjL5LShJJ1owezyJFP5CmqoUqUwzouXr/u35SBpmVJi+uc0bzTuHPj/VXkP
 s1xex5ln1EBUgL+TkiNbdc/qHiWyfBbZI3SG3C9xgkEFc6WU6WNIjKxZsT2MB6iN
 ZH6NA==
X-ME-Sender: <xms:mEE6Zy3SHxyCZfqf2z0pE6sQbn_pTS5XYXKxULyPb9Kouh_0Ff1nMg>
 <xme:mEE6Z1EH05-deGyzcbjhYXpPsrOZPAeyrKkLkL11gVj3uwpES6IOR2Fz3Q9b80Wt2
 jncl0uSPFhnkE-l5Nk>
X-ME-Received: <xmr:mEE6Z647eZls7DUZal8m9vlaG6AHeNcLhKS2Eu8bmXEVx_n_kRj8i99as8pNCZkjThpV>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdekgdduvdefucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
 rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh
 htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeen
 ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg
 hvqeenucggtffrrghtthgvrhhnpedthfeuvddtveelgeeuleevvdejveehffevveehvdeu
 ffdtfefhvdeugefgtefgtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh
 grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep
 vddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhgrrhhiuhhsrdhkjhgvlhgurg
 hhlhesghhmrghilhdrtghomhdprhgtphhtthhopeejgeefkeeiseguvggssghughhsrdhg
 nhhurdhorhhg
X-ME-Proxy: <xmx:mEE6Zz0piHESxJ4_UJdSQQiUVBCHao3SyYfcqgsGpm2rh4yj4GXIMw>
 <xmx:mEE6Z1EhhtLO7vi9hQTeW8LE01FbafIQZi5V6mvwdCkybNp6sk2orA>
 <xmx:mEE6Z8-RnZobrJWhUzgnP7Vpll7gUPoTSe9b7yYJgA3LVcRxNnKA9g>
 <xmx:mEE6Z6mgiMU87BBpEGIpwePtJSxSog5Gdpq4QYtyf680MHOGrLAHBw>
 <xmx:mEE6Z6Sne04_F6aZCO6or3JMktSTXdBjo-ZcIAO22VErd1C5VIxoQy7b>
Feedback-ID: i07de48aa:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 17 Nov 2024 14:18:47 -0500 (EST)
Message-ID: <ddf93180-0296-4a97-8666-4cf91159997e@HIDDEN>
Date: Sun, 17 Nov 2024 21:18:45 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#74386: Tree-sitter javascript indentation
To: Marius Kjeldahl <marius.kjeldahl@HIDDEN>, 74386 <at> debbugs.gnu.org
References: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
Content-Language: en-US
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 74386
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.7 (-)

Hi!

On 17/11/2024 01:26, Marius Kjeldahl wrote:
> When using js-ts-mode, after multiline function parameter lists, or
> multiline if clauses, Emacs typically adds two spaces indentation
> after where the previous line ends. But because that line is already
> indented, the effective indentation becomes four spaces (compare to
> where the function definition or if clause starts). I would like this
> to be only two. This is most likely a preference, but still.
> 
> I haven't been able to figure out if it is possible to customize Emacs
> to do what I want. Or even learn where I can dig in and figure out
> what I need to change to accomplish it. I've tried a reddit group and
> also posted an issue on the tree-sitter github repo. But was told the
> correct place to report it is as an Emacs bug.
> 
> So any pointers or suggestion?

It would help if you also give specific examples of code where incorrect 
indentation occurs. People can guess, but they might not guess all the 
cases you want.

Just paste the code inside email, assuming monospaced text.

(And to clarify how this mailing list works: please use "reply all", so 
that the bug# email address is retained in To:).




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

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


Received: (at submit) by debbugs.gnu.org; 16 Nov 2024 23:27:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 16 18:27:12 2024
Received: from localhost ([127.0.0.1]:55159 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCSC8-0005Oe-5I
	for submit <at> debbugs.gnu.org; Sat, 16 Nov 2024 18:27:12 -0500
Received: from lists.gnu.org ([209.51.188.17]:55776)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <marius.kjeldahl@HIDDEN>) id 1tCSC6-0005OV-6N
 for submit <at> debbugs.gnu.org; Sat, 16 Nov 2024 18:27:10 -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 <marius.kjeldahl@HIDDEN>)
 id 1tCSC5-0004Bc-Vn
 for bug-gnu-emacs@HIDDEN; Sat, 16 Nov 2024 18:27:10 -0500
Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <marius.kjeldahl@HIDDEN>)
 id 1tCSC4-0007Zv-Ib
 for bug-gnu-emacs@HIDDEN; Sat, 16 Nov 2024 18:27:09 -0500
Received: by mail-oi1-x235.google.com with SMTP id
 5614622812f47-3e5f86e59f1so1099641b6e.1
 for <bug-gnu-emacs@HIDDEN>; Sat, 16 Nov 2024 15:27:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1731799626; x=1732404426; darn=gnu.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=4TvNOnW3sxiZBQ4ispr8DjbGMw86POFP+VLy1CGsubY=;
 b=VnFgDI0m6dveSzK97Hj4moMD6aL9eyoIKsYRTtUx+42zkhkN93i9BBoPn45R02ND0K
 swNI3P9uc8MN+h5DToTLHPKf5D7Jero5r3lre/Hac1GQpsjB3JL3krAdE0IFrzcR5xZR
 QaI8VGYt+a3rm0b8G7q3EOwIbkSW4ZOFRw/irY3oFHO6s5bvlPEJaYTwux1+ZzVmgIhh
 38LUnN3pTltCr4iDq0lSMaG27bCnmikAvqt+PBg1e4WEf3GCIxZeksYVLC8DS6Rw9kyy
 EvkjsQih00NGftXLhYbqA5yYZW6ZWYCiD51QscpPj/PS4Dk52+LTWyQ7tjgUWXxt7P2/
 urEQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1731799626; x=1732404426;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=4TvNOnW3sxiZBQ4ispr8DjbGMw86POFP+VLy1CGsubY=;
 b=vaMGT7PqhJmwR35qLGhIesng/lJWEM1NFyPoyMuXDFt2tP6LqWa9q2FeY7GGtaHZcd
 mRF1fwdmq0Z/vwoX327SyKV89FXm16E7iiAzkrercf+fyVw0+hFnioSoZFo0LLqUgLQN
 2fmu9eB28OvnDRK8g2XWSg16eIdM3a+OTrW/a2M2WLqTkhgsQs8c/2PPsn/b1Nct7xzh
 zUmy4EJ6T5EXzKd250vmafjHyiT0kQXUeQ2daleNtJtT107iRm+qsWst4rx89AK13hiy
 sppmbX/0fjo587Q8vfQ3KSlC4cUFPBE5hQg3zDEGUmgQQhYpw9VUPsCQITAVO1qrrBWy
 EZTg==
X-Gm-Message-State: AOJu0YyMMOY/dFLxG4xPxY+j4N59zXrwFbPczs8g5Bssz0AT6Qpe4kSY
 kNJ8TXzLTcdkrhRvRK24iE953DDNV42BgivEJQXRKsKrRhpiIU5E/DISiA9ePC8Velt1TZTLRjc
 CwurpBV8TG3zZ+5MXxk2PddkkDRnskA==
X-Google-Smtp-Source: AGHT+IEQxLXPUVLRCnMkJEWOtiVZ5Xtc903HNkftz1Pfk5pNw9juAKU4j5gsG0pjvWB7LILF3ohrBnLJK5QQEV5mGdQ=
X-Received: by 2002:a05:6870:7f01:b0:288:563b:e48d with SMTP id
 586e51a60fabf-2962df98a35mr6488171fac.10.1731799626456; Sat, 16 Nov 2024
 15:27:06 -0800 (PST)
MIME-Version: 1.0
From: Marius Kjeldahl <marius.kjeldahl@HIDDEN>
Date: Sun, 17 Nov 2024 00:26:55 +0100
Message-ID: <CAHdMyCLdB7MoQndwwtXbAXKLM9Huku7aMs6qvCzXVhx1WoS3rw@HIDDEN>
Subject: Tree-sitter javascript indentation
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::235;
 envelope-from=marius.kjeldahl@HIDDEN; helo=mail-oi1-x235.google.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, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, 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 (--)

When using js-ts-mode, after multiline function parameter lists, or
multiline if clauses, Emacs typically adds two spaces indentation
after where the previous line ends. But because that line is already
indented, the effective indentation becomes four spaces (compare to
where the function definition or if clause starts). I would like this
to be only two. This is most likely a preference, but still.

I haven't been able to figure out if it is possible to customize Emacs
to do what I want. Or even learn where I can dig in and figure out
what I need to change to accomplish it. I've tried a reddit group and
also posted an issue on the tree-sitter github repo. But was told the
correct place to report it is as an Emacs bug.

So any pointers or suggestion?

Thanks,

Marius K.




Acknowledgement sent to Marius Kjeldahl <marius.kjeldahl@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#74386; 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, 12 Jan 2025 05:45:02 UTC

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