如何在emacs中调用进程Python中断和键盘中断?
How to invoke Process Python interrupt and keyboard interrupt in emacs?
我在 Emacs 中使用 Python,Elpy 和 iPython。我 运行 来自文件的代码 C-c C-c,但有时我想终止进程(键盘中断)。我使用相同的快捷方式尝试终止进程(根据 this question)。
我的目标是尝试区分是终止整个 Python 进程还是只是中断内核。使用上面的快捷方式,它有时会执行第一个,有时会执行第二个。我还没有找到任何线索,如何概括它。
所以,问题是:如何停止Python进程,如何中断内核?
我只想定义一个函数来向进程发送中断。我使用 anaconda-mode
而不是 elpy
,所以我不确定 elpy
使用什么来获取关联的 process-buffer
,但是 python-mode
有 python-shell-get-process-or-error
。然后你可以绑定键 C-c C-a,例如,在 python-mode-map
到下面的函数。
(defun my-interrupt ()
"Send an interrupt signal to python process"
(interactive)
(let ((proc (ignore-errors
(python-shell-get-process-or-error))))
(when proc
(interrupt-process proc))))
我在 Emacs 中使用 Python,Elpy 和 iPython。我 运行 来自文件的代码 C-c C-c,但有时我想终止进程(键盘中断)。我使用相同的快捷方式尝试终止进程(根据 this question)。
我的目标是尝试区分是终止整个 Python 进程还是只是中断内核。使用上面的快捷方式,它有时会执行第一个,有时会执行第二个。我还没有找到任何线索,如何概括它。
所以,问题是:如何停止Python进程,如何中断内核?
我只想定义一个函数来向进程发送中断。我使用 anaconda-mode
而不是 elpy
,所以我不确定 elpy
使用什么来获取关联的 process-buffer
,但是 python-mode
有 python-shell-get-process-or-error
。然后你可以绑定键 C-c C-a,例如,在 python-mode-map
到下面的函数。
(defun my-interrupt ()
"Send an interrupt signal to python process"
(interactive)
(let ((proc (ignore-errors
(python-shell-get-process-or-error))))
(when proc
(interrupt-process proc))))