[erlang-questions] Autosaving *.erl in emacs before compilation

Bill Clementson billclem@REDACTED
Wed Jun 13 18:26:33 CEST 2007

"Roberto Saccon" <rsaccon@REDACTED> writes:

> Does anybody know how to also add the distel module reloading to the compile shortcut ?
> I tried with:
> (global-set-key [f9] (lambda () (interactive) (progn (save-buffer) (erlang-compile) (erl-reload-modules))))
> but got this error message:
> Waiting for Erlang shell prompt (press C-g to abort). [2 times]
> progn: Wrong number of arguments: (lambda (node) "reload all out-of-date modules" (interactive (list (erl-target-node))) (erl-rpc (lambda (result) (message "load: %s" result)) nil node (quote
> distel) (quote reload_modules) nil)), 0

You probably want something like the following instead:

(define-key erlang-mode-map [f9]
  (lambda ()
      (erl-reload-modules (erl-target-node)))))

Two things to note:
1. The distel function erl-reload-modules expects an argument - that
   was why you were getting the error. I added erl-target-node as the
   arg so that it would reload from the target node that had been
   specified previously. This will work ok if you are compiling in the
   erlang-mode erlang shell and using that as the source buffer's node
   (which appears to be what you intended). However, if the node that
   you connected distel to is different, it may reload a different
   beam file.

2. I changed your code from using global-set-key to "define-key
   erlang-mode-map" - this will allow you to use F9 for other things
   when you're working in a non-erlang buffer.

Bill Clementson

More information about the erlang-questions mailing list