首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用cscope建立语义

用cscope建立语义
EN

Stack Overflow用户
提问于 2013-12-24 09:16:27
回答 1查看 1.8K关注 0票数 2

我开始尝试使用emacs作为我的开发环境,我遇到了一些麻烦。我希望使用具有语义的cscope,以便在我的代码库中进行相当健壮的搜索。但是,在安装了cscope (使用apt-get install cscope)并将xscope.el迁移到我的~/.emacs.d/之后,我仍然很难用xscope.el文件调用一些设置。当我试图调用(semanticdb-enable-cscope-databases)时,会发现一个错误,即符号的函数定义无效。我使用的是emacs 24.3

代码语言:javascript
复制
(semantic-mode 1)

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

;; Semantic
(global-semantic-idle-completions-mode t)
(global-semantic-decoration-mode t)
(global-semantic-highlight-func-mode t)
(global-semantic-show-unmatched-syntax-mode t)

;; auto-complete stuff
(add-to-list 'load-path "~/.emacs.d")
(require 'auto-complete-config)
(ac-config-default)

(add-hook 'c-mode-common-hook '(lambda ()

      ;; ac-omni-completion-sources is made buffer local so
      ;; you need to add it to a mode hook to activate on
      ;; whatever buffer you want to use it with.  This
      ;; example uses C mode (as you probably surmised).

      ;; auto-complete.el expects ac-omni-completion-sources to be
      ;; a list of cons cells where each cell's car is a regex
      ;; that describes the syntactical bits you want AutoComplete
      ;; to be aware of. The cdr of each cell is the source that will
      ;; supply the completion data.  The following tells autocomplete
      ;; to begin completion when you type in a . or a ->

      (add-to-list 'ac-omni-completion-sources
                   (cons "\\." '(ac-source-semantic)))
      (add-to-list 'ac-omni-completion-sources
                   (cons "->" '(ac-source-semantic)))

      ;; ac-sources was also made buffer local in new versions of
      ;; autocomplete.  In my case, I want AutoComplete to use
      ;; semantic and yasnippet (order matters, if reversed snippets
      ;; will appear before semantic tag completions).

          (setq ac-sources '(ac-source-semantic ac-source-yasnippet))
  ))

(require 'xcscope)
(semanticdb-enable-cscope-databases)  ;;This is causing problems

;;C mode
(require 'cc-mode)

;;Color theme
(require 'color-theme)
(setq color-theme-is-global t)
(add-to-list 'load-path "/home/bob/.emacs.d/theme/ample-theme/ample-theme.el")
;;(require 'ample-theme)
(eval-after-load "color-theme"
  '(progn
     (color-theme-initialize)
     (color-theme-jsc-dark)))

;;set font
(set-face-attribute 'default nil :family "Anonymous Pro" :height 140)

;;line numbers
(global-linum-mode 1)
(custom-set-variables '(linum-format (quote "%4d \u2502 ")))

;;treat .h files at C++
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))

;; use F5 as compile
(global-set-key [(f5)] 'compile)

;; make compilation window smaller
(setq compilation-window-height 8)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-25 17:34:09

现在,我真的开始写一个答案,以便能够随着时间的推移来完善它。这就是我到现在为止的成就:

有几个版本的cedet

Emacs24.3包括cedet-2.0。但是,关于下面引用的集市版本,它似乎有点过时了。我相信在这个版本中,cscope是semantic-symref-tool-alist中支持的工具之一。变量semantic-symref-tool-alist在信息手册中进行了描述。其中一个是用键笔画C-h i g (semantic-user) Configuring SymRef到达的。

在加载semantic-symref-tool-alist之后,可以看到semantic/symref的默认值。其成员之一是:

代码语言:javascript
复制
 ((lambda
    (rootdir)
    (file-exists-p
     (expand-file-name "cscope.out" rootdir)))
  . cscope)

我认为这个,是cscope内置版本的cscope支持,不需要额外的启用(?)

官方发布的是cedet-1.1,来自https://sourceforge.net/projects/cedet/files/cedet/cedet-1.1.tar.gz/download

在这个版本中,函数semanticdb-enable-cscope-databases定义在文件semantic/semanticdb-cscope.el中。

市场版的cedet是cedet-2.0。它可通过集市获得,网址如下:

代码语言:javascript
复制
bzr checkout bzr://cedet.bzr.sourceforge.net/bzrroot/cedet/code/trunk cedet

在这个版本中,函数semanticdb-enable-cscope-databases是在cedet/semantic/db-cscope.el中定义的。

在emacs 24.3附带的cedet版本中缺少此文件。

Σ:这让我相信,如果你想使用你的设置,你应该使用市场版的cedet-2.0。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20758082

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档