NXML-Mode
Posted by Rex under Computing, Development | Permalink | | Leave A Comment
One of the things I love about Emacs is its extensibility. It has all sorts of different edit modes for different file types. For example, SGML mode comes standard for editing XML & HTML. It’s a step up from normal text edit mode, it renders tags in color fonts. But it’s pretty plain vanilla editing– no syntax validation nor smart tag completion.
I started to use nxml-mode earlier this week and am liking it. Here’re some of the nice features:
- Smarter rendering of tags
- Real-time syntax checking
- Tag completion
- Support of folding
- Link handling
You can download nxml-mode here. The latest file as of this writing is “nxml-mode-20041004.tar.gz”. Unzip the package into the standard emacs “site-lisp” directory (it’s /usr/share/emacs/site-lisp on my macbook).
Configure it to auto-load and bind to various file extension via the following configuration in your .emacs file:
(load “rng-auto.el”)
(add-to-list ‘auto-mode-alist
(cons (concat “\\.” (regexp-opt ‘(“xml” “xsd” “sch” “rng” “xslt” “svg” “rss”) t) “\\'”)
‘nxml-mode))
(setq magic-mode-alist
(cons ‘(“<???xml ” . nxml-mode)
magic-mode-alist))
(fset ‘xml-mode ‘nxml-mode)
(fset ‘html-mode ‘nxml-mode)