Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rustic-babel): disable toolchain when invalid/unneeded #499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ considered."

(defvar rustic-babel-spinner nil)

(defun rustic-babel-cargo-params (toolchain)
"Return a list of cargo commands for babel evaluation.
If TOOLCHAIN has a value other than `nil' or `+', then add
TOOLCHAIN to the list, else return a list of cargo commands with
no toolchain. Users may need non-toolchain when the computing
environment installed Cargo with a method other than rustup such
as with an operating system's package manager, in which case
Cargo has no support for toolchain specification."
(remove nil (list "cargo"
(unless (or (null toolchain)
(equal "+" toolchain))
toolchain)
"build"
"--quiet")))

(defun rustic-babel-eval (dir toolchain-kw-or-string main-p)
"Start a rust babel compilation process.
Compilation is started in directory DIR with appropriate
Expand All @@ -73,9 +88,12 @@ 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)
(eq 0 (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 (rustic-babel-cargo-params toolchain))
(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 +144,7 @@ execution with rustfmt."

;; run project
(let* ((err-buff (get-buffer-create rustic-babel-compilation-buffer-name))
(params (list "cargo" toolchain "run" "--quiet"))
(params (rustic-babel-cargo-params toolchain))
(inhibit-read-only t))
(rustic-make-process
:name rustic-babel-process-name
Expand Down