Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (52 sloc) 2.253 kB
cf028f8 @defunkt basics
authored
1 ;; JavaScript Keywords
2 (setq coffee-js-keywords
3 '("if" "else" "true" "false" "new" "return" "try" "catch"
4 "finally" "throw" "break" "continue" "for" "in" "while"
5 "delete" "instanceof" "typeof" "switch" "super" "extends"
6 "class"))
7
8 ;; Reserved keywords either by JS or CS.
9 (setq coffee-js-reserved
10 '("case" "default" "do" "function" "var" "void" "with"
11 "const" "let" "debugger" "enum" "export" "import" "native"
12 "__extends" "__hasProp"))
13
14 ;; CoffeeScript keywords.
15 (setq coffee-cs-keywords
16 '("then" "unless" "yes" "no" "on" "off" "and" "or" "is"
17 "isnt" "not" "of" "by" "where" "when"))
18
19 (defvar coffee-keywords-regexp (regexp-opt
20 (append
21 coffee-js-reserved
22 coffee-js-keywords
23 coffee-cs-keywords) 'words))
24
25 (setq coffee-types '(""))
26 (defvar coffee-type-regexp (regexp-opt coffee-types 'words))
27
28 (setq coffee-constant-regexp "")
29
30 (setq coffee-events '(""))
31 (defvar coffee-event-regexp (regexp-opt coffee-events 'words))
32
33 (setq coffee-functions '(""))
34 (defvar coffee-functions-regexp (regexp-opt coffee-functions 'words))
35
36 ;; create the list for font-lock.
37 ;; each class of keyword is given a particular face
38 (setq coffee-font-lock-keywords
39 `(
40 (,coffee-type-regexp . font-lock-type-face)
41 (,coffee-constant-regexp . font-lock-constant-face)
42 (,coffee-event-regexp . font-lock-builtin-face)
43 (,coffee-functions-regexp . font-lock-function-name-face)
44 (,coffee-keywords-regexp . font-lock-keyword-face)
45
46 ;; note: order above matters. `coffee-keywords-regexp' goes last because
47 ;; otherwise the keyword "state" in the function "state_entry"
48 ;; would be highlighted.
49 ))
50
51 ;; define the mode
52 (define-derived-mode coffee-mode fundamental-mode
53 "coffee-mode"
54 "Major mode for editing CoffeeScript..."
55
56 ;; code for syntax highlighting
57 (setq font-lock-defaults '((coffee-font-lock-keywords)))
58
59 ;; clear memory
60 (setq coffee-keywords-regexp nil)
61 (setq coffee-types-regexp nil)
62 (setq coffee-constants-regexp nil)
63 (setq coffee-events-regexp nil)
64 (setq coffee-functions-regexp nil))
Something went wrong with that request. Please try again.