Move decision about when to process sync vs async
This commit is contained in:
parent
ad9604e60a
commit
0e708ee64a
@ -207,10 +207,7 @@ error."
|
|||||||
(format "CARGO_HOME=%s" (expand-file-name cargo-home)))
|
(format "CARGO_HOME=%s" (expand-file-name cargo-home)))
|
||||||
process-environment)))
|
process-environment)))
|
||||||
(deferred:nextc
|
(deferred:nextc
|
||||||
(if (memq 'racer-company-backend company-backends)
|
(racer--shell-command racer-cmd (cons command args))
|
||||||
;; If racer-company-backend is in use, call the asynchronous version.
|
|
||||||
(racer--shell-command-async racer-cmd (cons command args))
|
|
||||||
(deferred:next (racer--shell-command racer-cmd (cons command args))))
|
|
||||||
(lambda (output)
|
(lambda (output)
|
||||||
(-let [(exit-code stdout _stderr) output]
|
(-let [(exit-code stdout _stderr) output]
|
||||||
;; Use `equal' instead of `zero' as exit-code can be a string
|
;; Use `equal' instead of `zero' as exit-code can be a string
|
||||||
@ -244,23 +241,39 @@ Return a list (exit-code stdout stderr)."
|
|||||||
(let (exit-code stdout stderr)
|
(let (exit-code stdout stderr)
|
||||||
;; Create a temporary buffer for `call-process` to write stdout
|
;; Create a temporary buffer for `call-process` to write stdout
|
||||||
;; into.
|
;; into.
|
||||||
(with-temp-buffer
|
(deferred:nextc
|
||||||
(setq exit-code
|
;; If racer-company-backend is in use, call the asynchronous version.
|
||||||
(apply #'call-process program nil
|
(if (memq 'racer-company-backend company-backends)
|
||||||
(list (current-buffer) tmp-file-for-stderr)
|
(deferred:nextc
|
||||||
nil args))
|
(apply #'deferred:process-ec program args)
|
||||||
(setq stdout (buffer-string)))
|
(lambda (output)
|
||||||
(setq stderr (racer--slurp tmp-file-for-stderr))
|
;; deferred combines stdout and stderr
|
||||||
(setq racer--prev-state
|
(list (nth 0 output) (nth 1 output) "")))
|
||||||
(list
|
(progn
|
||||||
:program program
|
(with-temp-buffer
|
||||||
:args args
|
(setq exit-code
|
||||||
:exit-code exit-code
|
(apply #'call-process program nil
|
||||||
:stdout stdout
|
(list (current-buffer) tmp-file-for-stderr)
|
||||||
:stderr stderr
|
nil args))
|
||||||
:default-directory default-directory
|
(setq stdout (buffer-string)))
|
||||||
:process-environment process-environment))
|
(setq stderr (racer--slurp tmp-file-for-stderr))
|
||||||
(list exit-code stdout stderr))))
|
(deferred:next
|
||||||
|
(lambda ()
|
||||||
|
(list exit-code stdout stderr)))))
|
||||||
|
(lambda (output)
|
||||||
|
(setq exit-code (nth 0 output)
|
||||||
|
stdout (nth 1 output)
|
||||||
|
stderr (nth 2 output))
|
||||||
|
(setq racer--prev-state
|
||||||
|
(list
|
||||||
|
:program program
|
||||||
|
:args args
|
||||||
|
:exit-code exit-code
|
||||||
|
:stdout stdout
|
||||||
|
:stderr stderr
|
||||||
|
:default-directory default-directory
|
||||||
|
:process-environment process-environment))
|
||||||
|
(list exit-code stdout stderr))))))
|
||||||
|
|
||||||
(defun racer--shell-command-async (program args)
|
(defun racer--shell-command-async (program args)
|
||||||
"Execute PROGRAM with ARGS.
|
"Execute PROGRAM with ARGS.
|
||||||
|
Reference in New Issue
Block a user