Gedit highlights Octave .m files as Objective-C Sources

I’ve had this problem since Fedora 11, and it still persists in Fedora 14. Previously, I’ve deleted the objc.lang file as suggested in this thread, however, I’ve recently switched over to the following method:

1. Close all gedit instances
2. Edit the mime-type definition file:

sudo vi /usr/share/mime/packages/freedesktop.org.xml

3. Comment out the objective c mime-type definition by adding a line above line 25666 containing

<!--

and a line above what is now line 25717 containing

-->

.

The end result should look like:

...
    <glob pattern="*.not"/>
  </mime-type>
  <!--
  <mime-type type="text/x-objcsrc">
    <comment>Objective-C source code</comment>
    <comment xml:lang="ar">ﺶﻓﺭﺓ ﻢﺻﺩﺭ ﺎﻠﻫﺪﻓ-C </comment>
    <comment xml:lang="be@latin">Kryničny kod Objective-C</comment>
    <comment xml:lang="bg">Изходен код — Objective C</comment>
    <comment xml:lang="ca">codi font en Objective-C</comment>
    <comment xml:lang="cs">Zdrojový kód v Objective-C</comment>
    <comment xml:lang="da">Objektiv C-kildekode</comment>
    <comment xml:lang="de">Objective-C-Quelltext</comment>
    <comment xml:lang="el">πηγαίος κώδικας Objective-C</comment>
    <comment xml:lang="en_GB">Objective-C source code</comment>
    <comment xml:lang="eo">fontkodo en Objective-C</comment>
    <comment xml:lang="es">código fuente en Objective-C</comment>
    <comment xml:lang="eu">Objective-C iturburu-kodea</comment>
    <comment xml:lang="fi">Objective-C-lähdekoodi</comment>
    <comment xml:lang="fr">code source Objective-C</comment>
    <comment xml:lang="ga">cód foinseach Objective-C</comment>
    <comment xml:lang="he">קוד מקור של Objective-C</comment>
    <comment xml:lang="hu">Objective-C forráskód</comment>
    <comment xml:lang="id">Kode program Objective-C</comment>
    <comment xml:lang="it">Codice sorgente Objective-C</comment>
    <comment xml:lang="ja">Objective-C ソースコード</comment>
    <comment xml:lang="kk">Objective-C бастапқы коды</comment>
    <comment xml:lang="ko">Objective-C 소스 코드</comment>
    <comment xml:lang="lt">Objective-C pradinis kodas</comment>
    <comment xml:lang="lv">Objective-C pirmkods</comment>
    <comment xml:lang="ms">Kod sumber Objective-C</comment>
    <comment xml:lang="nb">Objective-C-kildekode</comment>
    <comment xml:lang="nl">Objective-C-broncode</comment>
    <comment xml:lang="nn">Objective-C-kjeldekode</comment>
    <comment xml:lang="pl">Kod źródłowy Objective-C</comment>
    <comment xml:lang="pt">código fonte Objective-C</comment>
    <comment xml:lang="pt_BR">Código fonte Objective-C</comment>
    <comment xml:lang="ro">Cod sursă Objective-C</comment>
    <comment xml:lang="ru">исходный код Objective-C </comment>
    <comment xml:lang="sk">Zdrojový kód v Objective-C</comment>
    <comment xml:lang="sl">Datoteka izvorne kode Objective-C</comment>
    <comment xml:lang="sq">Kod burues C objekt</comment>
    <comment xml:lang="sr">Објектни-C изворни ко̂д</comment>
    <comment xml:lang="sv">Objective-C-källkod</comment>
    <comment xml:lang="uk">вихідний код мовою Objective-C</comment>
    <comment xml:lang="vi">Mã nguồn Objective-C</comment>
    <comment xml:lang="zh_CN">Objective-C 源代码</comment>
    <comment xml:lang="zh_TW">Objective-C 源代碼</comment>
    <sub-class-of type="text/x-csrc"/>
    <magic priority="30">
      <match value="#import" type="string" offset="0"/>
    </magic>
    <glob pattern="*.m"/>
  </mime-type>
  -->
  <mime-type type="text/x-ocaml">
    <comment>OCaml source code</comment>
...

4. Update the mime-type database:

sudo update-mime-database /usr/share/mime/

5. Restart gedit

Source: Nothing Fancy, Just Blogging.

Posted Sunday, January 30th, 2011 under linux, tips and tricks.

2 comments

  1. Or similarly:
    -open file “/usr/share/gtksourceview-2.0/language-specs/objc.lang” as sudo
    -comment out the line (#26 for me) associating *.m files with Obj-C:

    <!– *.m –>

    -restart gedit
    -you can still use Obj-C highlights but *.m is now associated with Octave by default.

  2. @Jacques,

    Great tip! Thanks

Leave a Reply