Erlang man pages in Emacs

Well it’s actually as simple as running M-x man RET module_name RET in minibuffer.

I’m using Erlang setup from rpm on FC7 and by default man pages are located under /usr/lib/erlang/man/ so to use above command in minibuffer you must make sure you have your erlang’s man path either in /etc/man.config or you’ve added it into MANPATH with something like export MANPATH=$MANPATH:/usr/lib/erlang/man in your .bash_profile in case your Erlang man pages are not in location accessible by default.

You may also pass man path in minibuffer manually without changing /etc/man.config or MANPATH. In my case to view man page for ‘lists’ module it will look like:

M-x man RET -M /usr/lib/erlang/man lists RET

I’ve customized some stuff for myself in emacs and made binding to F6 key so that whenever i set cursor on module name in my erlang buffer and press F6 i get man page in another window poped up describing module at point. So if you have in your code or in any buffer, for example:

(em@localhost)2> lists:reverse([1, 2, 3]).

you need to move cursor to lists and press F6. Quite handy if you consult man pages often, which is the case for me now as i learn Erlang.

Here is the corresponding elisp helper function and key binding from my dot emacs:

(defun get-erl-man ()
  (interactive)
  (let* ((man-path “/usr/lib/erlang/man”)
         (man-args (format “-M %s %s” man-path (current-word))))
    (man man-args)))

(global-set-key [(f6)] (lambda () (interactive) (get-erl-man)))

Leave a Reply