+(defun mdw-javascript-style ()
+ (setq js-indent-level 2)
+ (setq js-expr-indent-offset 0))
+
+(defun mdw-fontify-javascript ()
+
+ ;; Other stuff.
+ (mdw-javascript-style)
+ (setq js-auto-indent-flag t)
+
+ ;; Now define things to be fontified.
+ (make-local-variable 'font-lock-keywords)
+ (let ((javascript-keywords
+ (mdw-regexps "abstract" "boolean" "break" "byte" "case" "catch"
+ "char" "class" "const" "continue" "debugger" "default"
+ "delete" "do" "double" "else" "enum" "export" "extends"
+ "final" "finally" "float" "for" "function" "goto" "if"
+ "implements" "import" "in" "instanceof" "int"
+ "interface" "let" "long" "native" "new" "package"
+ "private" "protected" "public" "return" "short"
+ "static" "super" "switch" "synchronized" "throw"
+ "throws" "transient" "try" "typeof" "var" "void"
+ "volatile" "while" "with" "yield"
+
+ "boolean" "byte" "char" "double" "float" "int" "long"
+ "short" "void"))
+ (javascript-constants
+ (mdw-regexps "false" "null" "undefined" "Infinity" "NaN" "true"
+ "arguments" "this")))
+
+ (setq font-lock-keywords
+ (list
+
+ ;; Handle the keywords defined above.
+ (list (concat "\\_<\\(" javascript-keywords "\\)\\_>")
+ '(0 font-lock-keyword-face))
+
+ ;; Handle the predefined constants defined above.
+ (list (concat "\\_<\\(" javascript-constants "\\)\\_>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Handle numbers too.
+ ;;
+ ;; The following isn't quite right, but it's close enough.
+ (list (concat "\\_<\\("
+ "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
+ "[0-9]+\\(\\.[0-9]*\\|\\)"
+ "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+ "[lLfFdD]?")
+ '(0 mdw-number-face))
+
+ ;; And anything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face))))))
+
+;;;--------------------------------------------------------------------------
+;;; Scala programming configuration.
+
+(defun mdw-fontify-scala ()
+
+ ;; Comment filling.
+ (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
+
+ ;; Define things to be fontified.
+ (make-local-variable 'font-lock-keywords)
+ (let ((scala-keywords
+ (mdw-regexps "abstract" "case" "catch" "class" "def" "do" "else"
+ "extends" "final" "finally" "for" "forSome" "if"
+ "implicit" "import" "lazy" "match" "new" "object"
+ "override" "package" "private" "protected" "return"
+ "sealed" "throw" "trait" "try" "type" "val"
+ "var" "while" "with" "yield"))
+ (scala-constants
+ (mdw-regexps "false" "null" "super" "this" "true"))
+ (punctuation "[-!%^&*=+:@#~/?\\|`]"))
+
+ (setq font-lock-keywords
+ (list
+
+ ;; Magical identifiers between backticks.
+ (list (concat "`\\([^`]+\\)`")
+ '(1 font-lock-variable-name-face))
+
+ ;; Handle the keywords defined above.
+ (list (concat "\\_<\\(" scala-keywords "\\)\\_>")
+ '(0 font-lock-keyword-face))
+
+ ;; Handle the constants defined above.
+ (list (concat "\\_<\\(" scala-constants "\\)\\_>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Magical identifiers between backticks.
+ (list (concat "`\\([^`]+\\)`")
+ '(1 font-lock-variable-name-face))
+
+ ;; Handle numbers too.
+ ;;
+ ;; As usual, not quite right.
+ (list (concat "\\_<\\("
+ "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
+ "[0-9]+\\(\\.[0-9]*\\|\\)"
+ "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+ "[lLfFdD]?")
+ '(0 mdw-number-face))
+
+ ;; Identifiers with trailing operators.
+ (list (concat "_\\(" punctuation "\\)+")
+ '(0 mdw-trivial-face))
+
+ ;; And everything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face)))
+
+ font-lock-syntactic-keywords
+ (list
+
+ ;; Single quotes around characters. But not when used to quote
+ ;; symbol names. Ugh.
+ (list (concat "\\('\\)"
+ "\\(" "."
+ "\\|" "\\\\" "\\(" "\\\\\\\\" "\\)*"
+ "u+" "[0-9a-fA-F]\\{4\\}"
+ "\\|" "\\\\" "[0-7]\\{1,3\\}"
+ "\\|" "\\\\" "." "\\)"
+ "\\('\\)")
+ '(1 "\"")
+ '(4 "\""))))))