Ralph Corderoy <ra...@inputplus.co.uk> wrote:

> > Since I've got a lot of refer files, I've added a text/x-refer mime
> > type in my system. It recognizes the file if it has the extension .ref
> > or if it begins by a %.
>
> Does that clash with PostScript recognition at all?  PostScript files
> often starting with a % as it's the comment character.
>
>     %!PS-Adobe-1.0


No, it doesn't...  but because of a bug in the refer.xml
file that I hadn't notice ! I've fixed that now, thanks to
you.

Seeing your question, I also had a look at the file
/usr/share/mime/packages/freedesktop.org.xml on which such
expressions are defined, and it appears that a "%" as first
character is used by a lot of files, but usually as part of
more longer string -- that's the case of pdf, postcript,
postcript fonts, and encapsulated postcript files.

The exceptions are matlab and tex files, which can be
recognized by a single "%" but with a very low priority of 10.

Tex files are better defined, with a priority of 50, if the
string "documentclass" begins at the second character.

Matlab files are better defined, with a priority of 50, by
the string "function" begining at the first character.

To avoid most of the conflicts, we can change the priority
of the "%" of a refer file: more than 10, and less than 50,
so that if a file begins by a "%" it is a refer file, except
if that character is part of the definition of another file.
WIth such a definition, Tex and Matlab files will not be
recognized correctly if 1) they don't have extension, and 2)
they only match the single "%" expression.

Here is a corrected refer.xml, in wich the bug is fixed, and
the priority defined to 40.


Cheers,

Pierre-Jean.



Attachment: refer.xml
Description: XML document

Reply via email to