ipython emacs 缩进错误

sud*_*udo 5 emacs ipython

emacs 中 ipython 提示符中的一个非常烦人的问题:

In [128]: if 1==1:
   .....:     print "yes"
   .....: else:    
   .....:     print "no"
   .....:     
IndentationError: unindent does not match any outer indentation level
Run Code Online (Sandbox Code Playgroud)

它看起来与我完全一致,不确定是什么触发了错误。当我在终端中执行此操作时没有这样的问题。

Iva*_*rus 3

您可以尝试使用以下命令切换自动缩进

%autoindent

因为我认为这曾经给我带来过问题。

您可以使用ipython 的自定义功能永久更改此设置。正确导入后(请参阅链接),以下内容应在 ipy_user_conf.py 中运行:

# Emacs sets the term to dumb so we can distinguish that way
if os.environ['TERM'] == 'dumb':
    ip.options.autoindent = 0
Run Code Online (Sandbox Code Playgroud)