I am proficient in developing basic syntax highlighting modes based on
font-lock-defaults and regex (even with
Today I faced with format of natural language translation dictionary which look like:
__ begin [bɪˈgɪn] v1 began [bɪˈgæn] v2 begun [bɪˈgʌn] v3 v ru: начать ua: починати __ smile [smaɪl] v ru: улыбаться n ru: улыбка __ e.g. abbr en: for example la: exempli gratia __ x-rays topic: sci en: a kind of radiation that can pass through most solid materials, often used in medicine __ woman [ˈwʊmən] s women [wɪmɪn] pl n ru: женщина ua: жінка __ colour gb ['kʌlə] color us ['kʌlər] n ru: цвет ua: колір __ white [waɪt] adj ant: black ru: чорный ua: чорний
As easy to see indenting and new lines with special prefixes define syntax.
Indenting in first part of entry used to separate word variances. Blank lines in second part of article separate different word meaning, lines should begin with defined prefixes and indenting is not allowed.
regex is not context aware and can't be used to properly highlight such file format.
File format have property that is can be validated from any point of file with small lookup around for
So I am interested in writing mode that properly highlighted and "localy" validated file (no need to validate far from screen several screens).
Is it possible to develop code or mark text in buffer after parsing so in a few cases when intending necessary function for indenting (by TAB) would be easy to code?
What API should I use to develop such mode myself?
Are there any good reference of existing code to follow?