emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hangs when reading DTD


From: Stefan
Subject: Re: hangs when reading DTD
Date: Sat, 13 Nov 2004 19:15:47 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (darwin)

>> > PS: A regexp is really not the best tool here.

> I was reluctant to detect html with a regexp.  But it allowed having a general
> purpose mechanism, rather than hard coding XML into `set-auto-mode'.

Well, another option is to allow a function in place of the regexp.
I.e. You could allow entries like

        (detect-foo-mode . foo-mode)

instead of

        ("my foo-mode regexp" . foo-mode)

but as you pointed out later, maybe it'd be even better to just allow the
function to return the mode to use.  Although, maybe it might make just as
much sense to just keep things as they are except use a new function
sgml-auto-mode and use that one whenver the file looks like some sgml
derivative: the function can then choose between html, xml, sgml, xhtml, ...

> True, if the file is xml/sgml, and there are many initial comments, it can
> look pretty far into the buffer.  But in that case we are have a good chance
> to have a match anyways.  If the buffer doesn't start with \s *<, this regexp
> shouldn't hurt much.

Agreed.  Efficiency shouldn't be a major problem since the "cosly" search
only takes place when it succeeds.

> What could a function do other than my regexp?

For example, it could work correctly without signalling a "Stack overflow in
regexp matcher" even if the file starts with 100KB of <!--...--> comments.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]