;;; grace-generic-mode.el --- generic mode for editing Grace programs ;; ;; Copyright (C) 2012 James Noble ;; ;; Author: James Noble ;; Created: 22 May 2012 ;; Updated: 19 Apr 2016 ;; Keywords: generic, comment, font-lock (require 'generic-x) (define-generic-mode grace-generic-mode '(("//")) ;; can't get comments to work '("assert" "self" "true" "false" "catch" "raise" "return" "method" "const" "def" "var" "object" "class" "type" "prefix" "where" "super" "outer" "finally" "inherit" "as" "is" "if" "then" "dialect" "require" "else" "elseif" "while" "for" "loop" "do" "match" "catch" "case" "import" "use" "trait" "alias" "exclude" ) '((":=" . 'font-lock-keyword-face) ("=" . 'font-lock-keyword-face) (";" . 'font-lock-keyword-face) ("{" . 'font-lock-keyword-face) ("}" . 'font-lock-keyword-face) (":" . 'font-lock-keyword-face) ("->" . 'font-lock-keyword-face) ("->" . 'font-lock-keyword-face) ;; ("if" . 'font-lock-builtin-face) ;; ("then" . 'font-lock-builtin-face) ;; ("else" . 'font-lock-builtin-face) ;; ("while" . 'font-lock-builtin-face) ;; ("for" . 'font-lock-builtin-face) ;; ("loop" . 'font-lock-builtin-face) ;; ("do" . 'font-lock-builtin-face) ;; ("match" . 'font-lock-builtin-face) ;; ("case" . 'font-lock-builtin-face) ) '(".grace\\'" ".grc\\'") '( (lambda () (grace-mode-startup)) ) "Generic mode for editing Grace programs, see http://gracelang.org") (defun grace-untabify-buffer () "untabifies the whole buffer" (interactive "") (msg "running grace-untabify-buffer") (save-excursion (mark-whole-buffer) (untabify (region-beginning) (region-end)) )) (defun grace-mode-startup () "start up grace model" (msg "running grace-mode-startup") (add-hook 'write-contents-functions 'grace-untabify-buffer) (make-local-variable 'comment-start) (make-local-variable 'comment-end) (setq comment-start "//") (setq comment-end "") (let ((table (syntax-table))) (modify-syntax-entry ?\n "> b" table) (modify-syntax-entry ?\^m "> b" table) (modify-syntax-entry ?/ "- 12b" table)) )