OSDN Git Service

post WM_NULL to attached threads on yamy exit to unmap mayu{32,64}.dll
[yamy/yamy.git] / mayu-mode.el
1 ;;; mayu-mode.el --- mayu setting editing commands for Emacs
2
3 ;;; Copyright (C) 2000-2005 TAGA Nayuta <nayuta@ganaware.org>
4
5 ;; Author: TAGA Nayuta <nayuta@ganaware.org>
6 ;; Maintainer: TAGA Nayuta <nayuta@ganaware.org>
7 ;; Keywords: languages, faces
8
9 (require 'font-lock)
10
11 (defvar
12   mayu-font-lock-keywords
13   (let* ((warning-face 
14           (if (boundp 'font-lock-warning-face)
15               font-lock-warning-face
16             font-lock-function-name-face))
17          (preprocessor-face 
18           (if (boundp 'font-lock-builtin-face)
19               font-lock-builtin-face
20             font-lock-preprocessor-face))
21          (function-name-face 
22           (if (boundp 'font-lock-builtin-face)
23               font-lock-builtin-face
24             font-lock-function-name-face)))
25     `((,(concat
26          "\\<\\("
27          "[AMCWS]-"
28          "\\|IC-"
29          ;;"\\|I-"
30          "\\|[INCSK]L-"
31          "\\|M[0-9]-"
32          "\\|L[0-9]-"
33          "\\|U-"
34          "\\|D-"
35          "\\|R-"
36          "\\|E[01]-"
37          "\\|MAX-"
38          "\\|MIN-"
39          "\\|MMAX-"
40          "\\|MMIN-"
41          "\\)"
42          ) . font-lock-keyword-face)
43       ("#.*$" . font-lock-comment-face)
44       ("/[^/\n]*/" . font-lock-string-face)
45       ("\\\\$" . ,warning-face)
46       (,(concat
47          "^\\s *\\<\\("
48          "key"
49          "\\|event\\s +\\(prefixed\\|after-key-up\\|before-key-down\\)"
50          "\\|keyseq"
51          "\\|def\\s +\\(key\\|alias\\|mod\\|sync\\|subst\\|option\\)"
52          "\\|mod"
53          "\\|keymap"
54          "\\|keymap2"
55          "\\|window"
56          "\\|include"
57          "\\|if"
58          "\\|define"
59          "\\|else"
60          "\\|elseif"
61          "\\|elsif"
62          "\\|endif"
63          "\\)\\>"
64          ) . ,preprocessor-face)
65       (,(concat
66          "&\\("
67          "Default"
68          "\\|KeymapParent"
69          "\\|KeymapWindow"
70          "\\|KeymapPrevPrefix"
71          "\\|OtherWindowClass"
72          "\\|Prefix"
73          "\\|Keymap"
74          "\\|Sync"
75          "\\|Toggle"
76          "\\|EditNextModifier"
77          "\\|Variable"
78          "\\|Repeat"
79          "\\|Undefined"
80          "\\|Ignore"
81          "\\|PostMessage"
82          "\\|ShellExecute"
83          "\\|SetForegroundWindow"
84          "\\|LoadSetting"
85          "\\|VK"
86          "\\|Wait"
87          "\\|InvestigateCommand"
88          "\\|MayuDialog"
89          "\\|DescribeBindings"
90          "\\|HelpMessage"
91          "\\|HelpVariable"
92          "\\|WindowRaise"
93          "\\|WindowLower"
94          "\\|WindowMinimize"
95          "\\|WindowMaximize"
96          "\\|WindowHMaximize"
97          "\\|WindowVMaximize"
98          "\\|WindowHVMaximize"
99          "\\|WindowMove"
100          "\\|WindowMoveTo"
101          "\\|WindowMoveVisibly"
102          "\\|WindowClingToLeft"
103          "\\|WindowClingToRight"
104          "\\|WindowClingToTop"
105          "\\|WindowClingToBottom"
106          "\\|WindowClose"
107          "\\|WindowToggleTopMost"
108          "\\|WindowIdentify"
109          "\\|WindowSetAlpha"
110          "\\|WindowRedraw"
111          "\\|WindowResizeTo"
112          "\\|WindowMonitor"
113          "\\|WindowMonitorTo"
114          "\\|MouseMove"
115          "\\|MouseWheel"
116          "\\|ClipboardChangeCase"
117          "\\|ClipboardUpcaseWord"
118          "\\|ClipboardDowncaseWord"
119          "\\|ClipboardCopy"
120          "\\|EmacsEditKillLinePred"
121          "\\|EmacsEditKillLineFunc"
122          "\\|LogClear"
123          "\\|DirectSSTP"
124          "\\|PlugIn"
125          "\\|Recenter"
126          "\\|SetImeStatus"
127          "\\|SetImeString"
128          "\\)\\>"
129          ) . ,function-name-face)
130       "Default font-lock-keywords for mayu mode.")))
131
132 (defvar mayu-mode-syntax-table nil
133   "syntax table used in mayu mode")
134 (setq mayu-mode-syntax-table (make-syntax-table))
135 (modify-syntax-entry ?# "<\n" mayu-mode-syntax-table)
136 (modify-syntax-entry ?\n ">#" mayu-mode-syntax-table)
137
138 (defvar mayu-mode-map
139   (let ((map (make-sparse-keymap)))
140     (define-key map "\C-c\C-c" 'comment-region)
141     map))
142
143 ;;;###autoload
144 (defun mayu-mode ()
145   "A major mode to edit mayu setting files."
146   (interactive)
147   (kill-all-local-variables)
148   (use-local-map mayu-mode-map)
149
150   (make-local-variable 'comment-start)
151   (setq comment-start "# ")
152   (make-local-variable 'comment-start-skip)
153   (setq comment-start-skip "\\(^\\|\\s-\\);?#+ *")
154   (make-local-variable 'comment-indent-function)
155   (setq comment-indent-function 'mayu-comment-indent)
156   (make-local-variable 'parse-sexp-ignore-comments)
157   (setq parse-sexp-ignore-comments t)
158
159   (make-local-variable  'font-lock-defaults)
160   (setq major-mode 'mayu-mode
161         mode-name "mayu"
162         font-lock-defaults '(mayu-font-lock-keywords nil)
163         )
164   (set-syntax-table mayu-mode-syntax-table)
165   (run-hooks 'mayu-mode-hook))
166
167 ;;; derived from perl-mode.el
168 (defun mayu-comment-indent ()
169   (if (and (bolp) (not (eolp)))
170       0                                 ;Existing comment at bol stays there.
171     (save-excursion
172       (skip-chars-backward " \t")
173       (max (if (bolp)                   ;Else indent at comment column
174                0                        ; except leave at least one space if
175              (1+ (current-column)))     ; not at beginning of line.
176            comment-column))))
177
178 (provide 'mayu-mode)
179
180 ;;; mayu-mode.el ends here