Skip to content

Commit f27474d

Browse files
authored
Merge pull request #594 from minikN/master
Add support for multiple operators
2 parents 2822593 + 672377e commit f27474d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

php-face.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
:group 'php-faces
107107
:tag "PHP Logical Op")
108108

109+
(defface php-arithmetic-op '((t (:inherit php-operator)))
110+
"PHP Mode face used to arithmetic operators (+, -, %, ...)."
111+
:group 'php-faces
112+
:tag "PHP Arithmetic Op")
113+
114+
(defface php-inc-dec-op '((t (:inherit php-operator)))
115+
"PHP Mode face used to increment and decremt operators (--, ++)."
116+
:group 'php-faces
117+
:tag "PHP Increment/Decrement Op")
118+
109119
(defface php-string-op '((t (:inherit php-operator)))
110120
"PHP Mode face used to logical operators (.)."
111121
:group 'php-faces

php-mode.el

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,11 +1543,14 @@ a completion list."
15431543
("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call))
15441544
("\\<\\(const\\)\\s-+\\(\\_<.+?\\_>\\)" (1 'php-keyword) (2 'php-constant-assign))
15451545

1546+
;; Logical operator (!)
1547+
("\\(![^=]\\)" 1 'php-logical-op)
1548+
15461549
;; Highlight special variables
15471550
("\\(\\$\\)\\(this\\)\\>" (1 'php-$this-sigil) (2 'php-$this))
15481551
("\\(\\$+\\)\\(\\sw+\\)" (1 'php-variable-sigil) (2 'php-variable-name))
15491552
("\\(->\\)\\([a-zA-Z0-9_]+\\)" (1 'php-object-op) (2 'php-property-name))
1550-
1553+
15511554
;; Highlight function/method names
15521555
("\\<function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1 'php-function-name)
15531556

@@ -1622,7 +1625,7 @@ a completion list."
16221625

16231626
;; Highlight class name after "use .. as"
16241627
("\\<as\\s-+\\(\\sw+\\)" 1 font-lock-type-face)
1625-
1628+
16261629
;; Class names are highlighted by cc-mode as defined in
16271630
;; c-class-decl-kwds, below regexp is a workaround for a bug
16281631
;; where the class names are not highlighted right after opening
@@ -1651,6 +1654,23 @@ a completion list."
16511654
("\\?\\(\\(:?\\sw\\|\\s_\\)+\\)\\s-+\\$" 1 font-lock-type-face)
16521655
("function.+:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face)
16531656
(")\\s-*:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*\\(?:\{\\|;\\)" 1 font-lock-type-face)
1657+
1658+
;; Assignment operators (=, +=, ...)
1659+
("\\([^=<!>]+?\\([\-+./%]?=\\)[^=<!>]+?\\)" 2 'php-assignment-op)
1660+
1661+
;; Comparison operators (==, ===, >=, ...)
1662+
("\\([!=]=\\{1,2\\}[>]?\\|[<>]=?\\)" 1 'php-comparison-op)
1663+
1664+
;; Arithmetic operators (+, -, *, **, /, %)
1665+
("\\(?:[A-Za-z0-9[:blank:]]\\)\\([\-+*/%]\\*?\\)\\(?:[A-Za-z0-9[:blank:]]\\)" 1 'php-arithmetic-op)
1666+
1667+
;; Increment and Decrement operators (++, --)
1668+
("\\(\-\-\\|\+\+\\)\$\\w+" 1 'php-inc-dec-op) ;; pre inc/dec
1669+
("\$\\w+\\(\-\-\\|\+\+\\)" 1 'php-inc-dec-op) ;; post inc/dec
1670+
1671+
;; Logical operators (and, or, &&, ...)
1672+
;; Not operator (!) is defined in "before cc-mode" section above.
1673+
("\\(&&\\|\|\|\\)" 1 'php-logical-op)
16541674
))
16551675
"Detailed highlighting for PHP Mode.")
16561676

0 commit comments

Comments
 (0)