具有Python代码完成的Emacs>代码完成建议没有弹出

时间:2012-08-12 22:45:00

标签: python emacs code-completion

安装后:

[rope]
[ropemode]
[pymacs]
[ropemacs]
[autocomplete 1.3.1]

配置.emacs

(add-to-list 'load-path "~/.emacs.d/autocomplete1.3.1")
(add-to-list 'load-path "~/share/emacs/lisp/")

(setq py-install-directory "~/share/emacs/lisp/")
(require 'python-mode)

(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(autoload 'pymacs-autoload "pymacs")

(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)

(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/autocomplete1.3.1/ac-dict")
(ac-config-default)

(require 'auto-complete)
(global-auto-complete-mode t)

我输入sys.之后的句号,并希望代码完成类似于Komodo Edit。

不幸的是,我能做到的最好,就是按 M - / 来调出分屏代码完成缓冲区。

如何在GNU Emacs中实现代码完成,类似于Komodo-Edit?

这是一个引起我注意的pymacs bug错误:

1 个答案:

答案 0 :(得分:1)

以下是ac-config-default的定义,因为它是您配置AC的唯一方法:

(defun ac-config-default ()
  (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
  (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
  (add-hook 'css-mode-hook 'ac-css-mode-setup)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
  (global-auto-complete-mode t))

没有Python配置,所以你不能指望AC适用于Python。

进行设置:

(add-hook 'python-mode-hook 'ac-ropemacs-setup)

无耻插件:以下是AC的替代ropemacs来源 - 因为附带的来源没有显示文档:https://github.com/cofi/dotfiles/blob/master/emacs.d/config/cofi-python.el#L75

这里再次配置:

(add-hook 'python-mode-hook (lambda ()
                              (setq ac-source (append ac-source '(ac-source-nropemacs
                                                                  ac-source-nropemacs-dot)))))