rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.13k stars 181 forks source link

Support running interactive programs #544

Closed isvilen closed 6 months ago

isvilen commented 6 months ago

If universal argument is set before invoking rust-run (C-u C-c C-c C-r) the output buffer will be in Comint mode with compilation-shell-minor-mode and user input can be processed.

psibi commented 6 months ago

@isvilen Looks good to me apart from minor comment. But for this to be merged, this would need two more updates:

isvilen commented 6 months ago

I've updated the README file, but I can find any existing tests for rust-cargo.el, so I am not sure how to add a test for this feature.

psibi commented 6 months ago

so I am not sure how to add a test for this feature.

We have some tests for it in rustic mode for cargo-run etc: https://github.com/emacs-rustic/rustic/blob/17a79c659b0eb304e35705facb114caf61eae2e9/test/rustic-cargo-test.el#L6

Can you see if you can adapt it from there ? It's okay if it's a separate file.

isvilen commented 6 months ago

@psibi Added tests for rust-compile and rust-run in interactive and non-interactive mode.

psibi commented 6 months ago

@isvilen Thanks, it works and I tested it locally too with a few different program.

Although I was not successful with the test-project/src/main.rs: How do you ensure when running using rust-run that args.len() != 1 since I don't see a way to pass a parameter to cargo run itself.

Probably I'm missing something since I mostly use rustic and rust-mode has different way to pass an option ?

isvilen commented 6 months ago

@isvilen Thanks, it works and I tested it locally too with a few different program.

Although I was not successful with the test-project/src/main.rs: How do you ensure when running using rust-run that args.len() != 1 since I don't see a way to pass a parameter to cargo run itself.

Probably I'm missing something since I mostly use rustic and rust-mode has different way to pass an option ?

I just set rust-cargo-default-arguments before invoking rust-run see https://github.com/rust-lang/rust-mode/blob/947ebf993818f7135e12d4b0da6f5b05ba790c14/rust-cargo-tests.el#L47

psibi commented 6 months ago

Thank you!

Andsbf commented 5 months ago

thanks you both for that @psibi @isvilen 💯