【问题标题】:restart process executed in eshell in emacs在 emacs 中的 eshell 中执行的重启进程
【发布时间】:2015-03-07 00:45:44
【问题描述】:

我已经在 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))
)

希望它给出了我正在尝试的要点,但它失败了。有什么想法吗?

【问题讨论】:

    标签: emacs eshell


    【解决方案1】:

    我建议寻找一种类似 eshell 的方式来杀死进程(我自己不是 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)))))
    

    【讨论】:

      猜你喜欢
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      • 2012-02-13
      • 1970-01-01
      相关资源
      最近更新 更多