简体   繁体   中英

Erlang emacs mode - setting outdir

Does anyone know how to configure Erlang emacs mode so that compiling a buffer [Cc Ck] writes the beam file to the ebin directory rather than the current directory ?

Thanks!

You might want to have a look to this thread on the Erlang Questions Mailing List:

http://www.erlang.org/pipermail/erlang-questions/2007-August/028367.html

Moreover, you should be able to compile your file in debug mode: Cu Cc Ck

The erlang-compile command should support prefix arguments. You might want to have a look to:

http://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html

If you set up your directory structure like so:

/
/src/
/ebin/

and place your module (eg "my_file.erl") in the "/src/" directory then compile it (Cc Ck) then Emacs should automatically put the beam into the "/ebin/" directory.

However, if your module isn't in a directory named "/src/" (or if the "ebin" directory is missing) the beam will be dropped alongside the source file.

To see exactly how this works take a peek at $ERL_TOP/lib/tools/emacs/erlang.el and search for "ebin". Here's what you'll find:

(defun inferior-erlang-compile-outdir ()
  "Return the directory to compile the current buffer into."
  (let* ((buffer-dir (directory-file-name
              (file-name-directory (buffer-file-name))))
     (parent-dir (directory-file-name
              (file-name-directory buffer-dir)))
         (ebin-dir (concat (file-name-as-directory parent-dir) "ebin"))
     (buffer-dir-base-name (file-name-nondirectory 
                (expand-file-name
                 (concat (file-name-as-directory buffer-dir)
                     ".")))))
    (if (and (string= buffer-dir-base-name "src")
         (file-directory-p ebin-dir))
    (file-name-as-directory ebin-dir)
      (file-name-as-directory buffer-dir))))

Not sure when this goody was added, but it was in OTP_R13B03 and it works for me in R14B03.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM