Function: sgml-xml-guess
sgml-xml-guess is a byte-compiled function defined in sgml-mode.el.gz.
Signature
(sgml-xml-guess)
Documentation
Guess whether the current buffer is XML. Return non-nil if so.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/sgml-mode.el.gz
(defun sgml-xml-guess ()
"Guess whether the current buffer is XML. Return non-nil if so."
(save-excursion
(goto-char (point-min))
(or (string= "xml" (file-name-extension (or buffer-file-name "")))
;; Maybe the buffer-size check isn't needed, I don't know.
(and (zerop (buffer-size))
(string= "xhtml" (file-name-extension (or buffer-file-name ""))))
(looking-at "\\s-*<\\?xml")
(when (re-search-forward
(eval-when-compile
(mapconcat #'identity
'("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
"\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"")
"\\s-+"))
nil t)
(string-match "X\\(HT\\)?ML" (match-string 3))))))