ipython emacs缩进错误

ipython emacs缩进错误,emacs,ipython,Emacs,Ipython,emacs中的ipython提示符中存在非常恼人的问题: In [128]: if 1==1: .....: print "yes" .....: else: .....: print "no" .....: IndentationError: unindent does not match any outer indentation level 在我看来,它看起来完全一致,不确定是什么触发了错误。当我在终端中执行此操作时,没有这样的问

emacs中的ipython提示符中存在非常恼人的问题:

In [128]: if 1==1:
   .....:     print "yes"
   .....: else:    
   .....:     print "no"
   .....:     
IndentationError: unindent does not match any outer indentation level

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

是的,这很奇怪。在我看来,在emacs shell中使用标准的
python
解释器在评估代码时效果很好,但使用
ipython
失败。如果您使用的是
python mode.el
软件包,则可能需要安装
ipython.el
以获得适当的
ipython
支持。OTOH,如果您使用的是emacs通常附带的
python.el
,那么您可能必须切换到标准的
python
解释器(我相信
ipython.el
仅用于第三方
python mode.el
包,而不是emacs默认使用的
python.el
).

您可以尝试使用

%autoindent

因为我认为这已经给我造成了问题

您可以使用永久更改此设置。在正确导入(请参阅链接)后,以下内容应在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

我也有同样的问题。在调用ipython之后,它发生在emacs中的任何shell(例如eshell)中,而不仅仅是在python-mode.el或ipython.el提供的解决问题的ipython shell(M-x ipython)中!有没有办法保存此指令,以避免每次重新启动ipython模式时都必须键入它?我添加了一个关于使其永久化的注释。当ipython启动时,可能只有emacs才能调用
%autoindent
,但这似乎不太可靠,因为
%autoindent
总是切换AFAICT。