Skip to content

Commit

Permalink
don't require Cargo.toml for compile commands
Browse files Browse the repository at this point in the history
  • Loading branch information
brotzeit committed May 27, 2022
1 parent 10fbcb0 commit 0da1159
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rustic-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ in your project like `pwd'"
(let ((c (if (listp command)
command
(split-string command))))
(rustic-compilation-start c args)))
(rustic-compilation-start c (append (list :no-default-dir t) args))))

;;;###autoload
(defun rustic-cargo-build ()
Expand Down
2 changes: 1 addition & 1 deletion rustic-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ARGS is a plist that affects how the process is run.
(process (or (plist-get args :process) rustic-compilation-process-name))
(mode (or (plist-get args :mode) 'rustic-compilation-mode))
(directory (or (plist-get args :directory) (funcall rustic-compile-directory-method)))
(workspace (rustic-buffer-workspace))
(workspace (rustic-buffer-workspace (plist-get args :no-default-dir)))
(sentinel (or (plist-get args :sentinel) #'rustic-compilation-sentinel))
(file-buffer (current-buffer)))
(rustic-compilation-setup-buffer buf directory mode)
Expand Down
16 changes: 10 additions & 6 deletions rustic.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,20 @@

(defun rustic-buffer-workspace (&optional nodefault)
"Get workspace for the current buffer."
;; this variable is buffer local so we can use the cached value
(if rustic--buffer-workspace
rustic--buffer-workspace
(with-temp-buffer
(let ((ret (call-process (rustic-cargo-bin) nil (list (current-buffer) nil) nil "locate-project" "--workspace")))
(when (and (/= ret 0) (not nodefault))
(error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
(goto-char 0)
(let* ((output (json-read))
(dir (file-name-directory (cdr (assoc-string "root" output)))))
(setq rustic--buffer-workspace dir))))))
(cond ((and (/= ret 0) nodefault)
(error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
((and (/= ret 0) (not nodefault))
(setq rustic--buffer-workspace default-directory))
(t
(goto-char 0)
(let* ((output (json-read))
(dir (file-name-directory (cdr (assoc-string "root" output)))))
(setq rustic--buffer-workspace dir))))))))

(defun rustic-buffer-crate (&optional nodefault)
"Return the crate for the current buffer.
Expand Down

0 comments on commit 0da1159

Please sign in to comment.