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

Use RUSTIC-CARGO-BIN in org babel code #525

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ should be wrapped in which case we will disable rustfmt."
((eq toolchain-kw-or-string 'stable) "+stable")
(toolchain-kw-or-string (format "+%s" toolchain-kw-or-string))
(t (format "+%s" rustic-babel-default-toolchain))))
(params (list "cargo" toolchain "build" "--quiet"))
(params (list (rustic-cargo-bin) 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 +126,7 @@ execution with rustfmt."

;; run project
(let* ((err-buff (get-buffer-create rustic-babel-compilation-buffer-name))
(params (list "cargo" toolchain "run" "--quiet"))
(params (list (rustic-cargo-bin) toolchain "run" "--quiet"))
(inhibit-read-only t))
(rustic-make-process
:name rustic-babel-process-name
Expand Down Expand Up @@ -215,7 +215,7 @@ after successful compilation."
Return full path if EXPAND is t."
(let* ((default-directory org-babel-temporary-directory)
(dir (make-temp-file-internal "cargo" 0 "" nil)))
(shell-command-to-string (format "cargo new %s --bin --quiet" dir))
(shell-command-to-string (format "%s new %s --bin --quiet" (rustic-cargo-bin) dir))
(if expand
(concat (expand-file-name dir) "/")
dir)))
Expand Down Expand Up @@ -406,7 +406,7 @@ at least one time in this emacs session before this command can be used."
(default-directory org-babel-temporary-directory)
(body (org-element-property :value (org-element-at-point)))
(project (rustic-babel-project))
(params (list "cargo" "clippy")))
(params (list (rustic-cargo-bin) "clippy")))
(let* ((dir (setq rustic-babel-dir (expand-file-name project)))
(main (expand-file-name "main.rs" (concat dir "/src")))
(default-directory dir))
Expand Down
4 changes: 2 additions & 2 deletions rustic-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Execute process in PATH."

(defun rustic-cargo-install-crate-p (crate)
"Ask whether to install crate CRATE."
(let ((cmd (format "cargo install cargo-%s" crate)))
(let ((cmd (format "%s install cargo-%s" (rustic-cargo-bin) crate)))
(when (yes-or-no-p (format "Cargo-%s missing. Install ? " crate))
(async-shell-command cmd (rustic-cargo-bin) "cargo-error"))))

Expand Down Expand Up @@ -519,7 +519,7 @@ The CRATE-LINE is a single line from the `rustic-cargo-oudated-buffer-name'"
(let (upgrade)
(dolist (crate crates)
(setq upgrade (concat upgrade (format "-p %s@%s " (rustic-crate-name crate) (rustic-crate-version crate)))))
(let ((output (shell-command-to-string (format "cargo upgrade %s" upgrade))))
(let ((output (shell-command-to-string (format "%s upgrade %s" (rustic-cargo-bin) upgrade))))
(if (string-match "error: no such subcommand:" output)
(rustic-cargo-install-crate-p "edit")
(rustic-cargo-reload-outdated)))))
Expand Down
3 changes: 2 additions & 1 deletion rustic-comint.el
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Read the full command from the minibuffer when ARG is non-nil or
when called with a prefix command \\[universal-argument]."
(interactive "P")
(let* ((command (if arg
(read-from-minibuffer "Cargo run command: " "cargo run -- ")
(read-from-minibuffer "Cargo run command: "
(concat (rustic-cargo-bin) " run -- "))
(concat (rustic-cargo-bin) " run "
(setq rustic-run-arguments
(read-from-minibuffer
Expand Down
6 changes: 3 additions & 3 deletions rustic-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ If NOCONFIRM is non-nil, install all dependencies without prompting user."
(when (and (or missing-fd missing-makedocs missing-rg)
(or noconfirm (y-or-n-p "Missing some dependencies for rustic doc, install them? ")))
(when missing-fd
(rustic-doc--start-process "install-fd" "cargo" nil "install" "fd-find"))
(rustic-doc--start-process "install-fd" (rustic-cargo-bin) nil "install" "fd-find"))
(when missing-rg
(rustic-doc--start-process "install-rg" "cargo" nil "install" "ripgrep"))
(rustic-doc--start-process "install-rg" (rustic-cargo-bin) nil "install" "ripgrep"))
(when missing-makedocs
(rustic-doc--start-process "install-makedocs" "cargo" nil
(rustic-doc--start-process "install-makedocs" (rustic-cargo-bin) nil
"install" "cargo-makedocs"))))))

;;;###autoload
Expand Down
4 changes: 2 additions & 2 deletions rustic-popup.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ If directory is not in a rust project call `read-directory-name'."
(c (intern (concat "rustic-cargo-" command))))
(if (commandp c)
(call-interactively c)
(call-interactively 'rustic-compile (concat "cargo " command)))))
(call-interactively 'rustic-compile (concat (rustic-cargo-bin) " " command)))))
(when rustic-kill-buffer-and-window
(kill-buffer-and-window)))

Expand Down Expand Up @@ -220,7 +220,7 @@ corresponding line."

(defun rustic-popup-help-flags (command)
"Get flags of COMMAND."
(let ((string (shell-command-to-string (format "cargo %s -h" command)))
(let ((string (shell-command-to-string (format "%s %s -h" (rustic-cargo-bin) command)))
flags)
(dolist (s (split-string string "\n"))
(when (and (not (string-match "^\s+\-h" s))
Expand Down
Loading