'(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
csharp-mode-hook perl-mode-hook cperl-mode-hook
python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
- tcl-mode-hook go-mode-hook
+ tcl-mode-hook go-mode-hook js-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
(add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
(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 'awk-mode-hook 'mdw-fontify-awk t)
(mdw-post-config-mode-hack))
;;;--------------------------------------------------------------------------
+;;; Javascript programming configuration.
+
+(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)))))
+
+ (mdw-post-config-mode-hack))
+
+;;;--------------------------------------------------------------------------
;;; C# programming configuration.
;; Make indentation nice.