dot/emacs, el/dot-emacs.el: Support for Dylan code.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 2 Apr 2013 01:47:16 +0000 (02:47 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 2 Apr 2013 01:50:44 +0000 (02:50 +0100)
dot/emacs
el/dot-emacs.el

index 7c2e73f..f207a0a 100644 (file)
--- a/dot/emacs
+++ b/dot/emacs
 
 (mapc (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
       '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
-       csharp-mode-hook perl-mode-hook cperl-mode-hook
+       csharp-mode-hook perl-mode-hook cperl-mode-hook dylan-mode-hook
        python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
        tcl-mode-hook go-mode-hook js-mode-hook javascript-mode-hook
        conf-mode-hook m4-mode-hook autoconf-mode-hook autotest-mode-hook
 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
 
+(add-hook 'dylan-mode-hook 'mdw-fontify-dylan t)
+
 (progn
   (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
   (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
index 236e6da..4f9bd59 100644 (file)
@@ -967,6 +967,10 @@ doesn't match any of the regular expressions in
   (((class color) (type x)) :background "RoyalBlue4")
   (t :underline t))
 
+(mdw-define-face dylan-header-background
+  (((class color) (type x)) :background "NavyBlue")
+  (t :background "blue"))
+
 (mdw-define-face magit-diff-add
   (t :foreground "green"))
 (mdw-define-face magit-diff-del
@@ -1897,6 +1901,74 @@ strip numbers instead."
   (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
+;;; Dylan programming configuration.
+
+(defun mdw-fontify-dylan ()
+
+  (make-local-variable 'font-lock-keywords)
+
+  ;; Horrors.  `dylan-mode' sets the `major-mode' name after calling this
+  ;; hook, which undoes all of our configuration.
+  (setq major-mode 'dylan-mode)
+  (font-lock-set-defaults)
+
+  (let* ((word "[-_a-zA-Z!*@<>$%]+")
+        (dylan-keywords (mdw-regexps
+
+                         "C-address" "C-callable-wrapper" "C-function"
+                         "C-mapped-subtype" "C-pointer-type" "C-struct"
+                         "C-subtype" "C-union" "C-variable"
+
+                         "above" "abstract" "afterwards" "all"
+                         "begin" "below" "block" "by"
+                         "case" "class" "cleanup" "constant" "create"
+                         "define" "domain"
+                         "else" "elseif" "end" "exception" "export"
+                         "finally" "for" "from" "function"
+                         "generic"
+                         "handler"
+                         "if" "in" "instance" "interface" "iterate"
+                         "keyed-by"
+                         "let" "library" "local"
+                         "macro" "method" "module"
+                         "otherwise"
+                         "profiling"
+                         "select" "slot" "subclass"
+                         "table" "then" "to"
+                         "unless" "until" "use"
+                         "variable" "virtual"
+                         "when" "while"))
+        (sharp-keywords (mdw-regexps
+                         "all-keys" "key" "next" "rest" "include"
+                         "t" "f")))
+    (setq font-lock-keywords
+         (list (list (concat "\\<\\(" dylan-keywords
+                             "\\|" (concat "with\\(out\\)?-" word)
+                             "\\|" (concat word ":")
+                             "\\)\\>")
+                     '(0 font-lock-keyword-face))
+               (list (concat "#\\(" sharp-keywords "\\)\\>")
+                     '(0 font-lock-variable-name-face))
+               (list (concat "\\("
+                             "\\([-+]\\|\\<\\)[0-9]+" "\\("
+                               "\\(\\.[0-9]+\\)?" "\\([eE][-+][0-9]+\\)?"
+                               "\\|" "/[0-9]+"
+                             "\\)"
+                             "\\|" "\\.[0-9]+" "\\([eE][-+][0-9]+\\)?"
+                             "\\|" "#b[01]+"
+                             "\\|" "#o[0-7]+"
+                             "\\|" "#x[0-9a-zA-Z]+"
+                             "\\)\\>")
+                     '(0 mdw-number-face))
+               (list (concat "\\("
+                             "\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\|"
+                             "\\_<[-+*/=<>:&|]+\\_>"
+                             "\\)")
+                     '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
+
+;;;--------------------------------------------------------------------------
 ;;; REXX configuration.
 
 (defun mdw-rexx-electric-* ()