Function: vc-dir-refresh
vc-dir-refresh is an interactive and byte-compiled function defined in
vc-dir.el.gz.
Signature
(vc-dir-refresh)
Documentation
Refresh the contents of the *VC-dir* buffer.
Throw an error if another update process is in progress.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-dir.el.gz
(defun vc-dir-refresh ()
"Refresh the contents of the *VC-dir* buffer.
Throw an error if another update process is in progress."
(interactive)
(if (vc-dir-busy)
(error "Another update process is in progress, cannot run two at a time")
(let ((def-dir default-directory)
(backend vc-dir-backend))
(vc-set-mode-line-busy-indicator)
;; Call the `dir-status' backend function.
;; `dir-status' is supposed to be asynchronous.
;; It should compute the results, and then call the function
;; passed as an argument in order to update the vc-dir buffer
;; with the results.
;; Create a buffer that can be used by `dir-status' and call
;; `dir-status' with this buffer as the current buffer. Use
;; `vc-dir-process-buffer' to remember this buffer, so that
;; it can be used later to kill the update process in case it
;; takes too long.
(unless (buffer-live-p vc-dir-process-buffer)
(setq vc-dir-process-buffer
(generate-new-buffer (format " *VC-%s* tmp status" backend))))
;; set the needs-update flag on all non-directory entries
(ewoc-map (lambda (info)
(unless (vc-dir-fileinfo->directory info)
(setf (vc-dir-fileinfo->needs-update info) t) nil))
vc-ewoc)
;; Bzr has serious locking problems, so setup the headers first (this is
;; synchronous) rather than doing it while dir-status is running.
(ewoc-set-hf vc-ewoc (vc-dir-headers backend def-dir) "")
(let ((buffer (current-buffer)))
(with-current-buffer vc-dir-process-buffer
(setq default-directory def-dir)
(erase-buffer)
(vc-call-backend
backend 'dir-status-files def-dir nil
(lambda (entries &optional more-to-come)
;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
;; If MORE-TO-COME is true, then more updates will come from
;; the asynchronous process.
(with-current-buffer buffer
(vc-dir-update entries buffer)
(unless more-to-come
(let ((remaining
(ewoc-collect
vc-ewoc 'vc-dir-fileinfo->needs-update)))
(if remaining
(vc-dir-refresh-files
(mapcar #'vc-dir-fileinfo->name remaining))
(setq mode-line-process nil)
(run-hooks 'vc-dir-refresh-hook))))))))))))