我正在Emacs下对OCaml进行编码,在工作文件夹中有一个makefile
,还有几个包含.ml
文件的子文件夹。如果我启动M-x compile
,并且make
在makefile
的缓冲区上可以正常工作,但在.ml
文件的缓冲区上不起作用,则会给我一个错误:
-*- 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
这是可以理解的,因为默认目录是不包含
makefile
的子文件夹。有谁知道如何将makefile
文件夹始终设置为编译的默认目录?
最佳答案
Matthias Puech在项目根目录中有一个solution文件,其中包含一个.dir-local
文件:
((nil . ((eval . (setq default-directory
(locate-dominating-file buffer-file-name
".dir-locals.el")
)))))
大概也可以使用类似的内容:
(shell-command-to-string "git rev-parse --show-toplevel")
作为最里面的位。
关于emacs - 如何在Emacs中设置编译的默认目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9037833/