<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:9pt;font-family:Sans Serif">
<p>On Friday 02 February 2007, Thomas Leonard wrote:</p>
<p>&gt; On 1/28/07, David Faure &lt;dfaure@trolltech.com&gt; wrote:</p>
<p>&gt; &gt; Hello,</p>
<p>&gt; &gt; I'm starting to implement shared-mime-info for KDE4.</p>
<p>&gt; &gt; I hadn't read the spec for a very long time, so I did it again, and: I still like it very much :)</p>
<p>&gt; &gt; I just have a few questions.</p>
<p>&gt; </p>
<p>&gt; (note: I'm not the maintainer any more, but I'll try to answer some of</p>
<p>&gt; this anyway)</p>
<p></p>
<p>Thanks. You probably have best insight into why things were specified this way ;)</p>
<p></p>
<p>&gt; &gt; First question: user overrides.</p>
<p>&gt; &gt; &gt; This specification uses the XDG Base Directory Specification[BaseDir] to define the prefixes below which the database is stored. In the rest of this document, paths shown with the prefix &lt;MIME&gt; indicate the files should be loaded from the mime subdirectory of every directory in XDG_DATA_HOME:XDG_DATA_DIRS.</p>
<p>&gt; &gt; &gt; For example, when using the default paths, &quot;Load all the &lt;MIME&gt;/text/html.xml files&quot; means to load /usr/share/mime/text/html.xml, /usr/local/share/mime/text/html.xml, and ~/.local/share/mime/text/html.xml (if they exist).</p>
<p>&gt; &gt; The first sentence puts XDG_DATA_HOME first; the second sentence puts ~/.local in the directory list;</p>
<p>&gt; </p>
<p>&gt; That sentence doesn't say what order should be used. Normally, reading</p>
<p>&gt; the lowest-priority files first is desirable, although it depends how</p>
<p>&gt; you want to implement it, of course. </p>
<p>Of course, that's not what I meant. To apply precedence correctly, one can read</p>
<p>from global to local (and add at every level) or from local to global (and skip already seen stuff).</p>
<p>What matters is to define which directory has more precedence than which other.</p>
<p>OK I agree that it's probably obvious which one has precedence, it just reads strangely</p>
<p>when two sentence seem to contradict each other.</p>
<p></p>
<p>&gt; &gt; However, how does that allow the user to remove a pattern-&gt;mimetype association?</p>
<p>&gt; &gt; For instance, /usr/share/mime/globs says application/msword:*.doc</p>
<p>&gt; &gt; but since this gives a wrong mimetype to e.g. /usr/share/doc/cvs/contrib/intro.doc</p>
<p>&gt; &gt; how can I, as a user, remove the &quot;application/msword:*.doc&quot; association?</p>
<p>&gt; </p>
<p>&gt; You'd have to define a higher priority rule to match them.</p>
<p>Well, if the user assigns *.doc to another mimetype then indeed that one will have precedence.</p>
<p>But if you just want to remove the rule, you can't.</p>
<p></p>
<p>&gt; You can't disable rules in the current spec.</p>
<p>I think this removes control from the user. And it makes for a bad GUI too: a user can define his</p>
<p>own mimetype, so the GUI must allow to edit globs for mimetypes. But then for some mimetypes</p>
<p>(those he created), he can add/remove globs, whereas for other mimetypes (those defined globally),</p>
<p>he can't remove globs. Well, he can, if he added them himself, but not otherwise. Argl ;)</p>
<p></p>
<p>&gt; I'm not sure the example is very realistic... most .doc files are Word</p>
<p>&gt; documents so I don't think you'd want to disable the rule completely.</p>
<p>Well the example is very realistic, it's exactly what kde has been doing for years,</p>
<p>for the reason I mentionned.</p>
<p>What's more, it's just an example :)</p>
<p></p>
<p>&gt; ~/.local/share/mime/packages/Override.xml</p>
<p>&gt; ~/.local/share/mime/packages/*.xml</p>
<p>&gt; /usr/local/share/mime/packages/Override.xml</p>
<p>&gt; /usr/local/share/mime/packages/*.xml</p>
<p>Yes, this is what I understood. That part is quite flexible, but the generated output isn't.</p>
<p>If in ~/.local/share/mime/packages/Override.xml I redefine a mimetype, that redefinition</p>
<p>should indeed override the one from /usr/local/... But it can't do that, since the generated</p>
<p>files are concatenated together, so the ~/.local stuff only adds stuff.</p>
<p></p>
<p>Solution 1 would be to generate a ~/.local/share/mime/allglobs (and allmagic, allaliases etc.)</p>
<p>which would contain all globs/magic/aliases definition; the merged view of global and local.</p>
<p>Applications would only need to read those files, which would have all the info so they would</p>
<p>be able to &quot;remove&quot; stuff that is defined in the global files. The added &quot;all&quot; suggested here</p>
<p>is for compatibility reasons, to avoid changing the meaning of the existing local files.</p>
<p></p>
<p>Solution 2 would be to add syntax for removing in the local globs, magic and aliases files.</p>
<p>Like, starting a line with a &quot;-&quot; or something.</p>
<p></p>
<p>However in both cases it means the general meaning of &quot;what's defined in ~/.local&quot; would</p>
<p>change compared to the current spec. I wonder how much people currently have in ~/.local</p>
<p>though, other than entirely new mimetypes, though, since no gui can really be done on top</p>
<p>of the current spec imho ;)</p>
<p>Defining new mimetypes in ~/.local would work the same, re-defining existing mimetypes</p>
<p>would work with much more flexibility: really redefining instead of merely adding rules.</p>
<p></p>
<p>-- </p>
<p>David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,</p>
<p>Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).</p>
<p></p>
</body></html>