Re: gedit/gtksourceview trouble making new language-spec



On 12/31/2010 12:47 AM, M Watts wrote:
On 12/31/2010 11:34 AM, Ed Greenberg wrote:
Hi Folks,  Trying to make a new language definition for gedit
(gtksourceview), I seem to be stuck.

I'd like to highlight a c-like language called "Asterisk Extension
Language."

I started by making a copy of the language-specs/c.lang file in my
~/.local/share/gtksourceview-2.0/language-specs directory, called ael.lang.
<language id="ael" _name="ael" version="0.1" _section="Sources">
<metadata>
<property name="mimetypes">text/x-ael</property>
<property name="globs">*.ael</property>
<property name="line-comment-start">//</property>
<property name="block-comment-start">/*</property>
<property name="block-comment-end">*/</property>
</metadata>
----snip---

Try starting the .lang file with:

<?xml version="1.0" encoding="UTF-8"?>
I had this in the file, but not in the email. (Should have put a ---snip--- above my fragement, as well as below.)

<language id="ael" _name="ael" version="2.0" _section="Sources" mimetypes="text/x-ael">
Got it working!

1. Turns out that running gedit from the command line produces error messages related to the opening and parsing of the .lang file.

2. Errors indicated first that the mimetypes attribute referenced above is not valid in the language ID.

3. After fixing that, the remaining error was: (gedit:7443): GtkSourceView-WARNING **: Failed to load '/home/edg/.local/share/gtksourceview-2.0/language-specs/ael.lang': Missing main language definition (id = "ael".)

The resolution to this was down lower in the file, where we had <context id="c">. This seems to be the "main language definition." There needs to be one for "ael", not for "c".

I now have the beginnings of highlighting, so I can learn how to highlight additional parts of the file.

Thanks to Mr. Watts for getting me going.

Ed Greenberg
Austin, TX


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]