1

In Emacs, is there some way to color double quoted strings based on their content? Ideally, any expression that gets evaluated within the string would be colored the same as if it were not enclosed within quotes. Currently, the entirety of strings are colored pink, which I believe is the default in Emacs for the PHP major mode.

Examples:

"a$b"
"{$a + 1}bc"

In the first example, a would still be colored pink but $b would be colored as if it were not enclosed in quotes. In the second, $a + 1 should be colored as if it were not within quotes. Ideally, the brackets would also be their own color to de-limit expressions visually.

2
  • Can you be more specific on the expression by providing some examples? Commented May 9, 2014 at 19:08
  • Done. I refrained from doing so initially because I wasn't sure if I could explicitly color them. Commented May 9, 2014 at 20:08

1 Answer 1

1

I don't think that Emacs ships with a PHP mode, and it's unclear which one you are using. (It's probably this one, but it could also be php+-mode or even something else).

web-mode, which supports a number of HTML templating languages, does some highlighting along the lines of what you want:

The downside is that it's really designed around templating, not programming. It does pretty good syntax highlighting, but if you're looking for something with a bunch of php- functions, web-mode probably isn't a good fit.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.