forked from melton1968/math
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.el
More file actions
62 lines (51 loc) · 2.07 KB
/
math.el
File metadata and controls
62 lines (51 loc) · 2.07 KB
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
(require 'math-syntax)
(require 'math-indent)
(require 'math-parse)
(require 'math-tokenize)
(defconst math-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [?\C-i] 'math-indent)
(define-key map [?\M-q] 'math-fill)
(define-key map [?\C-c ?\C-f] 'math-tokenize-next)
(define-key map [?\C-c ?\C-b] 'math-tokenize-prev)
(define-key map [?\C-c ?\C-t] 'math-tokenize-region)
(define-key map [?\C-c ?t] 'math-tokenize-buffer)
(define-key map [?\C-c ?\C-p] 'math-parse-region)
(define-key map [?\C-c ?p] 'math-parse-buffer)
map)
"Keymap for `math-mode'.")
(defconst math-indent-list
(list
(math-link :statement :bol 0 t)
(math-link :comment-first :comment-start 0 t)
(math-link :comment-text :comment-start +3 t)
(math-link :comment-last :comment-start +1 t)
))
(define-derived-mode math-mode prog-mode "Math"
"Major mode for editing Mathmatica code.
The hook `math-mode-hook' is run with no args at mode initialization.
\\{math-mode-map}"
:syntax-table math-syntax-table
:abbrev-table nil
;; We want to use the math-syntax-table to automagically handle
;; comments.
(set (make-local-variable 'comment-start) "(*")
(set (make-local-variable 'comment-end) "*)")
(set (make-local-variable 'comment-use-syntax) t)
;;(set (make-local-variable 'fill-paragraph-fn) 'math-comment-fill)
;;(set (make-local-variable 'paragraph-start) "\f\\|[ \t]*$\\|[-*] +.+$")
;;(set (make-local-variable 'paragraph-separate) "$")
(set (make-local-variable 'parse-sexp-lookup-properties) t)
(set (make-local-variable 'parse-sexp-ignore-comments) t)
;; We have to override the syntax-table to properly recognize
;; Mathmatica Syntax Characters as keywords.
(set (make-local-variable 'syntax-propertize-function)
math-syntax-propertize-function)
;; Turn on the syntax highlighting.
(set (make-local-variable 'font-lock-defaults)
'((math-mode-font-lock-defaults)))
;; Finally, run the math-mode-hook to users can make customizations
;; or take other actions.
(run-hooks 'math-mode-hook)
)
(provide 'math-mode)