2

我开始尝试使用 emacs 作为我的开发环境,但遇到了一些麻烦。我希望将 cscope 与语义一起使用,以获得一种相当健壮的方式来搜索我的代码库。但是,在安装 cscope (with apt-get install cscope) 并xscope.el进入我~/.emacs.d/的 .emacs 文件后,我仍然无法调用一些设置。当我尝试调用(semanticdb-enable-cscope-databases)时,我收到一个错误,即符号的函数定义无效。我正在使用 emacs 24.3

(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)
4

1 回答 1

1

现在,我真的开始写一个答案,以便能够随着时间的推移对其进行改进。这就是我到现在为止的距离:

有几个版本cedet

Emacs 24.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。其成员之一是:

 ((lambda
    (rootdir)
    (file-exists-p
     (expand-file-name "cscope.out" rootdir)))
  . cscope)

我认为这cscopecedet-2.0 内置版本中的支持,不需要额外启用 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 的 bazar 版本是cedet-2.0。它可以通过集市获得:

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 的集市版本。

于 2013-12-25T17:34:09.003 回答