Skip to content

Commit

Permalink
Merge pull request #781 from emacs-php/rename/php-this-face
Browse files Browse the repository at this point in the history
Remove $ from facename for interop with treesit
  • Loading branch information
zonuexe committed May 27, 2024
2 parents 4bc08f6 + 0e4d7db commit c8e4c16
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lisp/php-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
8 changes: 4 additions & 4 deletions tests/7.4/typed-property.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(" ")
Expand All @@ -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(")
Expand Down
4 changes: 2 additions & 2 deletions tests/issue-136.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(" = ")
Expand Down
4 changes: 2 additions & 2 deletions tests/issue-201.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/lang/doc-comment/comments.php.24.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(" ")
Expand Down
4 changes: 2 additions & 2 deletions tests/lang/doc-comment/comments.php.27.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(" ")
Expand Down
4 changes: 2 additions & 2 deletions tests/lang/doc-comment/comments.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(" ")
Expand Down
4 changes: 2 additions & 2 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit c8e4c16

Please sign in to comment.