[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: magic-mode-alist has too high a priority
From: |
Juri Linkov |
Subject: |
Re: magic-mode-alist has too high a priority |
Date: |
Thu, 24 Feb 2005 19:05:22 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.50 (gnu/linux) |
Dominique de Waleffe <address@hidden> writes:
> I need to view/edit ontologies in OWL syntax (XML files).
> I use an owl-mode which puts ("\\.owl$" . owl-mode) in front of
> auto-mode-alist.
>
> However when I view those ontologies, the magic-mode-alist specified
> function (xml-mode) is called because of the <?xml token on the first
> line. So I find my file visited in xml-mode instead of the owl-mode.
.owl is not a valid extension for Web-Ontology files. It was rejected
by the OWL WG. A valid extension for Web-Ontology files is .rdf
(and media type is application/rdf+xml). The best way to identify
Web-Ontology files is to check whether file contents has the string
"http://www.w3.org/1999/02/22-rdf-syntax-ns#" or
"http://www.w3.org/2002/07/owl#".
However, I agree that it is too confusing when you want to add
a new extension-to-mode rule, and Emacs ignores your settings.
There should be an additional level of settings where auto-mode-alist
takes precedence over magic-mode-alist.
For example, the recommended checking order for MIME types guessing
is the following:
1. If a MIME type is provided explicitly (eg, by a ContentType HTTP
header, a MIME email attachment, an extended attribute or some
other means) then that should be used instead of guessing.
2. If no explicit type is present, magic rules with a priority of 80
or more should be tried next. These rules have a very low
false-positive rate.
3. If there is still no match, the glob rules should be applied to
the name to get the type.
4. If no glob rules match, the remaining magic rules should be
tried next.
The first rule corresponds in Emacs to the `-*-...-*-' construct
at the beginning of a file. The second rule corresponds to
`auto-mode-interpreter-regexp' rather than to `magic-mode-alist'
since `auto-mode-interpreter-regexp' has lower false-positive rate
than `magic-mode-alist'. The third rule is `auto-mode-alist',
and the fourth rule is `magic-mode-alist'.
So perhaps the best solution is to change the checking order to:
1. -*-...-*-
2. auto-mode-interpreter-regexp
3. auto-mode-alist
4. magic-mode-alist
and to remove filename checking rules for html-mode, sgml-mode
and xml-mode from auto-mode-alist. Or at least to mark them
somehow specially in the auto-mode-alist (with an additional
list element) that would tell Emacs to check these rules later
(at an additional 5th step) when checking `magic-mode-alist' fails.
--
Juri Linkov
http://www.jurta.org/emacs/