content-based highlighting selection?

Kevin Funk kfunk at kde.org
Thu Feb 26 17:39:57 GMT 2015


On Thursday 26 February 2015 16:22:30 René J.V. Bertin wrote:
> Hi,
> 
> This is probably more of a Kate question, but I'll try here first: is the
> highlighting selection based on content analysis, and if so, is there a way
> to add patterns to that mechanism? Use case: files without extension that
> are written in Tcl, and (most all) have a token for vi, ft=tcl which could
> be used to activate the appropriate highlighter.

This is my understanding of the way highlighting file selection works:

KTE is using QMimeType/QMimeDatabase (KMimeType in KDE4 times) to look up the 
mime type of a file on disk. This actually does (besides looking at the file 
name) so called "magic sniffing" on files, i.e. scans the file's content for 
patterns to find out its mime type [1]. QMimeType/QMimeDatabase are using 
shared-mime-info information, which contains these patterns [2].

The mime type is then used to select the appropriate highlighting file.

Though, honestly, I'm not sure why there is both 'extensions' and 'mimetype' 
in some highlighting files...

@KTE devs: Correct me if I'm wrong please. :)

[1] checking order: http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm140625828606432
[2] shared-mime-info payload: http://cgit.freedesktop.org/xdg/shared-mime-info/tree/freedesktop.org.xml.in (see 'magic' tags in the XML file)

> 
> Thanks,
> R.
> _______________________________________________
> KDevelop mailing list
> KDevelop at kde.org
> https://mail.kde.org/mailman/listinfo/kdevelop

-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20150226/c249c1b4/attachment.sig>


More information about the KDevelop mailing list