概要:覺得別人寫的不夠傻瓜,於是自己整理一下。
下載地址:
Emacs:http://www.ourcomments.org/cgi-bin/emacsw32-dl-latest.pl。下載最新的latest
EmacsW32+Emacs patched。
Erlang OTP:http://www.erlang.org/download.html。下載Windows
Binary File。
Distel:http://sourceforge.net/projects/distel/。目前最新版本:distel-3.3.tar.gz。(這個地址已經停止更新)。另外一個下載地址:http://code.google.com/p/distel/
安裝:
1。首先安裝Erlang和Emacs:安裝過程和一般應用軟件差不多,這裏略過。爲避免路徑中空格帶來麻煩,Erlang的安裝路徑不要帶空格 (如D:\erl5.9.1)。 解壓縮Distel到D:/erl5.9.1/lib/distel-3.3(這個路徑隨意,便於管理,將它放到erlang的lib下面)
2。配置環境變量:ERL_HOME=D:\erl5.9.1 PATH加入%ERL_HOME%/bin ERL_WORK=D:\Erlang_work(這個路徑配置爲erlang工程的目錄)
如下表示,配置成功。
3。創建.emacs文件:.emacs在圖形界面是新建不了的。可以用剛纔安裝的Emacs,複製如下內容到emacs.txt,用Emacs打開,然後保存爲.emacs。
;; Erlang mode
(setq load-path (cons "D:/erl5.9.1/lib/tools-2.6.7/emacs" load-path))
(setq erlang-root-dir "D:/erl5.9.1")
(setq exec-path (cons "D:/erl5.9.1/bin" exec-path))
(require 'erlang-start)
;; Distel
(let ((distel-dir "D:/erl5.9.1/lib/tools-2.6.7/elisp"))
(unless (member distel-dir 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)))))
別忘記將以上路徑更換爲自己實際的路徑 。注意路徑分隔符 是正斜槓“/” 而不是反斜槓“/”。這樣emacs啓動時可以自動加載erlang
mode和distel的配置文件。
4。再在D:
/Erlang_work(環境變量HOME)建立一個名爲“.erlang.cookie”的文本文件,內容隨意,例如:
it_is_a_secret_file
這個文件是Erlang的Magic Cookie文件。由於Distel需要和運行的erlang節點進行通信,因此這一步不可少。
5。創建一個Emacs的快捷方式,放在桌面或者任務欄快速啓動,右擊快捷方式選“屬性”,將“起始位置”設爲"D:
/Erlang_work”或"%ERL_WORK% "(HOME環境變量)。這樣Emacs啓動後可以直接定位到erlang工程的目錄。
或者複製.emacs文件到系統盤符(一般是C):\Documents and Settings\你的用戶名\Application Data\ (XP)。
系統盤符(一般是C):\Users\你的用戶名\AppData\Roaming\ (Vista&7)。
6。啓動Emacs,打開一個erl文件 ,應該能看到多了一個“Erlang”菜單,菜單下有一個Distel的子菜單 (注意:如果不打開一個erl文件是看不到“Erlang”菜單的!) ,如圖:
1。編譯:Erlang->Compile->Compile-Buffer。
2。運行:如下圖:
參考資料:
1.http://blog.csdn.net/yaonai2003/article/details/6422710
2.Bill Clementson's Blog:Distel = Emacs erlang-mode++http://bc.tech.coop/blog/070528.html(內容提到在Emacs窗口中如何打開Debugger窗口)
thomesca(北蔡):http://blog.csdn.net/thomescai
(轉載請保留)