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

Roberto Saccon rsaccon@REDACTED
Thu Jun 14 21:31:33 CEST 2007


thanks, however I get an error when I use define-key erlang-mode-map
when loading emacs:

  Wrong type argument: keymap, nil

everything works fine with global-set-key or with define-key and just
reloading the ermacs preferences file.

I also added a bit of elisp for defining a project and using the
projects Emakefile for compiling



(setq erlang-project "~/path/my-default-project")

(defun set-erlang-project (erlang-project-new)
  (setq erlang-project erlang-project-new))

(defun emakefile ()
  (shell-command
    (concat
      (concat
        (concat "cd " erlang-project) "; erl -make"))))

(define-key erlang-mode-map [f13] ;; gives  error when starting emacs,
don't know why
;;(global-set-key [f13]
  (lambda ()
    (interactive)
    (progn
      (save-buffer)
      (emakefile)
      (erl-reload-modules (erl-target-node)))))



Anybody knows a better way to find the directory of the Emakefile,
e.g. stepping upwards until found (my sourcefiles are in src and
subfolders) ?  I am an absolute beginner with elisp.

regards

On 6/13/07, Bill Clementson <billclem@REDACTED> wrote:
> "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 ()
>     (interactive)
>     (progn
>       (save-buffer)
>       (erlang-compile)
>       (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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
Roberto Saccon



More information about the erlang-questions mailing list