简体   繁体   English

如何在erlang.el中覆盖次级erlang-compile-outdir

[英]How to overwrite inferior-erlang-compile-outdir in erlang.el

I'm using erlang-mode. 我正在使用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 . 光束与源文件在同一文件夹中生成,该文件位于嵌套文件夹中,而不是仅存储在文件夹src中

I think I should overwrite the inferior-erlang-compile-outdir in the erlang.el but I failed. 我想我应该在erlang.el中覆盖次级erlang-compile-outdir但是我失败了。

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. PS: get-project-path是一个获取项目根路径的函数。

===========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. 这是正确的, inferior-erlang-compile-outdir定义了编译文件的放置位置。 Though your use of let* is wrong. 虽然你使用let*是错误的。 let lets you define scoped variables, in your case you don't need it at all. let你可以定义范围变量,在你的情况下根本不需要它。 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 . 对于未来的参考,如果你想使用let看看在这里的文档

But the erlang-mode is not loaded yet when you define it. 但是当你定义它时,erlang-mode还没有被加载。 So your function gets overwritten by the original once the erlang-mode is loaded. 因此,一旦加载了erlang模式,您的函数就会被原始函数覆盖。 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")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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