[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML
From: |
D. D. Brierton |
Subject: |
Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML |
Date: |
Tue, 24 Feb 2004 17:16:50 +0000 |
User-agent: |
Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
On Tue, 24 Feb 2004 08:47:18 -0800, Kin Cho wrote:
> (add-hook 'find-file-hooks 'my-find-file-hooks t)
>
> (defun my-find-file-hooks ()
> (when (save-excursion (search-forward-regexp "\?xml\\|XHTML" 80 t))
> ;; do whatever you need to do
> ))
Thanks for this suggestion, Kin. Following on from your suggestion, I
guess that rather than adding a hook to find-file-hooks, I guess I could
add it to 'sgml-html-mode-hook instead, so .php or .html files etc
initially open in sgml-html-mode, but then if a <?xml or //W3C//DTD XHTML
string was found it would then switch into xml-html-mode. So I guess, that
would go something like:
(add-hook 'sgml-html-mode-hook 'check-for-xhtml-hook t)
(defun check-for-xhtml-hook ()
(when (save-excursion (search-forward-regexp "<[?]xml\\|//W3C//DTD XHTML" 80
t))
'xml-html-mode ;; looks like this line isn't right
))
As you may be able to tell, though, my lisp is pretty crappy. The above
doesn't seem to work. It seems that 'xml-html-mode is not sufficient to
change the mode of the buffer. What am I doing wrong there?
Thanks for your help.
Best, Darren
--
======================================================================
D. D. Brierton darren@dzr-web.com www.dzr-web.com
Trying is the first step towards failure (Homer Simpson)
======================================================================