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: treesit-range-settings with ':local' : I missed something or it's a bug? Date: Sat, 27 Jan 2024 23:09:02 -0800 Message-ID: References: <6107698.MhkbZ0Pkbq@3-191.divsi.unimi.it> <5C4F13B5-3FE3-499E-8F23-8B528AF194B7@gmail.com> <10408919.nUPlyArG6x@fedora> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) 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="33358"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Vincenzo Pupillo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 28 08:10:05 2024 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 1rTzIr-0008Ub-D7 for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Jan 2024 08:10:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTzI9-0007gz-Ql; Sun, 28 Jan 2024 02:09:21 -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 1rTzI5-0007gA-Lx for emacs-devel@gnu.org; Sun, 28 Jan 2024 02:09:17 -0500 Original-Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTzI4-00030U-05 for emacs-devel@gnu.org; Sun, 28 Jan 2024 02:09:17 -0500 Original-Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5d8b887bb0cso769506a12.2 for ; Sat, 27 Jan 2024 23:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706425754; x=1707030554; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Y8Ikw3hM0CRiQNMvseDwiiJHe6icoXXexdSdk23IYKg=; b=EhLmd7d93YB+hsZfsex033vI3Q1lpkfNA013YyD5p1Tg/xApbotHYR9dG8pw+5wXPc X+M4IWcwQjyjLtyec7l41R9iXyL0vJcNz+rgdp+J+KNTSwyOCGwBs6o1Py+fa/H00ZQk mj54Wou/BPpXZ+2NRykgX2GnqTjc0WdWXvxkyZzEnpdoU0H0/X9wLiDii76UB9ev7yzJ 6LoD7unOp+BK8p/Yel1IlSgUFnXQqlgz/hJkyroPbjmjzovLOIm9hkOFBQuvxkbD92h9 BjKfm1EMpbtm7/bSw5MNfV50uoqvJiUSbJdvIxlf1phGRfwudpVd5iVEK2sSk73NGz1/ v/5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706425754; x=1707030554; 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:message-id:reply-to; bh=Y8Ikw3hM0CRiQNMvseDwiiJHe6icoXXexdSdk23IYKg=; b=g9T/kOHMZPDEyLaDFcQgI96wqnrciQm2WiDFUCAEuGjNx3AjrXx7vmpRaBOc7Me9QY Qgrb2Kv02XTa8WNUlhWjWbRBeCh9tnueA7+f9MMizVyg4Np/Rx42sf8xxN27tZDhLTg8 XryY+P7+eY/8WCmwF8X9ArsTG9tMIcPOs8qygXlEhistqE4OroUSg9JGFPtaMIfgVOPW 1nGHLfxwDZbX/JVeszF28THaSFN6ZpzBfY8BSILUEFVKmeSWqPzceyfUGU13+pxuqY13 Y3tzjoRqTIsjNO7dLXQSSyKGM1febP+h76gD+P6dDw0VSjjnladOBVFD1VS6dnrd6aj/ GFsQ== X-Gm-Message-State: AOJu0YywH13/TJeABIupYCh58Qc3JasHPwcI5ogEYPUZsb5xrlwCYZE/ D2cyEkNinthST7c791LYCDabMaQ2oYaOs+DXWfY8iE57j/av+7fGsOuEzF4x X-Google-Smtp-Source: AGHT+IFyFKpWv7Pzb8iR8NfMssGsP7M58FLXni/Twj6IZgviGrlbSxJlvXtNwisY1b9nKlWDQEgeSg== X-Received: by 2002:a17:902:bb85:b0:1d5:c08e:52eb with SMTP id m5-20020a170902bb8500b001d5c08e52ebmr2794840pls.65.1706425753857; Sat, 27 Jan 2024 23:09:13 -0800 (PST) Original-Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id w3-20020a170902c78300b001d73a2acc0csm3303715pla.283.2024.01.27.23.09.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2024 23:09:13 -0800 (PST) In-Reply-To: <10408919.nUPlyArG6x@fedora> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=casouri@gmail.com; helo=mail-pg1-x535.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, T_SCC_BODY_TEXT_LINE=-0.01 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:315533 Archived-At: > On Jan 27, 2024, at 2:23 AM, Vincenzo Pupillo = wrote: >=20 > No. I defined a function for "treesit-language-at", which works = correctly=20 > without tree-sitter-phodoc parser (the version without phpdoc is here = https:// > github.com/vpxyz/php-ts-mode) > I find two problems:=20 > 1. treesit-range-rules does not reset the variable "local" at the end = of pcase=20 > as it does with "host", "embed" and "offset". If there is a parser = with the=20 > :local attribute, all parsers defined after it are marked as :local=20 > Without fix:=20 > treesit-range-settings is a variable defined in = =E2=80=98~/Projects/Emacs/php-ts-mode/ > treesit.el=E2=80=99. >=20 > Its value is > ((# phpdoc t nil) > (# html t nil) > (# javascript t (1 . -1)) > (# css t (1 . -1))) > Local in buffer index4.php; global value is nil >=20 > with fix: > treesit-range-settings is a variable defined in = =E2=80=98~/Projects/Emacs/php-ts-mode/ > treesit.el=E2=80=99. >=20 > Its value is > ((# phpdoc t nil) > (# html nil nil) > (# javascript nil (1 . -1)) > (# css nil (1 . -1))) > Local in buffer index4.php; global value is nil Thanks, I pushed a fix for it. > 2. treesit-font-lock-fontify-region: the variable "global-parser" is = set with=20 > all parsers defined, including local parsers. As result the root-nodes=20= > variable, without fix are ("document node" is a phpdoc node):=20 > root-nodes (# # 672-810> # #=20 > # #=20 > #) >=20 > with fix: =20 > root-nodes (# # 672-810> # #=20 > # #) >=20 > you can see the difference in the attached screenshots. > The patch I wrote is not a solution (it's trivial) . I think there are = other=20 > "moving parts" to take into account. >=20 > Thanks. Actually, local parsers are not included in the return value of = (treesit-parser-list). By default, treesit-parser-list returns all the = parsers whose tag is nil, but all the local parsers carry a tag of = =E2=80=98embedded. To actually return all the parsers in the buffer you = need to use (treesit-parser-list nil nil t), ie, pass t to the TAG = parameter.=20 I pulled your php-ts-mode_phpdoc.el and played around with it. I found = the root cause to be the call to=20 (treesit-parser-create =E2=80=98phpdoc) In the major mode body. This creates a global phpdoc parser that = fontifies everything in doc face. Removing that, plus the fix for #1 that I just pushed to master, should = fix the font-lock problem you are observing. I couldn=E2=80=99t fine the patch you mentioned in the thread so I = don=E2=80=99t know if this is what your patch does. Yuan=