Erlmacs - Simple script to update your .emacs file for Erlang development

https://github.com/dlachausse/erlmacs

erlmacs automatically configures and updates your .emacs file with support for the emacs mode that is included with Erlang/OTP. It frees you from having to locate the installation directory of Erlang/OTP and its bundled emacs mode.

It is an escript that only depends upon Erlang/OTP and Emacs.

Note: There is not much in the way of error checking at this moment, but it does make a backup of your .emacs files before any destructive operations.

EDIT: I just made an updated v1.1.0 release with the following new feature:

erlmacs now automatically detects and supports ~/.emacs.el and ~/.emacs.d/init.el in addition to ~/.emacs as configuration file locations.

It also can be done entirely in elisp:

(use-package erlang
  :mode
  (("\\.\\([ehxy]rl\\|app\\.src\\|escript\\)\\'" . erlang-mode)
   ("/ebin/.+\\.app" . erlang-mode))
  :hook ((erlang-mode . my-erlang-mode-init)
         (shell-mode . erlstack-mode))
  :init
  (setq erlang-root-dir (getenv "_KERL_ACTIVE_DIR"))
  (setq erlang-kerl-name (file-name-nondirectory erlang-root-dir))
  (setq erlstack-otp-src-path (concat "~/.kerl/builds/" erlang-kerl-name "/otp_src_git"))
  (add-to-list 'load-path (concat erlang-root-dir "/lib/tools-3.5.3/emacs"))
  :config
  (require 'erlstack-mode))

@rfk23 I considered trying to do this in elisp, but ultimately opted for the escript approach so that I could get the paths from Erlang itself at runtime. There are version numbers that change over time in the path to the tools directory for example.

Also it seems that your approach depends upon installing Erlang with KERL and would not work if you install it with a different method unless you set the necessary environment variable by hand, which somewhat defeats the purpose of a script like this.

Erlmacs also has functionality to update your .emacs configuration when you update to new versions of Erlang and remove the erlmacs configuration file from your .emacs automatically if you decide you no longer want it.