Perl programmer for hire: download my resume (PDF).
John Bokma MexIT
freelance Perl programmer

nXML mode: a short how to

Wednesday, October 1, 2008 | 0 comments

Even before I had decided to use Emacs as my default editor I had read about nXML mode, an add-on for GNU Emacs which turns it into a powerful XML editor with continuous validation and completion. Since I use XML files to store allmost all the content on this web site - using a Perl program to generate the actual HTML files - I decided to give this mode a try, instead of using Exchanger XML Lite on Ubuntu. The latter had been my XML editor of choice for quite some time on Windows XP Professional. But I missed several features, like for example spell checking and macro recording.

Downloading and installing nXML mode

First I downloaded the latest version of nXML mode, dated the 4th of October, 2004 via a link on the nXML mode web page.

Next, I decompressed and unpacked the downloaded file using:

tar zxvf nxml-mode-20041004.tar.gz

Then I moved the newly created directory, nxml-mode-20041004, into the .emacs.d directory located in my home directory:

mv nxml-mode-20041004 ~/.emacs.d

If you have more than one user on your system interested in using nXML mode, you might want to install the nXML directory in a more suitable location, but for me this would do for now.

Next, using Emacs I created the init.el file, which wasn't in my ~/.emacs.d yet:

C-x C-f ~/.emacs.d/init.el

and entered the following lines:

(load "~/.emacs.d/nxml-mode-20041004/rng-auto.el")

(setq auto-mode-alist
      (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)

The first line loads the nXML mode into Emacs. If you have moved the nXML mode directory to a different location, or downloaded a different version, make sure to modify the path.

The second piece of Emacs Lisp turns on nxml-mode for several file extensions.

Also today

Please post a comment | read 0 comments | RSS feed