mirror of
https://github.com/vale981/py-vterm-interaction.el
synced 2025-03-05 10:01:41 -05:00
fix the prompt timer
This commit is contained in:
parent
11861302aa
commit
108a8d1ca2
1 changed files with 22 additions and 13 deletions
|
@ -124,9 +124,12 @@ 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 '()
|
(defvar python-vterm-repl--launch-timers '()
|
||||||
"A timer that is used to determine the interpreter upon launch.")
|
"A timer that is used to determine the interpreter upon launch.")
|
||||||
|
|
||||||
|
(defvar-local python-vterm-repl--buffer-id '()
|
||||||
|
"An id to identify the buffer even if it does not exist anymore.")
|
||||||
|
|
||||||
(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.
|
||||||
|
|
||||||
|
@ -137,23 +140,29 @@ python interpreter is ipython. This times out after
|
||||||
(let ((new-buffer
|
(let ((new-buffer
|
||||||
(generate-new-buffer (python-vterm-repl-buffer-name ses-name)))
|
(generate-new-buffer (python-vterm-repl-buffer-name ses-name)))
|
||||||
(vterm-shell python-vterm-repl-program)
|
(vterm-shell python-vterm-repl-program)
|
||||||
(vterm-environment (if context (plist-get context :env) env)))
|
(vterm-environment (if context (plist-get context :env) env))
|
||||||
|
(id (gensym "python-vterm-buffer")))
|
||||||
(with-current-buffer new-buffer
|
(with-current-buffer new-buffer
|
||||||
|
(setq python-vterm-repl--buffer-id id)
|
||||||
(when context
|
(when context
|
||||||
(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)
|
||||||
(setq python-vterm-repl--launch-timer
|
|
||||||
(run-with-timer 1 1
|
(push (cons id
|
||||||
(lambda (buffer)
|
(run-with-timer .1 1
|
||||||
(if (python-vterm-repl-prompt-status)
|
(lambda (buffer)
|
||||||
(progn
|
(let ((timer (alist-get id python-vterm-repl--launch-timers)))
|
||||||
(setq python-vterm-repl-interpreter
|
(if (and buffer (buffer-live-p buffer))
|
||||||
(if (eq (python-vterm--execute-script "is_ipython") :false)
|
(if (python-vterm-repl-prompt-status)
|
||||||
:python :ipython))
|
(progn
|
||||||
(cancel-timer python-vterm-repl--launch-timer))
|
(setq python-vterm-repl-interpreter
|
||||||
(message "waiting for prompt...")))
|
(if (eq (python-vterm--execute-script "is_ipython") :false)
|
||||||
new-buffer))
|
:python :ipython))
|
||||||
|
(cancel-timer timer)))
|
||||||
|
(cancel-timer timer))))
|
||||||
|
new-buffer))
|
||||||
|
python-vterm-repl--launch-timers)
|
||||||
(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