[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 08d83fc 443/468: Merge pull request #180 from nbf
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 08d83fc 443/468: Merge pull request #180 from nbfalcon/bugfix/lua-start-process-hangs |
Date: |
Thu, 5 Aug 2021 04:59:26 -0400 (EDT) |
branch: elpa/lua-mode
commit 08d83fcbccf56b00d5262da74012deaaf511804b
Merge: e81d0f2 1135932
Author: immerrr again <immerrr@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #180 from nbfalcon/bugfix/lua-start-process-hangs
`lua-start-proces': don't hang if already running
---
lua-mode.el | 50 +++++++++++++++++++++++++-------------------------
test/test-process.el | 24 ++++++++++++++++++++++++
2 files changed, 49 insertions(+), 25 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 0428a315..ccdb1be 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -311,7 +311,7 @@ Should be a list of strings."
"The active Lua process")
(defvar lua-process-buffer nil
- "Buffer used for communication with the Lua process")
+ "Buffer used for communication with the Lua process.")
(defun lua--customize-set-prefix-key (prefix-key-sym prefix-key-val)
(cl-assert (eq prefix-key-sym 'lua-prefix-key))
@@ -1911,32 +1911,33 @@ This function just searches for a `end' at the
beginning of a line."
PROGRAM defaults to NAME, which defaults to `lua-default-application'.
When called interactively, switch to the process buffer."
(interactive)
- (or switches
- (setq switches lua-default-command-switches))
(setq name (or name (if (consp lua-default-application)
(car lua-default-application)
lua-default-application)))
(setq program (or program lua-default-application))
- (setq lua-process-buffer (apply 'make-comint name program startfile
switches))
- (setq lua-process (get-buffer-process lua-process-buffer))
- (set-process-query-on-exit-flag lua-process nil)
- (with-current-buffer lua-process-buffer
- ;; enable error highlighting in stack traces
- (require 'compile)
- (setq lua--repl-buffer-p t)
- (make-local-variable 'compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist
- (cons (list lua-traceback-line-re 1 2)
- compilation-error-regexp-alist))
- (compilation-shell-minor-mode 1)
- (setq-local comint-prompt-regexp lua-prompt-regexp)
-
- ;; Don't send initialization code until seeing the prompt to ensure that
- ;; the interpreter is ready.
- (while (not (lua-prompt-line))
- (accept-process-output (get-buffer-process (current-buffer)))
- (goto-char (point-max)))
- (lua-send-string lua-process-init-code))
+ ;; don't re-initialize if there already is a lua process
+ (unless (comint-check-proc (format "*%s*" name))
+ (setq lua-process-buffer (apply #'make-comint name program startfile
+ (or switches
lua-default-command-switches)))
+ (setq lua-process (get-buffer-process lua-process-buffer))
+ (set-process-query-on-exit-flag lua-process nil)
+ (with-current-buffer lua-process-buffer
+ ;; enable error highlighting in stack traces
+ (require 'compile)
+ (setq lua--repl-buffer-p t)
+ (make-local-variable 'compilation-error-regexp-alist)
+ (setq compilation-error-regexp-alist
+ (cons (list lua-traceback-line-re 1 2)
+ compilation-error-regexp-alist))
+ (compilation-shell-minor-mode 1)
+ (setq-local comint-prompt-regexp lua-prompt-regexp)
+
+ ;; Don't send initialization code until seeing the prompt to ensure that
+ ;; the interpreter is ready.
+ (while (not (lua-prompt-line))
+ (accept-process-output (get-buffer-process (current-buffer)))
+ (goto-char (point-max)))
+ (lua-send-string lua-process-init-code)))
;; when called interactively, switch to process buffer
(if (called-interactively-p 'any)
@@ -1944,8 +1945,7 @@ When called interactively, switch to the process buffer."
(defun lua-get-create-process ()
"Return active Lua process creating one if necessary."
- (unless (comint-check-proc lua-process-buffer)
- (lua-start-process))
+ (lua-start-process)
lua-process)
(defun lua-kill-process ()
diff --git a/test/test-process.el b/test/test-process.el
new file mode 100644
index 0000000..bedb11c
--- /dev/null
+++ b/test/test-process.el
@@ -0,0 +1,24 @@
+;;; test-funcname-at-point.el --- Test the repl functions
+
+;;; Commentary:
+
+;; Test functions to interact with the REPL.
+
+;;; Code:
+
+(describe "`lua-start-process'"
+ (it "doesn't hang for an already-running process"
+ ;; Acquire a *lua* repl buffer
+ (save-current-buffer
+ (funcall-interactively #'lua-start-process)
+ ;; Input some text
+ (with-current-buffer lua-process-buffer
+ (insert "table.insert"))
+ (switch-to-buffer (get-buffer-create "*scratch*"))
+ ;; Try restarting the repl buffer
+ (funcall-interactively #'lua-start-process)
+
+ ;; `lua-start-process' shouldn't hang, and it should have switched back.
+ (expect (current-buffer) :to-be lua-process-buffer))))
+
+;;; test-process.el ends here
- [nongnu] elpa/lua-mode a0d6744 331/468: travis.yml: add Emacs-25.1, (continued)
- [nongnu] elpa/lua-mode a0d6744 331/468: travis.yml: add Emacs-25.1, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dccda19 336/468: Wrap lua--fill-paragraph in save-excursion, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7a97e1b 341/468: correct spelling mistake, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0715340 337/468: Merge pull request #131 from jorams/fill-paragraph-save-excursion, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d759699 335/468: Merge pull request #129 from immerrr/fix-global-variable-in-lua-interpreter, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 459e3b7 427/468: Fix FIXME: `lua-prefix-key' is always `boundp', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b793852 434/468: Add regression test, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6a30c39 447/468: lua-is-continuing-statement-p: short-circuit to false for "breaker" kws, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b043ca4 451/468: lua-is-continuing-statement-p-1: fix missing save-excursion on branch, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6a837f7 458/468: with-lua-buffer: ensure font-lock is activated, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 08d83fc 443/468: Merge pull request #180 from nbfalcon/bugfix/lua-start-process-hangs,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 56af490 446/468: lua-find-regexp: escape string/comment after a match is ignored, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 93da584 449/468: Bump indentation tests, add missing function-call-arguments suite, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0018e95 452/468: make-indentation-pair: don't calculate full indentation on every closer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d2ff304 456/468: Copy cl-signum into lua--signum for backward compat, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3688bf7 347/468: Merge pull request #136 from EdwardBetts/spelling, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6c69183 351/468: Merge pull request #139 from rrthomas/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode eacf137 349/468: Spell “Lua” consistently and its “process” (not “subprocess”), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode acd0c55 354/468: Revert to using group-n in lua--left-shifter-regexp, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3ba5ecc 360/468: Minor simplification of lua-get-create-process, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c6e053e 361/468: Spell “Lua” consistently and its “process” (not “subprocess”), Philip Kaludercic, 2021/08/05