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: Mon, 07 Nov 2022 09:05:13 +0100 Message-ID: <87v8nri406.fsf@thornhill.no> 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> <7D986EF0-5967-47B9-A59B-747ABA08F6DF@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="17461"; 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 Mon Nov 07 09:06:38 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 1orx9R-0004Jh-Mu for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Nov 2022 09:06:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orx8c-0005us-G7; Mon, 07 Nov 2022 03:05:46 -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 1orx8E-0005pM-BQ for emacs-devel@gnu.org; Mon, 07 Nov 2022 03:05:30 -0500 Original-Received: from out0.migadu.com ([94.23.1.103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orx88-0005cR-Oq; Mon, 07 Nov 2022 03:05:21 -0500 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=1667808314; 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=CMCBPh69zWgO2xbVBFOXuFyTkc8P3Ozu9HaD4U6w8aE=; b=b+WRdFy3X1H0jmi1h/jwG/1LBBrREFfOuzulCvI+Oh+FkfXxz0f1ntPJ9liiv/mhKqNZUu Xdq+XQoENq0b67++Y/nIXFWzBMYJZPuPJyp11eTMNMo9vVqksv5a3hz1DF6EXRtTMmLOjs 4DtG0rXxnfqWc27a6LG1FmG0kOJS5mQK/LSTj8tyy61/iEOYqbL8IyJXIs9UoSFPRjtC6N 9Jqj7Zx8/h3jC0w3od8OFEcbQ1lafKN4VsIiFzzRRsgovGidRe6m0lIPAVyD13fqjwv8GP Q3EHXbyMYjrBxtuvJPoXm+tDS+HzvQJW1eW1uWvyNEZfLlRzvzGMa9ibGQwPmQ== In-Reply-To: <7D986EF0-5967-47B9-A59B-747ABA08F6DF@gmail.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=94.23.1.103; envelope-from=theo@thornhill.no; helo=out0.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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299281 Archived-At: Hi Yuan. >>> The indentation code has a list of rules, and it runs each rule >>> top-to-bottom until one rules matches, then it uses that rule to >>> determine how much to indent. The ordering of each rule could be >>> tweaked so that most frequent case comes forward. We can also >>> arrange these rules not linearly but in a tree, so if one rules >>> matches/doesn=E2=80=99t match, some other rules can be skipped. >>=20 >> I think the system as it is now it fine, at least for the time >> being. But I hold no strong opinions there :) > > Yeah if there is no performance issue, it=E2=80=99s better to keep things= simple. > >>>=20 >>> What exactly did you compile? I tried byte-compiling indentation rules = before but didn=E2=80=99t see a significant speed-up. >>>=20 >>> Yuan >>=20 >> See https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode= .el#L92 >>=20 >> Sometimes when exploring indentation i use rules like this. Usually I >> try to find other ways after, but I just assumed they weren't perf >> problems. Apparently they are! > > I see, we can precompile these queries automatically for the user.=20 > I think that's a good idea >>=20 >> And by the way, i created an anchor like this: >> https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode.el#= L57 >>=20 >> This is nice when you need to just move a token to col 0, such as >> preproc-directives. 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. >>=20 >> What do you think? > > I=E2=80=99ll add it, thanks! My pleasure :) Come to think of it. Maybe also some "this should always be fixed at column N"? --=20 Theo