-
Notifications
You must be signed in to change notification settings - Fork 0
/
mayu-mode.el
180 lines (168 loc) · 4.2 KB
/
mayu-mode.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
;;; mayu-mode.el --- mayu setting editing commands for Emacs
;;; Copyright (C) 2000-2005 TAGA Nayuta <nayuta@ganaware.org>
;; Author: TAGA Nayuta <nayuta@ganaware.org>
;; Maintainer: TAGA Nayuta <nayuta@ganaware.org>
;; Keywords: languages, faces
(require 'font-lock)
(defvar
mayu-font-lock-keywords
(let* ((warning-face
(if (boundp 'font-lock-warning-face)
font-lock-warning-face
font-lock-function-name-face))
(preprocessor-face
(if (boundp 'font-lock-builtin-face)
font-lock-builtin-face
font-lock-preprocessor-face))
(function-name-face
(if (boundp 'font-lock-builtin-face)
font-lock-builtin-face
font-lock-function-name-face)))
`((,(concat
"\\<\\("
"[AMCWS]-"
"\\|IC-"
;;"\\|I-"
"\\|[INCSK]L-"
"\\|M[0-9]-"
"\\|L[0-9]-"
"\\|U-"
"\\|D-"
"\\|R-"
"\\|E[01]-"
"\\|MAX-"
"\\|MIN-"
"\\|MMAX-"
"\\|MMIN-"
"\\)"
) . font-lock-keyword-face)
("#.*$" . font-lock-comment-face)
("/[^/\n]*/" . font-lock-string-face)
("\\\\$" . ,warning-face)
(,(concat
"^\\s *\\<\\("
"key"
"\\|event\\s +\\(prefixed\\|after-key-up\\|before-key-down\\)"
"\\|keyseq"
"\\|def\\s +\\(key\\|alias\\|mod\\|sync\\|subst\\|option\\)"
"\\|mod"
"\\|keymap"
"\\|keymap2"
"\\|window"
"\\|include"
"\\|if"
"\\|define"
"\\|else"
"\\|elseif"
"\\|elsif"
"\\|endif"
"\\)\\>"
) . ,preprocessor-face)
(,(concat
"&\\("
"Default"
"\\|KeymapParent"
"\\|KeymapWindow"
"\\|KeymapPrevPrefix"
"\\|OtherWindowClass"
"\\|Prefix"
"\\|Keymap"
"\\|Sync"
"\\|Toggle"
"\\|EditNextModifier"
"\\|Variable"
"\\|Repeat"
"\\|Undefined"
"\\|Ignore"
"\\|PostMessage"
"\\|ShellExecute"
"\\|SetForegroundWindow"
"\\|LoadSetting"
"\\|VK"
"\\|Wait"
"\\|InvestigateCommand"
"\\|MayuDialog"
"\\|DescribeBindings"
"\\|HelpMessage"
"\\|HelpVariable"
"\\|WindowRaise"
"\\|WindowLower"
"\\|WindowMinimize"
"\\|WindowMaximize"
"\\|WindowHMaximize"
"\\|WindowVMaximize"
"\\|WindowHVMaximize"
"\\|WindowMove"
"\\|WindowMoveTo"
"\\|WindowMoveVisibly"
"\\|WindowClingToLeft"
"\\|WindowClingToRight"
"\\|WindowClingToTop"
"\\|WindowClingToBottom"
"\\|WindowClose"
"\\|WindowToggleTopMost"
"\\|WindowIdentify"
"\\|WindowSetAlpha"
"\\|WindowRedraw"
"\\|WindowResizeTo"
"\\|WindowMonitor"
"\\|WindowMonitorTo"
"\\|MouseMove"
"\\|MouseWheel"
"\\|ClipboardChangeCase"
"\\|ClipboardUpcaseWord"
"\\|ClipboardDowncaseWord"
"\\|ClipboardCopy"
"\\|EmacsEditKillLinePred"
"\\|EmacsEditKillLineFunc"
"\\|LogClear"
"\\|DirectSSTP"
"\\|PlugIn"
"\\|Recenter"
"\\|SetImeStatus"
"\\|SetImeString"
"\\)\\>"
) . ,function-name-face)
"Default font-lock-keywords for mayu mode.")))
(defvar mayu-mode-syntax-table nil
"syntax table used in mayu mode")
(setq mayu-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?# "<\n" mayu-mode-syntax-table)
(modify-syntax-entry ?\n ">#" mayu-mode-syntax-table)
(defvar mayu-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'comment-region)
map))
;;;###autoload
(defun mayu-mode ()
"A major mode to edit mayu setting files."
(interactive)
(kill-all-local-variables)
(use-local-map mayu-mode-map)
(make-local-variable 'comment-start)
(setq comment-start "# ")
(make-local-variable 'comment-start-skip)
(setq comment-start-skip "\\(^\\|\\s-\\);?#+ *")
(make-local-variable 'comment-indent-function)
(setq comment-indent-function 'mayu-comment-indent)
(make-local-variable 'parse-sexp-ignore-comments)
(setq parse-sexp-ignore-comments t)
(make-local-variable 'font-lock-defaults)
(setq major-mode 'mayu-mode
mode-name "mayu"
font-lock-defaults '(mayu-font-lock-keywords nil)
)
(set-syntax-table mayu-mode-syntax-table)
(run-hooks 'mayu-mode-hook))
;;; derived from perl-mode.el
(defun mayu-comment-indent ()
(if (and (bolp) (not (eolp)))
0 ;Existing comment at bol stays there.
(save-excursion
(skip-chars-backward " \t")
(max (if (bolp) ;Else indent at comment column
0 ; except leave at least one space if
(1+ (current-column))) ; not at beginning of line.
comment-column))))
(provide 'mayu-mode)
;;; mayu-mode.el ends here