summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-12-05 12:34:21 +0000
committerTom Hacohen <tom@stosb.com>2016-12-05 12:34:21 +0000
commitaa190cb127749c90392b7b1288758ba0ee422b95 (patch)
tree077a68738f0a801e378a5a5b3e06a582a999b089
Initial import for emacs config files.
-rw-r--r--edje-mode.el513
-rw-r--r--eo-mode.el398
2 files changed, 911 insertions, 0 deletions
diff --git a/edje-mode.el b/edje-mode.el
new file mode 100644
index 0000000..b0d8602
--- /dev/null
+++ b/edje-mode.el
@@ -0,0 +1,513 @@
1;;; edje-mode-el -- Major mode for editing Edje files
2
3;; Author: Gustavo Sverzut Barbieri <barbieri@gmail.com>
4;; Created: 2007-07-23
5;; Keywords: Edje major-mode
6;; Url: http://barbieri-playground.googlecode.com/svn/dot-files/edje-mode.el
7;; (if you find this file have problems, check that Url and request update)
8
9;; Copyright (C) 2007 Gustavo Sverzut Barbieri <barbieri@gmail.com>
10
11;; This program is free software; you can redistribute it and/or
12;; modify it under the terms of the GNU General Public License as
13;; published by the Free Software Foundation; either version 2 of
14;; the License, or (at your option) any later version.
15
16;; This program is distributed in the hope that it will be
17;; useful, but WITHOUT ANY WARRANTY; without even the implied
18;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19;; PURPOSE. See the GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public
22;; License along with this program; if not, write to the Free
23;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24;; MA 02111-1307 USA
25
26;;; Commentary:
27;;
28;; This mode is based on tutorial from Scott Andrew Borton:
29;; http://two-wugs.net/emacs/mode-tutorial.html
30
31
32(defvar edje-mode-hook nil)
33
34(defun number-or-nil-to-string (v &optional default)
35 (cond ((numberp v) (number-to-string v))
36 ((stringp v) (if (string= v "") (number-to-string default) v))
37 (t (number-to-string default))))
38
39(defun non-empty-string (s)
40 (and (not (eq 'nil s))
41 (not (string= "" s))))
42
43(defun edje-new-program-action-signal-emit (source emission)
44 "Insert new program SIGNAL_EMIT"
45 (interactive "ssource: \nsemission: ")
46 (insert
47 (concat
48 " action: SIGNAL_EMIT \"" source "\" \"" emission "\";\n"
49 )))
50
51(defun edje-new-program-action-state-set (state value target)
52 "Insert new program STATE_SET"
53 (interactive "sstate: \nsvalue (0.0): \nstarget: ")
54 (insert
55 (concat
56 " action: STATE_SET \"" state "\" "
57 (number-or-nil-to-string value 0.0) ";\n"
58 " target: \"" target "\";\n"
59 )))
60
61(defun edje-new-program-action (action)
62 "Insert new program action"
63 (interactive "saction: ")
64 (setq action (upcase action))
65 (cond ((string= action "STATE_SET")
66 (edje-new-program-action-state-set "" 0.0 ""))
67 ((string= action "SIGNAL_EMIT")
68 (edje-new-program-action-signal-emit "" ""))
69 ))
70
71(defun edje-new-program (name signal source action)
72 "Insert new program block"
73 (interactive "sname: \nssignal: \nssource: \nsaction: ")
74 (insert
75 (concat
76 "\n"
77 " program {\n"
78 " name: \"" name "\";\n"
79
80 (if (non-empty-string signal)
81 (concat " signal: \"" signal "\";\n"))
82
83 (if (non-empty-string source)
84 (concat " source: \"" source "\";\n"))
85 ))
86
87 (edje-new-program-action action)
88
89 (insert
90 (concat
91 " }\n"
92 "\n"
93 )))
94
95(defun edje-new-desc-relative (x y &optional defx defy)
96 "Insert new part description 'relative' line"
97 (interactive "sx: \nsy: ")
98 (insert
99 (concat
100 " relative: "
101 (number-or-nil-to-string x defx) " "
102 (number-or-nil-to-string y defy) ";\n"
103 )))
104
105(defun edje-new-desc-offset (x y &optional defx defy)
106 "Insert new part description 'offset' line"
107 (interactive "sx: \nsy: ")
108 (insert
109 (concat
110 " offset: "
111 (number-or-nil-to-string x defx) " "
112 (number-or-nil-to-string y defy) ";\n"
113 )))
114
115(defun edje-new-desc-inherit (name val)
116 "Insert new part description 'inherit' line"
117 (interactive "sname: \nsvalue: ")
118 (insert
119 (concat
120 " inherit: \"" name "\" "
121 (number-or-nil-to-string val 0.0) ";\n"
122 )))
123
124(defun edje-new-desc-text (font size text)
125 "Insert new part description 'text' block"
126 (interactive "sfont: \nssize: \nstext: ")
127 (insert
128 (concat
129 " text {\n"
130 " font: \"" font "\";\n"
131 " size: " (number-or-nil-to-string size) ";\n"
132 " text: \"" text "\";\n"
133 " }\n"
134 )))
135
136(defun edje-new-desc-image (name)
137 "Insert new part description 'image' block"
138 (interactive "sname: ")
139 (insert
140 (concat
141 " image {\n"
142 " normal: \"" name "\";\n"
143 " }\n"
144 )))
145
146(defun edje-new-desc-color (r g b a &optional defr defg defb defa)
147 "Insert new part description 'color' line"
148 (interactive "sred: \nsgreen: \nsblue: \nsalpha: ")
149 (insert
150 (concat
151 " color: "
152 (number-or-nil-to-string r defr) " "
153 (number-or-nil-to-string g defg) " "
154 (number-or-nil-to-string b defb) " "
155 (number-or-nil-to-string a defa) ";\n"
156 )))
157
158(defun edje-new-desc (name val &optional
159 r1_rx r1_ry
160 r2_rx r2_ry
161 r1_ox r1_oy
162 r2_ox r2_oy
163 part_type)
164 "Insert new part description block"
165 (interactive "sName: \nsValue: ")
166 (insert
167 (concat
168 " description {\n"
169 " state: \"" name "\" " (number-or-nil-to-string val 0.0) ";\n"))
170 (if (string= part_type "RECT") (edje-new-desc-color 255 255 255 255))
171 (insert " rel1 {\n")
172 (edje-new-desc-relative r1_rx r1_ry 0.0 0.0)
173 (edje-new-desc-offset r1_ox r1_oy 0 0)
174 (insert
175 (concat
176 " }\n"
177 " rel2 {\n"
178 ))
179 (edje-new-desc-relative r2_rx r2_ry 1.0 1.0)
180 (edje-new-desc-offset r2_ox r2_oy -1 -1)
181 (insert " }\n")
182 (cond ((string= part_type "IMAGE") (edje-new-desc-image ""))
183 ((string= part_type "TEXT") (edje-new-desc-text "" 10 "contents"))
184 )
185 (insert " }\n")
186 )
187
188(defun edje-new-part (name type &optional
189 r1_rx r1_ry
190 r2_rx r2_ry
191 r1_ox r1_oy
192 r2_ox r2_oy)
193 "Insert new part"
194 (interactive "sName: \nsType: ")
195 (setq type (upcase type))
196 (insert
197 (concat
198 "\n"
199 " part {\n"
200 " name: \"" name "\";\n"
201 " type: " type ";\n"
202 " mouse_events: 0;\n"
203 ))
204 (edje-new-desc "default" 0.0 r1_rx r1_ry r2_rx r2_ry r1_ox r1_oy r2_ox r2_oy type)
205 (insert
206 (concat
207 " }\n"
208 )))
209
210(defun edje-setup-compile ()
211 (set (make-local-variable 'compile-command)
212 (concat "edje_cc " (buffer-file-name))
213 ))
214
215(defun edje-cc ()
216 "Runs edje_cc with current buffer."
217 (interactive)
218 (compile (edje-setup-compile)))
219
220(defvar edje-mode-map
221 (let ((edje-mode-map (make-sparse-keymap)))
222 (define-key edje-mode-map "\C-j" 'newline-and-indent)
223 (define-key edje-mode-map "\C-cp" 'edje-new-part)
224 (define-key edje-mode-map "\C-cd" 'edje-new-desc)
225 (define-key edje-mode-map "\C-cr" 'edje-new-desc-relative)
226 (define-key edje-mode-map "\C-co" 'edje-new-desc-offset)
227 (define-key edje-mode-map "\C-ch" 'edje-new-desc-inherit)
228 (define-key edje-mode-map "\C-cc" 'edje-new-desc-color)
229 (define-key edje-mode-map "\C-ci" 'edje-new-desc-image)
230 (define-key edje-mode-map "\C-ct" 'edje-new-desc-text)
231 (define-key edje-mode-map "\C-cg" 'edje-new-program)
232 (define-key edje-mode-map "\C-ca" 'edje-new-program-action)
233 (define-key edje-mode-map "\C-cs" 'edje-new-program-action-state-set)
234 (define-key edje-mode-map "\C-ce" 'edje-new-program-action-signal-emit)
235 edje-mode-map)
236 "Keymap for Edje major mode")
237
238(add-hook 'c-mode-hook 'edje-setup-compile)
239(add-to-list 'auto-mode-alist '("\\.edc$" . edje-mode))
240
241(defconst edje-font-lock-keywords-1
242 (eval-when-compile
243 (list
244 (list (concat "[ \t]*\\<"
245 (regexp-opt
246 '(
247 "collections"
248 "data"
249 "description"
250 "dragable"
251 "fill"
252 "fonts"
253 "group"
254 "image"
255 "images"
256 "origin"
257 "part"
258 "parts"
259 "program"
260 "programs"
261 "rel1"
262 "rel2"
263 "script"
264 "spectra"
265 "style"
266 "styles"
267 "text"
268 ) t) "\\>\\([ \t]*{\\|\\.\\)")
269 '(1 font-lock-function-name-face))
270
271 ))
272 "Major keywords")
273
274(defconst edje-font-lock-keywords-2
275 (eval-when-compile
276 (append edje-font-lock-keywords-1
277 (list
278 (list
279 (concat "^\\([ \t]*\\|[ \t]*[a-z]+\\.\\|\\)\\<"
280 (regexp-opt
281 '("action"
282 "after"
283 "alias"
284 "align"
285 "angle"
286 "aspect"
287 "aspect_preference"
288 "base"
289 "border"
290 "clip_to"
291 "collections"
292 "color"
293 "color2"
294 "color3"
295 "color_class"
296 "color_classes"
297 "confine"
298 "data"
299 "description"
300 "dragable"
301 "effect"
302 "elipsis"
303 "events"
304 "fill"
305 "fit"
306 "fixed"
307 "font"
308 "fonts"
309 "gradient"
310 "group"
311 "ignore_flags"
312 "image"
313 "images"
314 "in"
315 "inherit"
316 "item"
317 "max"
318 "middle"
319 "min"
320 "mouse_events"
321 "name"
322 "normal"
323 "offset"
324 "origin"
325 "part"
326 "parts"
327 "pointer_mode"
328 "precise_is_inside"
329 "program"
330 "programs"
331 "rel1"
332 "rel2"
333 "relative"
334 "repeat_events"
335 "signal"
336 "size"
337 "smooth"
338 "source"
339 "spectra"
340 "spectrum"
341 "spread"
342 "state"
343 "step"
344 "style"
345 "styles"
346 "tag"
347 "target"
348 "text"
349 "text_class"
350 "text_source"
351 "to"
352 "to_x"
353 "to_y"
354 "transition"
355 "tween"
356 "type"
357 "use_alternate_font_metrics"
358 "visible"
359 "x"
360 "y"
361 ) t) "\\>[ \t]*[:,]")
362 '(2 font-lock-keyword-face))
363 )))
364 "Minor keywords")
365
366(defconst edje-font-lock-keywords-3
367 (eval-when-compile
368 (append edje-font-lock-keywords-2
369 (list
370 (list
371 (concat "\\<"
372 (regexp-opt
373 '(; image options (st_images_image)
374 "RAW"
375 "COMP"
376 "LOSSY"
377 "USER"
378 ; part types (st_collections_group_parts_part_type)
379 "NONE"
380 "RECT"
381 "TEXT"
382 "IMAGE"
383 "SWALLOW"
384 "TEXTBLOCK"
385 "GRADIENT"
386 "GROUP"
387 ; ignore flags (st_collections_group_parts_part_ignore_flags)
388 ;"NONE"
389 "ON_HOLD"
390 ; pointer mode (st_collections_group_parts_part_pointer_mode)
391 "AUTOGRAB"
392 "NOGRAB"
393 ; aspect (st_collections_group_parts_part_description_aspect_preference)
394 "NONE"
395 "VERTICAL"
396 "HORIZONTAL"
397 "BOTH"
398 ; text effect (st_collections_group_parts_part_effect)
399 "NONE"
400 "PLAIN"
401 "OUTLINE"
402 "SOFT_OUTLINE"
403 "SHADOW"
404 "SOFT_SHADOW"
405 "OUTLINE_SHADOW"
406 "OUTLINE_SOFT_SHADOW"
407 "FAR_SHADOW"
408 "FAR_SOFT_SHADOW"
409 "GLOW"
410 ; image fill (st_collections_group_parts_part_description_fill_type)
411 "SCALE"
412 "TILE"
413 ; program action (st_collections_group_programs_program_action)
414 "STATE_SET"
415 "ACTION_STOP"
416 "SIGNAL_EMIT"
417 "DRAG_VAL_SET"
418 "DRAG_VAL_STEP"
419 "DRAG_VAL_PAGE"
420 "SCRIPT"
421 ; program transition (st_collections_group_programs_program_transition)
422 "LINEAR"
423 "SINUSOIDAL"
424 "CUBIC_BEZIER"
425 "ACCELERATE"
426 "DECELERATE"
427 ) t) "\\>")
428 '(1 font-lock-builtin-face))
429 )))
430 "Enumerate values")
431
432(defconst edje-font-lock-keywords-4
433 (eval-when-compile
434 (append edje-font-lock-keywords-3
435 (list
436 (list
437 (concat "[ \t]*#"
438 (regexp-opt
439 '("if"
440 "ifdef"
441 "ifndef"
442 "define"
443 "else"
444 "endif"
445 "include"
446 "undef") t) "[ \t]*")
447 '(1 font-lock-builtin-face))
448 )))
449 "CPP directives")
450
451(defconst edje-font-lock-keywords-5
452 (eval-when-compile
453 (append edje-font-lock-keywords-4
454 (list
455 (list "[ \t]*#undef[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
456 '(1 font-lock-variable-name-face))
457 (list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)("
458 '(1 font-lock-function-name-face))
459 (list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
460 '(1 font-lock-variable-name-face))
461 )))
462 "CPP directives that define constants")
463
464
465(defvar edje-font-lock-keywords edje-font-lock-keywords-5)
466
467(defvar edje-mode-syntax-table
468 (let ((edje-mode-syntax-table (make-syntax-table)))
469 ; This is added so entity names with underscores can be more easily parsed
470 (modify-syntax-entry ?_ "w" edje-mode-syntax-table)
471 (modify-syntax-entry ?/ ". 124b" edje-mode-syntax-table)
472 (modify-syntax-entry ?* ". 23" edje-mode-syntax-table)
473 (modify-syntax-entry ?\n "> b" edje-mode-syntax-table)
474
475 edje-mode-syntax-table)
476 "Syntax table for edje-mode")
477
478(c-add-style
479 "edje"
480 '("gnu"
481 (indent-tabs-mode . nil)
482 (tab-width . 8)
483 (c-basic-offset . 3)
484 (c-backslash-column . 72)
485 (c-hanging-braces-alist .
486 ((block-open after)
487 (brace-list-open after)
488 (substatement-open after))
489 )
490 (c-offsets-alist .
491 ((statement-block-intro . +)
492 (defun-open . 0)
493 (substatement-open . 0)
494 (defun-block-intro . +)
495 (block-open . 0)
496 (label . +)
497 ))))
498
499
500(define-derived-mode edje-mode c-mode "Edje"
501 "Major mode for editing Edje files"
502 (interactive)
503 (use-local-map edje-mode-map)
504 (set-syntax-table edje-mode-syntax-table)
505 (set (make-local-variable 'font-lock-defaults) '(edje-font-lock-keywords))
506 (set (make-local-variable 'require-final-newline) t)
507 (c-set-style "edje")
508 (run-hooks 'edje-mode-hook)
509 )
510
511(provide 'edje-mode)
512
513;;; edje-mode.el ends here
diff --git a/eo-mode.el b/eo-mode.el
new file mode 100644
index 0000000..f455711
--- /dev/null
+++ b/eo-mode.el
@@ -0,0 +1,398 @@
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)