Function: vc-wait-for-process-before-save
vc-wait-for-process-before-save is a byte-compiled function defined in
vc-dispatcher.el.gz.
Signature
(vc-wait-for-process-before-save PROC MESSAGE)
Documentation
Make Emacs wait for PROC before saving buffers under current VC tree.
If waiting for PROC takes more than a second, display MESSAGE.
This is used to implement vc-async-checkin. It effectively switches
to a synchronous checkin in the case that the user asks to save a buffer
under the tree in which the checkin operation is running.
The hook installed by this function will make Emacs unconditionally wait
for PROC if the root of the current VC tree couldn't be determined, and
whenever writing out a buffer which doesn't have any buffer-file-name(var)/buffer-file-name(fun)
yet.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-dispatcher.el.gz
(defun vc-wait-for-process-before-save (proc message)
"Make Emacs wait for PROC before saving buffers under current VC tree.
If waiting for PROC takes more than a second, display MESSAGE.
This is used to implement `vc-async-checkin'. It effectively switches
to a synchronous checkin in the case that the user asks to save a buffer
under the tree in which the checkin operation is running.
The hook installed by this function will make Emacs unconditionally wait
for PROC if the root of the current VC tree couldn't be determined, and
whenever writing out a buffer which doesn't have any `buffer-file-name'
yet."
(letrec ((root (vc-root-dir))
(hook
(lambda ()
(cond ((not (process-live-p proc))
(remove-hook 'before-save-hook hook))
((or (and buffer-file-name
(or (not root)
(file-in-directory-p buffer-file-name
root)))
;; No known buffer file name but we are saving:
;; perhaps writing out a `special-mode' buffer.
;; A `before-save-hook' cannot know whether or
;; not it'll be written out under ROOT.
;; Err on the side of switching to synchronous.
(not buffer-file-name))
(with-delayed-message (1 message)
(while (process-live-p proc)
(when (input-pending-p)
(discard-input))
(sit-for 0.05)))
(remove-hook 'before-save-hook hook))))))
(add-hook 'before-save-hook hook)))