emacs24.3python模式在函数结束后错误地缩进代码

2024-09-28 22:03:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Emacs编写一些Python代码,但是当我完成一个函数块并想定义下一个函数时,该行会自动缩进:

def funA(x):
    print("Hello!")
    return 1

def funB(y):<--- cursor is here, when I press RET line is automatically indented!

既然def应该在第一列中,我如何才能使Emacs不这样做呢?在


Tags: 函数代码helloreturnhere定义isdef
1条回答
网友
1楼 · 发布于 2024-09-28 22:03:53

这是一个已知的错误,已在Emacs的当前开发版本中修复:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18228

作为临时修复,您可以使用以下代码,这将导致electric-indent-mode不重新缩进冒号上的当前行:

(add-hook 'python-mode-hook
          (lambda ()
            (setq electric-indent-chars '(?\n))))

相关问题 更多 >