Changing kate syntax highlighting for .pro files

Roderick Johnstone rmj at ast.cam.ac.uk
Thu Mar 29 10:31:24 UTC 2012


On 28/03/12 17:51, T.C. Hollingsworth wrote:
> On Wed, Mar 28, 2012 at 9:11 AM, Roderick Johnstone <rmj at ast.cam.ac.uk> wrote:
>> Hi
>>
>> How can I change the mode of syntax highlighting that kate does for a
>> file extension of .pro? I read the section on syntax highlighting in the
>> kate handbook but am none the wiser.
> 
> That would be because the syntax highlighting chapter mentions "MIME
> types" but not file extensions, though both are affected by the same
> configuration screen.  I just added a brief mention of file extensions
> [1]; let me know if I can make it more clear.

Thank you, that reference was very helpful. I think its quite clear as
written.

> 
>> kde 4.8.1 (on F16) recognises files with extension .pro, for syntax
>> highlighting purposes, as qmake files. This is shown by a checked radio
>> button under in tools/highlighting/other/QMake when editing a file with
>> this extension. Also, tools/mode/other/QMake is checked.
>>
>> I'd like to make kate activate tools/highlighting/sources/RSIIDL for
>> syntax highlighting automatically for the .pro file extension instead
>> since this file type is used by the Interactive Data Language (now owned
>> by Excelis, but formerly by RSI, hence RSIIDL, to avoid a conflict with
>> IDL the Interface Definition Language) for its language source files.
>> I'd like to be able to make this change on a system-wide basis.
> 
> You can change this per-user in Settings > Editor Component >
> Open/Save > Modes & Filetypes:
> http://docs.kde.org/stable/en/kde-baseapps/kate/config-dialog-editor.html#pref-open-save-modes-filetypes
> 
> Simply remove the *.pro extension from the "File extensions" text box
> under Other/QMake and add it to Sources/RSI IDL.

I tried this and got incredibly confused! Most of the time it didn't
seem to make any difference, but occasionally some files would be
highlighted correctly.

I figured maybe there was some caching going on somewhere and found that
in the Settings/ Configure Kate / Application/ General there was an
option to "Keep meta-information past sessions" which was ticked.
Unticking this make your suggestion above work well.

Having read a bit about this in the Kate Handbook I found that I was
able to reset this meta-information by making a trivial edit to my files
with another editor. (Interestingly it seems that the file does actually
have to be changed on disk, not just have an edit made and undone and
then the file saved).

After some experimenting I found that I didnt actually need to remove
the *.pro from the Other/Qmake entry in Settings > Editor Component >
> Open/Save > Modes & Filetypes dialogue, it seems to be enough to bump
the priority field in Sources/RSI IDL section up to "1".

> 
> Unfortunately, AFAIK it's not possible to change it for all user
> accounts on the system.

I found that adding the text: priority="1" to the line that starts
"<language" in the file /usr/share/kde4/apps/katepart/syntax/rsiidl.xml
is able to effect this change for all users.

ie that line now reads:

<language name="RSI IDL" priority="1" version="1.04" kateversion="2.1"
section="Sources" extensions="*.pro" mimetype="text/x-rsiidl-src"
author="Markus Fraenz (fraenz at linmpi.mpg.de)" license="">

Thanks again for your help.

Roderick
> 
> -T.C.
> 
> [1] http://commits.kde.org/kate/2ed211891b52593a0d6f08b367656f2cd0ef76df



More information about the kde mailing list