在emacs中使用钢筋? [英] Use rebar in emacs?
问题描述
.emacs中有一个 defun
以获取erlang项目路径,我该如何执行shell命令来执行以下操作:
There is a defun
in .emacs to get erlang project path, how can I execute a shell-command to do the following:
cd *~/erlang-project-folder*
make
我使用钢筋来构建我的项目,并且有一个Makefile来做所有的事情。
I'm using rebar to build my project, and there is a Makefile to do everything.
我可以通过覆盖 erlang-compile-function
,但我不熟悉Emacs Lisp,请帮忙。
I can compile by overriding erlang-compile-function
, but I'm not familiar with Emacs Lisp, please help.
这是我的。 emacs:
Here is my .emacs:
(defun erlang-project-dir ()
(let* ((src-path (file-name-directory (buffer-file-name)))
(pos (string-match "/src/" src-path)))
(if pos (substring src-path 0 (+ 1 pos)) src-path)))
;; there is an error: wrong type argument: commandp
(defun my-inferior-erlang-compile ()
(shell-command.
(concat (concat (concat "cd" erlang-project-dir) "; make"))))
(defvar erlang-compile-function 'my-inferior-erlang-compile)
推荐答案
而不是依赖目录结构,最好尝试找到 rebar.config $位于项目根目录的c $ c>文件。这可以通过以下代码实现:
Instead of relying on directory structure, it's better to try to locate the rebar.config
file that is in the root of your project. This could be achieved with following code:
(defun my-find-rebar-root ()
(let ((dir (locate-dominating-file default-directory "rebar.config")))
(or dir default-directory)))
之后,您可以使用此功能进行编译:
and after that you can use this function for compilation:
(defun my-inferior-erlang-compile ()
(interactive)
(let ((default-directory (my-find-rebar-root)))
(compile "make")))
虽然我不确定使
在这里是正确的命令 - 也许最好使用 rebar编译
而不是
Although, I'm not sure that the make
is right command here - maybe it's better to use rebar compile
instead?
PS我希望,我会找到一些空闲时间,并将在EDE中完成钢筋支持 - 在这种情况下,它将是与项目合作的统一界面。
P.S. I hope, that I'll find some free time, and will finish rebar support in EDE - in this case, it will be the same unified interface for work with projects.
这篇关于在emacs中使用钢筋?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!