mirror of
https://github.com/vale981/py-vterm-interaction.el
synced 2025-03-05 10:01:41 -05:00
make launch more robust
This commit is contained in:
parent
0755613c86
commit
11861302aa
1 changed files with 13 additions and 15 deletions
|
@ -124,6 +124,8 @@ If SESSION-NAME is not given, the default session name `main' is assumed."
|
||||||
(substring bn 8 -1)
|
(substring bn 8 -1)
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
(defvar-local python-vterm-repl--launch-timer '()
|
||||||
|
"A timer that is used to determine the interpreter upon launch.")
|
||||||
|
|
||||||
(defun python-vterm--launch (ses-name env context)
|
(defun python-vterm--launch (ses-name env context)
|
||||||
"Launch a new Python REPL buffer with SES-NAME and ENV.
|
"Launch a new Python REPL buffer with SES-NAME and ENV.
|
||||||
|
@ -141,21 +143,17 @@ python interpreter is ipython. This times out after
|
||||||
(setq default-directory (plist-get context :cwd))
|
(setq default-directory (plist-get context :cwd))
|
||||||
(setq python-vterm-repl-script-buffer (plist-get context :script-buffer)))
|
(setq python-vterm-repl-script-buffer (plist-get context :script-buffer)))
|
||||||
(python-vterm-repl-mode)
|
(python-vterm-repl-mode)
|
||||||
(run-with-timer 1 nil
|
(setq python-vterm-repl--launch-timer
|
||||||
|
(run-with-timer 1 1
|
||||||
(lambda (buffer)
|
(lambda (buffer)
|
||||||
(with-current-buffer buffer
|
(if (python-vterm-repl-prompt-status)
|
||||||
(with-timeout (python-vterm-repl-launch-timeout
|
(progn
|
||||||
(progn (display-warning 'python-vterm "Python REPL did not start in time.")
|
|
||||||
(kill-buffer buffer)))
|
|
||||||
(while (not (python-vterm-repl-prompt-status))
|
|
||||||
(message "waiting for prompt...")
|
|
||||||
(sit-for 0.5)
|
|
||||||
t)
|
|
||||||
(setq python-vterm-repl-interpreter
|
(setq python-vterm-repl-interpreter
|
||||||
(if (eq (python-vterm--execute-script "is_ipython") :false)
|
(if (eq (python-vterm--execute-script "is_ipython") :false)
|
||||||
:python :ipython)))))
|
:python :ipython))
|
||||||
new-buffer)
|
(cancel-timer python-vterm-repl--launch-timer))
|
||||||
|
(message "waiting for prompt...")))
|
||||||
|
new-buffer))
|
||||||
(add-function :filter-args (process-filter vterm--process)
|
(add-function :filter-args (process-filter vterm--process)
|
||||||
(python-vterm-repl-run-filter-functions-func ses-name)))
|
(python-vterm-repl-run-filter-functions-func ses-name)))
|
||||||
new-buffer))
|
new-buffer))
|
||||||
|
|
Loading…
Add table
Reference in a new issue