首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >emacs自动完成不适用于jde

emacs自动完成不适用于jde
EN

Stack Overflow用户
提问于 2012-07-30 04:07:16
回答 1查看 1.7K关注 0票数 4

我想用emacs开发java。我安装了欧洲央行,jde和自动完成的扩展。每个人都工作得很好,而没有开始其他人。但是当我想把它们放在一起的时候,发生了一些问题。

  1. 自动完成模式不是用jde自动启动的,我需要通过M自动完成模式启动它.如果没有jde,自动完成模式将自动启动。
  2. 当我在jde中手动启动自动完成模式时,自动完成不能正常工作.它只会自动完成出现的单词。

以下是我的.emacs内容:

代码语言:javascript
复制
(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.
 )

版本信息是:

代码语言:javascript
复制
emacs : 24.1
auto complete : 1.3.1
ecb : 2.40
cedet : 1.1
elib : 1.0
jdee : 2.4.0.1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-31 03:59:11

要用jde-mode自动启动jde-mode,需要将jde-mode添加到ac-modes中。

代码语言:javascript
复制
(push 'jde-mode ac-modes)

然后,您需要向ac-sources添加特定于JDEE的源代码。我不确定JDEE与语义的集成程度,您可能可以使用预定义的源代码:

代码语言:javascript
复制
(add-hook 'jde-mode-hook (lambda () (push 'ac-source-semantic ac-sources)))

如果不是,您可能需要用ac-define-source定义一个专门的源。有关示例,请参见auto-complete-config.el

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11715296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档