From 81fb08fcc06095c2ee93a821b33a3865ef463af4 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 3 Apr 2013 10:06:00 +0100 Subject: [PATCH] dot/emacs, el/dot-emacs.el: F# mode configuration. --- dot/emacs | 4 +- el/dot-emacs.el | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/dot/emacs b/dot/emacs index 920b370..4309028 100644 --- a/dot/emacs +++ b/dot/emacs @@ -579,7 +579,7 @@ 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 - a68-mode-hook a68-mode-hooks asm-mode-hook + a68-mode-hook a68-mode-hooks asm-mode-hook fsharp-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 @@ -668,6 +668,8 @@ (add-hook 'java-mode-hook 'mdw-fontify-java t) (add-hook 'js-mode-hook 'mdw-fontify-javascript t) (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t) + (add-hook 'fsharp-mode-hook 'mdw-fontify-fsharp t) + (add-hook 'inferior-fsharp-mode-hooks 'mdw-fontify-inferior-fsharp t) (add-hook 'awk-mode-hook 'mdw-fontify-awk t) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index d594b17..dc96aaf 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -1524,6 +1524,126 @@ doesn't match any of the regular expressions in "Major mode for editing C# code.") ;;;-------------------------------------------------------------------------- +;;; 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" + "base" "begin" "break" + "checked" "class" "component" "const" "constraint" + "constructor" "continue" + "default" "delegate" "do" "done" "downcast" "downto" + "eager" "elif" "else" "end" "exception" "extern" + "false" "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" "null" + "object""of" "open" "or" "override" + "parallel" "params" "private" "process" "protected" + "public" "pure" + "rec" "recursive" "return" + "sealed" "sig" "static" "struct" + "tailcall" "then" "to" "trait" "true" "try" "type" + "upcast" "use" + "val" "virtual" "void" "volatile" + "when" "while" "with" + "yield")) + + (fsharp-builtins + (mdw-regexps "asr" "land" "lor" "lsl" "lsr" "lxor" "mod")) + + (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))))) + + (mdw-post-config-mode-hack)) + +(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 () -- 2.11.0