2013-07-17 14 views
1

我正在使用erlang模式。該光束與源文件在嵌套文件夾中生成在同一個文件夾中,而不是僅在文件夾src中生成。如何覆蓋erlang.el中的erlang-compile-outdir

我想我應該覆蓋erlang.el中的erlang-compile-outdir,但是我失敗了。

以下是我的函數:

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

PS:獲得項目路徑是讓我的項目的根路徑的功能。

===========更新=================

(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))) 
+0

你能指定「不起作用」?您的更新代碼片段完全按照我的理解您希望它執行的操作。編譯文件時,你的erlang shell輸出了什麼? – ahilsend

+0

與源文件相同的目錄。 'c(「/ Users/suyejun/project/code/src/lib/lib_dungeon_rush」,[{outdir,「/ Users/suyejun/project/code/src/lib /」),bin_opt_info,debug_info,{i,「。 ./include「},{i,」../../ include「}])。' – goofansu

+0

我希望你的項目根目錄下有一個Makefile文件?還有什麼是「(require-package'erlang)」? – ahilsend

回答

3

這是正確的,inferior-erlang-compile-outdir定義在哪裏放置編譯文件。 雖然您使用let*是錯誤的。 let可以讓你定義範圍變量,在你的情況下你根本不需要它。如果你想使用let看一看的doc here

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

以供將來參考:只要Concat的兩個字符串。

但是在定義erlang模式時尚未加載。所以一旦erlang模式被加載,你的函數就會被原始的函數覆蓋。您必須事先定義它。這應該做到這一點:

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

這就是要點,非常感謝你。 – goofansu

+0

對不起,我弄錯了一些東西。它不起作用。請參閱我的更新。 – goofansu