简体   繁体   English

为什么我输入“ else:”后Emacs Jedi总是插入“ elif”?

[英]Why does Emacs Jedi always insert “elif” after I type “else:”?

I have installed “Jedi” mode in Emacs but am finding that it auto-inserts the word elif every time I create a new line and then type e l s e : Enter because the colon character apparently kicks off Jedi's completion logic with elif suggested as the top suggestion, and my pressing Enter apparently selects it. 我已经在Emacs中安装了“ Jedi”模式,但是发现每次创建新行后它都会自动插入elif这个词,然后键入e l s e 输入,因为冒号字符显然以elif Jedi elif逻辑被建议为elif顶部的建议,然后按Enter键显然将其选中。 So I always, every time I try to type an else clause, have to backspace over the extraneous elif before continuing. 因此,我总是在每次尝试键入else子句时都必须在多余的elif上退格,然后再继续。

Is this problem unique to me? 这个问题对我来说是唯一的吗? I activate Jedi by closely following the documentation: 我通过严格遵循文档来激活Jedi:

(add-hook 'python-mode-hook 'jedi:setup)                                        
(setq jedi:complete-on-dot t)                                                   
(setq jedi:get-in-function-call-delay 200)                                      
(setq jedi:tooltip-method nil)

You can find my entire .emacs.d/init.el under version control on GitHub: 您可以在GitHub上的版本控制下找到我的整个.emacs.d/init.el

https://github.com/brandon-rhodes/dot-emacs

The current version of Jedi and its associated tools on my system is: 我系统上的Jedi及其相关工具的当前版本为:

(:emacs-version "24.3.1" :jedi-version "0.2.0alpha2")
((:version "3.4.0 |Continuum Analytics, Inc.| (default, Mar 17 2014, 16:13:08) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]" :file nil :name "sys")
 (:version "0.8.0-final0" :file "/home/brandon/.v/fopnp-py3/lib/python3.4/site-packages/jedi/__init__.py" :name "jedi")
 (:version "0.0.5" :file "/home/brandon/.v/fopnp-py3/lib/python3.4/site-packages/epc/__init__.py" :name "epc")
 (:version "0.0.3" :file "/home/brandon/.v/fopnp-py3/lib/python3.4/site-packages/sexpdata.py" :name "sexpdata"))

I note that the : character is bound to the Emacs function python-indent-electric-colon but I am not sure how to determine whether that function is somehow setting off Jedi's completion logic without meaning to. 我注意到:字符绑定到Emacs函数python-indent-electric-colon但是我不确定如何确定该函数是否以某种方式抵消了Jedi的完成逻辑,而没有意义。

I think this is a bug with the python-mode: tab-always-indent value is true but the behavior is the same that it was before. 我认为这是python模式的错误: tab-always-indent值为true,但行为与以前相同。

https://www.gnu.org/software/emacs/manual/html_node/emacs/Indent-Convenience.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Indent-Convenience.html

My solution: 我的解决方案:

(add-hook 'python-mode-hook
    (lambda ()
        (setq-local electric-indent-chars (remq ?: electric-indent-chars))
    )
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM