Skip to content

Instantly share code, notes, and snippets.

@alexott
Created October 22, 2012 07:30
Show Gist options
  • Save alexott/3930120 to your computer and use it in GitHub Desktop.
Save alexott/3930120 to your computer and use it in GitHub Desktop.
Working configuration for CEDET from bzr & GNU Emacs (with working C++ & Java name completion)
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;; Copyright (C) Alex Ott
;;
;; Author: Alex Ott <[email protected]>
;; Keywords: cedet, C++, Java
;; Requirements: CEDET from bzr (http://cedet.sourceforge.net/bzr-repo.shtml)
;; Do checkout of fresh CEDET, and use this config (don't forget to change path below)
(setq cedet-root-path (file-name-as-directory "~/projects/cedet-bzr/"))
(load-file (concat cedet-root-path "cedet-devel-load.el"))
(add-to-list 'load-path (concat cedet-root-path "contrib"))
;; select which submodes we want to activate
(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
;; Activate semantic
(semantic-mode 1)
;; load contrib library
(require 'eassist)
;; customisation of modes
(defun alexott/cedet-hook ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-c?" 'semantic-ia-complete-symbol)
;;
(local-set-key "\C-c>" 'semantic-complete-analyze-inline)
(local-set-key "\C-c=" 'semantic-decoration-include-visit)
(local-set-key "\C-cj" 'semantic-ia-fast-jump)
(local-set-key "\C-cq" 'semantic-ia-show-doc)
(local-set-key "\C-cs" 'semantic-ia-show-summary)
(local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)
)
(add-hook 'c-mode-common-hook 'alexott/cedet-hook)
(add-hook 'lisp-mode-hook 'alexott/cedet-hook)
(add-hook 'scheme-mode-hook 'alexott/cedet-hook)
(add-hook 'emacs-lisp-mode-hook 'alexott/cedet-hook)
(add-hook 'erlang-mode-hook 'alexott/cedet-hook)
(defun alexott/c-mode-cedet-hook ()
(local-set-key "\C-ct" 'eassist-switch-h-cpp)
(local-set-key "\C-xt" 'eassist-switch-h-cpp)
(local-set-key "\C-ce" 'eassist-list-methods)
(local-set-key "\C-c\C-r" 'semantic-symref)
)
(add-hook 'c-mode-common-hook 'alexott/c-mode-cedet-hook)
(semanticdb-enable-gnu-global-databases 'c-mode t)
(semanticdb-enable-gnu-global-databases 'c++-mode t)
(when (cedet-ectag-version-check t)
(semantic-load-enable-primary-ectags-support))
;; SRecode
(global-srecode-minor-mode 1)
;; EDE
(global-ede-mode 1)
(ede-enable-generic-projects)
;; Setup JAVA....
(require 'cedet-java)
;;; minimial-cedet-config.el ends here
Copy link

ghost commented Feb 9, 2017

I use this do some experiment for c++ projects in my emacs 24.3 and latest cedet in "https://git.code.sf.net/p/cedet/git" (also in emacs 23.1 and stable cedet1.1). I am quite satisfied with it except for one small "jump to function implement" issue in "semantic-analyze-proto-impl-toggle". alex, could you help me to check this issue?
my project is very simple(only 2 files):

  1. head file "y.hpp" in dir "~/emacs/test/zz1/"

    class y{
    public:
    int y1(int);//error here! semantic can't found implement in y.cpp
    };

  2. implement file "y.cpp" in dir "~/emacs/test/zz2/"

    #include "y.hpp"
    int y::y1(int b) // semantic can found definition use "semantic-ia-fast-jump" in y.hpp
    {
    return 0;
    }
    my cedet config is based on alex oot 's "minimial-cedet-config.el"([https://gist.github.com/alexott/3930120][1]) and only add following two lines:

(semantic-add-system-include "~/emacs/test/zz1/" 'c++-mode)

(semantic-add-system-include "~/emacs/test/zz2/" 'c++-mode)

i checked my semantic db cache and found all db file is create correctly,
this is info in cache db for y.hpp in zz1:
;; Object zz1/
;; SEMANTICDB Tags save file
(semanticdb-project-database-file "zz1/"
:tables (list
(semanticdb-table "y.hpp"
:major-mode 'c++-mode
:tags
'( ("y" type
(:members
( ("public" label nil (reparse-symbol classsubparts) [10 17])
("y1" function
(:prototype-flag t
:arguments
( ("" variable (:type "int") (reparse-symbol arg-sub-list) [27 31]))
:type "int")
(reparse-symbol classsubparts) [20 32]))
:type "class")
nil [1 35]))
:file "y.hpp"
:pointmax 37
:fsize 36
:lastmodtime '(22684 34221 595699 276000)
:unmatched-syntax 'nil
)
)
:file "!home!zzhao010!emacs!test!zz1!semantic.cache"
:semantic-tag-version "2.0"
:semanticdb-version "2.2"
)

this is info in cache db for y.cpp in zz2:

;; Object zz2/
;; SEMANTICDB Tags save file
(semanticdb-project-database-file "zz2/"
:tables (list
(semanticdb-table "y.cpp"
:major-mode 'c++-mode
:tags
'( ("y.hpp" include nil nil [1 17])
("y1" function
(:parent "y"
:arguments
( ("b" variable (:type "int") (reparse-symbol arg-sub-list) [28 34]))
:type "int")
nil [18 50]))
:file "y.cpp"
:pointmax 51
:fsize 50
:lastmodtime '(22684 34245 499621 155000)
:unmatched-syntax 'nil
)
)
:file "!home!zzhao010!emacs!test!zz2!semantic.cache"
:semantic-tag-version "2.0"
:semanticdb-version "2.2"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment