Function: vc-do-async-command

vc-do-async-command is a byte-compiled function defined in vc-dispatcher.el.gz.

Signature

(vc-do-async-command BUFFER ROOT COMMAND &rest ARGS)

Documentation

Run COMMAND asynchronously with ARGS, displaying the result.

Send the output to BUFFER, which should be a buffer or the name of a buffer, which is created. ROOT should be the directory in which the command should be run. The process object is returned. Display the buffer in some window, but don't select it.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-dispatcher.el.gz
(defun vc-do-async-command (buffer root command &rest args)
  "Run COMMAND asynchronously with ARGS, displaying the result.
Send the output to BUFFER, which should be a buffer or the name
of a buffer, which is created.
ROOT should be the directory in which the command should be run.
The process object is returned.
Display the buffer in some window, but don't select it."
  (let ((dir default-directory)
	(inhibit-read-only t)
        new-window-start proc)
    (setq buffer (get-buffer-create buffer))
    (if (get-buffer-process buffer)
	(error "Another VC action on %s is running" root))
    (with-current-buffer buffer
      (setq default-directory root)
      (let* (;; Run in the original working directory.
             (default-directory dir)
             (orig-fun vc-filter-command-function)
             (vc-filter-command-function
              (lambda (&rest args)
                (cl-destructuring-bind (&whole args cmd _ flags)
                    (apply orig-fun args)
                  (goto-char (point-max))
                  (unless (eq (point) (point-min))
                    (insert "\n"))
                  (setq new-window-start (point))
                  (insert "Running \"" cmd)
                  (dolist (flag flags)
                    (insert " " flag))
                  (insert "\"...\n")
                  args))))
	(setq proc (apply #'vc-do-command t 'async command nil args))))
    (unless vc--inhibit-async-window
      (when-let ((window (display-buffer buffer)))
        (set-window-start window new-window-start)))
    proc))