Skip to content

Commit

Permalink
allow setting additional args with rust-cargo-default-arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
brotzeit committed Feb 3, 2022
1 parent 07e1e0a commit 832980d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ post](https://www.badykov.com/emacs/2021/05/29/emacs-cargo-mode/).
extending it with other features such as integration with LSP and with
flycheck.

## Customization

`rust-cargo-default-arguments` set additional cargo args used for check,compile,run,test

## For package maintainers

Expand Down
13 changes: 9 additions & 4 deletions rust-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
:type 'boolean
:group 'rust-mode)

(defcustom rust-cargo-default-arguments ""
"Default arguments when running common cargo commands."
:type 'string
:group 'rust-mode)

;;; Buffer Project

(defvar-local rust-buffer-project nil)
Expand Down Expand Up @@ -59,12 +64,12 @@
(defun rust-check ()
"Compile using `cargo check`"
(interactive)
(rust--compile "%s check" rust-cargo-bin))
(rust--compile "%s check %s" rust-cargo-bin rust-cargo-default-arguments))

(defun rust-compile ()
"Compile using `cargo build`"
(interactive)
(rust--compile "%s build" rust-cargo-bin))
(rust--compile "%s build %s" rust-cargo-bin rust-cargo-default-arguments))

(defun rust-compile-release ()
"Compile using `cargo build --release`"
Expand All @@ -74,7 +79,7 @@
(defun rust-run ()
"Run using `cargo run`"
(interactive)
(rust--compile "%s run" rust-cargo-bin))
(rust--compile "%s run %s" rust-cargo-bin rust-cargo-default-arguments))

(defun rust-run-release ()
"Run using `cargo run --release`"
Expand All @@ -84,7 +89,7 @@
(defun rust-test ()
"Test using `cargo test`"
(interactive)
(rust--compile "%s test" rust-cargo-bin))
(rust--compile "%s test %s" rust-cargo-bin rust-cargo-default-arguments))

(defun rust-run-clippy ()
"Run `cargo clippy'."
Expand Down

0 comments on commit 832980d

Please sign in to comment.