2

I have a problem with auto-complete package in Emacs. Currently I have up and running cedet with proper autocompletion, but auto-complete package has some weird behaviour. It doesn't use semantic's (senator's?) database until I explicitly visit include file and make "C-u M-x bovinate". Then I can return to the source file and auto-complete's completion list will look exactly as the semantic's one.

Another point is if I edit my source file, for example, in c++-mode and try to "bovinate" header in c-mode, auto-complete won't get any additional points in it's completion list.

Any ideas how to get auto-complete work automatically?

My .emacs file is (Major parts of it were taken from Alex Ott's article)

(load "~/.emacs.d/cedet/cedet-devel-load.el")
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-local-symbol-highlight-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-decoration-mode)

(require 'semantic/ia)
(semantic-mode 1)

(require 'semantic/bovine/gcc)

(semantic-add-system-include "/usr/include/mpi/" 'c++-mode)

;; ;; Imenu integration
(defun my-semantic-hook ()
  (imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)

;; Class suggest improvement
(defun my-c-mode-cedet-hook ()
 (local-set-key "." 'semantic-complete-self-insert)
 (local-set-key ">" 'semantic-complete-self-insert))
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)

;;;; Semantic and auto-config integration
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "/home/zvord/.emacs.d/ac-dict")
(define-key ac-mode-map [(meta return)] 'auto-complete)

(defun my-cedet-hook ()
  (add-to-list 'ac-sources 'ac-source-semantic))
(add-hook 'c-mode-common-hook 'my-cedet-hook)

From all I've read this should be enough to get auto-complete work, but it isn't.

4

2 回答 2

2

您的自动完成配置是否允许自动开始完成?您需要检查以下变量的值:ac-auto-show-menu- 等待多久显示可能完成的菜单(默认为 0.5 秒),以及ac-auto-start- 何时开始完成(您需要输入多少符号 - 原始值为 2)。

自动完成的完整配置可能如下所示(除了您在 中的设置my-cedet-hook):

(require 'auto-complete-config)
(ac-config-default)
;; start after 3 characters were typed
(setq ac-auto-start 3)
;; show menu immediately...
(setq ac-auto-show-menu t)
;; explicit call to auto-complete
(define-key ac-mode-map [(meta return)] 'auto-complete)

我使用类似的配置,它对我来说很好,显示语义数据的完成。您尝试对哪种语言使用名称补全?例如,对于 C++,有必要将条目添加到 spp-table 等。

于 2012-11-04T13:35:33.083 回答
0

尝试改变:

(defun my-cedet-hook () (add-to-list 'ac-sources 'ac-source-semantic))

进入:

(defun my-cedet-hook () (add-to-list 'ac-sources 'ac-source-semantic-raw))

它应该工作。

于 2013-09-17T21:51:30.743 回答