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: CC Mode -> Tree sitter challenge Date: Sun, 06 Nov 2022 07:04:47 +0100 Message-ID: References: <87v8nu1mt1.fsf@thornhill.no> <83eduh4vcf.fsf@gnu.org> <87mt951r69.fsf@thornhill.no> <83tu3d34u7.fsf@gnu.org> <87eduhxy9l.fsf@thornhill.no> <83pme130xs.fsf@gnu.org> <717833B0-285B-460F-B37B-F0B215BD1185@thornhill.no> <3A13DCFD-3306-492B-8022-DCE95EC340A3@thornhill.no> <87a655xspj.fsf@thornhill.no> <4E432374-A97A-48A0-A1C8-89C1DB47A7F8@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="39239"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Eli Zaretskii , monnier@iro.umontreal.ca To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 06 07:05:42 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 1orYmr-0009yt-RI for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Nov 2022 07:05:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orYmJ-0006Lr-SP; Sun, 06 Nov 2022 01:05:07 -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 1orYmH-0006Lc-Gw for emacs-devel@gnu.org; Sun, 06 Nov 2022 01:05:06 -0500 Original-Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orYmF-0005Or-Dj; Sun, 06 Nov 2022 01:05:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1667714697; 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=7l5ajm23DPAV1jwnHvkqZe7CJ3O1yWNNVgQKktC6hhw=; b=qbUMY8dgC3dnWVsYiFRprxBR1K/DCzd5t1QJQIqZ7fl+DNGPudjCEAXZpdZgYdjqLH+9QX 29OzXc5sMkfq0tlU3shdyNHCLlnQ19vgAh4Z59ssm2nwTkSgNwrd93x2GhMuqrrwwwf1ZP e4PkuxSnm6dWr+NQ/DQ+oz+5+Df2k6BmBpO7k4P2L8O7ZTL31kYobC8lJ05mYjXqwCWwOr pk4FkNgaBQ+BCpyBEXAELKd0mwOUdv3aNY7gmWTv7atKlP4PRRGkoydC591SJPsatvkV5l qZfqaZxoPbWv0svVIX8fgphpPhPmqebjRWXViOnNa8/+Dsn51IUbRt2qJMhR7g== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <4E432374-A97A-48A0-A1C8-89C1DB47A7F8@gmail.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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:299240 Archived-At: On 6 November 2022 02:13:14 CET, Yuan Fu wrote: > > >> On Nov 5, 2022, at 9:38 AM, Theodor Thornhill wro= te: >>=20 >>=20 >> Hi again, Eli! >>=20 >>>>=20 >>>> Interesting=2E My guess is that there are still some improvement poss= ible in the indent-region code, considering that part of treesit=2Eel is qu= ite new=2E >>>>=20 >>>> What do you think, Yuan? Any thoughts? >>>>=20 >>>> Anyways, I'll keep working on this and see how far I get next coming = weeks=2E At least in performance it seems I have a good thing going here :-= ) >>>>=20 >>>=20 >>> Thinking of it, some of the indentation questions isn't compiled=2E I'= ll run it again later when they are compiled as well :-) >>>=20 >>=20 >> Yes, that was the issue=2E Now the scores are as follows: > >The indentation code has a list of rules, and it runs each rule top-to-bo= ttom until one rules matches, then it uses that rule to determine how much = to indent=2E The ordering of each rule could be tweaked so that most freque= nt case comes forward=2E We can also arrange these rules not linearly but i= n a tree, so if one rules matches/doesn=E2=80=99t match, some other rules c= an be skipped=2E I think the system as it is now it fine, at least for the time being=2E Bu= t I hold no strong opinions there :) > >What exactly did you compile? I tried byte-compiling indentation rules be= fore but didn=E2=80=99t see a significant speed-up=2E > >Yuan See https://git=2Esr=2Eht/~theo/tree-sitter-modes/tree/master/item/c-ts-mo= de=2Eel#L92 Sometimes when exploring indentation i use rules like this=2E Usually I tr= y to find other ways after, but I just assumed they weren't perf problems= =2E Apparently they are! And by the way, i created an anchor like this:=20 https://git=2Esr=2Eht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode= =2Eel#L57 This is nice when you need to just move a token to col 0, such as preproc-= directives=2E Maybe that should be a standard one? It could use the buffer-= root-node, but this was so simple and fast that I just did it like that=2E What do you think? Theo