Setting up Emacs 23.4, CEDET 1.1, and SemanticDB to use GNU Global on Windows

2.4k Views Asked by At

I've been trying to get my Emacs config for Java development working. It's pretty good - I've gotten malabar-mode working and have GNU Global working for tag browsing. The one thing I can't get working is getting semanticdb to use gnu global properly. None of my imports are found.

First, this is a Maven multi-module project with all sources checked out from the top-level root project folder. All other projects are below this one in the directory tree. There is a single GTAGS database in this root folder covering everything.

Things that work:

  • M-x gtags-find-tag RET symbol RET works fine, so the database is good and global can find it.
  • M-x cedet-gnu-global-version-check works and reports that my version is good.
  • M-x cedet-gnu-global-expand-filename works
  • M-x semanticdb-find-test-translate-path shows a "GNU Global Search Table" when in a Java buffer
  • I have the JDK source folder set as a system include folder, so core Java imports are parsed properly.

My java config is as follows (cedet initialization is earlier in the file):

(add-local-load-path "malabar/lisp")

(require 'malabar-mode)
(setq malabar-groovy-lib-dir (concat emacs-local-site-lisp "malabar/lib"))
(add-to-list 'auto-mode-alist '("\\.java\\'" . malabar-mode))

;; enable semanticdb support for gnu global
(when (cedet-gnu-global-version-check t)
  (semanticdb-enable-gnu-global-databases 'java-mode))

(add-hook 'java-mode-hook
    (lambda ()
    (gtags-mode 1)))

(add-hook 'java-mode-hook 'flymake-mode-on)

(defun my-java-flymake-init ()
  (list "javac" (list (flymake-init-create-temp-buffer-copy
                   'flymake-create-temp-with-folder-structure))))

(add-to-list 'flymake-allowed-file-name-masks
         '("\\.java$" my-java-flymake-init flymake-simple-cleanup))

(add-hook 'java-mode-hook
      '(lambda ()
         (semantic-add-system-include (getenv "JAVA_HOME") 'java-mode)))
1

There are 1 best solutions below

5
On

The answer is related to how your projects are set up, and if you are using EDE. EDE is Emacs Development Envornment (play on IDE) and is how CEDET tracks which files belong to your project. That limiter is related to both performance (searching less stuff) and preventing configurations from one project bleeding into another.

Unfortunately, Maven is not yet supported in CEDET/EDE. You can, however, just tag the root of your project, and I'd guess ede-cpp-root (usually used for C++ projects) might be sufficient. We should probably make a java version of that.

Anyway, EDE can be configured to use GNU Global to find files quickly (see the manual for GNU Global support with both EDE and Semantic) but your GTAGS file needs to be at the project root.

If you are in project-1, and expect to jump to files in project-2, and GTAGS is as the root of project-1, then it won't work. You'd have to move your GTAGS file and EDE project up to a common parent directory.

In your current setup, if everything is already under a common directory with GTAGS, then it is more likely you just need to setup an EDE project to hang the GTAGS file finding feature.

There are threads in the cedet-devel mailing list archive of a couple folks who have had some success in this.