1.下载erlang最新版本: http://www.erlang.org/download.html
(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
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
).
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 `
.
erlware-mode package is replacement for erlang-mode, using it as a base, but adding following new functionality:
edoc
utility;(add-to-list 'load-path "~/emacs/distel/elisp") (require 'distel) (distel-setup)
;; 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)))))
这个模式和elang的环境有很大关系,第一次要输入节点什么的。
that some of them requires running Erlang environment, and when you'll execute them first time, they will ask you for a name of the node, that will be used to get all necessary information. User can switch between nodes with theerl-choose-nodename
command(C-c C-d n
). And for checking availability of the concrete node theerl-ping
command(C-c C-d g
) could be used. The command will ask you for name of the node, and if it available, it will load to node all modules are needed to work with distel. Name of the current node is displayed in the status line.
PS:
distel还可以启动debugger,i不过我觉得没什么用,不好玩。也玩不来,算了吧。
c_c c+d l erl-process-list 打开连接node的进程结构,可以看到,够强大