This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalore-mode.el
174 lines (149 loc) · 5.63 KB
/
alore-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
;;; alore-mode.el --- a major mode for editing alore programs
;; Based on lua mode.
;;
;; Authors:
;; Current Jukka Lehtosalo <[email protected]> (alore mode)
;; 2001 Christian Vogler <[email protected]> (lua mode)
;; 1997 Bret Mogilefsky <[email protected]> starting from
;; tcl-mode by Gregor Schmid <[email protected]>
;; with tons of assistance from
;; Paul Du Bois <[email protected]> and
;; Aaron Smith <[email protected]>.
;; Original notes and license:
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
(defconst alore-using-xemacs (string-match "XEmacs" emacs-version)
"Nil unless using XEmacs).")
;; Variables
(defvar alore-mode-map nil
"Keymap used with alore-mode.")
(defvar alore-prefix-key "\C-c"
"Prefix for all alore-mode commands.")
(defvar alore-mode-hook nil
"Hooks called when alore mode fires up.")
(defvar alore-mode-menu (make-sparse-keymap "Alore")
"Keymap for alore-mode's menu.")
(defvar alore-font-lock-keywords
(eval-when-compile
(list
;; Keywords.
(concat "\\<"
(regexp-opt '("and"
"as"
"bind"
"break"
"case"
"class"
"const"
"def"
"div"
"dynamic"
"elif"
"else"
"encoding"
"end"
"except"
"finally"
"for"
"if"
"implements"
"import"
"in"
"interface"
"is"
"mod"
"module"
"nil"
"not"
"or"
"private"
"raise"
"repeat"
"return"
"self"
"super"
"switch"
"to"
"try"
"until"
"var"
"void"
"while") t)
"\\>")
"Default expressions to highlight in Alore mode.")))
(defconst alore-indent-whitespace " \t"
"Character set that constitutes whitespace for indentation in alore.")
;; alore-mode
(defun alore-mode ()
"Major mode for editing alore scripts.
The following keys are bound:
\\{alore-mode-map}
"
(interactive)
(let ((switches nil)
s)
(kill-all-local-variables)
(setq major-mode 'alore-mode)
(setq mode-name "Alore")
(set (make-local-variable 'comment-start) "--")
(set (make-local-variable 'comment-start-skip) "--")
(set (make-local-variable 'font-lock-defaults)
'(alore-font-lock-keywords nil nil ((?_ . "w"))))
(make-local-variable 'alore-default-eval)
(or alore-mode-map
(alore-setup-keymap))
(use-local-map alore-mode-map)
(set-syntax-table (copy-syntax-table))
(modify-syntax-entry ?+ ".")
(modify-syntax-entry ?- ". 12")
(modify-syntax-entry ?* ".")
(modify-syntax-entry ?/ ".")
(modify-syntax-entry ?. ".")
(modify-syntax-entry ?\\ ".")
(modify-syntax-entry ?> ".")
(modify-syntax-entry ?< ".")
(modify-syntax-entry ?= ".")
(modify-syntax-entry ?\n ">")
(modify-syntax-entry ?\" "\"")
(modify-syntax-entry ?\' "\"")
;; _ needs to be part of a word, or the regular expressions will
;; incorrectly regognize end_ to be matched by "\\<end\\>"!
(modify-syntax-entry ?_ "w")
(if (and alore-using-xemacs
(featurep 'menubar)
current-menubar
(not (assoc "Alore" current-menubar)))
(progn
(set-buffer-menubar (copy-sequence current-menubar))
(add-menu nil "Alore" alore-xemacs-menu)))
;; Append Alore menu to popup menu for XEmacs.
(if (and alore-using-xemacs (boundp 'mode-popup-menu))
(setq mode-popup-menu
(cons (concat mode-name " Mode Commands") alore-xemacs-menu)))
(run-hooks 'alore-mode-hook)))
(defun alore-setup-keymap ()
"Set up keymap for alore mode.
If the variable `alore-prefix-key' is nil, the bindings go directly
to `alore-mode-map', otherwise they are prefixed with `alore-prefix-key'."
(setq alore-mode-map (make-sparse-keymap))
(let ((map (if alore-prefix-key
(make-sparse-keymap)
alore-mode-map)))
;; communication
(define-key map "\C-c" 'comment-region)
(if alore-prefix-key
(define-key alore-mode-map alore-prefix-key map))
))
(provide 'alore-mode)
;;; alore-mode.el ends here