rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.1k stars 176 forks source link

Question: how to add `--tests` to cargo check #439

Closed k-bx closed 2 years ago

k-bx commented 2 years ago

Hi. I'm using C-c C-d to run cargo check in a buffer. I'd love to extend the command to also check tests. What's the best way to do that atm? Thank you!

brotzeit commented 2 years ago

Hey, I'm afraid rust-mode doesn't provide this as a feature. So you can either additionally use a package from this list https://github.com/rust-lang/rust-mode#other-recommended-packages or look for a way to add additional parameters before running compile(requires a little elisp knowledge). Sorry that I don't implement it, but I don't want to add similar code in two places(I'm maintaining a package of the list I mentioned).

However I would gladly merge this feature. This would ideally be located at rust-compile.el.

brotzeit commented 2 years ago

Another option would be to run compile with C-u and then use recompile. But you can't configure the parameters as default...

k-bx commented 2 years ago

Gotcha. Just for clarity: would you be willing to expose an option that extends extra args in customize-group menu as PR?

brotzeit commented 2 years ago

Sorry but I'm not sure how this would look like. You mean add an additional defcustom that holds the additional arguments ?

k-bx commented 2 years ago

I've never done that, so not fully sure how to do that in elisp, but in haskell-mode for example you can say M-x customize-group haskell-compile and you will see something like this where you can override the stack build command from standard to whatever you want, adding any arguments you want.

Screenshot 2022-02-02 at 19 17 07
brotzeit commented 2 years ago

I think this is only meant for the user side. I never used customize.

I just checked the keybinding C-c C-d and I couldn't find it in rust-mode. Can you tell me which command you are actually using. You probably use rust-check ?

k-bx commented 2 years ago

Yes, it's rust-check, I bind it myself

brotzeit commented 2 years ago

I added an option https://github.com/rust-lang/rust-mode/commit/832980d96a3b7e985bc8bfb1dc2bd7e9599c6312, try to use (setq rust-cargo-default-arguments "--tests") in your config.

k-bx commented 2 years ago

@brotzeit it worked, customized via customize-group GUI. thank you!