nXhtmlをインストールする

Posted by Tatsuyano on Thu, Nov 1, 2012
In
Tags emacs

nXhtmlとは

htmlファイルには、javascriptやphp、perlなどhtml以外の複数の言語で書かれていたりする。
このため今までは、今書いている言語に合わせて、自分でモードの切り替えを行なっていたのだが、nXhtmlを使うと、自動で今書いている言語に合わせてモードを切り替えてくれる。

インストール

nXhtmlの本家サイトの、Download latest nXhtml (zip file)からzipをダウンロードし、pathの通っている階層(add-to-list ‘load-path “~/.emacs.d/elisp”)に移動。

wget http://ourcomments.org/Emacs/DL/elisp/nxhtml/zip/nxhtml-2.08-100425.zip
tar xvzf nxhtml-2.08-100425.zip
mv nxhtml .emacs.d/elisp/

.emacs.elに一行追加。
※ 00_init.elに追加するとエラーになってしまったため、やむなく.emacs.elに追加

cat >> .emacs.el
(load "nxhtml/autostart.el")

バイトコンパイル

M-x nxhtmlmaint-start-byte-compilation

コンパイル時にでるwarningの対応。下記の警告が出てくるので

Warning: `font-lock-beginning-of-syntax-function’ is an obsolete variable (as of Emacs 23.3); use `syntax-begin-function’ instead.

.emacs.d/elisp/nxhtml/util/mumamo.elの「font-lock-beginning-of-syntax-function」を「syntax-begin-function」に置換し、再度コンパイル。

nXhtmlのモードについて

「nXhtml/nxhtml Invalid)」や「PHP/nxhtml Completion AC Abbrev」にするには

M-x nxhtml-mumamo

参考サイト

以下のサイトを参考にさせていただきました。ありがとうございます!