php depracates a feature that I've been used to in
perl: using barewords in specific places to denote a
string. Just like in perl, this bareword could also be
a constant defined somewhere. That's okay in those
places where it is used as a constant key into an array
which fakes an aggregation object, atleast that's what
it is used quite often in perl. It needs just two lines
of extra highlit-code to make those place not be in
warning-face (red) but in constant-face (cyan) which is
still different from string-face (grey) and var-face
(yellow). This makes them peek out of the text but not
as strong as the warning-face, and at the same time it
reminds me that those symbols should be watched out for
to not hit a global constant.
The following u-diff show the additional two lines.
Personally, I would like to also hilit places of
barewords as function-call arguments, marking them as
constants too - most of the predefined global-consts in
the php-mode are actually used ever only as
call-arguments, and actually should only be most of the
time. A hilit with a bareword as call-arg could cover
even unknown such global constants.
'("\\&lt;[0-9]+" . default) ; number (also matches word)
;; barewords can be constants or their string
+ '("\\[\\(\\sw+\\)\\]" (1 font-lock-constant-face
+ '("\\(\\sw+\\)\\s-*=>\\s-*" (1
font-lock-constant-face nil nil))
;; Warn on any words not already fontified
'("\\&lt;\\sw+\\&gt;" . font-lock-warning-face)
Log in to post a comment.