I finally figured out how to switch from sgml-mode into xml-mode for
XHTML documents automagically.
I am documenting my solution here:
(setq find-file-hooks (append '(check-for-xml) find-file-hooks))
(defun check-for-xml ()
"Check to see if we need xml-mode"
(if (eq major-mode (quote sgml-mode))
(cond ((or (looking-at "<[?]xml.*[?]>")
(looking-at
"<!DOCTYPE[ \t]+html[ \t]+PUBLIC[ \t]+\"-//W3C//DTD XHTML"))
(xml-mode)))))
This is based on [1], which is an *old* Usenet post.
1.
http://groups.google.com/groups?hl=en&frame=right&th=5019597044946383&seekm=48686%40yale-celray.yale.UUCP#link3
--
Hugo Haas <hugo@larve.net> -
http://larve.net/people/hugo/
La vraie paresse, c'est de se lever � 6 heures du matin pour avoir plus
longtemps � ne rien faire. -- Tristan Bernard