1 | ; -!- emf -!- |
---|
2 | ; |
---|
3 | ; Created: 08-02-03 |
---|
4 | ; Synopsis: Cobra Language hook |
---|
5 | ; Authors: Mike Hopkirk |
---|
6 | ; copied from hkpython.emf |
---|
7 | ; |
---|
8 | define-macro fhook-cobra |
---|
9 | set-variable $buffer-mask "luh1" |
---|
10 | @# buffer-init "cobra" |
---|
11 | buffer-init-hooks |
---|
12 | set-variable $buffer-tab-width 4 |
---|
13 | ; tab mode off so uses tabs rather than spcs |
---|
14 | -1 buffer-mode "tab" |
---|
15 | !emacro |
---|
16 | |
---|
17 | ; buffer-init variables |
---|
18 | set-variable .fhook-cobra.setup ® "/history/fhook/cobra" "dfghiopx" |
---|
19 | set-variable .fhook-cobra.setup-mask "adefghikmnoptux" |
---|
20 | set-variable .fhook-cobra.comment "|#||#|# | #|r|" |
---|
21 | |
---|
22 | ; Set up collapse for cobra |
---|
23 | set-variable .fhook-cobra.collapse-open "^\\(class \\|def \\)" |
---|
24 | set-variable .fhook-cobra.collapse-close "^[a-z]\\|\\'" |
---|
25 | set-variable .fhook-cobra.collapse-mclose "0" |
---|
26 | set-variable .fhook-cobra.collapse-mnext "-1" |
---|
27 | |
---|
28 | ; setup item-list |
---|
29 | set-variable .fhook-cobra.item-list-s1 "^[ \t]*def[ \t]+\\(\\w+\\)" |
---|
30 | set-variable .fhook-cobra.item-list-r1 "Def \ecB\\1\ecA" |
---|
31 | set-variable .fhook-cobra.item-list-s2 "^[ \t]*class*[ \t]+\\(\\w+\\)\\([ \t]+:\\|[ \t]*{\\|[ \t]*$\\)" |
---|
32 | set-variable .fhook-cobra.item-list-r2 "Class \ecB\\1\ecA" |
---|
33 | |
---|
34 | !if &and &sin "h" .fhook-cobra.setup &band .hilight.flags 0x02 |
---|
35 | !if ¬ &exist .hilight.cobra |
---|
36 | set-variable .hilight.cobra &pinc .hilight.next 1 |
---|
37 | !endif |
---|
38 | 0 hilight .hilight.cobra 2 40 $global-scheme |
---|
39 | hilight .hilight.cobra 2 "#" .scheme.comment |
---|
40 | hilight .hilight.cobra 4 "\"" "\"" "\\" .scheme.string |
---|
41 | hilight .hilight.cobra 0 "\\[" .scheme.string |
---|
42 | hilight .hilight.cobra 0 "\\]" .scheme.string |
---|
43 | ; Quote |
---|
44 | hilight .hilight.cobra 4 "'" "'" "\\" .scheme.quote |
---|
45 | ; Hilight TODO in a comment - Examples |
---|
46 | ; i.e. # TODO: I need to do this */ |
---|
47 | ; hilight .hilight.cobra 20 "#\\s+[Tt][Oo][Dd][Oo]" .scheme.error |
---|
48 | hilight .hilight.cobra 18 "#\\s*[tT][oO][dD][oO]" .scheme.error |
---|
49 | ; Variables |
---|
50 | hilight .hilight.cobra 1 "var" .scheme.variable |
---|
51 | ; Keywords |
---|
52 | hilight .hilight.cobra 1 "and" .scheme.keyword |
---|
53 | hilight .hilight.cobra 1 "as" .scheme.keyword |
---|
54 | hilight .hilight.cobra 1 "assert" .scheme.keyword |
---|
55 | hilight .hilight.cobra 1 "body" .scheme.keyword |
---|
56 | hilight .hilight.cobra 1 "branch" .scheme.keyword |
---|
57 | hilight .hilight.cobra 1 "break" .scheme.keyword |
---|
58 | hilight .hilight.cobra 1 "catch" .scheme.keyword |
---|
59 | hilight .hilight.cobra 1 "class" .scheme.function |
---|
60 | hilight .hilight.cobra 1 "continue" .scheme.keyword |
---|
61 | hilight .hilight.cobra 1 "def" .scheme.keyword |
---|
62 | ; hilight .hilight.cobra 1 "def" .scheme.function |
---|
63 | hilight .hilight.cobra 1 "else" .scheme.keyword |
---|
64 | hilight .hilight.cobra 1 "end" .scheme.keyword |
---|
65 | hilight .hilight.cobra 1 "ensure" .scheme.keyword |
---|
66 | hilight .hilight.cobra 1 "enum" .scheme.function |
---|
67 | hilight .hilight.cobra 1 "event" .scheme.keyword |
---|
68 | hilight .hilight.cobra 1 "except" .scheme.keyword |
---|
69 | hilight .hilight.cobra 1 "extend" .scheme.keyword |
---|
70 | hilight .hilight.cobra 1 "false" .scheme.constant |
---|
71 | hilight .hilight.cobra 1 "finally" .scheme.keyword |
---|
72 | hilight .hilight.cobra 1 "for" .scheme.keyword |
---|
73 | hilight .hilight.cobra 1 "from" .scheme.keyword |
---|
74 | hilight .hilight.cobra 1 "get" .scheme.keyword |
---|
75 | hilight .hilight.cobra 1 "global" .scheme.keyword |
---|
76 | hilight .hilight.cobra 1 "has" .scheme.keyword |
---|
77 | hilight .hilight.cobra 1 "if" .scheme.keyword |
---|
78 | hilight .hilight.cobra 1 "ignore" .scheme.keyword |
---|
79 | hilight .hilight.cobra 1 "implements" .scheme.keyword |
---|
80 | hilight .hilight.cobra 1 "import" .scheme.keyword |
---|
81 | hilight .hilight.cobra 1 "in" .scheme.keyword |
---|
82 | hilight .hilight.cobra 1 "inherits" .scheme.keyword |
---|
83 | hilight .hilight.cobra 1 "inout" .scheme.keyword |
---|
84 | hilight .hilight.cobra 1 "interface" .scheme.function |
---|
85 | hilight .hilight.cobra 1 "invariant" .scheme.keyword |
---|
86 | hilight .hilight.cobra 1 "is" .scheme.keyword |
---|
87 | hilight .hilight.cobra 1 "listen" .scheme.keyword |
---|
88 | hilight .hilight.cobra 1 "namespace" .scheme.keyword |
---|
89 | hilight .hilight.cobra 1 "nil" .scheme.constant |
---|
90 | hilight .hilight.cobra 1 "not" .scheme.keyword |
---|
91 | hilight .hilight.cobra 1 "or" .scheme.keyword |
---|
92 | hilight .hilight.cobra 1 "out" .scheme.keyword |
---|
93 | hilight .hilight.cobra 1 "pass" .scheme.keyword |
---|
94 | hilight .hilight.cobra 1 "print" .scheme.keyword |
---|
95 | hilight .hilight.cobra 1 "pro" .scheme.keyword |
---|
96 | hilight .hilight.cobra 1 "raise" .scheme.keyword |
---|
97 | hilight .hilight.cobra 1 "require" .scheme.keyword |
---|
98 | hilight .hilight.cobra 1 "return" .scheme.keyword |
---|
99 | hilight .hilight.cobra 1 "set" .scheme.keyword |
---|
100 | hilight .hilight.cobra 1 "struct" .scheme.keyword |
---|
101 | hilight .hilight.cobra 1 "sig" .scheme.keyword |
---|
102 | hilight .hilight.cobra 1 "test" .scheme.keyword |
---|
103 | hilight .hilight.cobra 1 "then" .scheme.keyword |
---|
104 | hilight .hilight.cobra 1 "throw" .scheme.keyword |
---|
105 | hilight .hilight.cobra 1 "to" .scheme.keyword |
---|
106 | hilight .hilight.cobra 1 "to?" .scheme.keyword |
---|
107 | hilight .hilight.cobra 1 "trace" .scheme.keyword |
---|
108 | hilight .hilight.cobra 1 "true" .scheme.constant |
---|
109 | hilight .hilight.cobra 1 "try" .scheme.keyword |
---|
110 | hilight .hilight.cobra 1 "use" .scheme.keyword |
---|
111 | hilight .hilight.cobra 1 "using" .scheme.keyword |
---|
112 | hilight .hilight.cobra 1 "vari" .scheme.keyword |
---|
113 | hilight .hilight.cobra 1 "where" .scheme.keyword |
---|
114 | hilight .hilight.cobra 1 "while" .scheme.keyword |
---|
115 | hilight .hilight.cobra 1 "yield" .scheme.keyword |
---|
116 | ; isnames |
---|
117 | hilight .hilight.cobra 1 "abstract" .scheme.prepro |
---|
118 | hilight .hilight.cobra 1 "fake" .scheme.prepro |
---|
119 | hilight .hilight.cobra 1 "internal" .scheme.prepro |
---|
120 | hilight .hilight.cobra 1 "new" .scheme.prepro |
---|
121 | hilight .hilight.cobra 1 "nonvirtual" .scheme.prepro |
---|
122 | hilight .hilight.cobra 1 "override" .scheme.prepro |
---|
123 | hilight .hilight.cobra 1 "private" .scheme.prepro |
---|
124 | hilight .hilight.cobra 1 "protected" .scheme.prepro |
---|
125 | hilight .hilight.cobra 1 "public" .scheme.prepro |
---|
126 | hilight .hilight.cobra 1 "shared" .scheme.prepro |
---|
127 | hilight .hilight.cobra 1 "virtual" .scheme.prepro |
---|
128 | |
---|
129 | ; Operators |
---|
130 | hilight .hilight.cobra 0 "(" .scheme.operator |
---|
131 | hilight .hilight.cobra 0 ")" .scheme.operator |
---|
132 | hilight .hilight.cobra 1 ":" .scheme.operator |
---|
133 | hilight .hilight.cobra 1 "<" .scheme.operator |
---|
134 | hilight .hilight.cobra 1 ">" .scheme.operator |
---|
135 | hilight .hilight.cobra 1 "<=" .scheme.operator |
---|
136 | hilight .hilight.cobra 1 ">=" .scheme.operator |
---|
137 | hilight .hilight.cobra 1 "==" .scheme.operator |
---|
138 | hilight .hilight.cobra 1 "=" .scheme.operator |
---|
139 | hilight .hilight.cobra 1 "<>" .scheme.operator |
---|
140 | hilight .hilight.cobra 1 "," .scheme.operator |
---|
141 | hilight .hilight.cobra 1 "\\." .scheme.operator |
---|
142 | hilight .hilight.cobra 1 "ref" .scheme.operator |
---|
143 | |
---|
144 | hilight .hilight.cobra 1 "bool" .scheme.type |
---|
145 | hilight .hilight.cobra 1 "char" .scheme.type |
---|
146 | hilight .hilight.cobra 1 "dynamic" .scheme.type |
---|
147 | hilight .hilight.cobra 1 "number" .scheme.type |
---|
148 | hilight .hilight.cobra 1 "uint" .scheme.type |
---|
149 | hilight .hilight.cobra 1 "uint8" .scheme.type |
---|
150 | hilight .hilight.cobra 1 "uint16" .scheme.type |
---|
151 | hilight .hilight.cobra 1 "uint32" .scheme.type |
---|
152 | hilight .hilight.cobra 1 "uint64" .scheme.type |
---|
153 | hilight .hilight.cobra 1 "int" .scheme.type |
---|
154 | hilight .hilight.cobra 1 "int8" .scheme.type |
---|
155 | hilight .hilight.cobra 1 "int16" .scheme.type |
---|
156 | hilight .hilight.cobra 1 "int32" .scheme.type |
---|
157 | hilight .hilight.cobra 1 "int64" .scheme.type |
---|
158 | ; hilight .hilight.cobra 1 "long" .scheme.type |
---|
159 | hilight .hilight.cobra 1 "decimal" .scheme.type |
---|
160 | hilight .hilight.cobra 1 "float" .scheme.type |
---|
161 | hilight .hilight.cobra 1 "String" .scheme.type |
---|
162 | hilight .hilight.cobra 1 "Type" .scheme.type |
---|
163 | hilight .hilight.cobra 1 "List" .scheme.type |
---|
164 | hilight .hilight.cobra 1 "Set" .scheme.type |
---|
165 | hilight .hilight.cobra 1 "Dictionary" .scheme.type |
---|
166 | hilight .hilight.cobra 1 "Object" .scheme.type |
---|
167 | |
---|
168 | hilight .hilight.cobra 1 "-" .scheme.operator |
---|
169 | hilight .hilight.cobra 1 "+" .scheme.operator |
---|
170 | hilight .hilight.cobra 1 "%" .scheme.operator |
---|
171 | hilight .hilight.cobra 1 "/" .scheme.operator |
---|
172 | hilight .hilight.cobra 1 "*" .scheme.operator |
---|
173 | hilight .hilight.cobra 1 "pow" .scheme.operator |
---|
174 | hilight .hilight.cobra 1 "~" .scheme.operator |
---|
175 | hilight .hilight.cobra 0 "\\^" .scheme.operator |
---|
176 | hilight .hilight.cobra 1 "&" .scheme.operator |
---|
177 | hilight .hilight.cobra 1 "|" .scheme.operator |
---|
178 | hilight .hilight.cobra 1 "<<" .scheme.operator |
---|
179 | hilight .hilight.cobra 1 ">>" .scheme.operator |
---|
180 | hilight .hilight.cobra 1 "and" .scheme.operator |
---|
181 | hilight .hilight.cobra 1 "or" .scheme.operator |
---|
182 | hilight .hilight.cobra 1 "not" .scheme.operator |
---|
183 | |
---|
184 | |
---|
185 | !endif |
---|
186 | ; THis indent isnt 100% right - looks like wspc dedent is being |
---|
187 | ; overridden by default indent to previous non ws line |
---|
188 | ; bearable with user_setup->General->Tab_to_indent set to |
---|
189 | ; 'first column only' and use dwn arrow on line after s-Tab forced dedent. |
---|
190 | ; |
---|
191 | ; me generally needs fixing for languages without indentation delimiters |
---|
192 | ; (python, cobra ruby?) so when indent in effect tab and s-tab change to |
---|
193 | ; user-indent/user-dedent binding that overrides and updates default |
---|
194 | ; notion of what current indent level should be [TODO] |
---|
195 | !if &sin "d" .fhook-cobra.setup |
---|
196 | 0 indent .hilight.cobra 0 3 |
---|
197 | indent .hilight.cobra n "def.*$" 4 |
---|
198 | indent .hilight.cobra n "class.*$" 4 |
---|
199 | indent .hilight.cobra n "if .*$" 4 |
---|
200 | indent .hilight.cobra s "else$" -4 |
---|
201 | indent .hilight.cobra s "else.*$" -4 |
---|
202 | indent .hilight.cobra o "^[ \t]+$" -4 |
---|
203 | indent .hilight.cobra i "#" |
---|
204 | !endif |
---|
205 | |
---|
206 | buffer-init-fhook "cobra" |
---|
207 | |
---|