Next / Previous / Contents / Shipman's homepage

2.  Configuring your .emacs file

In order to use the nxml package under emacs, you must add these lines to your .emacs file, so that emacs knows where to find the nxml package:

;; /usr/share/emacs/site-lisp/tcc-nxml-emacs:  Add these lines
;;      to your .emacs to use nxml-mode.  For documentation of
;;      this mode, see http://www.nmt.edu/tcc/help/pubs/nxml/
;;--
;; Add the nxml files to emacs's search path for loading:
;;--
(setq load-path
      (append load-path
              '("/usr/share/emacs/site-lisp/nxml/")))
;;--
;; Make sure nxml-mode can autoload
;;--
(load "/usr/share/emacs/site-lisp/nxml/rng-auto.el")

;;--
;; Load nxml-mode for files ending in .xml, .xsl, .rng, .xhtml
;;--
(setq auto-mode-alist
      (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
            auto-mode-alist))

If adding these lines breaks emacs for other uses, you can set up a separate customization file just for nxml-mode.

For example, you can make a copy of your .emacs file named nxml.emacs and add the customizations shown above. Then to run emacs with nxml, use this command:

emacs -q --load ~/nxml.emacs

The -q option prevents emacs from reading your .emacs file, and the --load ~/nxml.emacs option causes it to read your customized setup file instead.