The original emacs mode for html: html-mode and html-helper-mode are not good. They cannot tell the javascipt and css part of the html files a lot of time.
After google-ing these days, I found a very good mode for html editing. It is call multi-web-mode. You can download it like this:
git clone https://github.com/fgallina/multi-web-mode.git
Then, add the following lines into your ~/.emacs:
(when (load (expand-file-name "~/.emacs.d/multi-web-mode/multi-web-mode.el")) (package-initialize)) (setq mweb-default-major-mode 'html-mode) (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|") (espresso-mode "]*>" "") (css-mode "]*>" ""))) (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5")) (multi-web-global-mode 1)
It should just work!
and add the following to your ~/.emacs:
autoload #’espresso-mode “espresso” “Start espresso-mode” t)
(add-to-list ‘auto-mode-alist ‘(“\\.js$” . espresso-mode))
(add-to-list ‘auto-mode-alist ‘(“\\.json$” . espresso-mode))
Right now, everything should be fine. ::)
Enjoy your web front-end programming!