[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML
From: |
Kin Cho |
Subject: |
Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML |
Date: |
24 Feb 2004 09:31:51 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
"D. D. Brierton" <darren@dzr-web.com> writes:
> 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
> ))
Change 'xml-html-mode to (xml-html-mode).
If you know C, 'xml-html-mode is like taking the address of a
function.
-kin