Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple operators #594

Merged
merged 2 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions php-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

(defface php-string-op '((t (:inherit php-operator)))
"PHP Mode face used to logical operators (.)."
:group 'php-faces
Expand Down
24 changes: 22 additions & 2 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
("\\<function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1 'php-function-name)

Expand Down Expand Up @@ -1622,7 +1625,7 @@ a completion list."

;; Highlight class name after "use .. as"
("\\<as\\s-+\\(\\sw+\\)" 1 font-lock-type-face)

;; Class names are highlighted by cc-mode as defined in
;; c-class-decl-kwds, below regexp is a workaround for a bug
;; where the class names are not highlighted right after opening
Expand Down Expand Up @@ -1651,6 +1654,23 @@ a completion list."
("\\?\\(\\(:?\\sw\\|\\s_\\)+\\)\\s-+\\$" 1 font-lock-type-face)
("function.+:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face)
(")\\s-*:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*\\(?:\{\\|;\\)" 1 font-lock-type-face)

;; Assignment operators (=, +=, ...)
("\\([^=<!>]+?\\([\-+./%]?=\\)[^=<!>]+?\\)" 2 'php-assignment-op)

;; Comparison operators (==, ===, >=, ...)
("\\([!=]=\\{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.")

Expand Down