branch: elpa/lua-mode
commit afc1ea04740fc7bc51c84d50736128b945888db4
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Send init-code in lua-start-process, enable compilation-shell-minor-mode
---
lua-mode.el | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index a67d56b..336e93a 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1524,6 +1524,21 @@ This function just searches for a `end' at the beginning
of a line."
(forward-line)))
ret))
+(defvar lua-process-init-code
+ (concat "function luamode_dofile(fname, displayname)"
+ " local f = assert(io.open(fname))"
+ " local d = f:read('*all')"
+ " f:close()"
+ " x, e = loadstring(d, '@'..displayname)"
+ " if fname ~= displayname then"
+ " os.remove(fname)"
+ " end"
+ " if e then"
+ " error(e)"
+ " end"
+ " return x()"
+ "end"))
+
(defun lua-start-process (&optional name program startfile &rest switches)
"Start a lua process named NAME, running PROGRAM.
PROGRAM defaults to NAME, which defaults to `lua-default-application'.
@@ -1535,37 +1550,26 @@ When called interactively, switch to the process
buffer."
(setq program (or program name))
(setq lua-process-buffer (apply 'make-comint name program startfile
switches))
(setq lua-process (get-buffer-process lua-process-buffer))
- ;; wait for prompt
(with-current-buffer lua-process-buffer
+ ;; wait for prompt
(while (not (lua-prompt-line))
(accept-process-output (get-buffer-process (current-buffer)))
- (goto-char (point-max))))
+ (goto-char (point-max)))
+ ;; send initialization code
+ (comint-simple-send nil lua-process-init-code)
+ ;; enable error highlighting in stack traces
+ (compilation-shell-minor-mode))
+
;; when called interactively, switch to process buffer
(if (lua--called-interactively-p 'any)
(switch-to-buffer lua-process-buffer)))
-(defvar lua-process-init-code
- (concat "function luamode_dofile(fname, displayname)"
- " local f = assert(io.open(fname))"
- " local d = f:read('*all')"
- " f:close()"
- " x, e = loadstring(d, '@'..displayname)"
- " if fname ~= displayname then"
- " os.remove(fname)"
- " end"
- " if e then"
- " error(e)"
- " end"
- " return x()"
- "end"))
-
(defun lua-get-create-process ()
(or (and (comint-check-proc lua-process-buffer)
lua-process)
(prog1 (lua-start-process)
(when (fboundp 'process-kill-without-query)
(process-kill-without-query lua-process))))
- (comint-simple-send lua-process lua-process-init-code)
lua-process)
(defun lua-kill-process ()