summaryrefslogtreecommitdiff
path: root/data/eo/eo-mode.el
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-12-05 12:34:43 +0000
committerTom Hacohen <tom@stosb.com>2016-12-05 12:34:43 +0000
commit92f8e013eaa62da6658556924f9a08cf31c75565 (patch)
treea7e96f649bb8e823e5510fb9e6cd6c3f23b3f920 /data/eo/eo-mode.el
parent0431dd24fd971149878ccbfb48c87f500d9b027c (diff)
Emacs configs: Move to designated repo.
Diffstat (limited to '')
-rw-r--r--data/eo/eo-mode.el398
1 files changed, 0 insertions, 398 deletions
diff --git a/data/eo/eo-mode.el b/data/eo/eo-mode.el
deleted file mode 100644
index f455711ed7..0000000000
--- a/data/eo/eo-mode.el
+++ /dev/null
@@ -1,398 +0,0 @@
1;;; eo-mode-el -- Major mode for editing Eo (eolian) files
2
3;; Author: Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
4;; Created: 2016-07-29
5;; Keywords: EFL Eo major-mode
6
7;; Copyright (C) 2016 Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
8
9;; This program is free software; you can redistribute it and/or
10;; modify it under the terms of the GNU General Public License as
11;; published by the Free Software Foundation; either version 2 of
12;; the License, or (at your option) any later version.
13
14;; This program is distributed in the hope that it will be
15;; useful, but WITHOUT ANY WARRANTY; without even the implied
16;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17;; PURPOSE. See the GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public
20;; License along with this program; if not, write to the Free
21;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22;; MA 02111-1307 USA
23
24;; To enable for *.eo and *.eot files, add to ~/.emacs:
25;;
26;; (add-to-list 'load-path "SOMEPATH/.emacs.d/site-packages/eo-mode.el")
27;; (add-to-list 'auto-mode-alist '("\\.eo$\\|\\.eot$" . eo-mode))
28;; (autoload 'eo-mode "eo-mode")
29
30
31(defvar eo-mode-hook nil)
32
33(defconst eo-font-lock-units
34 (eval-when-compile
35 (list
36 (list (concat
37 "^\\<"
38 (regexp-opt
39 '(
40 "abstract"
41 "class"
42 "mixin"
43 "interface"
44 "type"
45 "const"
46 "var"
47 "struct"
48 "enum"
49 "import"
50 ) t) "\\>\\(\\(\\s-+@"
51 "\\(extern\\|free([^)]+)\\)"
52 "\\)+\\|\\)\\s-+\\<\\([a-zA-Z_][a-zA-Z0-9_.]*\\)\\>")
53 '(1 font-lock-keyword-face)
54 '(2 font-lock-type-face)
55 '(5 font-lock-function-name-face)
56 )))
57 "Toplevel Units")
58
59(defconst eo-font-lock-blocks
60 (eval-when-compile
61 (append eo-font-lock-units
62 (list
63 (list (concat
64 "^\\s-+"
65 (regexp-opt
66 '(
67 "methods"
68 "events"
69 "implements"
70 "constructors"
71 "params"
72 "keys"
73 "values"
74 ) t) "\\s-*{")
75 '(1 font-lock-builtin-face)
76 ))))
77 "blocks")
78
79(defconst eo-font-lock-blocks-with-modifiers
80 (eval-when-compile
81 (append eo-font-lock-blocks
82 (list
83 (list (concat
84 "^\\s-+"
85 (regexp-opt
86 '(
87 "get"
88 "set"
89 ) t)
90 "\\(\\s-+@"
91 (regexp-opt
92 '(
93 "virtual_pure"
94 ) t)
95 "\\|\\)\\s-*{")
96 '(1 font-lock-builtin-face)
97 '(2 font-lock-type-face)
98 ))))
99 "blocks")
100
101(defconst eo-font-lock-constants
102 (eval-when-compile
103 (append eo-font-lock-blocks-with-modifiers
104 (list
105 (list (concat
106 "\\<"
107 (regexp-opt
108 '(
109 "null"
110 "true"
111 "false"
112 ) t) "\\>")
113 '(1 font-lock-constant-face)
114 ))))
115 "Constants")
116
117(defconst eo-font-lock-event
118 (eval-when-compile
119 (append eo-font-lock-constants
120 (list
121 (list (concat
122 "^\\s-+\\([a-zA-Z][a-zA-Z0-9_,]*\\)\\(\\s-+@"
123 (regexp-opt
124 '(
125 "private"
126 "protected"
127 "beta"
128 "hot"
129 ) t) "\\|\\)\\s-*\\(:\\|;\\)")
130 '(1 font-lock-variable-name-face)
131 '(2 font-lock-type-face)
132 ))))
133 "event")
134
135(defconst eo-font-lock-param
136 (eval-when-compile
137 (append eo-font-lock-event
138 (list
139 (list (concat
140 "^\\s-+\\(@"
141 (regexp-opt
142 '(
143 "in"
144 "out"
145 "inout"
146 ) t)
147 "\\s-+\\|\\)\\([a-zA-Z][a-zA-Z0-9_]*\\)"
148 "\\s-*:[^@]+*\\(\\(\\s-+@"
149 (regexp-opt
150 '(
151 "nonull"
152 "nullable"
153 "optional"
154 ) t)
155 "\\)+\\|\\)\\s-*;"
156 )
157 '(1 font-lock-type-face)
158 '(3 font-lock-variable-name-face)
159 '(4 font-lock-type-face)
160 ))))
161 "parameters")
162
163
164(defconst eo-font-lock-return
165 (eval-when-compile
166 (append eo-font-lock-param
167 (list
168 (list (concat
169 "^\\s-+return\\s-*:[^@]+*\\(\\(\\s-+@"
170 (regexp-opt
171 '(
172 "warn_unused"
173 ) t)
174 "\\)+\\|\\)\\s-*;"
175 )
176 '(1 font-lock-type-face)
177 ))))
178 "return")
179
180(defconst eo-font-lock-default-implementation
181 (eval-when-compile
182 (append eo-font-lock-return
183 (list
184 (list (concat
185 "^\\s-+"
186 (regexp-opt
187 '(
188 "class.constructor"
189 "class.destructor"
190 ) t)
191 "\\s-*;"
192 )
193 '(1 font-lock-builtin-face)
194 ))))
195 "Default Implementation")
196
197(defconst eo-font-lock-implementation
198 (eval-when-compile
199 (append eo-font-lock-default-implementation
200 (list
201 (list (concat
202 "^\\s-+"
203 "\\(@\\(auto\\|empty\\)\\s-+\\|\\)"
204 "\\([a-zA-Z.][a-zA-Z0-9_.]*\\)"
205 "\\s-*;"
206 )
207 '(1 font-lock-type-face)
208 '(3 font-lock-variable-name-face)
209 ))))
210 "Implementation")
211
212(defconst eo-font-lock-property
213 (eval-when-compile
214 (append eo-font-lock-implementation
215 (list
216 (list (concat
217 "^\\s-+\\(@property\\)\\s-+"
218 "\\([a-zA-Z][a-zA-Z0-9_]*\\)\\(\\(\\s-+@"
219 (regexp-opt
220 '(
221 "protected"
222 "class"
223 "virtual_pure"
224 "part"
225 ) t)
226 "\\)+\\|\\)\\s-*{"
227 )
228 '(1 font-lock-type-face)
229 '(2 font-lock-variable-name-face)
230 '(3 font-lock-type-face)
231 ))))
232 "Property method")
233
234(defconst eo-font-lock-method
235 (eval-when-compile
236 (append eo-font-lock-property
237 (list
238 (list (concat
239 "^\\s-+\\([a-zA-Z][a-zA-Z0-9_]*\\)\\(\\(\\s-+@"
240 (regexp-opt
241 '(
242 "protected"
243 "const"
244 "class"
245 "virtual_pure"
246 ) t)
247 "\\)+\\|\\)\\s-*{"
248 )
249 '(1 font-lock-variable-name-face)
250 '(2 font-lock-type-face)
251 ))))
252 "Method")
253
254
255(defconst eo-font-lock-fields
256 (eval-when-compile
257 (append eo-font-lock-method
258 (list
259 (list "^\\s-+\\<\\([a-zA-Z0-9][a-zA-Z0-9_,]*\\)\\>:"
260 '(1 font-lock-variable-name-face)
261 ))))
262 "Fields & Events without modifiers")
263
264(defconst eo-font-lock-complex-type
265 (eval-when-compile
266 (append eo-font-lock-fields
267 (list
268 (list (concat
269 "\\<"
270 (regexp-opt
271 '(
272 "accessor"
273 "array"
274 "iterator"
275 "hash"
276 "list"
277 ) t)
278 "\\>\\s-*<"
279 )
280 '(1 font-lock-builtin-face)
281 ))))
282 "Complex types, C++ template style.")
283
284(defconst eo-font-lock-expression-functions
285 (eval-when-compile
286 (append eo-font-lock-complex-type
287 (list
288 (list (concat
289 "\\<"
290 (regexp-opt
291 '(
292 "own"
293 "const"
294 "free"
295 ) t)
296 "\\>\\s-*("
297 )
298 '(1 font-lock-builtin-face)
299 ))))
300 "Expression Functions")
301
302(defconst eo-font-lock-known-types
303 (eval-when-compile
304 (append eo-font-lock-expression-functions
305 (list
306 (list (concat
307 "\\<"
308 (regexp-opt
309 '(
310 "byte"
311 "ubyte"
312 "char"
313 "short"
314 "ushort"
315 "int"
316 "uint"
317 "long"
318 "ulong"
319 "llong"
320 "ullong"
321 "int8"
322 "uint8"
323 "int16"
324 "uint16"
325 "int32"
326 "uint32"
327 "int64"
328 "uint64"
329 "int128"
330 "uint128"
331 "size"
332 "ssize"
333 "intptr"
334 "uintptr"
335 "ptrdiff"
336 "time"
337 "float"
338 "double"
339 "bool"
340 "void"
341 "void_ptr"
342 ) t)
343 "\\>"
344 )
345 '(1 font-lock-builtin-face)
346 ))))
347 "Expression Functions")
348
349(defgroup eo nil
350 "EFL's Eo formatting."
351 :prefix "eo-"
352 :group 'faces)
353
354(defface eo-docstring-face
355 '((t :inherit font-lock-string-face))
356 "Face used to highlight documentation strings."
357 :group 'eo)
358
359(defconst eo-font-lock-docstring
360 (eval-when-compile
361 (append eo-font-lock-known-types
362 (list
363 (list "\\(\\[\\[.*\\]\\]\\)"
364 '(1 'eo-docstring-face t) ;; t = overrides comment existing formatting
365 ))))
366 "Documentation")
367
368(defvar eo-font-lock eo-font-lock-docstring)
369
370(defvar eo-mode-syntax-table
371 (let ((eo-mode-syntax-table (make-syntax-table)))
372 ;; [ is open and matches ], but [[ is a docstring starter
373 (modify-syntax-entry ?[ "(]12c" eo-mode-syntax-table)
374 (modify-syntax-entry ?] ")[34c" eo-mode-syntax-table)
375 eo-mode-syntax-table)
376 "Syntax table for eo-mode")
377
378(c-add-style
379 "eo"
380 '("gnu"
381 (indent-tabs-mode . nil)
382 (tab-width . 8)
383 (c-basic-offset . 4)
384 (c-backslash-column . 72)
385 ))
386
387(define-derived-mode eo-mode c-mode "Eo"
388 "Major mode for editing Eo files"
389 (interactive)
390 (use-local-map eo-mode-map)
391 (set-syntax-table eo-mode-syntax-table)
392 (set (make-local-variable 'font-lock-defaults) '(eo-font-lock))
393 (set (make-local-variable 'require-final-newline) t)
394 (c-set-style "eo")
395 (run-hooks 'eo-mode-hook)
396 )
397
398(provide 'eo-mode)