I need something like this for gtksourceview: <mime-type type="text/x-prolog"> <_comment>Prolog source code</_comment> <sub-class-of type="text/plain"/> <glob pattern="*.prolog"/> </mime-type> Thanks.
Could you please provide a sample testcase? Any documentation of the file format?
Created attachment 23565 [details] testcase prolog As you can see here: http://filext.com/file-extension/pl Theorically the pl is the extension used by swi-prolog. The problem is that this extension is used too for perl files. Vim and kate uses the extension .prolog for prolog files, so I think it could be the extension we should use. Anyway if there is a way to use the pl extension for prolog files maybe would be better.
BTW, my mistake vim uses .pl for prolog files.
Time to ping here. BTW vim makes the detection for .pl for prolog and files with .pl that starts with #/usr.../perl changes the mime detection to perl
(In reply to comment #4) > Time to ping here. > BTW vim makes the detection for .pl for prolog and files with .pl that starts > with #/usr.../perl changes the mime detection to perl Please follow the instructions in the HACKING file about providing patches. http://cgit.freedesktop.org/xdg/shared-mime-info/plain/HACKING
Created attachment 40748 [details] [review] Patch Please take a look in my patch and give me some feedback. I also noticed that there are no tests for perl.
I think that this line on tests/list: test.pl text/x-prolog should be: test.pl text/x-prolog ox Right? I am having problems running/understanding the tests :(
(In reply to comment #7) > I think that this line on tests/list: > test.pl text/x-prolog > should be: > test.pl text/x-prolog ox > > Right? I am having problems running/understanding the tests :( Did you run the test suite? How it install the necessary bits are mentioned in the HACKING file, and the parameters to each line in the file explained at the top of tests/list. You would also need to add a Perl test case. I really don't expect this to work as easily as you think, given that you have the same glob as perl (*.pl).
Is there any way to add regex in <match> tag? What we want to do is: - Every .prolog file is text/x-prolog - Every .pro file is text/x-prolog - Every .pl file that doesn't have the word "perl" on the first line is text/x-prolog Do you have any hints on how can we achieve that?
So, this is how I did: <mime-type type="text/x-prolog"> <_comment>Prolog source file</_comment> <sub-class-of type="text/plain"/> <glob pattern="*.pl"/> <glob pattern="*.pro"/> <glob pattern="*.prolog"/> </mime-type> <mime-type type="application/x-perl"> <_comment>Perl script</_comment> <sub-class-of type="application/x-executable"/> <sub-class-of type="text/plain"/> <generic-icon name="text-x-script"/> <magic priority="80"> <match type="string" value='eval \"exec /usr/local/bin/perl' offset="0"/> <match type="string" value="/bin/perl" offset="1:16"/> <match type="string" value="/bin/env perl" offset="1:16"/> </magic> <!-- <glob pattern="*.pl"/> --> <glob pattern="*.pm"/><!-- module --> <glob pattern="*.al"/><!-- autoloader --> <glob pattern="*.perl"/> </mime-type> This seems to work really well. Check out the results using the "mimetype" tool: http://pastie.org/1342469 But I am having problems with the tests. test.pro text/x-prolog ox test.prolog text/x-prolog ox test-prolog.pl text/x-prolog ox Those 3 tests are working fine, but here comes the problem: test-perl.pl application/x-perl xoo The last "o" is failing. In my understanding: first letter is just checking filename. This fails (because it returns x-prolog) second letter is just content (magic). This is passing third letter is all together. This should pass but is failing. When I use "mimetype" on that file, it returns "x-perl", but on the test this is failing. How is that possible? Thank you :)
Please give me an answer so I can provide a git formated patch. Thank you!
Created attachment 40752 [details] [review] Patch 2 Here it is a patch.
Could the patch get a review, please?
Review of attachment 40752 [details] [review]: ::: freedesktop.org.xml.in @@ +2568,3 @@ + <_comment>Prolog source file</_comment> + <sub-class-of type="text/plain"/> + <glob pattern="*.pl"/> This and... @@ +2582,3 @@ <match type="string" value="/bin/env perl" offset="1:16"/> </magic> + <!-- <glob pattern="*.pl"/> --> this, are obviously wrong. This means that "*.pl" files will *always* be detected as Prolog files. Either the glob should have a priority, or neither should have a glob for it. The former is obviously more desirable, and Perl files should be the ones with the highest priority.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/90.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.