如何在Emacs中设置编译的默认目录? [英] How to set the default-directory of compilation in Emacs?
问题描述
makefile
,还有几个子文件夹包含 .ml
文件。如果我启动 Mx编译
和 make
在$ code> makefile ,但不支持$ code> .ml 文件的缓冲区,它给我一个错误: - * - mode:compilation; default-directory:... - * -
编译从Fri Jan 27开始18:51:35
make -k
make:***没有指定目标并没有找到makefile。停止。
编译异常退出代码2在Fri Jan 27 18:51:35
这是可以理解的,因为默认目录是不包含 makefile
的子文件夹。有没有人知道如何将 makefile
的文件夹设置为编译的默认目录?
Matthias Puech拥有一个 .dir-local 文件的
((nil。((eval)(setq default-directory
(locate-dominating-file buffer-file-name
.dir-locals.el)
)))))
大概也可以使用以下内容:(shell-command-to-stringgit rev-parse --show-toplevel)
作为最内层的位。
I am coding OCaml under Emacs, I have one makefile
in the working folder, and several sub-folders containing .ml
files. If I launch M-x compile
and make
works fine on a buffer of makefile
, but does not work on a buffer of a .ml
file, it gives me an error:
-*- mode: compilation; default-directory: "..." -*-
Compilation started at Fri Jan 27 18:51:35
make -k
make: *** No targets specified and no makefile found. Stop.
Compilation exited abnormally with code 2 at Fri Jan 27 18:51:35
It is understandable because the default-directory is sub-folder which does not contain makefile
. Does anyone know how to set the folder of makefile
always as the default-directory of compilation?
Matthias Puech has a solution involving a .dir-local
file in the project root directory:
((nil . ((eval . (setq default-directory
(locate-dominating-file buffer-file-name
".dir-locals.el")
)))))
It is presumably also possible to use something like: (shell-command-to-string "git rev-parse --show-toplevel")
as that innermost bit.
这篇关于如何在Emacs中设置编译的默认目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!