Next: Non-semantic files, Previous: General hints, Up: Setting up Emacs [Contents][Index]

#### 1.2.2 Setting up CEDET/semantic

To ensure ECB and semantic are working correctly for all by semantic supported languages you have to pay attention to the following aspects concerning your Emacs-setup:

1. Setting up CEDET/semantic itself

   This section implies that you either use Emacs >= 23.2 or that you have already successfully installed the CEDET-suite.

   For all semantic-supported file-types parsing files is done completely by semantic. ECB just displays the parsing results.

   - Users of Emacs >= 23.2: You just have to enable semantic by activating the semantic-mode. This can be done by adding code to your initialization-file (e.g. .emacs) like this:

         (semantic-mode 1)

     This should be placed BEFORE the statements which activate ECB.

     As an alternative you can use the `ecb-before-activate-hook` like follows:

         (add-hook 'ecb-before-activate-hook
                   (lambda () (semantic-mode 1)))

     This is a smarter way when you need semantic only if ECB is active.

   - Users of XEmacs or Emacs < 23.2: You should read carefully the file `INSTALL` shipped with the cedet-suite. In addition the CEDET-website offers a link to a “Gentle introduction to Cedet”. It’s worth to read it! You find it here: http://xtalk.msk.su/~ott/en/writings/emacs-devenv/EmacsCedet.html If CEDET is not correctly installed then ECB can not setup semantic for its needs.

   Minimum setup recommendation: It is very useful to enable the `global-semantic-idle-scheduler-mode` and `global-semanticdb-minor-mode`. Read the manual of Emacs 23.2 or the manual of cedet/semantic how to do this. With CEDET-versions >= 1.0pre6 this can be done by adding `semantic-load-enable-minimum-features` to your startup-file. Please read also the subsection “Jumping to the definition of external types” in ECB Methods-window.

2. Checking your hooks (Only for XEmacs and Emacs < 23.2!)

   If you use Emacs > 23.2 you can ignore the following paragraphs.

   If you have already checked point (1.) and if you have still problems getting ECB/semantic working properly for your sources you should check the related major-mode hook. Every major-mode X has a hook with name “X-hook” which is evaluated after activating the major-mode (see above, 2.), e.g. the hook for the major-mode `c++-mode` is `c++-mode-hook`.

   Semantic adds automatically during load-time a special “semantic-setup” to these major-mode hooks6 in form of a “setup-function”. Example: For c and c++ modes semantic adds `semantic-default-c-setup` to `c-mode-hook` and `c++-mode-hook`.

   If your own Emacs-setup (e.g. in `.emacs` or `site-lisp/site-start.el`) overwrites such a major-mode-hook then semantic can not be activated for this major-mode and in consequence ECB can not work properly too!

   Check if your Emacs-setup uses somewhere `setq` for adding code to a major-mode-hook. IMPORTANT: Use `add-hook` instead of `setq` 7!

If your source-files are “running” with correct `major-mode` and - in case of XEmacs or Emacs < 23.2 - correct major-mode hooks ECB and semantic will do what you expect them doing!

#### Footnotes

### (6)

Of course only for major-modes supported by semantic!

### (7)

`setq` replaces/overwrites the current value of a hook with the new value whereas `add-hook` adds the new value to the old-value of the hook!

Next: Non-semantic files, Previous: General hints, Up: Setting up Emacs [Contents][Index]