-
Notifications
You must be signed in to change notification settings - Fork 1
/
fffll.el
64 lines (58 loc) · 2.14 KB
/
fffll.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(defvar fffll-mode-hook nil)
(defvar fffll-tab-width 4)
(add-to-list 'auto-mode-alist '("\\.ff\\'" . fffll-mode))
(defun fffll-mode-indent-line ()
"Indent current line as fffll code"
(interactive)
(beginning-of-line)
(if (bobp)
(indent-line-to 0)
(let ((not-indented t) cur-indent)
(save-excursion
(forward-line -1)
(setq cur-indent (current-indentation))
(if (looking-at "^[ \t]*[}]")
(setq cur-indent (+ cur-indent fffll-tab-width)))
(while not-indented
(if (looking-at "[{]")
(setq cur-indent (+ cur-indent fffll-tab-width))
(if (looking-at "[}]")
(setq cur-indent (- cur-indent fffll-tab-width))
(if (looking-at "\n")
(setq not-indented nil))))
(forward-char)))
(if (looking-at "[ \t]*[}]")
(setq cur-indent (- cur-indent fffll-tab-width)))
(if (< cur-indent 0)
(setq cur-indent 0))
(if cur-indent
(indent-line-to cur-indent)
(indent-line-to 0)))))
(defconst fffll-font-lock-keywords
(list
'("^\\(--\\)\\([^*].*\\)$" (1 font-lock-comment-delimiter-face) (2 font-lock-comment-face))
'("[^*]\\(--\\)\\([^*].*\\)$" (1 font-lock-comment-delimiter-face) (2 font-lock-comment-face))
'("_\\([a-zA-Z0-9]*\\)" . font-lock-constant-face)
'("%.*$" . font-lock-keyword-face)
'("%[a-zA-Z0-9]+" . font-lock-keyword-face)
'("\\([a-zA-Z]\\([A-Za-z0-9]*\\)\\)(" 1 font-lock-function-name-face)
'("set(\\([a-zA-Z]\\([a-zA-Z0-9.]*\\)\\)" 1 font-lock-variable-name-face)
'("\\([a-zA-Z]\\([a-zA-Z0-9.]*\\)\\):" 1 font-lock-variable-name-face)))
;; (defvar fffll-mode-syntax-table
;; (let ((st (make-syntax-table)))
;; (modify-syntax-entry ?. "w" st)
;; (modify-syntax-entry ?- "14" st)
;; (modify-syntax-entry ?* "23" st)
;; st))
(defun fffll-mode ()
"Major mode for editting fffll files"
(interactive)
(kill-all-local-variables)
(setq indent-tabs-mode nil)
;(set-syntax-table fffll-mode-syntax-table)
(set (make-local-variable 'font-lock-defaults) '(fffll-font-lock-keywords))
(set (make-local-variable 'indent-line-function) 'fffll-mode-indent-line)
(setq major-mode 'fffll-mode)
(setq mode-name "fffll")
(run-hooks 'fffll-mode-hook))
(provide 'fffll)