0

我是 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;

}

我发现它可以完成关键字,如包含或头文件。当我尝试完成 s 的方法时,它失败了。当我使用命令时semantic-ia-complete-symbol 它只是报告Cannot find types for string s

谁能告诉我为什么它不能工作?非常感谢!

4

1 回答 1

0

只需更新到最新的 Emacs。在那里,您的示例适用于零配置,即

emacs -Q test.cc

M-x semantic-mode, semantic-ia-complete-symbol.

于 2014-11-26T15:44:42.513 回答