Skip to content

Commit 832980d

Browse files
committed
allow setting additional args with rust-cargo-default-arguments
1 parent 07e1e0a commit 832980d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ post](https://www.badykov.com/emacs/2021/05/29/emacs-cargo-mode/).
233233
extending it with other features such as integration with LSP and with
234234
flycheck.
235235

236+
## Customization
237+
238+
`rust-cargo-default-arguments` set additional cargo args used for check,compile,run,test
236239

237240
## For package maintainers
238241

rust-cargo.el

+9-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
:type 'boolean
2020
:group 'rust-mode)
2121

22+
(defcustom rust-cargo-default-arguments ""
23+
"Default arguments when running common cargo commands."
24+
:type 'string
25+
:group 'rust-mode)
26+
2227
;;; Buffer Project
2328

2429
(defvar-local rust-buffer-project nil)
@@ -59,12 +64,12 @@
5964
(defun rust-check ()
6065
"Compile using `cargo check`"
6166
(interactive)
62-
(rust--compile "%s check" rust-cargo-bin))
67+
(rust--compile "%s check %s" rust-cargo-bin rust-cargo-default-arguments))
6368

6469
(defun rust-compile ()
6570
"Compile using `cargo build`"
6671
(interactive)
67-
(rust--compile "%s build" rust-cargo-bin))
72+
(rust--compile "%s build %s" rust-cargo-bin rust-cargo-default-arguments))
6873

6974
(defun rust-compile-release ()
7075
"Compile using `cargo build --release`"
@@ -74,7 +79,7 @@
7479
(defun rust-run ()
7580
"Run using `cargo run`"
7681
(interactive)
77-
(rust--compile "%s run" rust-cargo-bin))
82+
(rust--compile "%s run %s" rust-cargo-bin rust-cargo-default-arguments))
7883

7984
(defun rust-run-release ()
8085
"Run using `cargo run --release`"
@@ -84,7 +89,7 @@
8489
(defun rust-test ()
8590
"Test using `cargo test`"
8691
(interactive)
87-
(rust--compile "%s test" rust-cargo-bin))
92+
(rust--compile "%s test %s" rust-cargo-bin rust-cargo-default-arguments))
8893

8994
(defun rust-run-clippy ()
9095
"Run `cargo clippy'."

0 commit comments

Comments
 (0)