简体   繁体   English

如何强制emacs的erlang-compile命令在包含目录中搜索

[英]How to force the erlang-compile command of emacs to search in the include directory

I am starting to work with emacs on some existing erlang projects. 我开始在一些现有的erlang项目上使用emacs。 I would like to use the command erlang-compile, if possible using the short cut Cc Ck , but it fails because most of my projects use some .hrl files, located in an include directory, while the commands knows only the src and ebin directories (it is the usual directory tree for erlang applications) 我想使用命令erlang-compile,如果可能的话,可以使用快捷方式Cc Ck ,但是它失败了,因为我的大多数项目都使用了一些.hrl文件,这些文件位于include目录中,而这些命令仅知道src和ebin目录(这是erlang应用程序的常用目录树)

I found a workaround by editing all the include directives and add the relative path to the include directory before each file name, but I don't like this, and it doesn't help if I want to compile using the options debug_info, export_all, native... 我找到了一种解决方法,方法是编辑所有include指令,并将相对路径添加到include目录中的每个文件名之前,但是我不喜欢这样,如果我想使用debug_info,export_all,原生...

Another workaround is to use an external command, but in this case I'll loose - I guess - the link between the compilation errors and the source code. 另一个解决方法是使用外部命令,但是在这种情况下,我会松散-我想-编译错误和源代码之间的链接。

The right way should be to pass an option list to the command (for example [{i,"../include"},debug_info] ). 正确的方法应该是将选项列表传递给命令(例如[{i,"../include"},debug_info] )。

I have tried to "eval" the command using M-: (erlang-compile XXX) but it fails (I dont know a bit of lisp syntax and anyway, it seems that erlang-compile has no arguments...) 我尝试使用M-: (erlang-compile XXX) “评估”命令,但失败(我一点也不了解lisp语法,总之,看来erlang-compile没有参数...)

I have seen this topic Use rebar in emacs? 我已经看到了这个主题在emacs中使用钢筋吗? but, as I understand the solution, it will use an external command, and it will behave like my second workaround. 但是,据我所知,该解决方案将使用一个外部命令,其行为类似于我的第二种解决方法。

is there another way or a setting to pass these arguments? 还有其他方法或设置可以传递这些参数吗?

It is not what you are looking for, but I would recommend using EDTS . 它不是您想要的,但是我建议您使用EDTS It consist quite few useful features, include directories can set up in .edts config file, and it tries to compile your code with each file save. 它包含很少的有用功能,包括可以在.edts配置文件中设置的目录,并且它会尝试在保存每个文件时编译您的代码。

And just an idea. 只是一个想法。 I would try using Emakefile interface. 我会尝试使用Emakefile接口。 It seems standard enough and emacs/erlang integration could be using it. 似乎已经足够标准了,emacs / erlang集成可能正在使用它。

You can set include paths in the erlang-compile-extra-opts variable. 您可以在erlang-compile-extra-opts变量中设置包含路径。 For example: 例如:

(setq erlang-compile-extra-opts '((i . "../include") debug_info))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM