+;;; F# programming configuration.
+
+(setq fsharp-indent-offset 2)
+
+(defun mdw-fontify-fsharp ()
+
+ (let ((punct "=<>+-*/|&%!@?"))
+ (do ((i 0 (1+ i)))
+ ((>= i (length punct)))
+ (modify-syntax-entry (aref punct i) ".")))
+
+ (modify-syntax-entry ?_ "_")
+ (modify-syntax-entry ?( "(")
+ (modify-syntax-entry ?) ")")
+
+ (setq indent-tabs-mode nil)
+
+ (let ((fsharp-keywords
+ (mdw-regexps "abstract" "and" "as" "assert" "atomic"
+ "begin" "break"
+ "checked" "class" "component" "const" "constraint"
+ "constructor" "continue"
+ "default" "delegate" "do" "done" "downcast" "downto"
+ "eager" "elif" "else" "end" "exception" "extern"
+ "finally" "fixed" "for" "fori" "fun" "function"
+ "functor"
+ "global"
+ "if" "in" "include" "inherit" "inline" "interface"
+ "internal"
+ "lazy" "let"
+ "match" "measure" "member" "method" "mixin" "module"
+ "mutable"
+ "namespace" "new"
+ "object" "of" "open" "or" "override"
+ "parallel" "params" "private" "process" "protected"
+ "public" "pure"
+ "rec" "recursive" "return"
+ "sealed" "sig" "static" "struct"
+ "tailcall" "then" "to" "trait" "try" "type"
+ "upcast" "use"
+ "val" "virtual" "void" "volatile"
+ "when" "while" "with"
+ "yield"))
+
+ (fsharp-builtins
+ (mdw-regexps "asr" "land" "lor" "lsl" "lsr" "lxor" "mod"
+ "base" "false" "null" "true"))
+
+ (bang-keywords
+ (mdw-regexps "do" "let" "return" "use" "yield"))
+
+ (preprocessor-keywords
+ (mdw-regexps "if" "indent" "else" "endif")))
+
+ (setq font-lock-keywords
+ (list (list (concat "\\(^\\|[^\"]\\)"
+ "\\(" "(\\*"
+ "[^*]*\\*+"
+ "\\(" "[^)*]" "[^*]*" "\\*+" "\\)*"
+ ")"
+ "\\|"
+ "//.*"
+ "\\)")
+ '(2 font-lock-comment-face))
+
+ (list (concat "'" "\\("
+ "\\\\"
+ "\\(" "[ntbr'\\]"
+ "\\|" "[0-9][0-9][0-9]"
+ "\\|" "u" "[0-9a-fA-F]\\{4\\}"
+ "\\|" "U" "[0-9a-fA-F]\\{8\\}"
+ "\\)"
+ "\\|"
+ "." "\\)" "'"
+ "\\|"
+ "\"" "[^\"\\]*"
+ "\\(" "\\\\" "\\(.\\|\n\\)"
+ "[^\"\\]*" "\\)*"
+ "\\(\"\\|\\'\\)")
+ '(0 font-lock-string-face))
+
+ (list (concat "\\_<\\(" bang-keywords "\\)!" "\\|"
+ "^#[ \t]*\\(" preprocessor-keywords "\\)\\_>"
+ "\\|"
+ "\\_<\\(" fsharp-keywords "\\)\\_>")
+ '(0 font-lock-keyword-face))
+ (list (concat "\\<\\(" fsharp-builtins "\\)\\_>")
+ '(0 font-lock-variable-name-face))
+
+ (list (concat "\\_<"
+ "\\(" "0[bB][01]+" "\\|"
+ "0[oO][0-7]+" "\\|"
+ "0[xX][0-9a-fA-F]+" "\\)"
+ "\\(" "lf\\|LF" "\\|"
+ "[uU]?[ysnlL]?" "\\)"
+ "\\|"
+ "\\_<"
+ "[0-9]+" "\\("
+ "[mMQRZING]"
+ "\\|"
+ "\\(\\.[0-9]*\\)?"
+ "\\([eE][-+]?[0-9]+\\)?"
+ "[fFmM]?"
+ "\\|"
+ "[uU]?[ysnlL]?"
+ "\\)")
+ '(0 mdw-number-face))
+
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face))))))
+
+(defun mdw-fontify-inferior-fsharp ()
+ (mdw-fontify-fsharp)
+ (setq font-lock-keywords
+ (append (list (list "^[#-]" '(0 font-lock-comment-face))
+ (list "^>" '(0 font-lock-keyword-face)))
+ font-lock-keywords)))
+
+;;;--------------------------------------------------------------------------
+;;; Go programming configuration.
+
+(defun mdw-fontify-go ()
+
+ (make-local-variable 'font-lock-keywords)
+ (let ((go-keywords
+ (mdw-regexps "break" "case" "chan" "const" "continue"
+ "default" "defer" "else" "fallthrough" "for"
+ "func" "go" "goto" "if" "import"
+ "interface" "map" "package" "range" "return"
+ "select" "struct" "switch" "type" "var"))
+ (go-intrinsics
+ (mdw-regexps "bool" "byte" "complex64" "complex128" "error"
+ "float32" "float64" "int" "uint8" "int16" "int32"
+ "int64" "rune" "string" "uint" "uint8" "uint16"
+ "uint32" "uint64" "uintptr" "void"
+ "false" "iota" "nil" "true"
+ "init" "main"
+ "append" "cap" "copy" "delete" "imag" "len" "make"
+ "new" "panic" "real" "recover")))
+
+ (setq font-lock-keywords
+ (list
+
+ ;; Handle the keywords defined above.
+ (list (concat "\\<\\(" go-keywords "\\)\\>")
+ '(0 font-lock-keyword-face))
+ (list (concat "\\<\\(" go-intrinsics "\\)\\>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Strings and characters.
+ (list (concat "'"
+ "\\(" "[^\\']" "\\|"
+ "\\\\"
+ "\\(" "[abfnrtv\\'\"]" "\\|"
+ "[0-7]\\{3\\}" "\\|"
+ "x" "[0-9A-Fa-f]\\{2\\}" "\\|"
+ "u" "[0-9A-Fa-f]\\{4\\}" "\\|"
+ "U" "[0-9A-Fa-f]\\{8\\}" "\\)" "\\)"
+ "'"
+ "\\|"
+ "\""
+ "\\(" "[^\n\\\"]+" "\\|" "\\\\." "\\)*"
+ "\\(\"\\|$\\)"
+ "\\|"
+ "`" "[^`]+" "`")
+ '(0 font-lock-string-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]+\\|\\)\\)")
+ '(0 mdw-number-face))
+
+ ;; And anything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face))))))
+
+;;;--------------------------------------------------------------------------
+;;; Rust programming configuration.
+
+(setq-default rust-indent-offset 2)
+
+(defun mdw-self-insert-and-indent (count)
+ (interactive "p")
+ (self-insert-command count)
+ (indent-according-to-mode))
+
+(defun mdw-fontify-rust ()
+
+ ;; Hack syntax categories.
+ (modify-syntax-entry ?= ".")
+
+ ;; Fontify keywords and things.
+ (make-local-variable 'font-lock-keywords)
+ (let ((rust-keywords
+ (mdw-regexps "abstract" "alignof" "as"
+ "become" "box" "break"
+ "const" "continue" "create"
+ "do"
+ "else" "enum" "extern"
+ "false" "final" "fn" "for"
+ "if" "impl" "in"
+ "let" "loop"
+ "macro" "match" "mod" "move" "mut"
+ "offsetof" "override"
+ "priv" "pub" "pure"
+ "ref" "return"
+ "self" "sizeof" "static" "struct" "super"
+ "true" "trait" "type" "typeof"
+ "unsafe" "unsized" "use"
+ "virtual"
+ "where" "while"
+ "yield"))
+ (rust-builtins
+ (mdw-regexps "array" "pointer" "slice" "tuple"
+ "bool" "true" "false"
+ "f32" "f64"
+ "i8" "i16" "i32" "i64" "isize"
+ "u8" "u16" "u32" "u64" "usize"
+ "char" "str")))
+ (setq font-lock-keywords
+ (list
+
+ ;; Handle the keywords defined above.
+ (list (concat "\\<\\(" rust-keywords "\\)\\>")
+ '(0 font-lock-keyword-face))
+ (list (concat "\\<\\(" rust-builtins "\\)\\>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Handle numbers too.
+ (list (concat "\\<\\("
+ "[0-9][0-9_]*"
+ "\\(" "\\(\\.[0-9_]+\\)?[eE][-+]?[0-9_]+"
+ "\\|" "\\.[0-9_]+"
+ "\\)"
+ "\\(f32\\|f64\\)?"
+ "\\|" "\\(" "[0-9][0-9_]*"
+ "\\|" "0x[0-9a-fA-F_]+"
+ "\\|" "0o[0-7_]+"
+ "\\|" "0b[01_]+"
+ "\\)"
+ "\\([ui]\\(8\\|16\\|32\\|64\\|s\\|size\\)\\)?"
+ "\\)\\>")
+ '(0 mdw-number-face))
+
+ ;; And anything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face)))))
+
+ ;; Hack key bindings.
+ (local-set-key [?{] 'mdw-self-insert-and-indent)
+ (local-set-key [?}] 'mdw-self-insert-and-indent))
+
+;;;--------------------------------------------------------------------------