|
67 | 67 |
|
68 | 68 | ;;; Internal
|
69 | 69 |
|
70 |
| -(defun rust--compile (format-string &rest args) |
| 70 | +(defun rust--compile (comint format-string &rest args) |
71 | 71 | (when (null rust-buffer-project)
|
72 | 72 | (rust-update-buffer-project))
|
73 | 73 | (let ((default-directory
|
74 | 74 | (or (and rust-buffer-project
|
75 | 75 | (file-name-directory rust-buffer-project))
|
76 |
| - default-directory))) |
77 |
| - (compile (apply #'format format-string args)))) |
| 76 | + default-directory)) |
| 77 | + ;; make sure comint is a boolean value |
| 78 | + (comint (not (not comint)))) |
| 79 | + (compile (apply #'format format-string args) comint))) |
78 | 80 |
|
79 | 81 | ;;; Commands
|
80 | 82 |
|
81 | 83 | (defun rust-check ()
|
82 | 84 | "Compile using `cargo check`"
|
83 | 85 | (interactive)
|
84 |
| - (rust--compile "%s check %s" rust-cargo-bin rust-cargo-default-arguments)) |
| 86 | + (rust--compile nil "%s check %s" rust-cargo-bin rust-cargo-default-arguments)) |
85 | 87 |
|
86 | 88 | (defun rust-compile ()
|
87 | 89 | "Compile using `cargo build`"
|
88 | 90 | (interactive)
|
89 |
| - (rust--compile "%s build %s" rust-cargo-bin rust-cargo-default-arguments)) |
| 91 | + (rust--compile nil "%s build %s" rust-cargo-bin rust-cargo-default-arguments)) |
90 | 92 |
|
91 | 93 | (defun rust-compile-release ()
|
92 | 94 | "Compile using `cargo build --release`"
|
93 | 95 | (interactive)
|
94 |
| - (rust--compile "%s build --release" rust-cargo-bin)) |
| 96 | + (rust--compile nil "%s build --release" rust-cargo-bin)) |
95 | 97 |
|
96 |
| -(defun rust-run () |
97 |
| - "Run using `cargo run`" |
98 |
| - (interactive) |
99 |
| - (rust--compile "%s run %s" rust-cargo-bin rust-cargo-default-arguments)) |
| 98 | +(defun rust-run (&optional comint) |
| 99 | + "Run using `cargo run` |
100 | 100 |
|
101 |
| -(defun rust-run-release () |
102 |
| - "Run using `cargo run --release`" |
103 |
| - (interactive) |
104 |
| - (rust--compile "%s run --release" rust-cargo-bin)) |
| 101 | +If optional arg COMINT is t or invoked with universal prefix arg, |
| 102 | +output buffer will be in comint mode, i.e. interactive." |
| 103 | + (interactive "P") |
| 104 | + (rust--compile comint "%s run %s" rust-cargo-bin rust-cargo-default-arguments)) |
| 105 | + |
| 106 | +(defun rust-run-release (&optional comint) |
| 107 | + "Run using `cargo run --release` |
| 108 | +
|
| 109 | +If optional arg COMINT is t or invoked with universal prefix arg, |
| 110 | +output buffer will be in comint mode, i.e. interactive." |
| 111 | + (interactive "P") |
| 112 | + (rust--compile comint "%s run --release" rust-cargo-bin)) |
105 | 113 |
|
106 | 114 | (defun rust-test ()
|
107 | 115 | "Test using `cargo test`"
|
108 | 116 | (interactive)
|
109 |
| - (rust--compile "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) |
| 117 | + (rust--compile nil "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) |
110 | 118 |
|
111 | 119 | (defun rust-run-clippy ()
|
112 | 120 | "Run `cargo clippy'."
|
|
118 | 126 | ;; set `compile-command' temporarily so `compile' doesn't
|
119 | 127 | ;; clobber the existing value
|
120 | 128 | (compile-command (mapconcat #'shell-quote-argument args " ")))
|
121 |
| - (rust--compile compile-command))) |
| 129 | + (rust--compile nil compile-command))) |
122 | 130 |
|
123 | 131 | ;;; _
|
124 | 132 | (provide 'rust-cargo)
|
|
0 commit comments