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

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

Re: magic-mode-alist gets in the way


From: James J. Ramsey
Subject: Re: magic-mode-alist gets in the way
Date: Tue, 4 Jan 2005 08:00:32 -0800 (PST)

--- Richard Stallman <address@hidden> wrote:

>     I can't think of a good reason why the content
> should always take precedence
>     over the file name.
> 
> In actual practice, that is normally what we want. 

Trouble is, when it *isn't* what is wanted, changing
the behavior is tricky. An example of the kind of
machinations involved in overriding the defaults is
shown here:

http://groups.yahoo.com/group/emacs-nxml-mode/message/893?threaded=1

One thought: if you are going to insist on having a
magic-mode-alist, then it may make sense to store the
regular expressions for certain file contents in
special variables, i.e. xml-magic-regexp,
html-magic-regexp, sgml-magic-regexp. That way, one
could put something like this in ~/.emacs:

(setq magic-mode-alist (cons '(html-magic-regexp .
nxml-mode) magic-mode-alist))

Considering that the value for html-magic-regexp would
be something like

(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
             (comment-re (concat "\\(?:!--"
incomment-re "*-->\\s *<\\)")))
        (concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<"
                comment-re "*"
                "\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *"
comment-re "*\\)?"
                "[Hh][Tt][Mm][Ll]"))

having a pre-defined html-magic-regexp would be a big
help.

If you are going to insist on having a
magic-mode-alist, then it will *have* to be
documented, and you should try to make it easier for
it to be modified. It is a variable that will
inevitably need to be edited, just like
auto-mode-alist.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

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