Emacs execute Python 以及 buffer has no process problem

在 Emacs 下安装  python-mode 后,可以在 Emacs 中调用 Python Shell: 

C-c C-c 打开一个新的Python Shell

C-c RET run current Python file, 如下图:




C-x k 可以退出这个shell, 也就是kill buffer (我现在粗浅地将buffer理解为每一个窗口)。

问题来了,如果再一次C-c RET 跑这个文件,会给出buffer has no process。 

究其原因,在http://www.cs.vassar.edu/~priestdo/emacspeak/list.archive.2002/msg00248.html

找到了解释:

This happens if yu are running term and you type 'exit' or possibly
'logout' while in the term buffer. When you do this, the shell process
you are running is killed and emacs doesn't know what to do anymore -
it was taking its imput from the inferior shell process and sending
output to that process, but when you typed 'exit' you killed that
process and emacs doesn't know what to do with your input anymore.

Solution is very simple. Don't exit/kill the terminal process. If you
no longer need the term process, then kill the buffer (from within
term this is C-x k), or switch to another buffer and then kill the term
buffer. Better still, just leave it alone - you will probably want it
again and if its already running, you don't have to start another one,
just switch to that buffer with C-x b.

简单来说,就是我已经把buffer kill掉了, Emacs就不知道接下来该干嘛了。

解决的办法就是保留这个buffer,或者再新建一个buffer, C-x b

但是使用 C-x k kill buffer 以后,新建一个buffer,再用C-c RET, 同样显示buffer has no process。

原因是kill的时候没有停止process

停止process的方法就是 C-d

这样shell里面就会显示,process python finished

此时可以kill buffer,再一次C-c RET的话,就不会显示buffer has no process



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值