From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kin Cho Newsgroups: gmane.emacs.help Subject: Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML Date: 24 Feb 2004 09:31:51 -0800 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <7iznb8e648.fsf@neoscale.com> References: <7i8yisfmqx.fsf@neoscale.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1077654097 10059 80.91.224.253 (24 Feb 2004 20:21:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2004 20:21:37 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 24 21:21:33 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Avj3c-0002tr-00 for ; Tue, 24 Feb 2004 21:21:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1Avggc-0004Hg-Pb for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Feb 2004 12:49:38 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!12.24.46.85!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: 12.24.46.85 Original-X-Trace: news.uni-berlin.de 1077643912 52613412 I 12.24.46.85 ([151019]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:121204 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:17166 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17166 "D. D. Brierton" 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 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