Skip to content

Commit

Permalink
Add -traditional and -standard faces to call faces
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe committed Jun 20, 2024
1 parent ee88d59 commit 0ed7faa
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
* `php-$this``php-this`
* `php-$this-sigil``php-this-sigil`
* Add `php-function-call-standard` face inherit `font-lock-function-call-face` on Emacs 29.1 and above ([#782], thanks [@bricka]!)
* Add `-tranditional` suffix to the `php-*-call` faces.
* `php-function-call``php-function-call-traditional`
* `php-method-call``php-method-call-traditional`
* `php-static-method-call``php-static-method-call-traditional`
* Add variables for the `php-function-call`, `php-method-call`, and `php-static-method-call` faces, defaulting to the `-traditional` face.

### Removed

Expand Down
28 changes: 22 additions & 6 deletions lisp/php-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,36 @@
:group 'php-faces
:tag "PHP Function Call Standard")

(defface php-function-call '((t ()))
(defface php-function-call-traditional '((t ()))
"PHP Mode face used to highlight function names in calles."
:group 'php-faces
:tag "PHP Function Call")
:tag "PHP Function Call Traditional")

(defface php-method-call '((t (:inherit php-function-call)))
(define-obsolete-face-alias 'php-function-call 'php-function-call-traditional "1.26.0")

(defface php-method-call-standard '((t (:inherit php-function-call-standard)))
"PHP Mode face used to highlight method names in calles."
:group 'php-faces
:tag "PHP Method Call")
:tag "PHP Method Call Standard")

(defface php-method-call-traditional '((t (:inherit php-function-call-traditional)))
"PHP Mode face used to highlight method names in calles."
:group 'php-faces
:tag "PHP Method Call Traditional")

(define-obsolete-face-alias 'php-method-call 'php-method-call-traditional "1.26.0")

(defface php-static-method-call '((t (:inherit php-method-call)))
(defface php-static-method-call-standard '((t (:inherit php-method-call-standard)))
"PHP Mode face used to highlight static method names in calles."
:group 'php-faces
:tag "PHP Static Method Call")
:tag "PHP Static Method Call Standard")

(defface php-static-method-call-traditional '((t (:inherit php-method-call-traditional)))
"PHP Mode face used to highlight static method names in calles."
:group 'php-faces
:tag "PHP Static Method Call Traditional")

(define-obsolete-face-alias 'php-static-method-call 'php-static-method-call-traditional "1.26.0")

(defface php-variable-name '((t (:inherit font-lock-variable-name-face)))
"PHP Mode face used to highlight variable names."
Expand Down
6 changes: 3 additions & 3 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ for \\[find-tag] (which see)."

;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but
;; not in $obj->var()
("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call))
("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 php-method-call))
("\\<\\(const\\)\\s-+\\(\\_<.+?\\_>\\)" (1 'php-keyword) (2 'php-constant-assign))

;; Logical operator (!)
Expand Down Expand Up @@ -1413,7 +1413,7 @@ for \\[find-tag] (which see)."

;; Highlight static method calls as such. This is necessary for method
;; names which are identical to keywords to be highlighted correctly.
("\\sw+::\\(\\sw+\\)(" 1 'php-static-method-call)
("\\sw+::\\(\\sw+\\)(" 1 php-static-method-call)
;; Multiple catch (FooException | BarException $e)
(,(rx symbol-start "catch" symbol-end
(* (syntax whitespace)) "(" (* (syntax whitespace))
Expand Down Expand Up @@ -1457,7 +1457,7 @@ for \\[find-tag] (which see)."
(1 'php-import-declaration)
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign t)))
;; Highlight function calls
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 php-function-call)
;; Highlight all upper-cased symbols as constant
("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant)

Expand Down
18 changes: 18 additions & 0 deletions lisp/php.el
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,24 @@ a completion list."
:group 'php
:tag "PHP Topsy Separator"
:type 'string)

(defcustom php-function-call 'php-function-call-traditional
"Face name to use for method call."
:group 'php
:tag "PHP Function Call"
:type 'face)

(defcustom php-method-call 'php-method-call-traditional
"Face name to use for method call."
:group 'php
:tag "PHP Method Call"
:type 'face)

(defcustom php-static-method-call 'php-static-method-call-traditional
"Face name to use for method call."
:group 'php
:tag "PHP Static Method Call"
:type 'face)

;;; PHP Keywords
(defconst php-magical-constants
Expand Down

0 comments on commit 0ed7faa

Please sign in to comment.