From d0949f1c17d1e72de1ac44ac72535c374ebf9e5a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 12 Feb 2023 02:10:36 +0900 Subject: [PATCH] Add "use function" and "use const" to font-lock-keyword --- lisp/php-mode.el | 10 ++++++ tests/lang/import/import-constant.php | 8 +++++ tests/lang/import/import-constant.php.faces | 31 +++++++++++++++++ tests/lang/import/import-function.php | 7 ++++ tests/lang/import/import-function.php.faces | 37 +++++++++++++++++++++ tests/php-mode-test.el | 2 ++ 6 files changed, 95 insertions(+) create mode 100644 tests/lang/import/import-constant.php create mode 100644 tests/lang/import/import-constant.php.faces create mode 100644 tests/lang/import/import-function.php create mode 100644 tests/lang/import/import-function.php.faces diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 179d5c90..407745b3 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1396,6 +1396,11 @@ for \\[find-tag] (which see)." ("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec) ;; Namespace declaration ("\\_" . 'php-namespace-declaration) + ;; import constant statement + (,(rx symbol-start (group "use" (+ (syntax whitespace)) "const") + (+ (syntax whitespace))) + (1 'php-import-declaration) + (,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign))) ;; import statement ("\\_" . 'php-import-declaration) ;; Class modifiers (abstract, final) @@ -1478,6 +1483,11 @@ for \\[find-tag] (which see)." ;; is usually overkill. `( ("\\<\\(@\\)" 1 'php-errorcontrol-op) + ;; import function statement + (,(rx symbol-start (group "use" (+ (syntax whitespace)) "function") + (+ (syntax whitespace))) + (1 'php-import-declaration) + (,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-function-name t))) ;; Highlight function calls ("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call) ;; Highlight all upper-cased symbols as constant diff --git a/tests/lang/import/import-constant.php b/tests/lang/import/import-constant.php new file mode 100644 index 00000000..791e241a --- /dev/null +++ b/tests/lang/import/import-constant.php @@ -0,0 +1,8 @@ +