From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.devel Subject: Re: Clarification about treesit-font-lock-settings Date: Sat, 25 Feb 2023 23:18:19 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000bbb93005f58da1f8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3589"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 26 06:22:33 2023 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 1pW9UX-0000mi-BZ for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Feb 2023 06:22:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pW9Tc-0001gR-Ut; Sun, 26 Feb 2023 00:21:38 -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 1pW2sg-0004hZ-Tl for emacs-devel@gnu.org; Sat, 25 Feb 2023 17:19:02 -0500 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pW2sf-0000HN-2r for emacs-devel@gnu.org; Sat, 25 Feb 2023 17:19:02 -0500 Original-Received: by mail-ed1-x531.google.com with SMTP id ee7so11317515edb.2 for ; Sat, 25 Feb 2023 14:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=NetS+SFeCswuIjpufXalMdqV250yENT34xUN3Zg2uBY=; b=Zq/55AQPnfPFpNG5/ubpp8WD45Hu08pZdA7V8qob3PuU2bxcAcSVv58eWp2XtQzSEa na+h9ke8QwseUHWd0rkC5eyc0p82uj4O4laks4diIgMqj53f2uSnTH7Q51OJvebZJAWT lWptnoou/usb5TUt6t7VcQtsKmEFyGgC3AvLR0IpB7H8VXcJYAym5ssuBpbvYnun/ZQI 4mGWAxN2zGfG2d5mhu+0I+EQARICtBNoI7f5Doj/ZINB+H8Xa6LdA4Tn5d0EhSKSUueW AjzpLIyCDK8qUBKu4nsDkuTbJ+9F2TziSO5eW+eWqmMOykDEeDBGC/wsoI6ql5ySMi8X NvuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NetS+SFeCswuIjpufXalMdqV250yENT34xUN3Zg2uBY=; b=xcseHoq91kmCzNPdfV/mcnnNRaFYk/4FGUQ5bTj+dXEG3pczx5eVMmczbDIYrLMPry hQPRVZ0V8lVZ7M+LyF7iu1S/GkIHROioeWF9jQzWP5eLIjePycAAL4/V7G1o2+RPIXad fQn218Xh+asjxxFEBcdiEBGGOOb9I2wcS9yua896hCl+zrkCfL5EOW0Z1FzR2DRvFLb8 mFRqhAYcxyk7sjuWBNV7SYBjD5ca5pbm8dTiFxwSv2HNX9CLUepHYL49ODuX6s0zD1EM NsKjRQHA2wdcVw2gou+qYJuh7Fzv9UCTQv82SlzQyumwmfU41siPKubMC2isHQIn9vi6 QXAA== X-Gm-Message-State: AO0yUKXJDLs8p3cJtDTraFUXqs0nRPXSYK9Df8f2bW1rXUpaVmN2n1Zt MCdUsWMbr5N0bpBNV+OEU5jGTv7EQKPDorMn3D7T2uenTjs= X-Google-Smtp-Source: AK7set9dIBjChdswlm7Fl+OAQaEuWPyvLa+YG5FNLotQbiU0D0iLs7SzV5SEhEf7ffZQdHgYbME7QkhzzGkXctzBeA0= X-Received: by 2002:a17:906:f256:b0:877:7480:c75d with SMTP id gy22-20020a170906f25600b008777480c75dmr13348115ejb.0.1677363536180; Sat, 25 Feb 2023 14:18:56 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=v.pupillo@gmail.com; helo=mail-ed1-x531.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, HTML_MESSAGE=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-Mailman-Approved-At: Sun, 26 Feb 2023 00:21:34 -0500 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:303809 Archived-At: --000000000000bbb93005f58da1f8 Content-Type: text/plain; charset="UTF-8" Okay, I figured out how to do it: :language 'php :feature 'attribute '((((attribute (_) @attribute_name) @font-lock-preprocessor-face) (:match "Deprecated" @attribute_name))) However, I cannot understand why "treesit-query-validate" says the query is correct, but I get an error. Thank you. Vincenzo Il giorno sab 25 feb 2023 alle ore 16:33 Vincenzo Pupillo < v.pupillo@gmail.com> ha scritto: > Hi, > I'm trying to understand how treesit-font-lock-settings works. > PHP supports annotations for classes, methods, functions, parameters, > properties and class constants, for e.g (this test come from php-mode): > > > #[ > Deprecated > ] > function f($arg1, > #[Deprecated] $arg2){} > #Deprecated <-- this is a comment > > I would like to highlight the "Deprecated" annotation. > "treesit-query-validation" says that this query is valid: > (treesit-query-validate 'php > '((attribute (name (:match "Deprecated")) > @font-lock-comment-delimiter-face)) > > This is the rule I wrote: > :language 'php > :feature 'attribute > '((attribute (name (:match "Deprecated"))) @font-lock-comment-delimiter- > face) > > > When I use my "php-ts-mode" on that code snippet, emacs reports the > following > errors: > Error during display: (jit-lock-function 1) reported (treesit-query-error > "Predicate `equal' requires two arguments but only given" 1) > Error during display: (jit-lock-function 6) reported (treesit-query-error > "Predicate `equal' requires two arguments but only given" 1) > Set report [2 times] > > Is this a bug or am I doing something wrong? > My "php-ts-mode" works quite well. Except for the annotations the syntax > highlighting is as good as php-mode. > > Thank you. > > Vincenzo > --000000000000bbb93005f58da1f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Okay, I figured out how to do it:
=C2=A0=C2= =A0 :language 'php
=C2=A0 =C2=A0:feature 'attribute
=C2=A0 = =C2=A0'((((attribute (_) @attribute_name) @font-lock-preprocessor-face)= (:match "Deprecated" @attribute_name)))

However, I cannot understand why "treesit-query-validate" says t= he query is correct, but I get an error.

Thank you= .
Vincenzo

Il giorno sab 25 feb 2023 alle ore 16:33 Vinc= enzo Pupillo <v.pupillo@gmail.com= > ha scritto:
Hi,
I'm trying to understand how treesit-font= -lock-settings works.
PHP supports annotations for classes, methods, fun= ctions, parameters,
properties and class constants, for e.g (this test = come from php-mode):

<?php

#[
=C2=A0Deprecated
]function f($arg1,
=C2=A0#[Deprecated] $arg2){}
#Deprecated <-- th= is is a comment

I would like to highlight the "Deprecated"= annotation.
"treesit-query-validation" says that this query = is valid:
(treesit-query-validate 'php
'((attribute (name (:m= atch "Deprecated")) @font-lock-comment-delimiter-face))

Th= is is the rule I wrote:
=C2=A0 =C2=A0:language 'php
=C2=A0 =C2=A0= :feature 'attribute
=C2=A0 =C2=A0'((attribute (name (:match &quo= t;Deprecated"))) @font-lock-comment-delimiter-
face)


Whe= n I use my "php-ts-mode" on that code snippet, emacs reports the = following
errors:
Error during display: (jit-lock-function 1) report= ed (treesit-query-error
"Predicate `equal' requires two argume= nts but only given" 1)
Error during display: (jit-lock-function 6) = reported (treesit-query-error
"Predicate `equal' requires two = arguments but only given" 1)
Set report [2 times]

Is this a = bug or am I doing something wrong?
My "php-ts-mode" works quit= e well. Except for the annotations the syntax
highlighting is as good a= s php-mode.

Thank you.

Vincenzo
--000000000000bbb93005f58da1f8--