kwrooijen / cargo.el

Emacs Minor Mode for Cargo, Rust's Package Manager.
GNU General Public License v3.0
169 stars 67 forks source link

Is there a way to provide input to interactive programs? #29

Open shepmaster opened 7 years ago

kwrooijen commented 7 years ago

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.

novski commented 7 years ago

+1

kwrooijen commented 7 years ago

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.

iwahbe commented 5 years ago

+1

SimonCockx commented 5 years ago

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’.

SimonCockx commented 5 years ago

Okay, I solved it this way: https://emacs.stackexchange.com/a/51194/23748. Perhaps this can be used to solve the problem?

Nequo commented 4 years ago

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)
  )
)
c02y commented 2 years ago
(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.

jesusdiazvico commented 5 months ago

None of these solutions work for me. Was this finally fixed in some other way?