From ee88d597bed1be3dab481513411ba91e46d24da3 Mon Sep 17 00:00:00 2001 From: Alex Figl-Brick Date: Thu, 20 Jun 2024 15:23:33 +0900 Subject: [PATCH 1/3] Add php-function-call-standard inherit font-lock-function-call-face --- AUTHORS.md | 1 + CHANGELOG.md | 3 +++ lisp/php-face.el | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index bdd02614..2c25aaee 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 3ec3ec28..84abbfb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ 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]!) ### Removed @@ -32,6 +33,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 d5ac817b..bb07e531 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -55,6 +55,12 @@ :group 'php-faces :tag "PHP Function Name") +(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 Standard") + (defface php-function-call '((t ())) "PHP Mode face used to highlight function names in calles." :group 'php-faces From 0ed7faa0b504d9fea62e66d52de9d8c85d29a43d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 20 Jun 2024 16:29:19 +0900 Subject: [PATCH 2/3] Add -traditional and -standard faces to call faces --- CHANGELOG.md | 5 +++++ lisp/php-face.el | 28 ++++++++++++++++++++++------ lisp/php-mode.el | 6 +++--- lisp/php.el | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84abbfb5..8a62ff7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lisp/php-face.el b/lisp/php-face.el index bb07e531..4f16a816 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -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." diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 3ec28d66..cfb1f17f 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 32142cb0..e78c7c97 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 From ccd28de9b881fea3d76e51785fa2e0da9e05347c Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 20 Jun 2024 16:29:43 +0900 Subject: [PATCH 3/3] Fix tests --- 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 +- 16 files changed, 52 insertions(+), 52 deletions(-) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index 93779d5c..660b7b0a 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 a4381657..1d249b6a 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 da2aea6c..00cedf07 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 28f9523d..6718eb44 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 fbb56dfa..df098c90 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 94f2abef..85469d9d 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 5801ea2a..5c3ccda8 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 595bcbab..bc3094e6 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 415bcaa2..bd0df9ce 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 ca033603..06f70485 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 9b2fe992..70c23fb3 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 ca033603..06f70485 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 19d681c5..7713374a 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 1d671f72..9bf83b50 100644 --- a/tests/lang/function/closure.php.faces +++ b/tests/lang/function/closure.php.faces @@ -1,7 +1,7 @@ ;; -*- mode: emacs-lisp -*- (("" . php-object-op) - ("funCall" . php-method-call) + ("funCall" . php-method-call-traditional) ("();\n"))