Function: vc-dir-refresh

vc-dir-refresh is an interactive and byte-compiled function defined in vc-dir.el.gz.

Signature

(vc-dir-refresh &optional OK-IF-ALREADY-RUNNING)

Documentation

Refresh the contents of the *VC-Dir* buffer.

Signal an error if another update process is in progress, unless OK-IF-ALREADY-RUNNING is non-nil.

If OK-IF-ALREADY-RUNNING is restart and another update process is in progress, kill it and start a new one.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-dir.el.gz
(defun vc-dir-refresh (&optional ok-if-already-running)
  "Refresh the contents of the *VC-Dir* buffer.

Signal an error if another update process is in progress, unless
OK-IF-ALREADY-RUNNING is non-nil.

If OK-IF-ALREADY-RUNNING is `restart' and another update process is in
progress, kill it and start a new one."
  (interactive)
  (cond*
   ((bind* (proc (and (buffer-live-p vc-dir-process-buffer)
                      (get-buffer-process vc-dir-process-buffer)))))
   ((and proc (not ok-if-already-running))
    (error "Another update process is in progress, cannot run two at a time"))
   ((and proc (not (eq ok-if-already-running 'restart)))) ;do nothing
   (proc
    ;; OK-IF-ALREADY-RUNNING is `restart'.
    (delete-process proc)
    :non-exit)
   (t
    (let ((def-dir default-directory)
	  (backend vc-dir-backend))
      (when (and vc-dir-save-some-buffers-on-revert (not non-essential))
        (vc-buffer-sync-fileset `(,vc-dir-backend (,def-dir)) t))
      (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.
      (vc-dir--set-vc-dir-process-buffer 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
      ;; mostly synchronous) rather than doing it while dir-status is running.
      (vc-dir--set-header def-dir 'reset-footer)
      (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
                 (if-let* ((remaining
                            (ewoc-collect vc-ewoc
                                          'vc-dir-fileinfo->needs-update)))
                     (vc-dir-refresh-files (mapcar #'vc-dir-fileinfo->name
                                                   remaining))
                   (setq mode-line-process nil)
                   (run-hooks 'vc-dir-refresh-hook))))))))))))