php-mode
php-mode copied to clipboard
Define individual faces for individual keywords
At the moment, changing the php-keyword
face, will affect elements like new
, public
, function
, extends
and more.
I believe this is because most *-kwds
constants will get assigned font-lock-keyword-face
by font-lock. In particular:
(c-lang-defconst c-typeless-decl-kwds
php (append (c-lang-const c-class-decl-kwds) '("function")))
(c-lang-defconst c-modifier-kwds
php '("abstract" "const" "final" "static"))
(c-lang-defconst c-protection-kwds
"Access protection label keywords in classes."
php '("private" "protected" "public"))
(c-lang-defconst c-postfix-decl-spec-kwds
php '("implements" "extends"))
(c-lang-defconst c-type-list-kwds
php '("@new" ;; @new is *NOT* language construct, it's workaround for coloring.
"new" "use" "implements" "extends" "namespace" "instanceof" "insteadof"))
(c-lang-defconst c-ref-list-kwds
php nil)
(c-lang-defconst c-block-stmt-2-kwds
php '("catch" "declare" "elseif" "for" "foreach" "if" "switch" "while"))
(c-lang-defconst c-simple-stmt-kwds
php '("break" "continue" "die" "echo" "exit" "goto" "return" "throw"
"include" "include_once" "print" "require" "require_once"))
(c-lang-defconst c-constant-kwds
php '("true" "false" "null"))
(c-lang-defconst c-lambda-kwds
php '("function" "use"))
(c-lang-defconst c-other-block-decl-kwds
php '("namespace"))
(c-lang-defconst c-other-kwds
"Keywords not accounted for by any other `*-kwds' language constant."
php
'(
"__halt_compiler"
"and"
"array"
"as"
"break"
"catch"
"clone"
"default"
"empty"
"enddeclare"
"endfor"
"endforeach"
"endif"
"endswitch"
"endwhile"
"eval"
"fn" ;; NOT c-lambda-kwds
"global"
"isset"
"list"
"or"
"parent"
"static"
"unset"
"var"
"xor"
"yield"
"yield from"
;; Below keywords are technically not reserved keywords, but
;; threated no differently by php-mode from actual reserved
;; keywords
;;
;;; declare directives:
"encoding"
"ticks"
"strict_types"
;;; self for static references:
"self"
))
these. In my opinon the user should have more freedom in choosing which statement should be fontified by what face (E.g. maybe I want if
to be colored different from class ... extends ...
).
I could write a PR for that, but first I wanted to make sure a change like that would be welcomed by the maintainer.
Waiting on feedback for this.
@minikN I can't make a decision without seeing the implementation, but I think you can probably accept your suggestion. If there is a problem with your pull-request I will re-implement it.
Alright. Will create PR shortly.
There you go: #606