Function: vc-exec-after
vc-exec-after is a byte-compiled function defined in
vc-dispatcher.el.gz.
Signature
(vc-exec-after CODE)
Documentation
Eval CODE when the current buffer's process is done.
If the current buffer has no process, just evaluate CODE. Else, add CODE to the process' sentinel. CODE should be a function of no arguments.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-dispatcher.el.gz
(defun vc-exec-after (code)
"Eval CODE when the current buffer's process is done.
If the current buffer has no process, just evaluate CODE.
Else, add CODE to the process' sentinel.
CODE should be a function of no arguments."
(let ((proc (get-buffer-process (current-buffer))))
(cond
;; If there's no background process, just execute the code.
;; We used to explicitly call delete-process on exited processes,
;; but this led to timing problems causing process output to be
;; lost. Terminated processes get deleted automatically
;; anyway. -- cyd
((or (null proc) (eq (process-status proc) 'exit))
;; Make sure we've read the process's output before going further.
(when proc (accept-process-output proc))
(if (functionp code) (funcall code) (eval code t)))
;; If a process is running, add CODE to the sentinel
((eq (process-status proc) 'run)
(vc-set-mode-line-busy-indicator)
(letrec ((fun (lambda (p _msg)
(remove-function (process-sentinel p) fun)
(vc--process-sentinel p code))))
(add-function :after (process-sentinel proc) fun)))
(t (error "Unexpected process state"))))
nil)