diff options
| author | Simeon Simeonov | 2026-02-14 10:44:11 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2026-02-14 10:44:11 +0100 |
| commit | aaac90c9b05e490660176dc6109b9e58c3bbe3c1 (patch) | |
| tree | 850d9c131aeaa749d2aaffaac54262b9917140fa /.emacs.d/lisp/rust-cargo.el | |
| parent | 5c2c9a50da3a3f534842ffe95a49fe990000a072 (diff) | |
Update markdown-mode and rust-mode
Diffstat (limited to '.emacs.d/lisp/rust-cargo.el')
| -rw-r--r-- | .emacs.d/lisp/rust-cargo.el | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/.emacs.d/lisp/rust-cargo.el b/.emacs.d/lisp/rust-cargo.el index d323b5d..bb5d2ac 100644 --- a/.emacs.d/lisp/rust-cargo.el +++ b/.emacs.d/lisp/rust-cargo.el | |||
| @@ -66,7 +66,9 @@ worksapce for commands like `cargo check`." | |||
| 66 | (goto-char 0) | 66 | (goto-char 0) |
| 67 | (let ((output (let ((json-object-type 'alist)) | 67 | (let ((output (let ((json-object-type 'alist)) |
| 68 | (json-read)))) | 68 | (json-read)))) |
| 69 | (cdr (assoc-string "root" output))))))) | 69 | (concat |
| 70 | (file-remote-p default-directory) | ||
| 71 | (cdr (assoc-string "root" output)))))))) | ||
| 70 | 72 | ||
| 71 | (defun rust-buffer-crate () | 73 | (defun rust-buffer-crate () |
| 72 | "Try to locate Cargo.toml using `locate-dominating-file'." | 74 | "Try to locate Cargo.toml using `locate-dominating-file'." |
| @@ -129,10 +131,29 @@ output buffer will be in comint mode, i.e. interactive." | |||
| 129 | (interactive "P") | 131 | (interactive "P") |
| 130 | (rust--compile comint "%s run --release" rust-cargo-bin)) | 132 | (rust--compile comint "%s run --release" rust-cargo-bin)) |
| 131 | 133 | ||
| 132 | (defun rust-test () | 134 | (defun rust-test (&optional arg is-test) |
| 133 | "Test using `cargo test`" | 135 | "Test using `cargo test`. |
| 134 | (interactive) | 136 | |
| 135 | (rust--compile nil "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) | 137 | If prefixed with `C-u`, pass additional arguments to the command |
| 138 | (from a string read from the minibuffer). | ||
| 139 | |||
| 140 | If optional arg IS-TEST is non-nil, | ||
| 141 | the argument `-- --show-output' will be automatically | ||
| 142 | added instead of being read from the minibuffer. | ||
| 143 | |||
| 144 | Note that the IS-TEST arg is not meant for general use, | ||
| 145 | and only exists for testing the `rust-mode' package. " | ||
| 146 | (interactive "P") | ||
| 147 | (let ((test-command | ||
| 148 | (if arg | ||
| 149 | (progn | ||
| 150 | (let ((custom-arg | ||
| 151 | (if is-test | ||
| 152 | "-- --show-output" | ||
| 153 | (string-trim (read-string "Enter Arguments: "))))) | ||
| 154 | (concat "%s test " custom-arg " %s"))) | ||
| 155 | "%s test %s"))) | ||
| 156 | (rust--compile nil test-command rust-cargo-bin rust-cargo-default-arguments))) | ||
| 136 | 157 | ||
| 137 | (defun rust-run-clippy () | 158 | (defun rust-run-clippy () |
| 138 | "Run `cargo clippy'." | 159 | "Run `cargo clippy'." |
| @@ -140,7 +161,7 @@ output buffer will be in comint mode, i.e. interactive." | |||
| 140 | (when (null rust-buffer-project) | 161 | (when (null rust-buffer-project) |
| 141 | (rust-update-buffer-project)) | 162 | (rust-update-buffer-project)) |
| 142 | (let* ((args (append (list rust-cargo-bin "clippy" | 163 | (let* ((args (append (list rust-cargo-bin "clippy" |
| 143 | (concat "--manifest-path=" rust-buffer-project)) | 164 | (concat "--manifest-path=" (file-local-name rust-buffer-project))) |
| 144 | rust-cargo-clippy-default-arguments)) | 165 | rust-cargo-clippy-default-arguments)) |
| 145 | ;; set `compile-command' temporarily so `compile' doesn't | 166 | ;; set `compile-command' temporarily so `compile' doesn't |
| 146 | ;; clobber the existing value | 167 | ;; clobber the existing value |
