emacs: Support for Erlang.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 8 Oct 2008 11:55:22 +0000 (12:55 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 8 Oct 2008 11:55:22 +0000 (12:55 +0100)
Sketchy but at least it's there.

Also sneak in a couple of bits of support for C# which somehow slipped
through the net before.

dot-emacs.el
emacs

index 1596f11..e837272 100644 (file)
@@ -1586,6 +1586,41 @@ strip numbers instead."
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
 
+;;;----- Erlang configuration -----------------------------------------------
+
+(setq erlang-electric-commannds
+      '(erlang-electric-newline erlang-electric-semicolon))
+
+(defun mdw-fontify-erlang ()
+
+  ;; --- Set fill prefix ---
+
+  (mdw-standard-fill-prefix "\\([ \t]*{?%*[ \t]*\\)")
+
+  ;; --- Fiddle with fontification ---
+
+  (make-local-variable 'font-lock-keywords)
+  (let ((erlang-keywords
+        (mdw-regexps "after" "and" "andalso"
+                     "band" "begin" "bnot" "bor" "bsl" "bsr" "bxor"
+                     "case" "catch" "cond"
+                     "div" "end" "fun" "if" "let" "not"
+                     "of" "or" "orelse"
+                     "query" "receive" "rem" "try" "when" "xor")))
+
+    (setq font-lock-keywords
+         (list
+          (list "%.*$"
+                '(0 font-lock-comment-face))
+          (list (concat "\\<\\(" erlang-keywords "\\)\\>")
+                '(0 font-lock-keyword-face))
+          (list (concat "^-\\sw+\\>")
+                '(0 font-lock-keyword-face))
+          (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
+                '(0 mdw-number-face))
+          (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+                '(0 mdw-punct-face))))))
+
 ;;;----- Texinfo configuration ----------------------------------------------
 
 (defun mdw-fontify-texinfo ()
diff --git a/emacs b/emacs
index 49c5649..c5da27b 100644 (file)
--- a/emacs
+++ b/emacs
 
 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
        '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
-         perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
-         tcl-mode-hook asm-mode-hook
-         TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
-         tex-mode-hook latex-mode-hook texinfo-mode-hook
-         emacs-lisp-mode-hook scheme-mode-hook
-         lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
-         slime-repl-mode-hook
-         sml-mode-hook haskell-mode-hook
+         csharp-mode-hook perl-mode-hook cperl-mode-hook
+         python-mode-hook awk-mode-hook tcl-mode-hook
+         asm-mode-hook TeX-mode-hook LaTeX-mode-hook
+         TeXinfo-mode-hook tex-mode-hook latex-mode-hook
+         texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
+         lisp-mode-hook lisp-interaction-mode-hook
+         inferior-lisp-mode-hook slime-repl-mode-hook
+         sml-mode-hook haskell-mode-hook erlang-mode-hook
          smalltalk-mode-hook rexx-mode-hook
          arm-assembler-mode-hook))
 
 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
 
 (add-hook 'java-mode-hook 'mdw-fontify-java t)
+(add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
 
 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
 
 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
 (setq-default haskell-indent-offset 2)
 
+(add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
+
 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)