4

我想在emacs中开发java。我安装了 ecb、jde 和自动完成扩展。在不启动其他人的情况下,每个人都可以很好地工作。但是当我想一起使用它们时,发生了一些问题。

  1. auto-complete-mode 不使用 jde 自动启动,我需要通过 Mx auto-complete-mode 启动它。如果没有 jde,自动完成模式将自动启动
  2. 当我在 jde 中手动启动自动完成模式时,自动完成无法正常工作。它只是自动完成出现的单词。

这是我的 .emacs 内容:

(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.
 )

版本信息是:

emacs : 24.1
auto complete : 1.3.1
ecb : 2.40
cedet : 1.1
elib : 1.0
jdee : 2.4.0.1
4

1 回答 1

1

要自动启动auto-complete-modejde-mode您需要jde-mode添加ac-modes

(push 'jde-mode ac-modes)

然后您需要将特定于 JDEE 的源添加到ac-sources. 我不确定 JDEE 与 Semantic 集成的程度,您也许可以使用它的预定义源:

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

如果没有,您可能需要使用ac-define-source. 请参阅auto-complete-config.el示例。

于 2012-07-31T03:59:11.207 回答