Open shepmaster opened 7 years ago
+1
Sorry for getting back at this so late, I've been pretty busy and (sadly) haven't done any Rust dev for a long while. IIRC I looked into this in January but there were some complications that made this harder than I initially thought. I don't know when I'll have time to look into this but pull requests are always welcome. Again sorry for this.
+1
This is a real pain that should be easy to resolve. At line 303 in cargo-process.el inside the function cargo-process--start (https://github.com/kwrooijen/cargo.el/blob/master/cargo-process.el#L303), compilation-start
is executed without comint mode. From the docs:
(compilation-start COMMAND &optional MODE NAME-FUNCTION HIGHLIGHT-REGEXP)
...
MODE is the major mode to set in the compilation buffer. Mode
may also be t meaning use ‘compilation-shell-minor-mode’ under ‘comint-mode’.
Okay, I solved it this way: https://emacs.stackexchange.com/a/51194/23748. Perhaps this can be used to solve the problem?
I slightly modified the solution provided by @SimonCockx to move your point to the end of the compilation buffer. This makes it so that you can type your input in directly after running the function.
(with-eval-after-load 'rust-mode
(define-key rust-mode-map (kbd "C-q") 'my-cargo-run))
(defun my-cargo-run ()
"Build and run Rust code."
(interactive)
(cargo-process-run)
(let (
(orig-win (selected-window))
(run-win (display-buffer (get-buffer "*Cargo Run*") nil 'visible))
)
(select-window run-win)
(comint-mode)
(read-only-mode 0)
(end-of-buffer)
)
)
(defun my-cargo-run () "Build and run Rust code." (interactive) (cargo-process-run) (let ( (orig-win (selected-window)) (run-win (display-buffer (get-buffer "*Cargo Run*") nil 'visible)) ) (select-window run-win) (comint-mode) (read-only-mode 0) (end-of-buffer) ) )
This enables the input but nothing else, if even fails when the program tries to println a string after the read line.
None of these solutions work for me. Was this finally fixed in some other way?
Currently not, however this should be quite easy to implement. I just need to create an additional mode which uses Comint instead of Compile. The downside is that comint-mode isn't as rich as compile-mode, This will be an optional global variable which can be enabled.