Emacs:为每个缓冲区设置编译命令 [英] Emacs: set compilation command per-buffer
问题描述
所以,假设我有一个文件 file.c 和一个文件 anothr.c.我想分别为每个文件设置编译命令,例如:gcc -Wall -O3 -of file.c
和 gcc -Wall -std=c99 -oa 另一个.c
.如何为该缓冲区设置 gcc
命令,以便每次打开它时,它都知道如何编译它?//-*-
指令或类似的东西有什么吗?谢谢.
so, suppose I have a file file.c, and a file anothr.c. I would like to set the compilation command for each of those files separately, say: gcc -Wall -O3 -o f file.c
, and gcc -Wall -std=c99 -o a another.c
. How can I set the gcc
command for that buffer so that every time I open it, it knows how to compile it? Is there something with the // -*-
directive or something like that? Thanks.
推荐答案
是的,您可以使用文件中的指令,也可以设置其他值.在第一或第二行试试这个:
Yes, you can use the directive in the file, and also set other value. Try this in line one or two:
// -*- compile-command: "gcc -Wall -O3 -o f file.c" -*-
然后用C-x v
重新加载文件,使设置生效.
and then re-load the file with C-x v
so that the setting takes effect.
我有时会设置诸如 c-indent-level: 4;c-basic-offset: 4;
也在里面.
I sometimes set things like c-indent-level: 4; c-basic-offset: 4;
in there too.
这篇关于Emacs:为每个缓冲区设置编译命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!