【问题标题】:emacs cedit c++ code completion failsemacs cedit c++ 代码完成失败
【发布时间】:2015-01-25 00:25:24
【问题描述】:

我是 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或头文件。当我尝试完成s的方法时,它失败了。当我使用命令semantic-ia-complete-symbol 它只是报告Cannot find types for string s

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

【问题讨论】:

    标签: c++ emacs autocomplete cedit


    【解决方案1】:

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

    emacs -Q test.cc
    

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

    【讨论】:

    • 我试过了,但它不起作用。我使用的是 emacs 24.3.1。如果我在这个文件中定义了一个类并且它可以成功地完成方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-01
    • 2011-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多