Created
November 9, 2012 20:54
-
-
Save legumbre/4048180 to your computer and use it in GitHub Desktop.
LLL-ringrun-config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; lua mode | |
(autoload #'lua-mode "lua-mode") | |
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode)) | |
(setq-default lua-default-application "telnet") | |
(setq-default lua-default-command-switches (list "localhost" "9000")) | |
(autoload #'flymake-lua-setup "flymake-lua" nil t) | |
;; (setq lua-prompt-regexp "[^\n]*\\(K>?[\t ]+\\)+$") | |
(eval-after-load 'lua-mode | |
'(progn | |
(define-key lua-mode-map (kbd "C-c C-r") 'lua-send-region) | |
(define-key lua-mode-map (kbd "C-c C-c") 'lua-send-buffer) | |
(define-key lua-mode-map (kbd "C-c C-l") 'lua-send-current-line) | |
(define-key lua-mode-map (kbd "C-M-x") 'lua-send-proc) | |
(setq lua-always-show t) | |
(add-hook 'lua-mode-hook 'flymake-lua-setup))) | |
;; xcodebuild with lua compilation phase error handling | |
(eval-after-load 'compile '(progn (add-to-list 'compilation-error-regexp-alist 'lua) | |
(add-to-list 'compilation-error-regexp-alist-alist '(lua "^.*?luac: \\([^:]*\\):\\([0-9]+\\):" (1 "%s.lua") 2)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; flymake configuration for lua | |
;;; assumes luac is in $PATH | |
;;; Install: | |
;; copy flymake-lua.el somewhere in your load-path | |
;; | |
;; in ~/.emacs: | |
;; (eval-after-load 'lua-mode '(add-hook 'lua-mode-hook 'flymake-lua-setup)) | |
;; (autoload #'flymake-lua-setup "flymake-lua" nil t) | |
;; use ~/tmp for temp files | |
(defvar flymake-temp-dir "~/tmp") | |
;; (setq flymake-log-level 3) | |
;;; disable moronic modal dialog | |
(setq flymake-gui-warnings-enabled nil) | |
(define-key lua-mode-map (kbd "C-x `") 'flymake-goto-next-error) | |
(custom-set-faces | |
'(flymake-errline ((t (:underline "red")))) | |
'(flymake-warnline ((t (:underline "yellow"))))) | |
(eval-after-load 'flymake | |
'(progn | |
(defun flymake-get-temp-dir () | |
(if (and (boundp 'flymake-temp-dir) | |
(file-readable-p flymake-temp-dir)) | |
flymake-temp-dir | |
temporary-file-directory)))) | |
(defun flymake-lua-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-in-temp-dir)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "luac" (list "-p" local-file)))) | |
(defun flymake-lua-setup () | |
(make-local-variable 'flymake-allowed-file-name-masks) | |
(make-local-variable 'flymake-err-line-patterns) | |
(make-local-variable 'flymake-no-changes-timeout) | |
(setq flymake-allowed-file-name-masks | |
'(("\\.lua\\'" flymake-lua-init))) | |
(setq flymake-err-line-patterns | |
'(("^.*luac[0-9.]*\\(.exe\\)?: *\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 2 3 nil 4))) | |
(setq flymake-no-changes-timeout 1) | |
(flymake-mode 1)) | |
(defun flymake-create-in-temp-dir (file-name &optional dir) | |
(let ((temporary-file-directory (flymake-get-temp-dir))) | |
(make-temp-file (file-name-nondirectory file-name)))) | |
(provide 'flymake-lua) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- sample development aids (called from ringrun.el) | |
function restart_level() | |
print "restarting level..." | |
level.stats.outcome = level_outcome_failed | |
hud_engine.responder:handle_replay(nil, {{node=NULL, down_node=NULL}}) | |
function engine:time_is_frozen() return true end | |
end | |
function lll_toggle_pause() | |
engine:set_pause_with_key(true) | |
if (engine.state == engine_state_running) then | |
engine:set_state(engine_state_paused) | |
elseif (engine.state == engine_state_paused) then | |
engine:set_state(engine_state_running) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun rr-restart-level () | |
"restart current ringrun level" | |
(interactive) | |
(with-temp-buffer | |
(insert "restart_level()") | |
(lua-send-buffer))) | |
(defun rr-toggle-pause () | |
"pause rr engine" | |
(interactive) | |
(with-temp-buffer | |
(insert | |
"lll_toggle_pause()") | |
(lua-send-buffer))) | |
(defun rr-value-at-point () | |
"" | |
(interactive) | |
(let ((sym (thing-at-point 'symbol))) | |
(message sym) | |
(with-temp-buffer | |
(insert | |
(concat "return " sym)) | |
(lua-send-buffer)))) | |
(defun rr-launch-ringrun () | |
(interactive) | |
(let* ((rr-dir (expand-file-name "~/dev/ringrun/src/RingRun/build/Debug")) | |
(rr-binary (expand-file-name "RingRun_Mac.app/Contents/MacOS/RingRun_Mac" rr-dir))) | |
(shell-command (concat rr-binary "&")))) | |
(eval-after-load 'lua-mode | |
'(progn | |
(define-key lua-mode-map (kbd "C-c .") 'rr-value-at-point) | |
(define-key lua-mode-map (kbd "C-c t") 'rr-toggle-pause) | |
(define-key lua-mode-map (kbd "C-c r") 'rr-restart-level))) | |
(provide 'ringrun) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment