在emacs中的eshell中执行重启过程

时间:2015-03-05 11:23:13

标签: emacs eshell

我在eshell中启动了一个python进程:

python app.py

我想用elisp函数重新启动它,我认为comint-quit-subjob执行时C-c C-\会导致进程失败,但我执行comint-quit-subjob的所有尝试都失败了

这是我到目前为止所做的:

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

希望它能给出我正在尝试的内容的精神,但它失败了。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我建议寻找一种杀死进程的eshell-ish方法(我自己不是eshell用户)。 Comint尝试在缓冲区中搜索某些内容。你可以解决做这样的事情(但它很脆弱和不优雅):

(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)))))
相关问题