读书人

装配erlang开发环境++emacs

发布时间: 2012-12-27 10:17:10 作者: rapoo

安装erlang开发环境++emacs

1.下载erlang最新版本:?http://www.erlang.org/download.html

?我用的是?Erlang/OTP R15B021)tar ?-xzvf ?otp_src_R15B02.tar.gz2) 按照INSTER.md中的说明一步步安装好;(检查环境,配置,编译工具....) ./configure? ? ? By default, Erlang/OTP will be installed in `/usr/local/{bin,lib/erlang}`.
? ? ?To instead install in `<BaseDir>/{bin,lib/erlang}`, use the
? ? ? `--prefix=<BaseDir>` option.3) make make install4)安装好前把老版本先干掉,装好后,记得设置PATH;5)最后在shell中用erl出现如下:装配erlang开发环境++emacs恭喜你成功了。?2.下载emacs最新版本:http://www.gnu.org/software/emacs/同理:安装好emacs吧。我安装了30分钟(要有耐心哦,太慢了)
3.work with erlang?http://alexott.net/en/writings/emacs-devenv/EmacsErlang.html?1)erlang_mode package commes with erlang distribution;?2)安装erlang_mode,只要装了完整的erlang,就会用的,只是要自己使生效,在.emacs中:
(add-to-list 'load-path ".....")(require 'erlang-start)(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))(setq erlang-root-dir "/opt/local/lib/erlang")(add-to-list 'exec-path "/opt/local/lib/erlang/bin")(setq erlang-man-root-dir "/opt/local/lib/erlang/man")
3)我们也可以定义自己的启动shell
     (defun my-erlang-mode-hook ()
        ;; 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")        ;; customize keys        (local-set-key [return] 'newline-and-indent)        );; Some Erlang customizations(add-hook 'erlang-mode-hook 'my-erlang-mode-hook)
4)erlang提供了我们一系列的命令来写代码,(导向,代码编写,和缩进..)navigation, code editing & indenting.
4.1)C-c C-j --(插入一个新的函数)erlang-generate-new-clause?to insert new clause in current point — this command takes name of function from previous clause,
接着有个吊一点的命令:建了一个相同的函数(是不是没有参数,用下C-c c-y,神奇的一下就是一样的函数了);
4.2)会区分erlang中的;与enter,这个谁用谁知道:就是打;会跳到下个分支,enter会到下一行;
4.3)c-c c-q对齐一个Function.Tab会对齐一行;对齐全buffer没有bond,要自己设置erlang-indent-current-buffer.
4.4)c-h mark 一个函数哦(这个不要用,与help有冲突。C-M-h 也是(这个准一点,推荐)方便。
4.5)C-c C-C用于注释,C-c C-u解除注释;----不要和c-x c-u搞错了,这个是撤消,不是erlang_mode的。
4.6)M-q:这个只对注释用,会让注释更+readable的
4.7)C-a M-a会跳到函数的开头,c-a M-e会到函数的结尾; C-M-a中到上一个clause,C-M-e中到下一个clause
4.8)代码补全:通用模块会gen_server,case if 什么 的会。其它要配置了。
4.9)c-c c-z打开erl c-c c-l看打下的shell发生了什么,c-c c-k打开shell并编译当前文件(这个最后不要用,自己定义行为的好)。
4.10)编译的太麻烦了,还不实用,还不如自己定义。

Compilation and work with?erl

User can execute Erlang's commands interactively using?erl?process running in the Emacs's buffer (process is running with?comint, so user can use standard commands of this package, for example, navigation through history of commands with?M-p?&?M-n?keys). This process is also used by?erlang-mode?to compile source code.

To run new?erl?process, user can use the?erlang-shell?command, but it will implicitly run when user run compilation of source code, or try to switch to?*erlang*?buffer with?erlang-shell-display?command (C-c C-z).

Compilation and loading of compiled code is performed with?erlang-compile?command (C-c C-k). If user gives prefix argument to this command, then compilation will performed with options?debug_info?&?export_all. To view compilation results, user can run?erlang-compile-display?command (C-c C-l). To move between errors, the?erlang-next-error?command (C-x `) is could be used. In this case, if you want to move to first error, you need to give prefix argument to this command, for example with?C-u C-x `.还有很多很多的mode,比如:只是行为不同,特定于一定的项目,(可以自己定义项目中的各种行为哦)

erlware-mode?package?is replacement for?erlang-mode, using it as a base, but adding following new functionality:

读书人网 >编程

热点推荐