From 35e7c66f68c70d8054600add35142d0a163e8ed1 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Tue, 1 Feb 2022 09:50:53 -0600 Subject: [PATCH] Add dee-mode.el for emacs --- dee-mode.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 dee-mode.el diff --git a/dee-mode.el b/dee-mode.el new file mode 100644 index 0000000..6b41fd4 --- /dev/null +++ b/dee-mode.el @@ -0,0 +1,59 @@ +;; A major mode for editing scripts written in Deelang + +(add-to-list 'auto-mode-alist '("\\.dee\\'" . dee-mode)) + +(defface dee-function-param-face + '((t . (:slant italic + :weight bold + :foreground "orange"))) + "A face to help identify function parameter in Deelang.") + +(defcustom dee-indent-offset 4 + "Default indentation offset for Deelang." + :group 'dee + :type 'integer + :safe 'integerp) + +(defvar dee-mode-map + (let ((map (make-sparse-keymap))) + map) + "Keymap for Deelang files") + +(defvar dee-mode-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?# "<" table) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?- "w" table) + (modify-syntax-entry ?? "w" table) + table) + "Syntax table for Deelang files") + +(defvar dee-font-lock-id-re + (rx (seq alpha (* (any alnum ?- ??))))) + +(defvar dee-font-lock-keywords + `(,(rx symbol-start + (or + "if" "elif" "else" "") + symbol-end) + (,(rx (group (regexp dee-font-lock-id-re)) (* space) "<-") + (1 font-lock-variable-name-face)) + (,(rx (group (regexp dee-font-lock-id-re)) (* space) "->") + (1 'dee-function-param-face)) + (,(rx (group (regexp dee-font-lock-id-re)) (* space) "(") + (1 font-lock-function-name-face)))) + +(defun dee-indent-line-function () + 'noindent) ;TODO + +(define-derived-mode dee-mode prog-mode "Dee" + "Major mode for editing scripts written in Deelang. + +\\{dee-mode-map}" + (set (make-local-variable 'indent-line-function) + #'dee-indent-line-function) + (set (make-local-variable 'font-lock-defaults) + `(,dee-font-lock-keywords + nil nil nil nil))) + +(provide 'dee)