简体   繁体   中英

How to overwrite inferior-erlang-compile-outdir in erlang.el

I'm using erlang-mode. The beam is generated in the same folder with the source file which is in nested folders instead of just in folder src .

I think I should overwrite the inferior-erlang-compile-outdir in the erlang.el but I failed.

Following is my function:

(defun inferior-erlang-compile-outdir ()
  (let* (format "%s/ebin" (get-project-path))))

PS: get-project-path is a function to get the root path of my project.

===========update=================

(require-package 'erlang)

;; add include directory to default compile path.
(defvar erlang-compile-extra-opts
  '(bin_opt_info 
    debug_info
    (i . "../include")
    (i . "../../include")))

;; define where put beam files.
(defun inferior-erlang-compile-outdir ()
  (concat (get-closest-pathname) "/ebin" ))

(require 'erlang-start)


;;----------------------------------------------------------------------------
;; Get closest pathname of file
;;----------------------------------------------------------------------------
(defun* get-closest-pathname (&optional (file "Makefile"))
  (let ((dir (locate-dominating-file default-directory file)))
    (or dir default-directory)))

That is correct, inferior-erlang-compile-outdir defines where to place compiled files. Though your use of let* is wrong. let lets you define scoped variables, in your case you don't need it at all. Just concat the two strings:

(defun inferior-erlang-compile-outdir ()
    (concat (get-project-path) "/ebin" ))

For future reference if you want to use let take a look at the doc here .

But the erlang-mode is not loaded yet when you define it. So your function gets overwritten by the original once the erlang-mode is loaded. You have to define it afterwards . This should do it:

(eval-after-load "erlang"
  '(defun inferior-erlang-compile-outdir ()
     (concat (expand-file-name (get-closest-pathname)) "ebin")))

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