0

i have started a python process in eshell:

python app.py

i want to restart this with a elisp function, i think comint-quit-subjob when executed with C-c C-\ kills the process but all my attempts to execute comint-quit-subjob have failed

This is what i have so far:

(defun restart-app()
  (with-current-buffer "*eshell*"
    (interactive)
    (comint-quit-subjob)
    (eshell-return-to-prompt)
    (insert "python app.py")
    (eshell-send-input))
)

Hopefully it gives the jist of what i am trying, but it fails. Any ideas?

chris
  • 7,222
  • 5
  • 31
  • 37

1 Answers1

0

I would suggest looking for a eshell-ish way of killing a process (I am not a eshell user myself). Comint tries to search something in the buffer. You can workaround that doing something like this (but it is brittle and unelegant):

(defun restart-app()
  (with-current-buffer "*eshell*"
    (interactive)
    (kill-process nil comint-ptyp)
    (run-with-timer 0.5 nil
                    (lambda ()
                      (with-current-buffer "*eshell*"
                        (goto-char (point-max))
                        (insert "python app.py")
                        (eshell-send-input)))))
juanleon
  • 9,220
  • 30
  • 41