Skip to content

Commit edbbc98

Browse files
committedNov 11, 2024
[ slakemoth ] emacs mode
1 parent c4397c1 commit edbbc98

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
 

‎slakemoth/slakemoth.el

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
;; based on: http://ergoemacs.org/emacs/elisp_syntax_coloring.html
2+
3+
;; define several class of keywords
4+
(setq slakemoth-keywords '("define" "table"
5+
"domain"
6+
"atom"
7+
"print" "ifsat" "allsat" "dump"
8+
"forall" "some" "next"
9+
"for" "the" "if"))
10+
(setq slakemoth-equality '())
11+
(setq slakemoth-operators '("==>" "&" "|" "!" "~" "=" "!=" ))
12+
(setq slakemoth-types '())
13+
14+
;; create the regex string for each class of keywords
15+
(setq slakemoth-keywords-regexp (regexp-opt slakemoth-keywords 'words))
16+
(setq slakemoth-equality-regexp (regexp-opt slakemoth-equality 'words))
17+
(setq slakemoth-operators-regexp (regexp-opt slakemoth-operators))
18+
(setq slakemoth-types-regexp (regexp-opt slakemoth-types 'words))
19+
20+
;; clear memory
21+
(setq slakemoth-keywords nil)
22+
(setq slakemoth-equality nil)
23+
(setq slakemoth-operators nil)
24+
(setq slakemoth-types nil)
25+
26+
;; create the list for font-lock.
27+
;; each class of keyword is given a particular face
28+
(setq slakemoth-font-lock-keywords
29+
`(
30+
(,slakemoth-types-regexp . font-lock-type-face)
31+
(,slakemoth-equality-regexp . font-lock-keyword-face)
32+
(,slakemoth-operators-regexp . font-lock-builtin-face)
33+
(,slakemoth-keywords-regexp . font-lock-keyword-face)
34+
))
35+
36+
;; syntax table
37+
(defvar slakemoth-syntax-table nil "Syntax table for `slakemoth-mode'.")
38+
(setq slakemoth-syntax-table
39+
(let ((synTable (make-syntax-table)))
40+
41+
;; Java/C++ style '//' comments
42+
(modify-syntax-entry ?/ ". 12b" synTable)
43+
(modify-syntax-entry ?\n "> b" synTable)
44+
45+
;; Symbols
46+
(modify-syntax-entry ?_ "w" synTable)
47+
(modify-syntax-entry ?- "w" synTable)
48+
49+
synTable))
50+
51+
;; define the mode
52+
(define-derived-mode slakemoth-mode fundamental-mode
53+
"Slakemoth mode"
54+
;; handling comments
55+
:syntax-table slakemoth-syntax-table
56+
(setq-local comment-start "//")
57+
(setq-local comment-end "")
58+
;; code for syntax highlighting
59+
(setq font-lock-defaults '((slakemoth-font-lock-keywords)))
60+
(setq mode-name "slakemoth")
61+
;; clear memory
62+
(setq slakemoth-keywords-regexp nil)
63+
(setq slakemoth-types-regexp nil)
64+
)
65+
66+
(provide 'slakemoth-mode)

0 commit comments

Comments
 (0)
Please sign in to comment.