简体   繁体   中英

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. 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)

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...

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 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...)

I have seen this topic Use rebar in 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 . 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.

And just an idea. I would try using Emakefile interface. It seems standard enough and emacs/erlang integration could be using it.

You can set include paths in the erlang-compile-extra-opts variable. For example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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