我开始尝试使用emacs作为我的开发环境,我遇到了一些麻烦。我希望使用带语义的cscope来搜索我的代码库。但是,在安装cscope(使用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)
答案 0 :(得分: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)
我认为是内置版本的cedet-2.0中的cscope
支持,并且不需要额外启用cscope(?)。
官方发布来自https://sourceforge.net/projects/cedet/files/cedet/cedet-1.1.tar.gz/download
cedet-1.1 。
在此版本中,函数semanticdb-enable-cscope-databases
在文件semantic/semanticdb-cscope.el
cedet版本的cedet是 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的集市版本。