如何让 ipython 在 emacs 下正常工作?
按照ipython 文档的建议,我启用了 ipython:
(require 'python)
(setq python-shell-interpreter "ipython")
Run Code Online (Sandbox Code Playgroud)
当我启动 ipython 服务器时收到以下警告。
Python 3.7.4 (default, Jul 9 2019, 18:15:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.
WARNING: your terminal doesn't support cursor position requests (CPR).
Run Code Online (Sandbox Code Playgroud)
“ [In]”提示根本不打印。并且当代码从另一个缓冲区发送时(例如通过python-shell-send-buffer)。这是一个示例屏幕转储(我猜测是i 8 i 8来自未正确显示的提示):
WARNING: your terminal doesn't support cursor position requests (CPR).
i
8
i
8
hello world
Run Code Online (Sandbox Code Playgroud)
交互时,“ [Out]”提示有时显示,有时不显示:
print('hello world')
hello world
4
Out[3]: 4
Run Code Online (Sandbox Code Playgroud)
我在 Macos 上运行 Emacs:
This is GNU Emacs 26.3 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511))
of 2019-09-02
Copyright (C) 2019 Free Software Foundation, Inc.
Run Code Online (Sandbox Code Playgroud)
(setq python-shell-interpreter-args "--simple-prompt -i")
Run Code Online (Sandbox Code Playgroud)
ipython 假设您有一个“普通”终端,但在 Emacs 中它在“哑”终端下运行。确实,ipython 应该能够通过TERM环境变量知道这一点。看起来最近在这方面做了一些努力:https://github.com/prompt-toolkit/python-prompt-toolkit/issues/390。希望它能在未来的版本中正常工作。