More Erlang+Emacs

I have found that Distel's built-in shell launcher wasn't cutting mustard as I needed to start shells with various flags and didn't see an easy way to accomplish this using what Distel provided. Digging around the Erlang mailing list, I found an elisp function that allowed me to pass flags to the shell. Place this snippet in your .emacs file after you've required erlang and distel:

    (defun erl-shell-with-flags (flags)
      "Start an erlang shell with flags"
      (interactive (list (read-string "Flags: ")))
      (set 'inferior-erlang-machine-options (split-string flags))

    ;; map Ctrl-c Ctrl-z to the new function
    (global-set-key "\C-c\C-z" 'erl-shell-with-flags)

Now when you start the erlang shell, a "Flags: " prompt will be presented. Simply add flags as you would on the command line and the shell will start up. Great for when you need multiple shells with different snames, names, cookies, etc…