setting up semantic with cscope

1.8k views Asked by At

I'm starting to experiment a bit with using emacs as my development envrionment and I am running into a bit of trouble. I wish to use cscope with semantic for a fairly robust way of searching through my code base. However, after installing cscope (with apt-get install cscope) and moving xscope.el into my ~/.emacs.d/, I am still having trouble calling some settings with my .emacs file. When I try to call (semanticdb-enable-cscope-databases), I get an error that the symbol's function definition is void. I am using 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)
1

There are 1 answers

1
Tobias On BEST ANSWER

Now, I really start writing an answer to be able to refine it with time. That is how far I got until now:

There are several versions of cedet.

Emacs 24.3 includes cedet-2.0. But, with respect to the bazaar version cited below it seems to be slightly outdated. I believe that in this version cscope is supported as one of the tools in semantic-symref-tool-alist. The variable semantic-symref-tool-alist is described in the info manual. One gets there with the key strokes C-h i g (semantic-user) Configuring SymRef.

One can see the default value of semantic-symref-tool-alist after loading semantic/symref. One of its members is:

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

I think that this is the cscope support in in the built-in version of cedet-2.0 and no additional enabling of cscope is required (?).


The official release is cedet-1.1 from https://sourceforge.net/projects/cedet/files/cedet/cedet-1.1.tar.gz/download.

In this version the function semanticdb-enable-cscope-databases is defined in the file semantic/semanticdb-cscope.el


The bazar-version of cedet is cedet-2.0. It is available via bazaar under:

bzr checkout bzr://cedet.bzr.sourceforge.net/bzrroot/cedet/code/trunk cedet

In this version the function semanticdb-enable-cscope-databases is defined in cedet/semantic/db-cscope.el.

This file is missing in the version of cedet shipped with emacs 24.3.


Σ: That makes me believe that if you want to use your setup you should use the bazaar version of cedet-2.0.