Subject: 23.2; ede-cpp-root-projects spp table is not taken into account by semantic in cedet

From: Jonathan Marchand <[email-masked]>
Date: Thu, 20 May 2010 16:03:30 +0200

Hi,

I can't find a way to make the autocompletion fully works with semantic in
emacs 23.2 with the built-in CEDET. This happens in the debian packaged
version, the release tarball and in the last bazaar snapshot of emacs23.2.
The reason is that the include filen are not parsed with the needed #define.
I found one reason for that to happen.

When loading a file located in a ede-cpp-root-project, the spp-table
preprocesser symbols are not taken into account by semantic. By browsing the
code, I find the problem :

In file lisp/cedet/ede/cpp-root.el, in the function ede-set-project-variables 
(called when you load a file within a ede-cpp-root-project), the semantic 
spp-table needs semantic/c and semantic/lex-spp to be loaded to get the symbols
defined in the ede-cpp-root-project.

However, no file elisp file provides semantic/c (and thus it's always evaluated
as nil). In the original CVS version of CEDET, this function waits for
semantic-c, which is provided by the semantic/bovine/semantic-c.el file. In the
emacs23.2 distribution, this file is renamed semantic/bovine/c.el and provides
semantic/bovine/c. If I replace semantic/c by semantic/bovine/c, the semantic
spp-table is updated correctly (furthermore I need to eval
(require 'semantic/bovine/c) before loading the files in the project, it seems
that this file is not evaluated when calling semantic-mode).

This bug is due to a bad translation from original package to the built-in
emacs one.

Here is the files with the changes I had to made to overcome this bug :

--.emacs---
(semantic-mode 1)
(global-ede-mode 1)
(global-semantic-decoration-mode)
+ (require 'semantic/bovine/c)
(ede-cpp-root-project "tlh"
                      :name "tlh"
                      :file "/home/jonathlela/tlh/Makefile"
                      :system-include-path '( "/home/jonathlela/devkitPro/libnds/include" )
                      :spp-table '(
                                    ( "ARM9" . "1" )
                                    ( "ARM7" . "1" )
                                  )
) 

---cpp-root.el---
(defmethod ede-set-project-variables ((project ede-cpp-root-project) &optional buffer)
  "Set variables local to PROJECT in BUFFER.
Also set up the lexical preprocessor map."
  (call-next-method)
-   (when (and (featurep 'semantic/c) (featurep 'semantic/lex-spp))
+   (when (and (featurep 'semantic/bovine/c) (featurep 'semantic/lex-spp))
    (setq semantic-lex-spp-project-macro-symbol-obarray
      (semantic-lex-make-spp-table (oref project spp-table)))
    ))

Nevertheless, The include files are still not parsed with the right #define. I
don't know yet if it's a bug or a PEBCAK. Have somenone successfully use
ede-cpp-root-project with the emacs23.2 build ?

Regards,

Jonathan Marchand