Working with mixed HTML and PHP code in emacs

I found that the html-helper-mode is a better alternative than either php or html mode.

To set this mode automatically for .php and .html files, just add the following entry in your .emacs configuration:

(setq auto-mode-alist (cons '("\\.php$" . html-helper-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))

To check in which mode you’re currently on,

C-h m
Display documentation of the current major mode (describe-mode).




3 thoughts on “Working with mixed HTML and PHP code in emacs”

  1. nXhtml should in theory be ideal for working with mixed HTML and PHP, as it uses its Multiple Major Modes mechanism to switch between major modes dynamically. In practice I’ve been experiencing font-lock bugs with it of late and have abandoned it for the time being; however YMMV, and it’s a very good solution when it’s stable.

  2. Yup, tried html-helper-mode for a little while and was disappointed. The JavaScript indentation is pretty horrible. Trying out nxhtml now…

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s