簡體   English   中英

如何在emacs python-mode中取消解釋器命令

[英]How to cancel interpreter command in emacs python-mode

如果我在python intepreter中輸入錯誤命令,有時我只會看到... 例如,如果我輸入help(random.unif並按回車鍵,我無法輸入新命令。我必須退出emacs並再次啟動python和解釋器。有沒有辦法糾正這個?

正如Pavel Anossov所解釋的那樣,您希望向Python發送一個CTRL-C來中斷它。

但在emacs中,默認情況下, CTRL-C是前綴鍵。

幸運的是,在大多數交互式shell模式中,包括python-mode和替代方案,連續兩次命中CTRL -C會向解釋器發送一個ctrl-C。 或者,從技術上講, CTRL-C CTRL-C綁定到comint-interrupt-subjob (當然,您可以以任何其他方式運行它-如果您真的想要,甚至可以使用META-X comint-interrupt-subjob 。)結果如下所示:

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help(f
...   ^C ^C
KeyboardInterrupt
>>> 

另一種方法是使用quoted-insert命令,通常綁定到CTRL-Q ,然后按CTRL-C 但是,因為這不會中斷通常的行輸入,所以通常必須使用換行符。 結果如下:

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help(f
... ^C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>> 

通常CTRL-C有效。 不確定emacs嵌入式解釋器。 或者,只需向解釋器提供它正在等待的任何內容(在您的示例中,a ) )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM