Skip to content

Commit

Permalink
fix(rustic-babel): disable toolchain when invalid/unneeded
Browse files Browse the repository at this point in the history
When the user installs Rust tools using a method other than rustup, e.g. using
an operating system's package manager, cargo generally has no support for
toolchain specification. In such case, the user can then `nil', or `""', so that
the rescpective functions in `rustic-babel' will remove the toolchain from
params, that is only toolchain has a valid value it uses toolchain.

See also: brotzeit#279 (comment)
  • Loading branch information
yuuyins committed Feb 13, 2023
1 parent a5fc66c commit 987affd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,18 @@ should be wrapped in which case we will disable rustfmt."
(toolchain (cond ((eq toolchain-kw-or-string 'nightly) "+nightly")
((eq toolchain-kw-or-string 'beta) "+beta")
((eq toolchain-kw-or-string 'stable) "+stable")
((or (null rustic-babel-default-toolchain)
(null (string-blank-p rustic-babel-default-toolchain)))
nil)
(toolchain-kw-or-string (format "+%s" toolchain-kw-or-string))
(t (format "+%s" rustic-babel-default-toolchain))))
(params (list "cargo" toolchain "build" "--quiet"))
(params (remove nil (list "cargo"
(unless (or (null toolchain)
(= 0 (string-blank-p toolchain))
(equal "+" toolchain))
toolchain)
"build"
"--quiet")))
(inhibit-read-only t))
(rustic-compilation-setup-buffer err-buff dir 'rustic-compilation-mode)
(when rustic-babel-display-compilation-buffer
Expand Down Expand Up @@ -126,7 +135,13 @@ execution with rustfmt."

;; run project
(let* ((err-buff (get-buffer-create rustic-babel-compilation-buffer-name))
(params (list "cargo" toolchain "run" "--quiet"))
(params (remove nil (list "cargo"
(unless (or (null toolchain)
(= 0 (string-blank-p toolchain))
(equal "+" toolchain))
toolchain)
"run"
"--quiet")))
(inhibit-read-only t))
(rustic-make-process
:name rustic-babel-process-name
Expand Down

0 comments on commit 987affd

Please sign in to comment.