rust-lang / rust-mode

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

Support running interactive programs #544

Closed isvilen closed 1 month ago

isvilen commented 1 month 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 1 month ago

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

isvilen commented 1 month 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 1 month 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 1 month ago

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

psibi commented 1 month 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 1 month 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 1 month ago

Thank you!

Andsbf commented 1 week ago

thanks you both for that @psibi @isvilen 💯