4
votes

I want to develop java in emacs. I install ecb, jde and auto-complete extensions. Each one works well without starting others. But when i want to use them together, some problem happened.

  1. auto-complete-mode doesn't auto start with jde, I need to start it by M-x auto-complete-mode. If without jde, auto-complete-mode will auto start
  2. When I manually start the auto-complete-mode in jde, the auto complete is not work well. It just auto complete the word that is appeared.

Here is my .emacs content:

(global-linum-mode 1)
(setq linum-format "%2d| ")

(setq default-tab-width 4)

(setq debug-on-error t)

;;no backup file
(setq make-backup-files nil)

(setq debug-on-error t)

;;auto complete config
(add-to-list 'load-path "D:/emacs-24.1/custom_el/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "D:/emacs-24.1/custom_el/auto-complete-1.3.1/dict")
(ac-config-default)

(setq stack-trace-on-error t)

(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/jdee-2.4.0.1/lisp"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/elib-1.0"))

(add-to-list 'load-path'  "d:/emacs-24.1/custom_el/ecb-2.40")


;; Initialize CEDET.
(load-file (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common/cedet.el"))
(load-file (expand-file-name "D:/emacs-24.1/custom_el/ecb-2.40/ecb.el"))


(require 'ecb)
(ecb-activate)
(ecb-byte-compile)


;; If you want Emacs to defer loading the JDE until you open a 
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;;  (setq defer-loading-jde t)
;;

(if defer-loading-jde
    (progn
      (autoload 'jde-mode "jde" "JDE mode." t)
      (setq auto-mode-alist
        (append
         '(("\\.java\\'" . jde-mode))
         auto-mode-alist)))
 (require 'jde))


;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
  (setq c-basic-offset 2))

(add-hook 'jde-mode-hook 'my-jde-mode-hook)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ecb-options-version "2.40")
 '(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

The version info is :

emacs : 24.1
auto complete : 1.3.1
ecb : 2.40
cedet : 1.1
elib : 1.0
jdee : 2.4.0.1
1
for example: if I input 'public' fisrt, the autocomplete do nothing, but when I input 'public' after, it can auto complete the 'public'. And the auto complete work well without jdeelinuxlsx

1 Answers

1
votes

To auto-start auto-complete-mode with jde-mode, you need to add jde-mode to ac-modes:

(push 'jde-mode ac-modes)

Then you need to add a JDEE-specific source to ac-sources. I'm not sure of the extent of JDEE integration with Semantic, you may be able to use the pre-defined source for it:

(add-hook 'jde-mode-hook (lambda () (push 'ac-source-semantic ac-sources)))

If not, you may need to define a specialized source with ac-define-source. See auto-complete-config.el for examples.