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: treesit-range-settings with ':local' : I missed something or it's a bug? Date: Thu, 25 Jan 2024 13:21:31 +0100 Message-ID: <1888799.tdWV9SEqCh@3-191.divsi.unimi.it> References: <6107698.MhkbZ0Pkbq@3-191.divsi.unimi.it> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39908"; 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 Thu Jan 25 13:35:59 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 1rSyxa-000A7q-Rx for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jan 2024 13:35:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSyx9-0007dw-9V; Thu, 25 Jan 2024 07:35:31 -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 1rSyji-0001b4-FC for emacs-devel@gnu.org; Thu, 25 Jan 2024 07:21:41 -0500 Original-Received: from mail-ed1-x535.google.com ([2a00:1450: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 1rSyjf-0005yf-H6 for emacs-devel@gnu.org; Thu, 25 Jan 2024 07:21:37 -0500 Original-Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-55a45a453eeso8408250a12.0 for ; Thu, 25 Jan 2024 04:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706185293; x=1706790093; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=k5dyDL53gYVF/6GxTOzyQN2k6NKMZ+tcKbr0CbXwXjY=; b=aN8WM3rIyJb5Jox17r2McD9/RLEhZqK/7K1qaCdUkfTNkL74Cb3BmgSb+yYBavUCyY NlzbeqLzsLUn21t/2KhdtV7gc6d0DPSHOwbQYaRQi82XjTrzko1Y4SQIoYPtGkRQsd4Q vndOvarTG5yWvihLBDy+trgjB56Cn9jR3IPZm3ovUFqEeG8LP13kBovppqBr0Yhji6gl EObQH7S8kyb+bbJHHH0B9JijUo7KoIWDHiaib2yVB+LktdaBzNk27eRg9YaQvg25+LWE JFFf0KPOGf0HtUvtW+p2uzUbjEDZXhyPuUWvL2kLXpgmOgZgdCPjnjH8lOvZXD9KnYjM SVTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706185293; x=1706790093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k5dyDL53gYVF/6GxTOzyQN2k6NKMZ+tcKbr0CbXwXjY=; b=SXh1RgpSS0drV97fXbPDNDTIQcBUn0jzXoWFDze3f8K0GCYWITRxheG7sIR4UYSCIo q+5CQquXAB3ULxiw7LwHkH6qtMaQHGjWkBbF8gF8ap4qvfJ+PShsYn5CBPVg3pCr/MTo 8t2GYIEt+3zAZvsUgtM3/hQaYR39sg64F8wQRmhhrczjlBmhIIrhNS8TSr2oXUgrZWxv CoBg1Gk1wYuQP44PQOXMdXSp/stQM7OOaqX6EUuR2OSbcqmS8Kii7Z8KyP4Fp/OPiZQH H5KHGAsnFiA+nLGuswQ4lycfSG+10BvkySXIiuVzlJEdHiu0g0UQVaH7psdgXkrX3EqB t3dg== X-Gm-Message-State: AOJu0YyRImec9sx2u9w4DZkLRWoOn+deAdS7MZD/knp2obcw1vEKnIKB MUkHYHRCX9NtF5h5hZuOApo7mGYmiHGv5P9hHk0F0Ya0Um14KfyQIncgwsIe X-Google-Smtp-Source: AGHT+IHd/L3AnZG04VkJ/CS9PbSr3vIzeOzoEC3deVdjGPcNax0rlEHb1a3Ge/6gCHUOBnFZOTUQpQ== X-Received: by 2002:a17:907:8b85:b0:a2f:d903:43ed with SMTP id tb5-20020a1709078b8500b00a2fd90343edmr862778ejc.3.1706185292653; Thu, 25 Jan 2024 04:21:32 -0800 (PST) Original-Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id cf22-20020a170906b2d600b00a2c047c6847sm961125ejb.113.2024.01.25.04.21.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 04:21:32 -0800 (PST) In-Reply-To: <6107698.MhkbZ0Pkbq@3-191.divsi.unimi.it> Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=v.pupillo@gmail.com; helo=mail-ed1-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-Mailman-Approved-At: Thu, 25 Jan 2024 07:35:22 -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:315350 Archived-At: yes, it is a bug. I will send a patch to debbugs.gnu.org in the next few da= ys. V. In data gioved=EC 11 gennaio 2024 12:15:24 CET, Vincenzo Pupillo ha scritto: > Hi,=20 > in the php-ts-mode I am writing, I am trying to use the tree-sitter-phpdo= c parser=20 > (I had tried before but without success, and I currently use a font block= based=20 > on regular expressions).=20 > tree-sitter-phpdoc requires a single doc block (a single /** */ doc block= and=20 > nothing else, no /* */ or #). I wrote these range rules: > (setq-local treesit-range-settings > (treesit-range-rules > :embed 'phpdoc > :host 'php > :local t > '(((comment) @cap > (:match "/\\*\\*" @cap))) >=20 > :embed 'html > :host 'php > '((program (text) @cap) > (text_interpolation (text) @cap)) >=20 > :embed 'javascript > :host 'html > :offset '(1 . -1) > '((script_element > (start_tag (tag_name)) > (raw_text) @cap)) >=20 > :embed 'css > :host 'html > :offset '(1 . -1) > '((style_element > (start_tag (tag_name)) > (raw_text) @cap)))) >=20 > With html, js and css it works fine. With phpdoc I tried with or without = :local.=20 > Without :local the parse intervals are all null. Without :local on the ot= her hand they are correct. > With this simple php snippet: > =20 > /** > * Test class > * @author v > */ > class Test { > /** @see http://example.com the lib */ > function test() { > echo "prova"; > } > } >=20 > Without :local the field rules are: > ((# ((1 . 1) (8 . 64) (82 . 120))) (# parser for html> ((1 . 1) (1 . 2))) (# ((1 . 1)))= =20 > (# ((1 . 1))) (# n= il)) >=20 > With :local the result is: > ((# nil) (# nil)=20 > (# nil) (# nil)=20 > (# nil)) >=20 >=20 > With :local the treesit-language-at breaks, and js or css rules=20 > are also applied to php code :-( >=20 > I tried tracking the node location sent from the parser to the font-lock-= rules I wrote for phpdoc,=20 > with :local the result is: >=20 > phpdoc-block node-start=3D 8 node-end=3D 64 start=3D 1 end=3D 166 > phpdoc-block node-start=3D 82 node-end=3D 120 start=3D 1 end=3D 166 > phpdoc-block node-start=3D 1 node-end=3D 166 start=3D 1 end=3D 166 >=20 > the first two are right, the last one is not. >=20 > Any idea? > Tested with: > GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.39, ca= iro version 1.18.0) of 2024-01-11 >=20 >=20 > Thanks >=20 > p.s. the function I wrote to get the ranges is: > (defun php-ts-mode--get-parser-ranges () > "Return the ranges covered by the parsers. >=20 > `php-ts-mode' use 5 parsers, this function returns, for the > current buffer, the ranges covered by each parser. > Usefull for debugging." > (let ((ranges)) > (if (not (treesit-parser-list)) > (message "At least one parser must be initialized")) > (cl-loop > for parser in (treesit-parser-list) > do (push (list parser (treesit-parser-included-ranges parser)) range= s) > finally return ranges))) >=20 >=20 >=20 >=20