Emacs安装CEDET与JDEE

因为Emacs自23.2版本后自带了CEDET,所以再安装的时候会出现问题,只需要把原来的那个删掉就可以了。在lisp目录cedet。


下载CEDET(目前最新版本是1.7) http://sourceforge.net/projects/cedet/files/cedet/1.0pre7/cedet-1.0pre7.tar.gz/download

完后用Emacs打开cedet-build.el 按照里面的说明

;;     M-x eval-buffer
;;     M-x cedet-build-in-this-emacs

ok


安装JDEE:

下载 http://jdee.sourceforge.net/

下载elib http://sourceforge.net/projects/jdee/files/jdee/Dependencies/elib.tar.gz/download 

完后解压,把下面代码放入.emacs中:

;; Set the debug option to enable a backtrace when a  
;; problem occurs.  
;; 当有问题出现显示错误信息,便于调试  
(setq debug-on-error t)  
;; Update the Emacs load-path to include the path to  
;; the JDE and its require packages. This code assumes  
;; that you have installed the packages in the emacs/site  
;; subdirectory of your home directory.  
;; 加载所需的package  
(add-to-list 'load-path (expand-file-name "~/.emacs.d/javaIDE/jdee-2.4.0.1/lisp"))  
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/cedet-1.0pre7/semantic"))  
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/cedet-1.0pre7/speedbar"))  
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/cedet-1.0pre7/eieio"))  
(add-to-list 'load-path (expand-file-name "~/.emacs.d/javaIDE/elib-1.0"))  
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/cedet-1.0pre7/common"))  
;; If you want Emacs to defer loading the JDE until you open a  
;; Java file, edit the following line  
;; 不自动加载jde-mode  
(setq defer-loading-jde t)  
;; to read:  
;;  (setq defer-loading-jde t)  
;; 编辑.java文件时加载jde  
(if defer-loading-jde  
    (progn  
      (autoload 'jde-mode "jde" "JDE mode." t)  
      (setq auto-mode-alist  
            (append  
             '(("\\.java\\'" . jde-mode))  
             auto-mode-alist)))  
;; 设置局部快捷键
  (define-key jde-mode-map (kbd "C-c C-v g m") 'jde-gen-main-method)
  (define-key jde-mode-map (kbd "C-c C-v g p") 'jde-gen-println)
  (define-key jde-mode-map (kbd "C-c C-v g C") 'jde-gen-class)
  (define-key jde-mode-map (kbd "C-c C-v g c") 'jde-gen-inner-class)
  (define-key jde-mode-map (kbd "C-c C-v g a l") 'jde-gen-action-listener)
  (define-key jde-mode-map (kbd "C-c C-v g m l") 'jde-gen-mouse-listener)
  (define-key jde-mode-map (kbd "C-c C-v g w l") 'jde-gen-window-listener)
  (require 'jde))

其中cedet elib换成自己的目录,打开一个java文件便可看到菜单中多了jde和jdb菜单,但此时不能用,还需要配置jdk:

1. M-x customize-variable 回车 输入 jde-jdk-registry

2. 点击INS(其实是insert缩写)version中写上jdk版本,path中写上路径(如果你的电脑上安装有多个jdk,可以继续INS添加,再进行3,否则直接save for future 退出就可以)

3. M-x customize-variable 回车jde-jdk回车在里面选择默认版本。

4. M-x customize-variables 回车 jde-enable-abbrev-mode toggle打开缩写模式

   C-h v jde-mode-abbreviations查看默认下的缩写(例如ab->abstract 在java文件中输入ab 空格即可看到扩展成abstract)

   M-x customize-variables 回车 jde-mode-abbreviations 可以自定义缩写

5. 变量补全,例如有个变量 abcefg,输入abc M-/即可立即扩展成abcefg

6. C-c C-v z 菜单JDE->Code Generation->import中查看更多的功能

7. M-x customize-variables 回车 jde-help-browse-jdk-doc 在URL中添加JDK帮助文档的index.html在本机中的位置(需要自己下载)

   然后快捷键C-c C-v C-n在浏览器中打开。(jde-browse-jdk-doc)

8. 可以自定义控制结构的缩写。参考http://jdee.sourceforge.net/jdedoc/html/jde-ug/jde-ug.html         Adding Your Own Control Flow Templates

9. C-c C-v C-. 弹出补全菜单 C-c C-v . 直接补全

10. M-x customize-variables RETURN jde-gen-code-template查看所有生成代码模板的函数名.
    可以自定义快捷键:
  (define-key jde-mode-map (kbd "C-c C-v g m") 'jde-gen-main-method)
  (define-key jde-mode-map (kbd "C-c C-v g p") 'jde-gen-println)
  (define-key jde-mode-map (kbd "C-c C-v g C") 'jde-gen-class)
  (define-key jde-mode-map (kbd "C-c C-v g c") 'jde-gen-inner-class)
  (define-key jde-mode-map (kbd "C-c C-v g a l") 'jde-gen-action-listener)
  (define-key jde-mode-map (kbd "C-c C-v g m l") 'jde-gen-mouse-listener)
  (define-key jde-mode-map (kbd "C-c C-v g w l") 'jde-gen-window-listener)




参考:

http://www.ibm.com/developerworks/cn/java/joy-emacs/

http://jdee.sourceforge.net/jdedoc/html/jde-ug/jde-ug.html

你可能感兴趣的:(jdk,Path,include,emacs,lisp,autoload)