【发布时间】:2013-06-13 19:16:28
【问题描述】:
我在启用了python-mode 的 Emacs 上有这段代码:
def func(a):
if a:
return True
return False
当我在return False 和def func( 之间移动光标时,代码会自动缩进,破坏它:
def func(a):
if a:
return True
return False #Oops!
我知道这是因为electric-indent-mode,这是一种次要的全局模式。但是,我尝试将其关闭,但问题仍然存在。
我使用的 elisp 代码是这样的:
(defun disable-electric-indent ()
(set (make-local-variable 'electric-indent-functions)
(list (lambda (arg) 'no-indent))))
这就是我的python-mode-hook 的样子:
(add-hook 'python-mode-hook
(lambda ()
(flyspell-prog-mode)
(auto-complete-mode)
(nlinum-mode)
(toggle-truncate-lines t)
(setq autopair-handle-action-fns
(list 'autopair-default-handle-action 'autopair-python-triple-quote-action))
(centered-cursor-mode)
(auto-indent-mode)
(autopair-mode)
(column-marker-1 80)
(flycheck-mode)
(setq ac-auto-start 2)
(disable-electric-indent) ;; esto deberia hacer que emacs deje de romper las pelotas con el codigo en python
(jedi:setup)))
如果我关闭auto-indent-mode,这种行为就会停止(但是,我没有自动缩进,gol)。
我的 emacs 版本:GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.1) of 2013-04-29 on eric
编辑:根据 melpa 的说法,我在其版本 0.24.2 中使用 python 包(内置 Python 对 Emacs 的飞行马戏团支持)。也许我应该删除它并在其版本 6.0.10 中使用 python-mode 包?
【问题讨论】:
-
如果引用 python-mode.el,请通过 bazaar 尝试当前主干,bzr 分支 lp:python-mode,resp。从launchpad.net/python-mode下载
-
实际上,如果我使用
python-mode.el,这种行为就会消失。我现在对该软件包有一些小问题,但没有什么是我无法解决的关键问题,谢谢! (请您的评论作为答案!) -
习惯
C-j而不是RET,或者将RET绑定到newline-and-indent。这会给你自动缩进。 -
@JorgeArayaNavarro 即使有小问题,也不要犹豫,在
https://bugs.launchpad.net/python-mode提交报告/请求。这将对我们和其他人有所帮助。
标签: emacs elisp python-mode