When using emacs for writing erlang source code, I have made the following configuration.
In the emacs, 6 windows are open at the same time, 4 windows for source code writing, 1 windows for terminal shell, 1 windows for erlang shell.
After one source code modification, I have use command "m-x ter” to switch “terminal shell”, then using “m-p” for recovering last history command, then pressing “enter” to run.
Then using “c-x, left ” to switch to erlang shell, then press m-p to repeat last command.
The above two switch process seems a little long, could you have better solution?
The
compilefunction is the general mechanism for such things, and thecompile-commandvariable tells it what to do (as a shell command to run).By default, the command is
make, so if you have a Makefile, you’re already sorted.If not, and writing one isn’t appropriate, then you can customise
compile-commandfor your files, perhaps using local variables.File-local variables for this purpose are covered in the linked Q&A.
You can also use Directory-local variables if you want it to automatically apply to all files under a given directory.
Or if there’s a general pattern which can be applied to all erlang files, everywhere, then you might set up
compile-commandusing the erlang mode hook.Finally, you can just supply the command on demand. Called interactively, M-x
compileprompts you for the command to run, and uses the previous command as the default for the next time.