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.bugs Subject: 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 Message-ID: <46C10E7C-C98F-4FA6-887A-EFD7EB306FC4@gmail.com> References: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_27E14A5F-6669-48CF-A375-E866CE2B59B6" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32243"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73516-done@debbugs.gnu.org To: Vincenzo Pupillo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 28 10:09:57 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1suSWb-0008EI-0v for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Sep 2024 10:09:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suSWG-0000KE-3D; Sat, 28 Sep 2024 04:09:36 -0400 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 1suSWD-0000JI-16 for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:09:33 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suSWC-0003XG-OA for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:09:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:Date:Mime-Version:From:To:Subject; bh=ZgMqKMF8+qW8Q7CfZapOizDHJgc8OeVkShVJCMiD9cQ=; b=rlyWett5TakudVzjnvIxqPQi3ecpnoGj1q2Il5B3qbcLvXRBuSQ9jeWRxRvaRRuKtOX5hUDlzUzAFIbWcpKhXpBjTf/bfSPxWQ43vL0q8dcF9uOKzxC3oO0om3LKFm3flXVN7vqPlJV/VvcLlPHMzE3sNha6Pg6u5oQDadEb16sMdmseQpujP9Rn7cG9lKBA3y7daKr8HMS5SdsYVrrE+Kz3xNLFcxhBUxHIciCJA8BTV4GQb+oCm6uwal25ZBag1ogD3hWGkhz3XT0f+9K23IbcjwwtzXnTGyyb6qiImd837tnXolviWA8fx8qrObyw/1sz65XdxWpwy/MIJNfqBA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1suSWg-0002yO-3I for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:10:02 -0400 Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2024 08:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 73516 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 73516@debbugs.gnu.org, casouri@gmail.com, v.pupillo@gmail.com Original-Received: via spool by 73516-done@debbugs.gnu.org id=D73516.172751098711395 (code D ref 73516); Sat, 28 Sep 2024 08:10:01 +0000 Original-Received: (at 73516-done) by debbugs.gnu.org; 28 Sep 2024 08:09:47 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <2626895.XAFRqVoOGU@3-191.divsi.unimi.it> X-Mailer: Apple Mail (2.3776.700.51) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292546 Archived-At: --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--