Skip to content

Commit

Permalink
Merge pull request #56 from Dushistov/rustc-1.24-fix
Browse files Browse the repository at this point in the history
Fix references to source code in compilation buffer for rustc 1.24
  • Loading branch information
kwrooijen authored May 21, 2018
2 parents b347184 + 8686a4f commit 0cf76fe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cargo-process.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,37 @@ Always set to nil if cargo-process--enable-rust-backtrace is nil"
(setenv cargo-process--rust-backtrace "1")
(setenv cargo-process--rust-backtrace nil))))

(defun cargo-process--workspace-root ()
"Find the worksapce root using `cargo metadata`."
(let* ((metadata-text (shell-command-to-string
(concat cargo-process--custom-path-to-bin " metadata --format-version 1 --no-deps")))
(metadata-json (json-read-from-string metadata-text))
(workspace-root (alist-get 'workspace_root metadata-json)))
workspace-root))


(defun cargo-process--start (name command &optional last-command)
"Start the Cargo process NAME with the cargo command COMMAND."
(set-rust-backtrace command)
(let* ((buffer (concat "*Cargo " name "*"))
(project-root (cargo-process--project-root))
(cmd
(or last-command
(cargo-process--maybe-read-command
(mapconcat #'identity (list cargo-process--custom-path-to-bin
command
"--manifest-path" (concat project-root "Cargo.toml")
cargo-process--command-flags)
" "))))
(project-root (cargo-process--project-root))
(default-directory (or project-root default-directory)))
(save-some-buffers (not compilation-ask-about-save)
(lambda ()
(and project-root
buffer-file-name
(string-prefix-p project-root (file-truename buffer-file-name)))))
(setq cargo-process-last-command (list name command cmd))
(compilation-start cmd 'cargo-process-mode (lambda(_) buffer))
(let ((default-directory (cargo-process--workspace-root)))
(compilation-start cmd 'cargo-process-mode (lambda(_) buffer)))
(set-process-sentinel (get-buffer-process buffer) 'cargo-process--finished-sentinel)))

(defun cargo-process--explain-action (button)
Expand Down

0 comments on commit 0cf76fe

Please sign in to comment.