chiark / gitweb /
dot/emacs, el/dot-emacs.el: Add support for Lua programming.
[profile] / el / dot-emacs.el
index 403a5e42b9a9b9a07904a3b6a9d2b2207d37b985..cd8b407644dd4bbbf64d0fed1b413b8d095b8728 100644 (file)
@@ -2550,6 +2550,49 @@ (defun mdw-fontify-pyrex ()
                "raise" "return" "struct" "try" "while" "with"
                "yield")))
 
+;;;--------------------------------------------------------------------------
+;;; Lua programming style.
+
+(setq lua-indent-level 2)
+
+(defun mdw-fontify-lua ()
+
+  ;; Miscellaneous fiddling.
+  (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)")
+
+  ;; Now define fontification things.
+  (make-local-variable 'font-lock-keywords)
+  (let ((lua-keywords
+        (mdw-regexps "and" "break" "do" "else" "elseif" "end"
+                     "false" "for" "function" "goto" "if" "in" "local"
+                     "nil" "not" "or" "repeat" "return" "then" "true"
+                     "until" "while")))
+    (setq font-lock-keywords
+         (list
+
+          ;; Set up the keywords defined above.
+          (list (concat "\\_<\\(" lua-keywords "\\)\\_>")
+                '(0 font-lock-keyword-face))
+
+          ;; At least numbers are simpler than C.
+          (list (concat "\\_<\\(" "0[xX]"
+                                  "\\(" "[0-9a-fA-F]+"
+                                        "\\(\\.[0-9a-fA-F]*\\)?"
+                                  "\\|" "\\.[0-9a-fA-F]+"
+                                  "\\)"
+                                  "\\([pP][-+]?[0-9]+\\)?"
+                            "\\|" "\\(" "[0-9]+"
+                                        "\\(\\.[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))))))
+
 ;;;--------------------------------------------------------------------------
 ;;; Icon programming style.