From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Recent updates to tree-sitter branch Date: Mon, 26 Sep 2022 01:35:59 -0700 Message-ID: References: <87wn9srn9n.fsf@localhost> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="37457"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Theodor Thornhill To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 26 10:38:51 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 1ocjda-0009Tq-TL for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Sep 2022 10:38:50 +0200 Original-Received: from localhost ([::1]:45186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocjdZ-0007pH-Qa for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Sep 2022 04:38:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocjax-0005Xt-1d for emacs-devel@gnu.org; Mon, 26 Sep 2022 04:36:07 -0400 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:40528) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocjas-0008VW-Mz for emacs-devel@gnu.org; Mon, 26 Sep 2022 04:36:06 -0400 Original-Received: by mail-pj1-x102c.google.com with SMTP id q9-20020a17090a178900b0020265d92ae3so11657186pja.5 for ; Mon, 26 Sep 2022 01:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date; bh=bLkMMquAKyrLPxjz1YiXYQvcsK8E9ShSU473ogs10OE=; b=qZ+a10hIgFUbJuaRJAPu+JJQiWTot7T3eNdKMmwV56JHC8krAx2iLKEsNdm4O5QqZL DeJ+Dzyd+7oPVhXgTbhHH1UiLSdEkqyY4rUnM2wONAIdPvvKKX/Ne14yMM4VfS4wtQwJ uhflnsqBSNDH96aIbnZC6pVaAH6tcyM+R+JHBzlsWIivkyL9S/FHbVg0wrQKkhCbew+q dk8W3JmTMrpWPX9HSZGMdfIUapvBXavuW4hun79k2+rrXStSlt6RMSR+71j5YOu3kNCB SqluoFijz3CGPNSGa3s2Tqv3wcuUbvNODVq8c0APHCXYyWJ7PtkdYOGIBCeUX7cVNqjx Ox/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=bLkMMquAKyrLPxjz1YiXYQvcsK8E9ShSU473ogs10OE=; b=3DRA05IwIWsp4j3S0+lPyV5ebQyEmNZ/zlLLCBaAvkfPyWThn4omlV2OLSJ+i6Ax0k LdoubRMT5QfpnOUzYpQf9OFAaiu36b7dneAyoy55MStGAbyAv4fQaQS57L+9kACb/eSf GnSh0eo7kaIz/6SfxsKZz1NMe/mkeiJ6K4jF9nCs8WVTLyMIuAKaku3Ft9DrARmX/vvi 27viIS3RJs2kcEjuCdrCdrE68px88fF5cZny5wuw1cFAsNSl6ZpcqI5V5lH07U3WOGJd zmsAXBXMySh/5fC9g1Od2qDEPNtQgHqoWGOcIIPiTcBtGwr0mJDfCozEErL5eSn1aTxv O0Ww== X-Gm-Message-State: ACrzQf2KSAnqmdFOg9jDjvwx5RXO9L/yGkoON9tPwDLLfpiJik5QwRuC mqtF5H64i/6tMaBViivFudhtvHL4yas= X-Google-Smtp-Source: AMsMyM7i7QfIIjdhz+5TzFlhUpxALF6CmxG7SPY4qHTYO3jZE7MPN8jdRp703iFLeygzFiI7bKHktg== X-Received: by 2002:a17:90a:e7c3:b0:203:bbbb:e589 with SMTP id kb3-20020a17090ae7c300b00203bbbbe589mr31132646pjb.175.1664181361051; Mon, 26 Sep 2022 01:36:01 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id v67-20020a622f46000000b0054ee4b632dasm11362860pfv.169.2022.09.26.01.36.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Sep 2022 01:36:00 -0700 (PDT) In-Reply-To: <87wn9srn9n.fsf@localhost> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=casouri@gmail.com; helo=mail-pj1-x102c.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-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" Xref: news.gmane.io gmane.emacs.devel:296265 Archived-At: > On Sep 24, 2022, at 11:17 PM, Ihor Radchenko = wrote: >=20 > Yuan Fu writes: >=20 >> 2. Although treesit-font-lock-settings didn=E2=80=99t change, = treesit-font-lock-defaults is abandoned. You are also now supposed to = use treesit-font-lock-rules to build the queries and set it to = treesit-font-lock-settings. It is much cleaner than setting = treesit-font-lock-settings manually. >=20 > I am not sure if it has been discussed, but may I ask a few questions > regarding treesit-font-lock-rules. >=20 > If my understanding is correct, the font-lock rules are somewhat > equivalent font-lock-keywords, but much more limited. >=20 > font-lock-keywords elements can have a form of >=20 > MATCHER > (MATCHER . SUBEXP) > (MATCHER . FACENAME) > (MATCHER . HIGHLIGHT) > (MATCHER HIGHLIGHT ...) > (eval . FORM) >=20 > where MATCHER is either a regexp or a function. >=20 > treesit-font-lock-rules rules take a form of > (MATCHER FACENAME) or (MATCHER FUNCTION) >=20 > where MATCHER can only be a query. >=20 > Is there any reason why MATCHER in treesit-font-lock-rules cannot be a > function with access to the fontified node? Hmm, I=E2=80=99m not sure what do you mean. The whole thing passed to = treesit-font-lock-rules is a single query, and we can=E2=80=99t really = change the query syntax, that=E2=80=99s defined by tree-sitter. = Basically in a query you have patterns paired with capture names, if the = pattern matches to a node, that node is returned with corresponding = capture name tagged on it. For font-lock, we just use face names as = capture names, and when a query returns captured nodes, fontify the node = with its capture name, aka a face (or a function). > It will allow more flexible > fontification, when programmatic query can be used to decide the > fontification. >=20 > Further, can OVERRIDE FLAG of the MATCH-HIGHLIGHT as in > font-lock-keywords be supported? >=20 > "If OVERRIDE is t, existing fontification can be overwritten. If > keep, only parts not already fontified are highlighted. If prepend = or > append, existing fontification is merged with the new, in which the = new > or existing fontification, respectively, takes precedence.=E2=80=9D I can do that, but would it be really useful? Unlike regex font-lock = which is used for so many different things, tree-sitter font-lock is, = IMO, only used to apply a base layer of language-specific highlight. How = would one use the override feature in this scenario? Yuan