From 832980d96a3b7e985bc8bfb1dc2bd7e9599c6312 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Thu, 3 Feb 2022 19:31:52 +0100 Subject: allow setting additional args with rust-cargo-default-arguments --- README.md | 3 +++ rust-cargo.el | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e841da..40f7037 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/rust-cargo.el b/rust-cargo.el index 30ba611..58f0151 100644 --- a/rust-cargo.el +++ b/rust-cargo.el @@ -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) @@ -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`" @@ -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`" @@ -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'." -- cgit v1.2.3