Function: vc-buffer-sync-fileset

vc-buffer-sync-fileset is a byte-compiled function defined in vc.el.gz.

Signature

(vc-buffer-sync-fileset FILESET &optional NOT-ESSENTIAL MISSING-IN-DIRS)

Documentation

Call vc-buffer-sync for most buffers visiting files in FILESET.

NOT-ESSENTIAL means it is okay to continue if the user says not to save.

For files named explicitly in FILESET, this function always syncs their buffers. By contrast, for directories named in FILESET, its behavior depends on MISSING-IN-DIRS. For each directory named in FILESET, it considers buffers visiting any file contained within that directory or its subdirectories. If MISSING-IN-DIRS is nil, it syncs only those buffers whose files exist on disk. Otherwise it syncs all of them.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc-buffer-sync-fileset (fileset &optional not-essential missing-in-dirs)
  "Call `vc-buffer-sync' for most buffers visiting files in FILESET.
NOT-ESSENTIAL means it is okay to continue if the user says not to save.

For files named explicitly in FILESET, this function always syncs their
buffers.  By contrast, for directories named in FILESET, its behavior
depends on MISSING-IN-DIRS.  For each directory named in FILESET, it
considers buffers visiting any file contained within that directory or
its subdirectories.  If MISSING-IN-DIRS is nil, it syncs only those
buffers whose files exist on disk.  Otherwise it syncs all of them."
  ;; This treatment of directories named in FILESET is wanted for, at
  ;; least, users with `vc-find-revision-no-save' set to non-nil: not
  ;; treating directories this way would imply calling `vc-buffer-sync'
  ;; on all buffers generated by \\`C-x v ~' during \\`C-x v D'.
  (let ((non-essential not-essential)
        dirs buffers)
    (dolist (name (cadr fileset))
      (if (file-directory-p name)
          (push (file-name-as-directory name) dirs)
        (when-let* ((buf (find-buffer-visiting name)))
          (push buf buffers))))
    (when dirs
      (setq buffers
            (cl-nunion buffers
                       (match-buffers
                        (lambda (buf)
                          (and-let*
                              ((file (buffer-local-value 'buffer-file-name buf))
                               ((cl-some (if not-essential
                                             (lambda (dir)
                                               ;; For speed (bug#79137).
                                               (string-prefix-p dir file))
                                           (lambda (dir)
                                             (file-in-directory-p file dir)))
                                         dirs))
                               ((or missing-in-dirs
                                    (file-exists-p file))))))))))
    (dolist (buf buffers)
      (with-current-buffer buf
        (vc-buffer-sync not-essential)))))