Bob Ippolito (@etrepum) on Python, Erlang, JavaScript, etc.

Distel and Erlang mode for Emacs, on Mac OS X


In the comments of my post on Erlang Mode for Emacs Tobbe pointed me at the new Distel repository for Distel. I had originally tried to install Distel last year when I began with Erlang but it didn't work. It works now! Here's the deal.

  1. Check out Distel. In my case I'm going to check it out to /Users/bob/src/distel:

    $ cd /Users/bob/src
    $ svn co distel
  2. Configure and compile Distel:

    $ ./configure
    $ make
  3. Configure Distel and configure Erlang mode, ensure that the inferior Erlang shell has an explicit node name of emacs so that Distel can connect to the. Here's my full .emacs:

    (add-to-list 'load-path  "/usr/local/lib/erlang/lib/tools-2.5.3/emacs")
          (setq erlang-root-dir "/usr/local/lib/erlang")
          (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
          (require 'erlang-start)
    (add-to-list 'load-path "/Users/bob/src/distel/elisp")
          (require 'distel)
    ;; prevent annoying hang-on-compile
    (defvar inferior-erlang-prompt-timeout t)
    ;; default node name to emacs@localhost
    (setq inferior-erlang-machine-options '("-sname" "emacs"))
    ;; tell distel to default to that node
    (setq erl-nodename-cache
            ;; Mac OS X uses "name.local" instead of "name", this should work
            ;; pretty much anywhere without having to muck with NetInfo
            ;; ... but I only tested it on Mac OS X.
            (car (split-string (shell-command-to-string "hostname"))))))
  4. Add Distel to your ~/.erlang so that it's on your Erlang code path:

    $ echo 'code:add_pathsz(["/Users/bob/src/distel/ebin"]).' >> ~/.erlang

If the Distel installation was done properly your Emacs mode line will be displayed as (Erlang EXT) next time you're editing an Erlang module. If you get a "nodedown: ..." message when executing a Distel command that means you haven't started a shell yet (C-c C-z). A good test is to stick your insertion point at a function name and hit M-. to get to its definition. M-TAB is auto-completion. I haven't used too much else from it yet.

(Now here's to hoping I don't have to learn any more elisp, ever).

blog comments powered by Disqus