From unknown Sat Jun 21 10:39:38 2025 X-Loop: help-debbugs@gnu.org Subject: bug#73516: 30.0.91; [PATCH] php-ts-mode: add support for the latest grammar version. Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Sep 2024 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73516 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 73516@debbugs.gnu.org X-Debbugs-Original-To: Bug Emacs Received: via spool by submit@debbugs.gnu.org id=B.172744396614393 (code B ref -1); Fri, 27 Sep 2024 13:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 Sep 2024 13:32:46 +0000 Received: from localhost ([127.0.0.1]:33717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suB5R-0003k0-RI for submit@debbugs.gnu.org; Fri, 27 Sep 2024 09:32:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:38766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suB5P-0003jq-ST for submit@debbugs.gnu.org; Fri, 27 Sep 2024 09:32:44 -0400 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 1suAaX-0001qh-IA for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 09:00:50 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suAaT-0001N6-P0 for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 09:00:48 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5c5cc65a8abso2160276a12.3 for ; Fri, 27 Sep 2024 06:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727442043; x=1728046843; 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=76CTqJtcY5zqHwuM1YmQgJY8OltbfhNIl3UDhaXT69o=; b=hfSBZfkoSd23fsmFtRhQQWeiuoLzKLUINS14kwls4iUGf3Zr3kfd6rRiETwFSWLrD0 53DcOat73nAf90PYKqSH8kuIK6+N9kvsvFCRFDFgzgqKHhzsEegIORFsG+dlzvEwa8kl q3u/rBZK0L3Q7BdmQ+45fkopD3S9Y7tUVY0VuQjDsSi7i/sAQ5bY+Oa7V+U0T9H0gE6M RAwRXfOAJ6x7UM/ZdLSI3p4QipEOspvd6ZuH5S1wUn2UGeYOKaAZTLoOsyzTXxuM5mWw cSasYJaP5+ZLZgpM/FZhrisBxJoTfPf+w7fasKsdwUDMOBOFp8HzY3h5iEm0yEAjkcRB 372g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727442043; x=1728046843; 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=76CTqJtcY5zqHwuM1YmQgJY8OltbfhNIl3UDhaXT69o=; b=dglozDXhXUQbpIFxNkoBI38KFgKjTOf09pIdMGHV9rK2V5kCt0vd9sN+JdTOdGNAFm YLFm5n4dGOD+X5+4KJGmxFSPkhm22ilhuWLe7tjMS22x8vQonNo/yBhXZ/Hkg+HUNNHm usS1oiT3DZd9MRHFrBKOrdaxBEAR4NV2tStL/sRZZnhOZAsHMPfDpXJpdE3MEbUfzSrr zxLz7594w2L1c+U2UiJUSXR9gHERipG0YpJz+5t1v6nklN9coK4ANBznAChiNZNX1cFj mDv3RqqGrNk1t8Sw7VrQxA2+GD3tN21xA6nRmpJj4BpZnI2mvedjtwKgL5Pr+tbnJsxq C+Qw== X-Gm-Message-State: AOJu0Yxjk+WC75dCKMMcOg1qYHIj+TCfD28K6lqMkblkmsdUyN4pxiat sgqcufdBNQsdIigl2iMHXfTihBZ3BvfPp4b+IYCwoF4GSaLaeY9Zt1CzDw== X-Google-Smtp-Source: AGHT+IEDxO7NJEaQnQWlu5lyykeQ87ptU/tK7bC3aulPuKzrIEUhlktlOkqxIzqFprRu1p1yBFY9Fg== X-Received: by 2002:a17:907:748:b0:a86:a30f:4aef with SMTP id a640c23a62f3a-a93c49199b6mr256773266b.22.1727442042477; Fri, 27 Sep 2024 06:00:42 -0700 (PDT) Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27c5b7fsm132144066b.66.2024.09.27.06.00.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 06:00:41 -0700 (PDT) From: Vincenzo Pupillo Date: Fri, 27 Sep 2024 15:00:40 +0200 Message-ID: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3688908.dWV9SEqChM" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=v.pupillo@gmail.com; helo=mail-ed1-x529.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --nextPart3688908.dWV9SEqChM Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Ciao, as usual the latest version of PHP grammar breaks the font lock. This patch supports both the old and the latest grammar. Version 0.23 supports the new features of PHP 8.4 (in release candidate). Thank you. Vincenzo --nextPart3688908.dWV9SEqChM Content-Disposition: attachment; filename="0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch" >From 669090265e653f457c7876461238c3898e4f3696 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Fri, 27 Sep 2024 13:07:06 +0200 Subject: [PATCH] Fix php-ts-mode font-lock for latest PHP grammar. Version 0.23 of the PHP grammar introduced some changes that affect the font lock. * lisp/progmodes/php-ts-mode.el (php-ts-mode--language-source-alist): Update php, html, js and css grammars version. (php-ts-mode--parent-html-heuristic): Fix docstring (php-ts-mode--test-namespace-name-as-prefix-p): New function. (php-ts-mode--test-namespace-aliasing-clause-p): New function. (php-ts-mode--test-namespace-use-group-clause-p): New function. (php-ts-mode--font-lock-settings): Use the new functions. --- lisp/progmodes/php-ts-mode.el | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 3f89de14075..87aefaf451f 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -83,12 +83,12 @@ ;;; Install treesitter language parsers (defvar php-ts-mode--language-source-alist - '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.8" "php/src")) + '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.0" "php/src")) (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) - (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.3")) - (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2")) - (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.21.0")) - (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0"))) + (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.0")) + (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0")) + (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.0")) + (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.23.0"))) "Treesitter language parsers required by `php-ts-mode'. You can customize this variable if you want to stick to a specific commit and/or use different parsers.") @@ -490,7 +490,7 @@ php-ts-mode--parent-html-bol (treesit-node-start parent))))) (defun php-ts-mode--parent-html-heuristic (node parent _bol &rest _) - "Returns position based on html indentation. + "Return position based on html indentation. Returns 0 if the NODE is after the , otherwise returns the indentation point of the last word before the NODE, plus the @@ -773,6 +773,21 @@ php-ts-mode--predefined-constant "__FUNCTION__" "__LINE__" "__METHOD__" "__NAMESPACE__" "__TRAIT__") "PHP predefined constant.") +(defun php-ts-mode--test-namespace-name-as-prefix-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) t))) + +(defun php-ts-mode--test-namespace-aliasing-clause-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) t))) + +(defun php-ts-mode--test-namespace-use-group-clause-p () + "Return t if the namespace_use_group_clause keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_use_group_clause)" t) t))) + (defun php-ts-mode--font-lock-settings () "Tree-sitter font-lock settings." (treesit-font-lock-rules @@ -866,7 +881,7 @@ php-ts-mode--font-lock-settings :language 'php :feature 'definition :override t - '((php_tag) @font-lock-preprocessor-face + `((php_tag) @font-lock-preprocessor-face ("?>") @font-lock-preprocessor-face ;; Highlights identifiers in declarations. (class_declaration @@ -889,10 +904,16 @@ php-ts-mode--font-lock-settings ("=>") @font-lock-keyword-face (object_creation_expression (name) @font-lock-type-face) - (namespace_name_as_prefix "\\" @font-lock-delimiter-face) - (namespace_name_as_prefix (namespace_name (name)) @font-lock-type-face) - (namespace_use_clause (name) @font-lock-property-use-face) - (namespace_aliasing_clause (name) @font-lock-type-face) + ,@(when (php-ts-mode--test-namespace-name-as-prefix-p) + '((namespace_name_as_prefix "\\" @font-lock-delimiter-face) + (namespace_name_as_prefix + (namespace_name (name)) @font-lock-type-face))) + ,@(if (php-ts-mode--test-namespace-aliasing-clause-p) + '((namespace_aliasing_clause (name) @font-lock-type-face)) + '((namespace_use_clause alias: (name) @font-lock-type-face))) + ,@(when (not (php-ts-mode--test-namespace-use-group-clause-p)) + '((namespace_use_group + (namespace_use_clause (name) @font-lock-type-face)))) (namespace_name "\\" @font-lock-delimiter-face) (namespace_name (name) @font-lock-type-face) (use_declaration (name) @font-lock-property-use-face)) @@ -931,8 +952,10 @@ php-ts-mode--font-lock-settings :language 'php :feature 'base-clause :override t - '((base_clause (name) @font-lock-type-face) + `((base_clause (name) @font-lock-type-face) (use_as_clause (name) @font-lock-property-use-face) + ,@(when (not (php-ts-mode--test-namespace-name-as-prefix-p)) + '((qualified_name prefix: "\\" @font-lock-delimiter-face))) (qualified_name (name) @font-lock-constant-face)) :language 'php -- 2.46.1 --nextPart3688908.dWV9SEqChM-- From unknown Sat Jun 21 10:39:38 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Vincenzo Pupillo Subject: bug#73516: closed (Re: bug#73516: 30.0.91; [PATCH] php-ts-mode: add support for the latest grammar version.) Message-ID: References: <46C10E7C-C98F-4FA6-887A-EFD7EB306FC4@gmail.com> <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> X-Gnu-PR-Message: they-closed 73516 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 73516@debbugs.gnu.org Date: Sat, 28 Sep 2024 08:10:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1727511002-11426-1" This is a multi-part message in MIME format... ------------=_1727511002-11426-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #73516: 30.0.91; [PATCH] php-ts-mode: add support for the latest grammar ve= rsion. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 73516@debbugs.gnu.org. --=20 73516: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D73516 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1727511002-11426-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 73516-done) by debbugs.gnu.org; 28 Sep 2024 08:09:47 +0000 Received: from localhost ([127.0.0.1]:51665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suSWR-0002xj-4L for submit@debbugs.gnu.org; Sat, 28 Sep 2024 04:09:47 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:53381) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suSWP-0002xR-4x for 73516-done@debbugs.gnu.org; Sat, 28 Sep 2024 04:09:45 -0400 Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20551eeba95so28557665ad.2 for <73516-done@debbugs.gnu.org>; Sat, 28 Sep 2024 01:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727510889; x=1728115689; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=ZgMqKMF8+qW8Q7CfZapOizDHJgc8OeVkShVJCMiD9cQ=; b=f+TbcAS5U/4HLoasspTbnLkt6W0cBawCj601Tz0+utZSbCu7ioBji8ElzuaNf5UUpb OsNZJ72JO9K0U8Da3OGisfkjRdt1pZwcAu5gcdTfFD0pEdGWwcHiItI264Ya9n8s4tHQ YuLYLK0p6OcUGNiHfdZKxo6XbeN8vwnpFaVFZ4XbHT0gLWYUa3OoRXhqqfOi96wa3UUT nxAXCZ+AFa606/oyjvMEmWLsFnjPN1lNAGh0P95+JseyZWfu4SNn4sgbnpnj6qoKkZHI 6mCY1MJJnhnlWWca3LgQGcqwbVMziO1xk1M2os7aJGd8L8XfEPtc2HlXrgEbcoamsNK1 6OTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727510889; x=1728115689; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZgMqKMF8+qW8Q7CfZapOizDHJgc8OeVkShVJCMiD9cQ=; b=DYIGN2jFVpJy35blegtCymCRjWVsKDQGw4/0eAkCURaTHOEvIabUv9gp5liTXkbrZ2 nyG0O1JhMWuO5Y7eHKLTrBUCQs7SzLGaD3lW8EiwQK1sJhOwwGK8w5s8KSUznOkqEGIB tjSq04oPPMIRPbVE0XgkgBQIMfwB7ddJPx2xe0YzmzCYheyXo/xq1MVXiPt2Hn8FIFiz 7kB3RTGi3ljS6BMUYwBvQNadR0l9gz77OYcqAaVUdYoiCg0fs1DyCMrL7oftPGqeO+Cp +Z3bUUPGLBJe1sTknanO/s/bV8Ef4YmvzCAqqzJErJvUwg821ohEw6deoC38RHxPNUDq DywA== X-Gm-Message-State: AOJu0YzrUeYT6mF2IYytH5+kNWT6haBJfTMrn71Al1x30YON99go3RC6 BOyPbHUwBEFh8KVuSJSZ+5EeKR/pNTZSw0u2EnofqjRB8J1SzqE4 X-Google-Smtp-Source: AGHT+IGouVcLJTKic7cMsxX+NlDrqxpcmmBU25L3cZSMYR+fX0hXROXBjEb/dqEiJaCdvJSi+wcR/A== X-Received: by 2002:a17:903:230c:b0:206:b79e:5780 with SMTP id d9443c01a7336-20b369d5024mr88980195ad.24.1727510889311; Sat, 28 Sep 2024 01:08:09 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:880f:a981:5530:3a90]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2652b4d6sm2756761b3a.177.2024.09.28.01.08.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Sep 2024 01:08:07 -0700 (PDT) From: Yuan Fu Message-Id: <46C10E7C-C98F-4FA6-887A-EFD7EB306FC4@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: bug#73516: 30.0.91; [PATCH] php-ts-mode: add support for the latest grammar version. Date: Sat, 28 Sep 2024 01:07:56 -0700 In-Reply-To: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> To: Vincenzo Pupillo References: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> X-Mailer: Apple Mail (2.3776.700.51) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73516-done Cc: 73516-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 27, 2024, at 6:00=E2=80=AFAM, Vincenzo Pupillo = wrote: >=20 > Ciao, > as usual the latest version of PHP grammar breaks the font lock. > This patch supports both the old and the latest grammar. > Version 0.23 supports the new features of PHP 8.4 (in release = candidate). >=20 > Thank you. > Vincenzo --Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6 Content-Disposition: attachment; filename=0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch Content-Type: text/x-patch; x-unix-mode=0644; name="0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch" Content-Transfer-Encoding: quoted-printable =46rom 669090265e653f457c7876461238c3898e4f3696 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Fri, 27 Sep 2024 13:07:06 +0200 Subject: [PATCH] Fix php-ts-mode font-lock for latest PHP grammar. Version 0.23 of the PHP grammar introduced some changes that affect the font lock. * lisp/progmodes/php-ts-mode.el (php-ts-mode--language-source-alist): Update php, html, js and css grammars version. (php-ts-mode--parent-html-heuristic): Fix docstring (php-ts-mode--test-namespace-name-as-prefix-p): New function. (php-ts-mode--test-namespace-aliasing-clause-p): New function. (php-ts-mode--test-namespace-use-group-clause-p): New function. (php-ts-mode--font-lock-settings): Use the new functions. --- lisp/progmodes/php-ts-mode.el | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el = b/lisp/progmodes/php-ts-mode.el index 3f89de14075..87aefaf451f 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -83,12 +83,12 @@ =20 ;;; Install treesitter language parsers (defvar php-ts-mode--language-source-alist - '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.8" = "php/src")) + '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.0" = "php/src")) (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) - (html . ("https://github.com/tree-sitter/tree-sitter-html" = "v0.20.3")) - (javascript . = ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2")) - (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" = "v0.21.0")) - (css . ("https://github.com/tree-sitter/tree-sitter-css" = "v0.21.0"))) + (html . ("https://github.com/tree-sitter/tree-sitter-html" = "v0.23.0")) + (javascript . = ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0")) + (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" = "v0.23.0")) + (css . ("https://github.com/tree-sitter/tree-sitter-css" = "v0.23.0"))) "Treesitter language parsers required by `php-ts-mode'. You can customize this variable if you want to stick to a specific commit and/or use different parsers.") @@ -490,7 +490,7 @@ php-ts-mode--parent-html-bol (treesit-node-start parent))))) =20 (defun php-ts-mode--parent-html-heuristic (node parent _bol &rest _) - "Returns position based on html indentation. + "Return position based on html indentation. =20 Returns 0 if the NODE is after the , otherwise returns the indentation point of the last word before the NODE, plus the @@ -773,6 +773,21 @@ php-ts-mode--predefined-constant "__FUNCTION__" "__LINE__" "__METHOD__" "__NAMESPACE__" "__TRAIT__") "PHP predefined constant.") =20 +(defun php-ts-mode--test-namespace-name-as-prefix-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, = nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) = t))) + +(defun php-ts-mode--test-namespace-aliasing-clause-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, = nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) = t))) + +(defun php-ts-mode--test-namespace-use-group-clause-p () + "Return t if the namespace_use_group_clause keyword is a namded node, = nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_use_group_clause)" = t) t))) + (defun php-ts-mode--font-lock-settings () "Tree-sitter font-lock settings." (treesit-font-lock-rules @@ -866,7 +881,7 @@ php-ts-mode--font-lock-settings :language 'php :feature 'definition :override t - '((php_tag) @font-lock-preprocessor-face + `((php_tag) @font-lock-preprocessor-face ("?>") @font-lock-preprocessor-face ;; Highlights identifiers in declarations. (class_declaration @@ -889,10 +904,16 @@ php-ts-mode--font-lock-settings ("=3D>") @font-lock-keyword-face (object_creation_expression (name) @font-lock-type-face) - (namespace_name_as_prefix "\\" @font-lock-delimiter-face) - (namespace_name_as_prefix (namespace_name (name)) = @font-lock-type-face) - (namespace_use_clause (name) @font-lock-property-use-face) - (namespace_aliasing_clause (name) @font-lock-type-face) + ,@(when (php-ts-mode--test-namespace-name-as-prefix-p) + '((namespace_name_as_prefix "\\" @font-lock-delimiter-face) + (namespace_name_as_prefix + (namespace_name (name)) @font-lock-type-face))) + ,@(if (php-ts-mode--test-namespace-aliasing-clause-p) + '((namespace_aliasing_clause (name) @font-lock-type-face)) + '((namespace_use_clause alias: (name) @font-lock-type-face))) + ,@(when (not (php-ts-mode--test-namespace-use-group-clause-p)) + '((namespace_use_group + (namespace_use_clause (name) @font-lock-type-face)))) (namespace_name "\\" @font-lock-delimiter-face) (namespace_name (name) @font-lock-type-face) (use_declaration (name) @font-lock-property-use-face)) @@ -931,8 +952,10 @@ php-ts-mode--font-lock-settings :language 'php :feature 'base-clause :override t - '((base_clause (name) @font-lock-type-face) + `((base_clause (name) @font-lock-type-face) (use_as_clause (name) @font-lock-property-use-face) + ,@(when (not (php-ts-mode--test-namespace-name-as-prefix-p)) + '((qualified_name prefix: "\\" @font-lock-delimiter-face))) (qualified_name (name) @font-lock-constant-face)) =20 :language 'php --=20 2.46.1 --Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Thanks! Merged to emacs-30. Yuan --Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6-- ------------=_1727511002-11426-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Sep 2024 13:32:46 +0000 Received: from localhost ([127.0.0.1]:33717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suB5R-0003k0-RI for submit@debbugs.gnu.org; Fri, 27 Sep 2024 09:32:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:38766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suB5P-0003jq-ST for submit@debbugs.gnu.org; Fri, 27 Sep 2024 09:32:44 -0400 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 1suAaX-0001qh-IA for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 09:00:50 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suAaT-0001N6-P0 for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 09:00:48 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5c5cc65a8abso2160276a12.3 for ; Fri, 27 Sep 2024 06:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727442043; x=1728046843; 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=76CTqJtcY5zqHwuM1YmQgJY8OltbfhNIl3UDhaXT69o=; b=hfSBZfkoSd23fsmFtRhQQWeiuoLzKLUINS14kwls4iUGf3Zr3kfd6rRiETwFSWLrD0 53DcOat73nAf90PYKqSH8kuIK6+N9kvsvFCRFDFgzgqKHhzsEegIORFsG+dlzvEwa8kl q3u/rBZK0L3Q7BdmQ+45fkopD3S9Y7tUVY0VuQjDsSi7i/sAQ5bY+Oa7V+U0T9H0gE6M RAwRXfOAJ6x7UM/ZdLSI3p4QipEOspvd6ZuH5S1wUn2UGeYOKaAZTLoOsyzTXxuM5mWw cSasYJaP5+ZLZgpM/FZhrisBxJoTfPf+w7fasKsdwUDMOBOFp8HzY3h5iEm0yEAjkcRB 372g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727442043; x=1728046843; 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=76CTqJtcY5zqHwuM1YmQgJY8OltbfhNIl3UDhaXT69o=; b=dglozDXhXUQbpIFxNkoBI38KFgKjTOf09pIdMGHV9rK2V5kCt0vd9sN+JdTOdGNAFm YLFm5n4dGOD+X5+4KJGmxFSPkhm22ilhuWLe7tjMS22x8vQonNo/yBhXZ/Hkg+HUNNHm usS1oiT3DZd9MRHFrBKOrdaxBEAR4NV2tStL/sRZZnhOZAsHMPfDpXJpdE3MEbUfzSrr zxLz7594w2L1c+U2UiJUSXR9gHERipG0YpJz+5t1v6nklN9coK4ANBznAChiNZNX1cFj mDv3RqqGrNk1t8Sw7VrQxA2+GD3tN21xA6nRmpJj4BpZnI2mvedjtwKgL5Pr+tbnJsxq C+Qw== X-Gm-Message-State: AOJu0Yxjk+WC75dCKMMcOg1qYHIj+TCfD28K6lqMkblkmsdUyN4pxiat sgqcufdBNQsdIigl2iMHXfTihBZ3BvfPp4b+IYCwoF4GSaLaeY9Zt1CzDw== X-Google-Smtp-Source: AGHT+IEDxO7NJEaQnQWlu5lyykeQ87ptU/tK7bC3aulPuKzrIEUhlktlOkqxIzqFprRu1p1yBFY9Fg== X-Received: by 2002:a17:907:748:b0:a86:a30f:4aef with SMTP id a640c23a62f3a-a93c49199b6mr256773266b.22.1727442042477; Fri, 27 Sep 2024 06:00:42 -0700 (PDT) Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27c5b7fsm132144066b.66.2024.09.27.06.00.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 06:00:41 -0700 (PDT) From: Vincenzo Pupillo To: Bug Emacs Subject: 30.0.91; [PATCH] php-ts-mode: add support for the latest grammar version. Date: Fri, 27 Sep 2024 15:00:40 +0200 Message-ID: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3688908.dWV9SEqChM" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=v.pupillo@gmail.com; helo=mail-ed1-x529.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --nextPart3688908.dWV9SEqChM Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Ciao, as usual the latest version of PHP grammar breaks the font lock. This patch supports both the old and the latest grammar. Version 0.23 supports the new features of PHP 8.4 (in release candidate). Thank you. Vincenzo --nextPart3688908.dWV9SEqChM Content-Disposition: attachment; filename="0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-php-ts-mode-font-lock-for-latest-PHP-grammar.patch" >From 669090265e653f457c7876461238c3898e4f3696 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Fri, 27 Sep 2024 13:07:06 +0200 Subject: [PATCH] Fix php-ts-mode font-lock for latest PHP grammar. Version 0.23 of the PHP grammar introduced some changes that affect the font lock. * lisp/progmodes/php-ts-mode.el (php-ts-mode--language-source-alist): Update php, html, js and css grammars version. (php-ts-mode--parent-html-heuristic): Fix docstring (php-ts-mode--test-namespace-name-as-prefix-p): New function. (php-ts-mode--test-namespace-aliasing-clause-p): New function. (php-ts-mode--test-namespace-use-group-clause-p): New function. (php-ts-mode--font-lock-settings): Use the new functions. --- lisp/progmodes/php-ts-mode.el | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 3f89de14075..87aefaf451f 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -83,12 +83,12 @@ ;;; Install treesitter language parsers (defvar php-ts-mode--language-source-alist - '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.8" "php/src")) + '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.0" "php/src")) (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) - (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.3")) - (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2")) - (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.21.0")) - (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0"))) + (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.0")) + (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0")) + (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.0")) + (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.23.0"))) "Treesitter language parsers required by `php-ts-mode'. You can customize this variable if you want to stick to a specific commit and/or use different parsers.") @@ -490,7 +490,7 @@ php-ts-mode--parent-html-bol (treesit-node-start parent))))) (defun php-ts-mode--parent-html-heuristic (node parent _bol &rest _) - "Returns position based on html indentation. + "Return position based on html indentation. Returns 0 if the NODE is after the , otherwise returns the indentation point of the last word before the NODE, plus the @@ -773,6 +773,21 @@ php-ts-mode--predefined-constant "__FUNCTION__" "__LINE__" "__METHOD__" "__NAMESPACE__" "__TRAIT__") "PHP predefined constant.") +(defun php-ts-mode--test-namespace-name-as-prefix-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) t))) + +(defun php-ts-mode--test-namespace-aliasing-clause-p () + "Return t if the namespace_name_as_prefix keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) t))) + +(defun php-ts-mode--test-namespace-use-group-clause-p () + "Return t if the namespace_use_group_clause keyword is a namded node, nil otherwise." + (ignore-errors + (progn (treesit-query-compile 'php "(namespace_use_group_clause)" t) t))) + (defun php-ts-mode--font-lock-settings () "Tree-sitter font-lock settings." (treesit-font-lock-rules @@ -866,7 +881,7 @@ php-ts-mode--font-lock-settings :language 'php :feature 'definition :override t - '((php_tag) @font-lock-preprocessor-face + `((php_tag) @font-lock-preprocessor-face ("?>") @font-lock-preprocessor-face ;; Highlights identifiers in declarations. (class_declaration @@ -889,10 +904,16 @@ php-ts-mode--font-lock-settings ("=>") @font-lock-keyword-face (object_creation_expression (name) @font-lock-type-face) - (namespace_name_as_prefix "\\" @font-lock-delimiter-face) - (namespace_name_as_prefix (namespace_name (name)) @font-lock-type-face) - (namespace_use_clause (name) @font-lock-property-use-face) - (namespace_aliasing_clause (name) @font-lock-type-face) + ,@(when (php-ts-mode--test-namespace-name-as-prefix-p) + '((namespace_name_as_prefix "\\" @font-lock-delimiter-face) + (namespace_name_as_prefix + (namespace_name (name)) @font-lock-type-face))) + ,@(if (php-ts-mode--test-namespace-aliasing-clause-p) + '((namespace_aliasing_clause (name) @font-lock-type-face)) + '((namespace_use_clause alias: (name) @font-lock-type-face))) + ,@(when (not (php-ts-mode--test-namespace-use-group-clause-p)) + '((namespace_use_group + (namespace_use_clause (name) @font-lock-type-face)))) (namespace_name "\\" @font-lock-delimiter-face) (namespace_name (name) @font-lock-type-face) (use_declaration (name) @font-lock-property-use-face)) @@ -931,8 +952,10 @@ php-ts-mode--font-lock-settings :language 'php :feature 'base-clause :override t - '((base_clause (name) @font-lock-type-face) + `((base_clause (name) @font-lock-type-face) (use_as_clause (name) @font-lock-property-use-face) + ,@(when (not (php-ts-mode--test-namespace-name-as-prefix-p)) + '((qualified_name prefix: "\\" @font-lock-delimiter-face))) (qualified_name (name) @font-lock-constant-face)) :language 'php -- 2.46.1 --nextPart3688908.dWV9SEqChM-- ------------=_1727511002-11426-1--