unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "D. D. Brierton" <darren@dzr-web.com>
Subject: Re: Suggestions? Better filetype sniffing -- XHTML vs. HTML
Date: Tue, 24 Feb 2004 17:16:50 +0000	[thread overview]
Message-ID: <pan.2004.02.24.17.16.42.300919@dzr-web.com> (raw)
In-Reply-To: 7i8yisfmqx.fsf@neoscale.com

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)
======================================================================

  reply	other threads:[~2004-02-24 17:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-24 14:56 Suggestions? Better filetype sniffing -- XHTML vs. HTML D. D. Brierton
2004-02-24 16:47 ` Kin Cho
2004-02-24 17:16   ` D. D. Brierton [this message]
2004-02-24 17:31     ` Kin Cho
2004-02-24 17:46       ` D. D. Brierton
2005-05-27 14:29         ` slashdevslashnull
     [not found]         ` <mailman.2088.1117208718.25862.help-gnu-emacs@gnu.org>
2005-05-27 23:39           ` Thien-Thi Nguyen
2005-05-31  6:52             ` don provan
2005-09-12  7:59               ` Thien-Thi Nguyen
2005-09-15 16:25                 ` don provan
2004-02-24 17:11 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pan.2004.02.24.17.16.42.300919@dzr-web.com \
    --to=darren@dzr-web.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).