From 39ed76f779983ffd8ce720d8506d05b5f4925b29 Mon Sep 17 00:00:00 2001 From: "U-CPT\\deb" Date: Tue, 3 Dec 2019 17:35:18 +0100 Subject: [PATCH 1/2] Add support for logical-, comparison-, arithmetic-, increment- and decrement operators. Add faces for increment-, decrement- and arithmetic operators --- php-face.el | 10 ++++++++++ php-mode.el | 24 ++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/php-face.el b/php-face.el index 1e060082..5bd821e5 100644 --- a/php-face.el +++ b/php-face.el @@ -106,6 +106,16 @@ :group 'php-faces :tag "PHP Logical Op") +(defface php-arithmetic-op '((t (:inherit php-operator))) + "PHP Mode face used to arithmetic operators (+, -, %, ...)." + :group 'php-faces + :tag "PHP Arithmetic Op") + +(defface php-inc-dec-op '((t (:inherit php-operator))) + "PHP Mode face used to increment and decremt operators (--, ++)." + :group 'php-faces + :tag "PHP Increment/Decrement Op") + (defface php-string-op '((t (:inherit php-operator))) "PHP Mode face used to logical operators (.)." :group 'php-faces diff --git a/php-mode.el b/php-mode.el index 2477d69f..290a5d20 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1543,11 +1543,14 @@ a completion list." ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) ("\\<\\(const\\)\\s-+\\(\\_<.+?\\_>\\)" (1 'php-keyword) (2 'php-constant-assign)) + ;; Logical operator (!) + ("\\(![^=]\\)" 1 'php-logical-op) + ;; Highlight special variables ("\\(\\$\\)\\(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)) - + ;; Highlight function/method names ("\\]+?\\([\-+./%]?=\\)[^=]+?\\)" 2 'php-assignment-op) + + ;; Comparison operatoes (==, ===, >=, ...) + ("\\([!=]=\\{1,2\\}[>]?\\|[<>]=?\\)" 1 'php-comparison-op) + + ;; Arithmetic operators (+, -, *, **, /, %) + ("\\(?:[A-Za-z0-9[:blank:]]\\)\\([\-+*/%]\\*?\\)\\(?:[A-Za-z0-9[:blank:]]\\)" 1 'php-arithmetic-op) + + ;; Increment and Decrement operators (++, --) + ("\\(\-\-\\|\+\+\\)\$\\w+" 1 'php-inc-dec-op) ;; pre inc/dec + ("\$\\w+\\(\-\-\\|\+\+\\)" 1 'php-inc-dec-op) ;; post inc/dec + + ;; Logical operators (and, or, &&, ...) + ;; Not operator (!) is defined in "before cc-mode" section above. + ("\\(&&\\|\|\|\\)" 1 'php-logical-op) )) "Detailed highlighting for PHP Mode.") From 672377e6128a11180d0e1d64b68026c5158271ee Mon Sep 17 00:00:00 2001 From: "U-CPT\\deb" Date: Tue, 3 Dec 2019 17:42:41 +0100 Subject: [PATCH 2/2] Fixed typo --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index 290a5d20..93e95410 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1658,7 +1658,7 @@ a completion list." ;; Assignment operators (=, +=, ...) ("\\([^=]+?\\([\-+./%]?=\\)[^=]+?\\)" 2 'php-assignment-op) - ;; Comparison operatoes (==, ===, >=, ...) + ;; Comparison operators (==, ===, >=, ...) ("\\([!=]=\\{1,2\\}[>]?\\|[<>]=?\\)" 1 'php-comparison-op) ;; Arithmetic operators (+, -, *, **, /, %)