如何从 Emacs 运行 cargo

How to run cargo from Emacs

我正在使用 Emacs 在 Rust 中编写测试。是否可以在 Emacs 本身中 运行 我的测试文件的 cargo run 命令,而不是每次构建都切换到终端?

从您的 Cargo.toml 文件(或项目根目录),运行 M-x compile 然后输入 cargo run 然后点击 RET。在同一目录中,您可以 运行 M-x recompile

您可以将以上内容绑定到短键绑定,但您可能应该调查 cargo.el

rustic mode provides an interface to a number of cargo commands. Among other things you can build, lint, and run tests at point. In the guide Configuring Emacs for Rust development我正在详细描述设置和使用。