Commit bb79e087 authored by Bobby Burden III's avatar Bobby Burden III

Change variable names, add customize group, add tab-width

parent 13dfa7f5
......@@ -27,37 +27,49 @@
;; create the list for font-lock.
;; each category of keyword is given a particular face
(setq kit-font-lock-keywords
;;; Customize variables
(defgroup kit nil
"A major mode for the Kit programming language."
:group 'languages)
(defcustom kit-tab-width 4
"The tab width to use when indenting Kit."
:type 'integer)
(defvar kit-font-lock-keywords
(let* (
;; define several category of keywords
(x-keywords
(kit-keywords
'("abstract" "box" "defer" "enum" "for" "function" "if" "import"
"match" "public" "sizeof" "struct" "trait" "typdef" "union"
"using" "var" "while"))
(x-types '("Box" "CString" "Float" "Int" "Ptr"))
(x-constants '("Self" "this"))
(x-events '())
(x-functions '("main" "printf"))
(kit-types '("Box" "CString" "Float" "Int" "Ptr"))
(kit-constants '("Self" "this"))
(kit-events '())
(kit-functions '("main" "printf"))
;; generate regex string for each category of keywords
(x-keywords-regexp (regexp-opt x-keywords 'words))
(x-types-regexp (regexp-opt x-types 'words))
(x-constants-regexp (regexp-opt x-constants 'words))
(x-events-regexp (regexp-opt x-events 'words))
(x-functions-regexp (regexp-opt x-functions 'words)))
(kit-keywords-regexp (regexp-opt kit-keywords 'words))
(kit-types-regexp (regexp-opt kit-types 'words))
(kit-constants-regexp (regexp-opt kit-constants 'words))
(kit-events-regexp (regexp-opt kit-events 'words))
(kit-functions-regexp (regexp-opt kit-functions 'words)))
`(
(,x-types-regexp . font-lock-type-face)
(,x-constants-regexp . font-lock-constant-face)
(,x-events-regexp . font-lock-builtin-face)
(,x-functions-regexp . font-lock-function-name-face)
(,x-keywords-regexp . font-lock-keyword-face)
(,kit-types-regexp . font-lock-type-face)
(,kit-constants-regexp . font-lock-constant-face)
(,kit-events-regexp . font-lock-builtin-face)
(,kit-functions-regexp . font-lock-function-name-face)
(,kit-keywords-regexp . font-lock-keyword-face)
)))
;;;###autoload
(define-derived-mode kit-mode c-mode "kit mode"
"Major mode for editing Kit Lang files."
(setq font-lock-defaults '((kit-font-lock-keywords))))
(make-local-variable 'kit-tab-width)
(setq-local font-lock-defaults '((kit-font-lock-keywords)))
(setq-local tab-width kit-tab-width))
(provide 'kit-mode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment