From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter indentation for js-mode & cc-mode Date: Fri, 28 Oct 2022 21:49:14 +0200 Message-ID: <87wn8jd8zp.fsf@thornhill.no> References: <9AF8BFDC-C9A2-4AE5-A8D2-E6AA05DA3C91@gmail.com> <87k04lljh6.fsf@thornhill.no> <541CF451-6FAC-4531-A8AF-8C86FBB9D40B@thornhill.no> <425E0075-3F44-4832-BA2E-61E7D0A26FF4@gmail.com> <87mt9ggvph.fsf@thornhill.no> <89721927-13CE-4A65-944C-0DC924127373@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28728"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Stefan Monnier To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 28 21:50:03 2022 Return-path: Envelope-to: ged-emacs-devel@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 1ooVMg-0007AF-TL for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Oct 2022 21:50:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooVMF-0000gJ-21; Fri, 28 Oct 2022 15:49:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooVM1-0000H2-1Z for emacs-devel@gnu.org; Fri, 28 Oct 2022 15:49:21 -0400 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooVLy-000883-ML for emacs-devel@gnu.org; Fri, 28 Oct 2022 15:49:20 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1666986556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gHOzeSFiMh+LWlTVN2EBZW/1iLSDl6pm54xD1atC8IY=; b=Mk4T20N5P6q+yyWiAHVBIiMBVEKqzRzSNTseQ63mtCjDGPaAIBex0kLaf7zihMj9NNhqBu Egud2hs9KUkdMMCwIG+XYQPwJ1jatZ4GHcdp6GaL+nnosKQwkfdHh8Uwz/6rrVfWnavHos /NXn8M3fU9y54GuYjUGwWvgMPhLSlZH0MJ0+uYTnns3ZiDSkWKDaB5xWqvbEsTpwsIppgV Ct9P3OUMe1RGf01wZgkw25ZD8IpdD6PDqa8MTXf1Rq65wzJjbogC5FMfLf14so4X1zbqoZ VJoNj6PT75/GPe98o7IOWPVTGMZVi3rRnKxEqWVDy1tOxe1xDlRaP0tfI8SR/A== In-Reply-To: <89721927-13CE-4A65-944C-0DC924127373@gmail.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298696 Archived-At: >>=20 > > Ok, I=E2=80=99m fairly certain this is due to tree-sitter reparsing after= we > indenting each line: treesit-buffer-root-node asks for the root node > of the parser, which triggers a reparse, because last indent modified > the buffer. We are basically reparsing as many time as there are lines > in the buffer. > > Indenting a similarly sized buffer where all indent are good is much > faster, because there is no reparse due to change to the buffer. Yeah, that's what I was seeing as well. I think this is correct. > > Tree-sitter indent should add an implementation for indent-for-region > function which precomputes indent for each line and indent lines in > batch. That ought to fix it. Added to TODO :-) Hehe, sorry! Theo