Menu

#5 highlight some barewords as constants

closed-rejected
nobody
None
5
2003-09-29
2002-07-21
No

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.

'("\\<[0-9]+" . default) ; number (also matches word)

;; barewords can be constants or their string
representation
+ '("\\[\\(\\sw+\\)\\]" (1 font-lock-constant-face
nil nil))
+ '("\\(\\sw+\\)\\s-*=>\\s-*" (1
font-lock-constant-face nil nil))
;; Warn on any words not already fontified
'("\\<\\sw+\\>" . font-lock-warning-face)

Discussion

  • Turadg Aleahmad

    Turadg Aleahmad - 2003-02-26
    • status: open --> open-rejected
     
  • Turadg Aleahmad

    Turadg Aleahmad - 2003-02-26

    Logged In: YES
    user_id=137402

    I don't want to make php-mode accomodate a deprecated
    feature so I'm not going to include your patch in the
    distribution. Of course, you're welcome to modify your copy.

    Thanks.

     
  • Turadg Aleahmad

    Turadg Aleahmad - 2003-09-29
    • status: open-rejected --> closed-rejected
     

Log in to post a comment.