branch: elpa/php-mode
commit 4792988a120d6ac515ba16605278d04cb8be0d69
Merge: c8e4c16ca0 ccd28de9b8
Author: USAMI Kenta <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #784 from emacs-php/feature/php-function-call-face
Add `font-lock-function-call` compatible faces
---
AUTHORS.md | 1 +
CHANGELOG.md | 8 +++++++
lisp/php-face.el | 34 +++++++++++++++++++++++-----
lisp/php-mode.el | 6 ++---
lisp/php.el | 18 +++++++++++++++
tests/7.4/typed-property.php.faces | 4 ++--
tests/8.0/attribute/class.php.faces | 12 +++++-----
tests/8.0/attribute/function.php.faces | 8 +++----
tests/constants.php.faces | 2 +-
tests/identifiers.php.faces | 6 ++---
tests/issue-197.php.faces | 4 ++--
tests/issue-201.php.faces | 6 ++---
tests/issue-439.php.faces | 4 ++--
tests/lang/class/anonymous-class.php.faces | 2 +-
tests/lang/doc-comment/comments.php.24.faces | 2 +-
tests/lang/doc-comment/comments.php.27.faces | 2 +-
tests/lang/doc-comment/comments.php.faces | 2 +-
tests/lang/function/calls.php.faces | 24 ++++++++++----------
tests/lang/function/closure.php.faces | 6 ++---
tests/static-method-calls.php.faces | 18 +++++++--------
tests/variables.php.faces | 2 +-
21 files changed, 110 insertions(+), 61 deletions(-)
diff --git a/AUTHORS.md b/AUTHORS.md
index bdd02614ce..2c25aaee2d 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -24,6 +24,7 @@ Names Sorted Alphabetically:
- Aaron S. Hawley
- Alan Pearce
+- Alex Figl-Brick
- Andreas Röhler
- Andrei Chițu
- Antoine Brand
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ec3ec288c..8a62ff7a24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,12 @@ All notable changes of the PHP Mode 1.19.1 release series
are documented in this
* 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`
+ * 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
@@ -32,6 +38,8 @@ All notable changes of the PHP Mode 1.19.1 release series are
documented in this
[#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
+[#782]: https://github.com/emacs-php/php-mode/issues/782
+[@bricka]: https://github.com/bricka
[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
diff --git a/lisp/php-face.el b/lisp/php-face.el
index d5ac817b9a..4f16a8160f 100644
--- a/lisp/php-face.el
+++ b/lisp/php-face.el
@@ -55,20 +55,42 @@
:group 'php-faces
:tag "PHP Function Name")
-(defface php-function-call '((t ()))
+(defface php-function-call-standard `((t ,(when (eval-when-compile (get
'font-lock-function-call-face 'face-defface-spec))
+ '(:inherit
font-lock-function-call-face))))
"PHP Mode face used to highlight function names in calles."
:group 'php-faces
- :tag "PHP Function Call")
+ :tag "PHP Function Call Standard")
-(defface php-method-call '((t (:inherit php-function-call)))
+(defface php-function-call-traditional '((t ()))
+ "PHP Mode face used to highlight function names in calles."
+ :group 'php-faces
+ :tag "PHP Function Call Traditional")
+
+(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 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")
+ :tag "PHP Method Call Traditional")
+
+(define-obsolete-face-alias 'php-method-call 'php-method-call-traditional
"1.26.0")
+
+(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 Standard")
-(defface php-static-method-call '((t (:inherit php-method-call)))
+(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")
+ :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."
diff --git a/lisp/php-mode.el b/lisp/php-mode.el
index 3ec28d66e3..cfb1f17f04 100644
--- a/lisp/php-mode.el
+++ b/lisp/php-mode.el
@@ -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 (!)
@@ -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))
@@ -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)
diff --git a/lisp/php.el b/lisp/php.el
index 32142cb010..e78c7c97dd 100644
--- a/lisp/php.el
+++ b/lisp/php.el
@@ -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
diff --git a/tests/7.4/typed-property.php.faces
b/tests/7.4/typed-property.php.faces
index 93779d5c14..660b7b0ad2 100644
--- a/tests/7.4/typed-property.php.faces
+++ b/tests/7.4/typed-property.php.faces
@@ -48,7 +48,7 @@
(" ")
("print" . php-function-name)
("()\n {\n ")
- ("var_dump" . php-function-call)
+ ("var_dump" . php-function-call-traditional)
("(")
("$" . php-this-sigil)
("this" . php-this)
@@ -60,5 +60,5 @@
("Typed" . font-lock-type-face)
(")")
("->" . php-object-op)
- ("print" . php-method-call)
+ ("print" . php-method-call-traditional)
("();\n"))
diff --git a/tests/8.0/attribute/class.php.faces
b/tests/8.0/attribute/class.php.faces
index a43816573f..1d249b6ac3 100644
--- a/tests/8.0/attribute/class.php.faces
+++ b/tests/8.0/attribute/class.php.faces
@@ -24,10 +24,10 @@
#[WithoutArgument]
#[")
- ("SingleArgument" . php-function-call)
+ ("SingleArgument" . php-function-call-traditional)
("(0)]
#[")
- ("FewArguments" . php-function-call)
+ ("FewArguments" . php-function-call-traditional)
("(")
("'Hello'" . php-string)
(", ")
@@ -40,9 +40,9 @@
("() {}
#[WithoutArgument] #[")
- ("SingleArgument" . php-function-call)
+ ("SingleArgument" . php-function-call-traditional)
("(0)] #[")
- ("FewArguments" . php-function-call)
+ ("FewArguments" . php-function-call-traditional)
("(")
("'Hello'" . php-string)
(", ")
@@ -55,11 +55,11 @@
("() {}
#[")
- ("Attr2" . php-function-call)
+ ("Attr2" . php-function-call-traditional)
("(")
("\"foo\"" . php-string)
("), ")
- ("Attr2" . php-function-call)
+ ("Attr2" . php-function-call-traditional)
("(")
("\"bar\"" . php-string)
(")]
diff --git a/tests/8.0/attribute/function.php.faces
b/tests/8.0/attribute/function.php.faces
index da2aea6c41..00cedf0730 100644
--- a/tests/8.0/attribute/function.php.faces
+++ b/tests/8.0/attribute/function.php.faces
@@ -11,10 +11,10 @@
#[WithoutArgument]
#[")
- ("SingleArgument" . php-function-call)
+ ("SingleArgument" . php-function-call-traditional)
("(0)]
#[")
- ("FewArguments" . php-function-call)
+ ("FewArguments" . php-function-call-traditional)
("(")
("'Hello'" . php-string)
(", ")
@@ -27,9 +27,9 @@
("() {}
#[WithoutArgument]#[")
- ("SingleArgument" . php-function-call)
+ ("SingleArgument" . php-function-call-traditional)
("(0)]#[")
- ("FewArguments" . php-function-call)
+ ("FewArguments" . php-function-call-traditional)
("(")
("'Hello'" . php-string)
(", ")
diff --git a/tests/constants.php.faces b/tests/constants.php.faces
index 28f9523d54..6718eb4490 100644
--- a/tests/constants.php.faces
+++ b/tests/constants.php.faces
@@ -46,7 +46,7 @@
(";\n")
("SomeClass" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("classIdentifier" . php-static-method-call)
+ ("classIdentifier" . php-static-method-call-traditional)
("();\n\n")
("__halt_compiler" . php-keyword)
("();\n\n")
diff --git a/tests/identifiers.php.faces b/tests/identifiers.php.faces
index fbb56dfa00..df098c908e 100644
--- a/tests/identifiers.php.faces
+++ b/tests/identifiers.php.faces
@@ -43,15 +43,15 @@
("the constant face. Just like c++-mode \"NS::Class::method()\"\n" .
font-lock-comment-face)
("ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n")
("\\SpaceName\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n")
("\\My_Class" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n\n")
("__halt_compiler" . php-keyword)
("();\n\n")
diff --git a/tests/issue-197.php.faces b/tests/issue-197.php.faces
index 94f2abefac..85469d9d9e 100644
--- a/tests/issue-197.php.faces
+++ b/tests/issue-197.php.faces
@@ -21,10 +21,10 @@
("$" . php-variable-sigil)
("test" . php-variable-name)
("->" . php-object-op)
- ("int" . php-method-call)
+ ("int" . php-method-call-traditional)
("();\n")
("$" . php-variable-sigil)
("test" . php-variable-name)
("->" . php-object-op)
- ("string" . php-method-call)
+ ("string" . php-method-call-traditional)
("();\n"))
diff --git a/tests/issue-201.php.faces b/tests/issue-201.php.faces
index 5801ea2acb..5c3ccda843 100644
--- a/tests/issue-201.php.faces
+++ b/tests/issue-201.php.faces
@@ -16,13 +16,13 @@
(";\n")
("self" . php-keyword)
("::" . php-paamayim-nekudotayim)
- ("test" . php-static-method-call)
+ ("test" . php-static-method-call-traditional)
("();\n")
("static" . php-keyword)
("::" . php-paamayim-nekudotayim)
- ("test" . php-static-method-call)
+ ("test" . php-static-method-call-traditional)
("();\n")
("parent" . php-keyword)
("::" . php-paamayim-nekudotayim)
- ("test" . php-static-method-call)
+ ("test" . php-static-method-call-traditional)
("();\n"))
diff --git a/tests/issue-439.php.faces b/tests/issue-439.php.faces
index 595bcbab7f..bc3094e6bd 100644
--- a/tests/issue-439.php.faces
+++ b/tests/issue-439.php.faces
@@ -52,7 +52,7 @@
(" ")
("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string)
(";\n\n")
- ("var_dump" . php-function-call)
+ ("var_dump" . php-function-call-traditional)
("(")
("<<<\"ABC\"\nLet'go Justin\nABC" . php-string)
(");\n\n")
@@ -60,7 +60,7 @@
(" (1 ")
("===" . php-comparison-op)
(" 1) {\n ")
- ("var_dump" . php-function-call)
+ ("var_dump" . php-function-call-traditional)
("(")
("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string)
(");\n}\n"))
diff --git a/tests/lang/class/anonymous-class.php.faces
b/tests/lang/class/anonymous-class.php.faces
index 415bcaa251..bd0df9ced2 100644
--- a/tests/lang/class/anonymous-class.php.faces
+++ b/tests/lang/class/anonymous-class.php.faces
@@ -17,7 +17,7 @@
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("};\n\n")
- ("is_object" . php-function-call)
+ ("is_object" . php-function-call-traditional)
("(1, ")
("new" . php-keyword)
(" ")
diff --git a/tests/lang/doc-comment/comments.php.24.faces
b/tests/lang/doc-comment/comments.php.24.faces
index ca03360391..06f70485f7 100644
--- a/tests/lang/doc-comment/comments.php.24.faces
+++ b/tests/lang/doc-comment/comments.php.24.faces
@@ -134,7 +134,7 @@
(" ")
("=" . php-assignment-op)
(" ")
- ("hoge" . php-function-call)
+ ("hoge" . php-function-call-traditional)
("();\n\n ")
("// " . font-lock-comment-delimiter-face)
("one-line comment\n" . font-lock-comment-face)
diff --git a/tests/lang/doc-comment/comments.php.27.faces
b/tests/lang/doc-comment/comments.php.27.faces
index 9b2fe992af..70c23fb3aa 100644
--- a/tests/lang/doc-comment/comments.php.27.faces
+++ b/tests/lang/doc-comment/comments.php.27.faces
@@ -135,7 +135,7 @@
(" ")
("=" . php-assignment-op)
(" ")
- ("hoge" . php-function-call)
+ ("hoge" . php-function-call-traditional)
("();\n\n ")
("// " . font-lock-comment-delimiter-face)
("one-line comment\n" . font-lock-comment-face)
diff --git a/tests/lang/doc-comment/comments.php.faces
b/tests/lang/doc-comment/comments.php.faces
index ca03360391..06f70485f7 100644
--- a/tests/lang/doc-comment/comments.php.faces
+++ b/tests/lang/doc-comment/comments.php.faces
@@ -134,7 +134,7 @@
(" ")
("=" . php-assignment-op)
(" ")
- ("hoge" . php-function-call)
+ ("hoge" . php-function-call-traditional)
("();\n\n ")
("// " . font-lock-comment-delimiter-face)
("one-line comment\n" . font-lock-comment-face)
diff --git a/tests/lang/function/calls.php.faces
b/tests/lang/function/calls.php.faces
index 19d681c557..7713374ae8 100644
--- a/tests/lang/function/calls.php.faces
+++ b/tests/lang/function/calls.php.faces
@@ -9,73 +9,73 @@
("foo" . php-variable-name)
(")) {\n 1")
("+" . php-arithmetic-op)
- ("bar" . php-function-call)
+ ("bar" . php-function-call-traditional)
("()+")
- ("foo" . php-function-call)
+ ("foo" . php-function-call-traditional)
("();\n}\n\n")
("$" . php-variable-sigil)
("foo" . php-variable-name)
("->" . php-object-op)
- ("string" . php-method-call)
+ ("string" . php-method-call-traditional)
("();\n")
("$" . php-variable-sigil)
("foo" . php-variable-name)
("->" . php-object-op)
- ("isset" . php-method-call)
+ ("isset" . php-method-call-traditional)
("();\n\n\n")
("$" . php-variable-sigil)
("a" . php-variable-name)
("->" . php-object-op)
- ("b" . php-method-call)
+ ("b" . php-method-call-traditional)
("();\n")
("$" . php-variable-sigil)
("a" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("a" . php-function-call)
+ ("a" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("aaa" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("aaa" . php-function-call)
+ ("aaa" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("_aa" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("_aa" . php-function-call)
+ ("_aa" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("a_a" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("a_a" . php-function-call)
+ ("a_a" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("aa_" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("aa_" . php-function-call)
+ ("aa_" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("a1c" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("a1c" . php-function-call)
+ ("a1c" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("あ" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
- ("あ" . php-function-call)
+ ("あ" . php-function-call-traditional)
("();\n")
("$" . php-variable-sigil)
("_a" . php-variable-name)
diff --git a/tests/lang/function/closure.php.faces
b/tests/lang/function/closure.php.faces
index 1d671f7253..9bf83b50bf 100644
--- a/tests/lang/function/closure.php.faces
+++ b/tests/lang/function/closure.php.faces
@@ -1,7 +1,7 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n\n")
- ("is_object" . php-function-call)
+ ("is_object" . php-function-call-traditional)
("(")
("static" . php-keyword)
(" ")
@@ -10,7 +10,7 @@
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("});\n\n")
- ("is_object" . php-function-call)
+ ("is_object" . php-function-call-traditional)
("(")
("static" . php-keyword)
(" ")
@@ -20,4 +20,4 @@
(" {\n ")
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
- ("});\n"))
\ No newline at end of file
+ ("});\n"))
diff --git a/tests/static-method-calls.php.faces
b/tests/static-method-calls.php.faces
index 34e77b9186..8cdd081581 100644
--- a/tests/static-method-calls.php.faces
+++ b/tests/static-method-calls.php.faces
@@ -3,37 +3,37 @@
("\n\n")
("ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n")
("\\Project\\Module\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n")
("\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("method" . php-static-method-call)
+ ("method" . php-static-method-call-traditional)
("();\n\n")
("ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("new" . php-static-method-call)
+ ("new" . php-static-method-call-traditional)
("();\n")
("\\Project\\Module\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("new" . php-static-method-call)
+ ("new" . php-static-method-call-traditional)
("();\n")
("\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("new" . php-static-method-call)
+ ("new" . php-static-method-call-traditional)
("();\n\n")
("ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("clone" . php-static-method-call)
+ ("clone" . php-static-method-call-traditional)
("();\n")
("\\Project\\Module\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("clone" . php-static-method-call)
+ ("clone" . php-static-method-call-traditional)
("();\n")
("\\ClassName" . php-constant)
("::" . php-paamayim-nekudotayim)
- ("clone" . php-static-method-call)
+ ("clone" . php-static-method-call-traditional)
("();\n"))
diff --git a/tests/variables.php.faces b/tests/variables.php.faces
index 7a7573c537..c777aa4ea5 100644
--- a/tests/variables.php.faces
+++ b/tests/variables.php.faces
@@ -56,5 +56,5 @@
("$" . php-variable-sigil)
("object" . php-variable-name)
("->" . php-object-op)
- ("funCall" . php-method-call)
+ ("funCall" . php-method-call-traditional)
("();\n"))