emacs cedit c ++代码完成失败

时间:2014-11-26 15:38:34

标签: c++ emacs autocomplete cedit

我是emacs的新手,我尝试使用cedit来完成代码。  我使用基于http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html

的简单设置

.emacs看起来像这样:

;; cedit
(semantic-mode 1)
(require 'semantic/ia)
(require 'semantic/bovine/gcc)
;;(require 'semantic/bovine/clang)
;;(semantic-clang-active)

(setq-mode-local c-mode semanticdb-find-default-throttle
                 '(project unloaded system recursive))

;;(semantic-idle-summary-mode )
;; if you want to enable support for gnu global
(semanticdb-enable-gnu-global-databases 'c-mode)
(semanticdb-enable-gnu-global-databases 'c++-mode)
;;(semantic-reset-system-include 'c-mode)
;;(semantic-reset-system-include 'c++-mode)
(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)
(add-hook 'c++-mode-common-hook 'my-c-mode-cedet-hook)

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


(global-ede-mode t)

用我这个简单的c ++文件测试后:

#include <string>
#include <map>
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

  string s; 

  map<int,int>a;

}

我发现它可以完成像include或header文件这样的关键字。当我尝试完成s的方法时,它会失败。当我使用命令semantic-ia-complete-symbol时 它只报告Cannot find types for string s

任何人都可以告诉我为什么它不起作用? 非常感谢!

1 个答案:

答案 0 :(得分:0)

只需更新到最新的Emacs即可。 在那里,你的例子使用零配置,即

emacs -Q test.cc

M-x semantic-modesemantic-ia-complete-symbol