From 0e4d7db6c8b09046d50a7dea33676c490940afc1 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 28 May 2024 03:32:01 +0900 Subject: [PATCH] Remove $ from facename for interop with treesit --- CHANGELOG.md | 5 +++++ lisp/php-face.el | 7 +++++-- lisp/php-mode.el | 2 +- tests/7.4/typed-property.php.faces | 8 ++++---- tests/issue-136.php.faces | 4 ++-- tests/issue-201.php.faces | 4 ++-- tests/lang/doc-comment/comments.php.24.faces | 4 ++-- tests/lang/doc-comment/comments.php.27.faces | 4 ++-- tests/lang/doc-comment/comments.php.faces | 4 ++-- tests/php-mode-test.el | 4 ++-- 10 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11708e02..3ec3ec28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Modify indentation of [PEAR Coding Standards] ([#774], [#777]) * No longer overindent it by default, since we don't see any mention in the coding style that it should hang `.`. (refs [#227] and [#229]) * **If you have any feedback on PEAR style, please let us know in [the discussion #776][#776].** + * Remove `$` from face names for interoperability with treesit ([#780], [emacs-php/php-ts-mode#68]) + * `php-$this` → `php-this` + * `php-$this-sigil` → `php-this-sigil` ### Removed @@ -28,6 +31,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [#775]: https://github.com/emacs-php/php-mode/pull/775 [#776]: https://github.com/emacs-php/php-mode/discussions/776 [#777]: https://github.com/emacs-php/php-mode/pull/777 +[#780]: https://github.com/emacs-php/php-mode/issues/780 +[emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68 [PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php ## [1.25.1] - 2023-11-24 diff --git a/lisp/php-face.el b/lisp/php-face.el index 70db33e0..d5ac817b 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -156,16 +156,19 @@ The operator is also knows as \"Paamayim Nekudotayim\"." :group 'php-faces :tag "PHP Magical Constant") -(defface php-$this '((t (:inherit php-constant))) +(defface php-this '((t (:inherit php-constant))) "PHP Mode face used to highlight $this variables." :group 'php-faces :tag "PHP $this") -(defface php-$this-sigil '((t (:inherit php-constant))) +(defface php-this-sigil '((t (:inherit php-constant))) "PHP Mode face used to highlight sigils($) of $this variable." :group 'php-faces :tag "PHP $this Sigil") +(define-obsolete-face-alias 'php-$this 'php-this "1.26.0") +(define-obsolete-face-alias 'php-$this-sigil 'php-this-sigil "1.26.0") + (defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) "PHP Mode face used to highlight errorcontrol operators (@).." :group 'php-faces diff --git a/lisp/php-mode.el b/lisp/php-mode.el index d66cf0af..3ec28d66 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1378,7 +1378,7 @@ for \\[find-tag] (which see)." ("\\(!\\)[^=]" 1 'php-logical-op) ;; Highlight special variables - ("\\(\\$\\)\\(this\\)\\>" (1 'php-$this-sigil) (2 'php-$this)) + ("\\(\\$\\)\\(this\\)\\>" (1 'php-this-sigil) (2 'php-this)) ("\\(\\$+\\)\\(\\sw+\\)" (1 'php-variable-sigil) (2 'php-variable-name)) ("\\(->\\)\\([a-zA-Z0-9_]+\\)" (1 'php-object-op) (2 'php-property-name)) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index fac03f33..93779d5c 100644 --- a/tests/7.4/typed-property.php.faces +++ b/tests/7.4/typed-property.php.faces @@ -32,8 +32,8 @@ (" ") ("null" . php-constant) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("string" . php-property-name) (" ") @@ -50,8 +50,8 @@ ("()\n {\n ") ("var_dump" . php-function-call) ("(") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("string" . php-property-name) (");\n }\n}\n\n(") diff --git a/tests/issue-136.php.faces b/tests/issue-136.php.faces index 538cdd97..0e5d6b71 100644 --- a/tests/issue-136.php.faces +++ b/tests/issue-136.php.faces @@ -103,8 +103,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" = ") diff --git a/tests/issue-201.php.faces b/tests/issue-201.php.faces index 7cd5f111..5801ea2a 100644 --- a/tests/issue-201.php.faces +++ b/tests/issue-201.php.faces @@ -8,8 +8,8 @@ ("\n\n") ("// " . font-lock-comment-delimiter-face) ("Start:\n" . font-lock-comment-face) - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) (";\n") ("$" . php-variable-sigil) ("that" . php-variable-name) diff --git a/tests/lang/doc-comment/comments.php.24.faces b/tests/lang/doc-comment/comments.php.24.faces index 593bb49e..ca033603 100644 --- a/tests/lang/doc-comment/comments.php.24.faces +++ b/tests/lang/doc-comment/comments.php.24.faces @@ -105,8 +105,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index 8b3b78e5..9b2fe992 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -106,8 +106,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index 593bb49e..ca033603 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -105,8 +105,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index dde44c7f..9890e0c8 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -533,8 +533,8 @@ style from Drupal." (should (eq 'php-variable-name (get-text-property (1- (point)) 'face))) (search-forward "$this") - (should (eq 'php-$this-sigil (get-text-property (match-beginning 0) 'face))) - (should (eq 'php-$this (get-text-property (1+ (match-beginning 0)) 'face))) + (should (eq 'php-this-sigil (get-text-property (match-beginning 0) 'face))) + (should (eq 'php-this (get-text-property (1+ (match-beginning 0)) 'face))) (search-forward "$x") (should (eq 'php-variable-sigil (get-text-property (match-beginning 0) 'face)))