Function: with-vc-properties

with-vc-properties is a macro defined in vc.el.gz.

Signature

(with-vc-properties FILES FORM SETTINGS)

Documentation

Execute FORM, then maybe set per-file properties for FILES.

If any of FILES is actually a directory, then do the same for all buffers for files in that directory. SETTINGS is an association list of property/value pairs. After executing FORM, set those properties from SETTINGS for which FORM did not call vc-file-setprop for that property (on any file). SETTINGS is evaluated once per file whose properties are to be updated, with the symbol file bound to the file name of each such file. Return the result of evaluating FORM.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defmacro with-vc-properties (files form settings)
  "Execute FORM, then maybe set per-file properties for FILES.
If any of FILES is actually a directory, then do the same for all
buffers for files in that directory.
SETTINGS is an association list of property/value pairs.  After
executing FORM, set those properties from SETTINGS for which FORM did
not call `vc-file-setprop' for that property (on any file).  SETTINGS is
evaluated once per file whose properties are to be updated, with the
symbol `file' bound to the file name of each such file.
Return the result of evaluating FORM."
  (declare (debug t) (indent 0))
  (cl-with-gensyms (flist)
    `(let ((vc-touched-properties (list t))
	   (,flist nil))
       (prog2 (dolist (file ,files)
                (if (file-directory-p file)
                    (dolist (buffer (buffer-list))
                      (let ((fname (buffer-file-name buffer)))
                        (when (and fname (string-prefix-p file fname))
                          (push fname ,flist))))
                  (push file ,flist)))
           ,form
         (dolist (file ,flist)
           (dolist (setting ,settings)
             (let ((property (car setting)))
               (unless (memq property vc-touched-properties)
                 (put (intern file vc-file-prop-obarray)
                      property (cdr setting))))))))))