ITPub博客

首页 > 应用开发 > IT综合 > ErLang环境搭建

ErLang环境搭建

原创 IT综合 作者:livedba 时间:2011-07-07 09:10:56 0 删除 编辑

http://pro-cyber.iteye.com/blog/550814

[@more@]

最近系统的在学习Erlang,需要在Windows下配置一个开发环境,中间遇到了些小问题,现简单将过程总结下,红色说明部分为注意事项:-)

1,下载相应的软件。

Erlang R1303: 点击下载
Distel-4.03: 点击下载
Emacs 22.3 : 点击下载


2,安装Erlang,解压Emacs、Disttel到相关目录,下面是我的本机的安装目录。


Erlang的安装路径:D:deverl5.7.4

说明:Erlang的安装路径不要包含空格,如C:Program Fileserl5.6.3这样的路径,因为Program Files之间的空格存在,是不被Distel认知的,如果要用Program Files,可以使用短文件名C:/progra~1/


Erlang工程目录:D:projecterlang

说明:这个目录需要你自己建立


Distel的解压路径:D:deverl5.7.4libdistel-4.03

Emacs的解压路径:D:devemacs-22.3


3,配置环境变量。


a)为Erlang添加一个变量

右击我的电脑-》高级-》环境变量-》系统变量-》新建:

Java代码
  1. 变量名:ERL_HOME
  2. 变量值:D:deverl5.7.4
变量名:ERL_HOME  
变量值:D:deverl5.7.4  


添加完成后,点击PATH,编辑PATH的变量值,在PATH里面添加

Java代码
  1. %ERL_HOME%bin;
 %ERL_HOME%bin; 


b) 同样,添加一个"工程目录"的环境变量:

Java代码
  1. 变量名:HOME
  2. 变量值:D:projecterlang
变量名:HOME 
变量值:D:projecterlang   


说明:变量名字必须为HOME

4,在你的之前设定的“工程目录”(本例为Erlang工程目录:D:projecterlang)下,新建一个名字为“.emacs”的文件(无后缀名),内容为:

Java代码
  1. ;; This is needed for Erlang mode setup
  2. (setq erlang-root-dir "D:/dev/erl5.7.4/")
  3. (setq load-path (cons "D:/dev/erl5.7.4/lib/tools-2.6.5/emacs" load-path))
  4. (setq exec-path (cons "D:/dev/erl5.7.4/bin" exec-path))
  5. (require 'erlang-start)
  6. ;; This is needed for Distel setup
  7. (let ((distel-dir "D:/dev/erl5.7.4/lib/distel-4.03/elisp"))
  8. (unless (member distel-dir load-path)
  9. ;; Add distel-dir to the end of load-path
  10. (setq load-path (append load-path (list distel-dir)))))
  11. (require 'distel)
  12. (distel-setup)
  13. ;; Some Erlang customizations
  14. (add-hook 'erlang-mode-hook
  15. (lambda ()
  16. ;; when starting an Erlang shell in Emacs, default in the node name
  17. (setq inferior-erlang-machine-options '("-sname" "emacs"))
  18. ;; add Erlang functions to an imenu menu
  19. (imenu-add-to-menubar "imenu")))
  20. ;; A number of the erlang-extended-mode key bindings are useful in the shell too
  21. (defconst distel-shell-keys
  22. '(("C-M-i" erl-complete)
  23. ("M-?" erl-complete)
  24. ("M-." erl-find-source-under-point)
  25. ("M-," erl-find-source-unwind)
  26. ("M-*" erl-find-source-unwind)
  27. )
  28. "Additional keys to bind when in Erlang shell.")
  29. (add-hook 'erlang-shell-mode-hook
  30. (lambda ()
  31. ;; add some Distel bindings to the Erlang shell
  32. (dolist (spec distel-shell-keys)
  33. (define-key erlang-shell-mode-map (car spec) (cadr spec)))))
;; This is needed for Erlang mode setup
(setq erlang-root-dir "D:/dev/erl5.7.4/")
(setq load-path (cons "D:/dev/erl5.7.4/lib/tools-2.6.5/emacs" load-path))
(setq exec-path (cons "D:/dev/erl5.7.4/bin" exec-path))
(require 'erlang-start)

;; This is needed for Distel setup
(let ((distel-dir "D:/dev/erl5.7.4/lib/distel-4.03/elisp"))
  (unless (member distel-dir load-path)
    ;; Add distel-dir to the end of load-path
    (setq load-path (append load-path (list distel-dir)))))

(require 'distel)
(distel-setup)

;; Some Erlang customizations
(add-hook 'erlang-mode-hook
	  (lambda ()
	    ;; when starting an Erlang shell in Emacs, default in the node name
	    (setq inferior-erlang-machine-options '("-sname" "emacs"))
	    ;; add Erlang functions to an imenu menu
	    (imenu-add-to-menubar "imenu")))

;; A number of the erlang-extended-mode key bindings are useful in the shell too
(defconst distel-shell-keys
  '(("C-M-i"   erl-complete)
    ("M-?"      erl-complete)	
    ("M-."      erl-find-source-under-point)
    ("M-,"      erl-find-source-unwind) 
    ("M-*"      erl-find-source-unwind) 
    )
  "Additional keys to bind when in Erlang shell.")

(add-hook 'erlang-shell-mode-hook
	  (lambda ()
	    ;; add some Distel bindings to the Erlang shell
	    (dolist (spec distel-shell-keys)
	      (define-key erlang-shell-mode-map (car spec) (cadr spec)))))


说明一:在Windows的explore里是不能直接创建.erlang文件的,如果文件名仅输入“.emacs”,会弹出错误警告,说什么“必需输入文件名”。新建方法有两个:一是在cmd命令行中输入 echo a<.emacs,在用文本编辑器编辑该文本;二是直接用editplus或者ue等文本工具直接另存为.emacs名字即可。


说明二:根据你自己实际情况,替换红色部分标注的路径。


5,同样在“工程目录”下,新建一个名字为“.erlang.cookie”,内容随意填写。


执行完以上步骤后,用emacs打开erlang的文件时,如果在菜单会出现“Erlang”的选项,如下图,表示配置成功

Menu



参考文章:http://bc.tech.coop/blog/070528.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25261409/viewspace-1052092/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-21

  • 博文量
    115
  • 访问量
    483879