how to compile erlang project with emacs - emacs

I had checked the doc of erlang-mode.
it's seem that C-c C-k, (erlang-compile) - Compiles the Erlang module in the current buffer.
just compile one file of current buffer. I wanna compile a project with rebar commond on emacs. eg. ./rebar compile
and it can display result like execute "erl -sname -pa ebin -pa deps/*/ebin".
how to do this on emacs?

Doing this the "right" way involves inferior emacs shells and such, and isn't trivial. But you can mostly get the desired effect with these two steps:
At the top level of your project directory, which you can get to by visiting your rebar.config file, execute M-x compile and after hitting enter, change the compile command to rebar get-deps compile, then hit enter to run it.
Assuming the compilation in the first step succeeds, execute C-u M-x erlang-shell and hit enter. It will prompt you for the shell arguments, which should be
erl -pa deps/*/ebin -pa ebin
Hit enter and you'll get an erlang shell prompt, with its erlang load path properly set up for your project.

Related

How to run cargo from Emacs

I'm writing tests in Rust with Emacs. Is it possible to run the cargo run command of my test file in Emacs itself, rather than switching to the terminal for every build?
From your Cargo.toml file (or the project root directory), run M-x compile and then enter cargo run and then hit RET. From that same directory you can run M-x recompile.
You could bind the above to short key bindings, but you should probably investigate cargo.el.
rustic mode provides an interface to a number of cargo commands. Among other things you can build, lint, and run tests at point. In the guide Configuring Emacs for Rust development I'm describing setup and usage in detail.

emacs compile-command find makefile in superior directory

This seems like such an obvious hack I hate to write it myself, but I've had no luck finding it.
I would like an approach to M-x compile that will search upward in the directory tree from cwd to the first directory with a Makefile, after which it runs the make command. So, it's basically
if ./Makefile exists, run the make command
otherwise, cd .. and try again
Stop at $HOME.
The following code defines compile-parent, which locates the nearest Makefile and creates a make command to use that Makefile. It behaves like compile in that it still prompts, showing you the command that it will use, and giving you a chance to edit it, e.g. by specifying a specific target.
(defun compile-parent (command)
(interactive
(let* ((make-directory (locate-dominating-file (buffer-file-name)
"Makefile"))
(command (concat "make -k -C "
(shell-quote-argument make-directory))))
(list (compilation-read-command command))))
(compile command))
You may also want to look at the Projectile extension, which provides a minor mode to detect projects by the presence of VCS metadata or specific build files, with several commands to work from the project root directory, including a projectile-compile command, that runs M-x compile from the project root.

How can I reload and re-enter a modified Racket file in Geiser?

I'm using Geiser in Emacs on Windows as a Racket programming environment. I'm working on the file "d:/code/racket/foo.rkt". "d:/code/racket/foo.rkt" is a module (it starts with #lang racket).
I can use ,enter "d:/code/racket/foo.rkt" at the Racket REPL to enter the module, and having done so I can successfully execute functions from the file.
However, if I change the file and re-run ,enter "d:/code/racket/foo.rkt", the file is not re-loaded: changes to functions in my file are not reflected when I re-execute them in the REPL.
I have tried re-compiling my buffer with C-c C-k before re-running ,enter, but this makes no difference.
I've also tried executing ,enter #f to exit the foo.rkt module, then re-running ,enter "d:/code/racket/foo.rkt"; this still doesn't reload the module.
I've also observed that running (enter! (file "d:/code/racket/foo.rkt")) instead of ,enter "d:/code/racket/foo.rkt" does reload the file.
Is this a known limitation of Geiser's ,enter form, or am I missing a trick?
(Versions are: Geiser 0.5, Emacs 24.3.1, Racket 6.0, Windows 8)

How do I eval the code when run its test in elisp with Emacs?

I'm writing some small puzzles to learn Emacs Lisp.
However, my current workflow is way too tedious :
change the code
eval-region or eval-buffer code
change the test
eval-region or eval-buffer test code
M-x ert, then press enter to run tests
How do I setup Emacs or the tests, so I can just "run the test" and Emacs will eval all codes for me ?
You probably should not run your tests within your Emacs session anyway. Rather, run the tests in a fresh Emacs session:
$ emacs -Q -b -l my-source-file.el -l my-test-file.el -f ert-run-tests-batch-and-exit
You can run this from M-x compile.

How to adjust the path that Emacs' compile-goto-error gets from the compilation buffer?

I am using Emacs 23 and have the following problem:
I run our project's build system from within Emacs like M-x compile -> cd /foo/bar && ./build
The build system now does some magic, "cd"s into some subdirectory for the build process and then gcc throws an error:
../src/somesource.cc:50 error: blablabla
Now the problem is that Emacs won't find that path, because it assumes the compile process started out in /foo/bar, and not in /foo/bar/builddir. So the leading "../" is not working for Emacs, e.g. when running compile-goto-error. Is there a way to tell Emacs to try skipping leading "../"?
The best solution might be to change the build system to emit messages when it changes directories. Emacs looks for
Entering directory `...'
...
Leaving directory `...'
(See the compilation-directory-matcher variable. If your build system does emit messages when it changes directories, but they're not in the format Emacs is looking for, you can add new regexps to compilation-directory-matcher.)
The other solution is to change compilation-search-path (which is a list of directories).
On a few occasions I solved by passing output of the make through sed.
First, debugged it interactively 'Compile command: make | sed 's/x/y/' . And then repackaged it as a custom emacs interactive function.