Emacs中的Python代码自动补全

3
1个回答

5
您想在收到该消息的上下文中激活自动完成模式,可以采取以下方法之一:
  • every time you open python files, by adding the following to your .emacs:

    (add-hook 'python-mode-hook
      (lambda ()
             (auto-complete-mode 1)))
    
  • or when you open any file, by adding the following to your .emacs:

    (global-auto-complete-mode t)
    

您所链接的问题提出了更加完整的方案(即包含我建议的前两个方案中的第一个):

(add-hook 'python-mode-hook
      (lambda ()
             (auto-complete-mode 1)
             (set (make-local-variable 'ac-sources)
                  (append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
             (set (make-local-variable 'ac-find-function) 'ac-python-find)
             (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate)
             (set (make-local-variable 'ac-auto-start) nil)))

使用代码片段和Rope,需要添加这些内容才能完全完成。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接