PHP syntax highlighter for Emacs
Asked Answered
R

4

7

Is there a good php syntax highlighter for Emacs? I'm using Emacs 23. I've tried php-mode, but that doesn't do anything. I've tried nXhtml, but that ignores my color theme and reverts to some awful looking default. Is there one I've missed or perhaps a configuration setting I've ignored?

Rosewater answered 22/4, 2010 at 16:12 Comment(0)
P
4

I used this one http://www.emacswiki.org/emacs/php-mode-improved.el for some times. But I switched back to nxhtml as I have to edit too many badly mixed php/html/js/css files these days.

I tried the deboutv one but it sux on emacs (it was created for xemacs) and the development has been dead for some time with some bad bugs left.

You should try the modes available on emacswiki and see if one is good enough for you. If not, well, you know what to do : create your own.

Phoenicia answered 22/4, 2010 at 16:21 Comment(3)
Hmm... I'll give the deboutv a try. Do you know if there a way to get nxhtml to use your color-theme of choice? Because I wouldn't mind that one, so long as I didn't have to use it's ugly green theme.Rosewater
I use nxhtml and a custom color-theme and everything looks just fine. The only problem I've had was with the different background colors for different languages in the same file - but they can be changed or simply disabled. Btw nxhtml uses php-mode.Resolvable
The php-mode-improved combined with Bozhidar's advice about the font lock fixed everything. Thanks.Rosewater
M
2

The php-mode you linked to most definitely provides syntax highlighting. If it "doesn't do anything", then you didn't install it correctly. You might want to re-check your configuration.

Margartmargate answered 23/4, 2010 at 0:17 Comment(3)
Which is what I was wondering. What then might be configured wrong? I followed the tutorial (before asking this question and again before writing this response) and still nothing. I can see that I'm in php-mode when the file is loaded, but I don't get any syntax highlighting. Is there something I've missed or the tutorials forgot to mention?Rosewater
You should check if your Emacs loaded without errors and if your font-locking(syntax highlighting) is enabledResolvable
Ah, font-locking it was. I found this page and it helped emacswiki.org/emacs/EnablingFontLock, particularly the part about SXEmacs. Thanks.Rosewater
M
1

I'm the author of php-fh : PHP Functions Highlighter for Emacs.

I've been using this piece of code for over 15 years and as this functionality doesn't seem to exist I decided to package it : https://github.com/pivaldi/php-fh

Mccreery answered 8/9 at 2:51 Comment(1)
Thanks! You could also contribute it to php-mode ?Mcvay
W
0

I think that nXhtml does not do anything with your color theme. It is rather your color theme that does not know about the background colors that nXhtml put on chunks with different major modes.

The different background colors are there so that you will be aware that you have the full capabilities of Emacs html editing in the html parts and the capabilities of the php editing mode you are using in the php parts.

You can just tell nXhtml to not color the background if you prefer that.

Whitefaced answered 3/6, 2010 at 0:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.