From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#74386: Tree-sitter javascript indentation Date: Thu, 12 Dec 2024 05:20:18 +0200 Message-ID: References: <2ce8c98e-c399-46f1-a930-04f27a3d56dd@gutov.dev> <389b6090-6ae9-433a-85cc-a2d2eb84751f@gutov.dev> <86r06t82gl.fsf@gnu.org> <4B4B99E7-C4A1-4124-BC85-2AD66EF0871B@gmail.com> <35B61F44-C551-44DB-A334-A893991BC799@gmail.com> <8A7428E6-50EE-4783-82FF-3A62C4756C56@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39213"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 74386@debbugs.gnu.org, Eli Zaretskii , Theodor Thornhill , marius.kjeldahl@gmail.com To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 12 04:21:32 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tLZlc-000A4V-9Q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Dec 2024 04:21:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLZlI-000583-J9; Wed, 11 Dec 2024 22:21:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLZl9-00057g-C9 for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:21:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLZl9-0001Wt-3n for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:21:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=md168JSaS1g08BYf5/AguIE8eABFGq86zuNs1O8FJBk=; b=pj8kJbnfhGTtx2p4Q/boYComVPOe2WV5E1cyLKHJc6YwPOTX69RfdMPICiBEzoFfxqN3qOElfyxSLkKAsbcW9GTXVgsGTt4rmTuvpMEyM9H8ipATCtLc2JqNNGNLpnDfRUJk78070jkW1+w4GmfBoiDNOpdxmqClzTBRLQ41ZLsBoyccTIb3fJsf0vcaR8o+j+IDIQhNKsNRj/MbryMCiTQ1Ei+L3oB4Li0occK5UDxdsbjoZ7z8JRySi5XgBqADU5j/LtsjAVa7z1n/nowMEHeTBQWr9kCe/b1cLnidROoJZnLtGti4xTIbrRXLeOPjw1LCgsVamft+E8h9u7Vj3A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLZl8-0003Ok-GQ for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2024 03:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74386 X-GNU-PR-Package: emacs Original-Received: via spool by 74386-submit@debbugs.gnu.org id=B74386.173397363712966 (code B ref 74386); Thu, 12 Dec 2024 03:21:02 +0000 Original-Received: (at 74386) by debbugs.gnu.org; 12 Dec 2024 03:20:37 +0000 Original-Received: from localhost ([127.0.0.1]:37086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLZkj-0003N4-1I for submit@debbugs.gnu.org; Wed, 11 Dec 2024 22:20:37 -0500 Original-Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]:53965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLZkd-0003Lw-SQ for 74386@debbugs.gnu.org; Wed, 11 Dec 2024 22:20:35 -0500 Original-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) Original-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: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrkeefgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeen ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg hvqeenucggtffrrghtthgvrhhnpeegleefteekgffhvdfhtdegveevveetteegteevgeet tdehhfdukeetheffueekkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptggrshhouhhrihesghhmrghilh drtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehthhgv ohesthhhohhrnhhhihhllhdrnhhopdhrtghpthhtohepjeegfeekieesuggvsggsuhhgsh drghhnuhdrohhrghdprhgtphhtthhopehmrghrihhushdrkhhjvghluggrhhhlsehgmhgr ihhlrdgtohhm X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Dec 2024 22:20:20 -0500 (EST) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296881 Archived-At: 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 >> >> > 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?