如何获取emacs以更改编译命令在每个缓冲区? [英] How do I get emacs to change the compilation command on a per-buffer basis?

查看:154
本文介绍了如何获取emacs以更改编译命令在每个缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个代码文件,一个是小测试脚本,另一个是我的主要代码(都是c ++代码文件)。我想要emacs为它们中的每一个使用不同的编译命令(例如make test_script为一个和make release为另一个)。

Suppose I have two code files, one is a small test script, the other is my main piece of code (both are c++ code files). I would like emacs to use different compilation commands for each of them (for example "make test_script" for one and "make release" for the other). What's the best way to do this?

推荐答案

可以使用编译命令局部变量到缓冲区。例如,在一个C ++源代码中:

You can use the compile-command local variable to the buffer. For instance, in one C++ source code:

// Local Variables:
// compile-command: "make release"
// End:

,您可以在其他源代码中更改使用其他编译方式。要触发编译,可以使用 Mx compile RET 。

and you can change that in the other source code to use the other means of compilation. To trigger that compilation, you can use M-xcompileRET.

根据您的问题, t 编译要求您,您可以添加以下内容:

As per your question, if you don't want compile to ask you, you can add the following:

// Local Variables:
// compilation-read-command: nil
// compile-command: "make release"
// End:

但是,当您加载该变量有风险的文件时,将会警告您。你可以接受它,但请注意,这意味着这可能导致任意命令运行时错误,当你只是编译加载文件的未知来源(即,如果你得到一个文件在某处有这些命令,你只是接受他们,当你编译文件将执行你自己的任何程序,而不先询问你。)

However, you will be warned when you load the file that this variable is risky. You can accept it, but note that this means that this can cause arbitrary commands to be run by error when you just compile with a loaded file of unknown source (that is, if you get a file somewhere that have these commands and you just accept them, when you compile the file will execute any program of your own without asking you first.)

这篇关于如何获取emacs以更改编译命令在每个缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆