Search code examples
regexemacslispphp-modefont-lock

Emacs php-mode font-lock properties are not applied to certain chars


For example variable dollar signs.

php-mode.el line 1087:

'("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)" (1 font-lock-variable-name-face)) ; $variable

If I'm not mistaken the regexp should match $variable including the dollar sign. Now, i'm trying to figure out why isn't the font-lock property applied to the dollar sign also. In the syntax table $ is considered a word just like A-z.

So i guess what i'm trying to ask is: Did anyone experienced the same problem and has he/she found a solution?


Solution

  • The 1 in there means match the first capture group denoted by (escaped) parens. The $ is outside that capture group. So it could either be moved inside, or change the 1 to a 0 which means use the entire regexp.