From 772a7a3be0f3d56dc8f416c50ff91af40949720a Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 15 Jul 2017 01:12:04 +0100 Subject: [PATCH] dot/emacs, el/dot-emacs.el: Add support for Lua programming. I don't love Lua, but it's better for writing Wireshark dissectors than C. So let's have some configuration. --- dot/emacs | 3 ++- el/dot-emacs.el | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/dot/emacs b/dot/emacs index 1062254..3de2694 100644 --- a/dot/emacs +++ b/dot/emacs @@ -748,7 +748,7 @@ lisp-mode-hook lisp-interaction-mode-hook makefile-mode-hook inferior-lisp-mode-hook slime-repl-mode-hook sml-mode-hook haskell-mode-hook erlang-mode-hook - smalltalk-mode-hook rexx-mode-hook + smalltalk-mode-hook rexx-mode-hook lua-mode-hook arm-assembler-mode-hook)) (global-font-lock-mode t) @@ -821,6 +821,7 @@ (add-hook 'go-mode-hook 'mdw-fontify-go t) (add-hook 'rust-mode-hook 'mdw-fontify-rust t) + (add-hook 'lua-mode-hook 'mdw-fontify-lua t) (add-hook 'icon-mode-hook 'mdw-fontify-icon t) (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 403a5e4..cd8b407 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -2551,6 +2551,49 @@ strip numbers instead." "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. ;; Icon indentation style. -- 2.11.0