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: treesit-range-settings with ':local' : I missed something or it's a bug? Date: Thu, 11 Jan 2024 12:15:24 +0100 Message-ID: <6107698.MhkbZ0Pkbq@3-191.divsi.unimi.it> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25477"; 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 11 12:49: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 1rNtYW-0006NZ-Cn for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Jan 2024 12:49:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNtXc-0000NJ-DL; Thu, 11 Jan 2024 06:48:08 -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 1rNt21-0001De-Rl for emacs-devel@gnu.org; Thu, 11 Jan 2024 06:15:29 -0500 Original-Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNt1z-0000CJ-U7 for emacs-devel@gnu.org; Thu, 11 Jan 2024 06:15:29 -0500 Original-Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-50ea98440a7so5330874e87.1 for ; Thu, 11 Jan 2024 03:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704971726; x=1705576526; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=g5fCCDK81SgHHHcGM7KaSOD8lWY+p9mEDLvRMnJ4OzI=; b=YnV9DKuk9kHx2NLvph/bjs3FA+Mb7kpPfKpH01YH7Z8xNJda3237XNLdFi9MSgZtxO 6A5TweVlKWULf/lmyfwt7HW+XL+OC5LZPCfJi5u8g52DAvYlJCKDA1Q1johcApBYb+0E 2wV3vpp5J46D27BtoRvJhD61cIl4l85BjFMkU/KRboKp6YBzjkPUqEEkWPs9/sr0AwLz 8sFiMJi6FOYNUq4MomST5r/WsALyePL9yVzIR7b58iy83S5QxG58uJbUv804GaSxlRtv OeQmQd9xoZ4qk9kuCGneTp51JEdfi9LUFNH2g3NOUDI2McrUp6vqKRfvsS0/+ew/2TMH kRAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704971726; x=1705576526; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g5fCCDK81SgHHHcGM7KaSOD8lWY+p9mEDLvRMnJ4OzI=; b=Y+Yy0WbNg8HrhLxZ99k9tOCac2CcXCmu3K8Q/CzL+ngcBW/Nc6NeF8rr0TXfp/6kIV bxG67+c/4AjeVI30SzjvYkidymsALBjUtRvxkYDgMZXinhRmQ/aa8cPXdDb5itALX964 HkjmPm2h5zel2DLlwXGSrZue0fPSAMwgjYdLt9UoMD94mNWddGlzWS3SeZE/LCv5n2Bn 4lhnR+ZiH4+DaW7Rkty7qkGVQ9FX5IddDNOp5aNyuPyKyokk8Epgs6+W9fIV2h2YcRm0 5E2FV+EKksP7zBpdeyHB2GYg3+EJqB0M5hQXtF4qnnOOzsFDxWBqCf3VB0aI7LdTE74z xAlQ== X-Gm-Message-State: AOJu0YzTiO1nbv0rqX730YKC2hQDt8EmDPeKSJ/DoN2N4cpFqfviTfzA yu9+529z5+0nFrumzGWfT3NKlZfWVdw= X-Google-Smtp-Source: AGHT+IEV3dSIRXSwEWPgIhcfJdGqQjT/Rv3Pr3bk7bRoccAMP0E3zg2jJ0AyaQVUh7oKKZQPNxEM0Q== X-Received: by 2002:a05:6512:3e0f:b0:50e:a9f0:4a88 with SMTP id i15-20020a0565123e0f00b0050ea9f04a88mr405099lfv.91.1704971725699; Thu, 11 Jan 2024 03:15:25 -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 v5-20020a1709060b4500b00a269597d173sm447088ejg.135.2024.01.11.03.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:15:25 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=v.pupillo@gmail.com; helo=mail-lf1-x129.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, 11 Jan 2024 06:48:07 -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:314851 Archived-At: Hi, in the php-ts-mode I am writing, I am trying to use the tree-sitter-phpdoc parser (I had tried before but without success, and I currently use a font block based on regular expressions). tree-sitter-phpdoc requires a single doc block (a single /** */ doc block and 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))) :embed 'html :host 'php '((program (text) @cap) (text_interpolation (text) @cap)) :embed 'javascript :host 'html :offset '(1 . -1) '((script_element (start_tag (tag_name)) (raw_text) @cap)) :embed 'css :host 'html :offset '(1 . -1) '((style_element (start_tag (tag_name)) (raw_text) @cap)))) With html, js and css it works fine. With phpdoc I tried with or without :local. Without :local the parse intervals are all null. Without :local on the other hand they are correct. With this simple php snippet: */ class Test { /** @see http://example.com the lib */ function test() { echo "prova"; } } Without :local the field rules are: ((# ((1 . 1) (8 . 64) (82 . 120))) (# ((1 . 1) (1 . 2))) (# ((1 . 1))) (# ((1 . 1))) (# nil)) With :local the result is: ((# nil) (# nil) (# nil) (# nil) (# nil)) With :local the treesit-language-at breaks, and js or css rules are also applied to php code :-( I tried tracking the node location sent from the parser to the font-lock-rules I wrote for phpdoc, with :local the result is: phpdoc-block node-start= 8 node-end= 64 start= 1 end= 166 phpdoc-block node-start= 82 node-end= 120 start= 1 end= 166 phpdoc-block node-start= 1 node-end= 166 start= 1 end= 166 the first two are right, the last one is not. Any idea? Tested with: GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.39, cairo version 1.18.0) of 2024-01-11 Thanks 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. `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)) ranges) finally return ranges)))