edts icon indicating copy to clipboard operation
edts copied to clipboard

Command to compile current module in edts-shell

Open fleimgruber opened this issue 8 years ago • 8 comments

From reading the docs and looking at functions / keybindings, I can only see edts-code-compile-and-display and using that the module of current buffer is not recompiled in the edts-shell. What am I missing?

fleimgruber avatar Sep 10 '17 13:09 fleimgruber

Hi!

Yes, edts-code-compile-and-display is the command to use. To see more details about what's going on, you can hit M-x edts-log-set-level RET debug RET to turn on debug logging before running the command

tjarvstrand avatar Sep 11 '17 12:09 tjarvstrand

Thanks for checking back. With debug log level I am getting

EDTS [debug]: Compiling proj async on dev_proj
EDTS [debug]: Sending async call to http://0:4587/compile_and_load
EDTS [debug]: Reply 200 received for request to http://0:4587/compile_and_load
EDTS [debug]: fetching xref-analysis of (proj) async on dev_proj
EDTS [debug]: Plugin call edts_xref:analyze on dev_proj
EDTS [debug]: Sending async call to http://0:4587/plugins/edts_xref/analyze
EDTS [debug]: running eunit tests in proj async on dev_proj
EDTS [debug]: Sending async call to http://0:4587/run_eunit
EDTS [debug]: Reply 200 received for request to http://0:4587/run_eunit
EDTS [debug]: Reply 200 received for request to http://0:4587/plugins/edts_xref/analyze

which looks fine. But the shell still references the old compilation. A manual c(proj) in the shell works though.

fleimgruber avatar Sep 11 '17 23:09 fleimgruber

That's odd. Have you managed to solve this issue? How does the code path look on the project node? Could it be that you have another version of the module compiled somewhere else on the code path?

tjarvstrand avatar Sep 25 '17 08:09 tjarvstrand

I am new to Erlang, so just to be sure: You mean whether there is a .beam file in one of the dirs in code:get_path()?

The only .beam I can find is next to the .erl file and its "Modified" property changes after an edts-code-compile-and-display, but it does not reflect the changes made before recompilation. Even if I remove the .beam file manually and recompile the old version gets used.

fleimgruber avatar Sep 26 '17 20:09 fleimgruber

Yeah, exactly. I've never heard of anything similar.

Could you supply a somewhat minimal code example and steps to reproduce?

tjarvstrand avatar Sep 27 '17 13:09 tjarvstrand

Emacs 25.2.1 EDTS 20170821.149 Erlang/OTP 20

mkdir hello
cd hello
echo '-module(hello).\n-export([start/0]).\n\nstart() ->\n    io:format("Hello World!~n").' > hello.erl

With point in the hello.erl buffer, start edts-shell, output:

Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V9.0  (abort with C-q C-g RET)
(edts-0@nirvana)1> 
=INFO REPORT==== 28-Sep-2017::15:19:31 ===
Found previous state to start from in "/Users/user/.emacs.d/edts/10024278_edts-0.xref".

again in hello.erl, edts-code-compile-and-display. Then in *edts[0]*

(edts-0@nirvana)1> hello:start().
Hello World!
ok

Then edit the string in hello.erl e.g. to "Hello World!!!~n", edts-code-compile-and-display again and in *edts[0]*

(edts-0@nirvana)2> hello:start().
Hello World!
ok

where Hello World!!! was expected.

The log of the second recompilation

EDTS [debug]: Compiling hello async on hello
EDTS [debug]: Sending async call to http://0:4587/compile_and_load
EDTS [debug]: Reply 200 received for request to http://0:4587/compile_and_load
EDTS [debug]: fetching xref-analysis of (hello) async on hello
EDTS [debug]: Plugin call edts_xref:analyze on hello
EDTS [debug]: Sending async call to http://0:4587/plugins/edts_xref/analyze
EDTS [debug]: running eunit tests in hello async on hello
EDTS [debug]: Sending async call to http://0:4587/run_eunit
EDTS [debug]: Reply 200 received for request to http://0:4587/run_eunit
EDTS [debug]: Reply 200 received for request to http://0:4587/plugins/edts_xref/analyze

A manual c(hello) from the shell recompiles correctly.

fleimgruber avatar Sep 28 '17 13:09 fleimgruber

Hi again,

If EDTS is enabled you should also have a erlang shell in a buffer called *hello* which is created as soon as you open the first source file in the project. Have you tried if the changes are loaded into that shell?

edts-shell doesn't really have that many bells and whistles. It just fires up an erlang shell with the correct code path set.

Actually, I'm fairly convinced this is your problem. The hint is that the log says Compiling hello async on hello whereas the name of the node that you're using is called edts-0

tjarvstrand avatar Oct 05 '17 06:10 tjarvstrand

yep, you got it. Changes are loaded into that shell alright. Now then when doing an edts-shell it could check whether a node already exists for that project and switch to it (and with prefix arg open a new one regardless). Just an idea. Feel free to close if this is not to be a default or you don't care.

fleimgruber avatar Oct 10 '17 18:10 fleimgruber