Changing config files is tricky (this wouldn't work as written for me because like many many people, I keep my emacs init in ~/.emacs.d/init.el instead of ~/.emacs). Why not do something like this?
Change erlmacs to just emit the elisp when you call it with 'elisp', then add the above snippet to your emacs init (or provide this setup as a elpa package).
Pro: you won't have to remember to call `erlmacs install` again when you periodically do `asdf install erlang latest`. Con: the version of erlang that gets `(erlang-start)` called is determined by your environment / the nearest .tool-versions file when you first invoke emacs.
Pushing this idea a little further, the only information that erlmacs uses that isn't available elsewhere is the value of ErlRoot. You could write a two-line script that simply emits erlroot on stdout (or fails), and invoke that from .emacs to configure your emacs environment appropriately. As a bonus, that erlroot script would probably be useful in other situations, too.
Good point! The next version should support other config file locations. This is something of a minimum viable solution to a problem I wanted to solve for myself.
I’m definitely open to feature requests and suggestions.
This is true. I might refactor the codebase to do what you're suggesting in the future.
For now I just pushed a new v1.1.0 release that automatically detects and supports ~/.emacs.el and ~/.emacs.d/init.el in addition to ~/.emacs as configuration file locations.
That should fix this problem for most people for now although I agree that your suggestion is probably more robust overall.
Pro: you won't have to remember to call `erlmacs install` again when you periodically do `asdf install erlang latest`. Con: the version of erlang that gets `(erlang-start)` called is determined by your environment / the nearest .tool-versions file when you first invoke emacs.