Function: vc-register
vc-register is an autoloaded, interactive and byte-compiled function
defined in vc.el.gz.
Signature
(vc-register &optional VC-FILESET COMMENT)
Documentation
Register into a version control system.
If VC-FILESET is given, register the files in that fileset. Otherwise register the current file. If COMMENT is present, use that as an initial comment.
The version control system to use is found by cycling through the list
vc-handled-backends. The first backend in that list which declares
itself responsible for the file (usually because other files in that
directory are already registered under that backend) will be used to
register the file. If no backend declares itself responsible, the
first backend that could register the file is used.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
;;;###autoload
(defun vc-register (&optional vc-fileset comment)
"Register into a version control system.
If VC-FILESET is given, register the files in that fileset.
Otherwise register the current file.
If COMMENT is present, use that as an initial comment.
The version control system to use is found by cycling through the list
`vc-handled-backends'. The first backend in that list which declares
itself responsible for the file (usually because other files in that
directory are already registered under that backend) will be used to
register the file. If no backend declares itself responsible, the
first backend that could register the file is used."
(interactive)
(let* ((fileset-arg (or vc-fileset (vc-deduce-fileset nil t)))
(backend (car fileset-arg))
(files (nth 1 fileset-arg)))
;; We used to operate on `only-files', but VC wants to provide the
;; possibility to register directories rather than files only, since
;; many VCS allow that as well.
(dolist (fname files)
(when (vc-call-backend backend 'registered fname)
(error "This file is already registered: %s" fname))
;; Watch out for new buffers of size 0: the corresponding file
;; does not exist yet, even though buffer-modified-p is nil.
(when-let* ((bname (get-file-buffer fname)))
(with-current-buffer bname
(when (and (not (buffer-modified-p))
(zerop (buffer-size))
(not (file-exists-p buffer-file-name)))
(set-buffer-modified-p t))
(vc-buffer-sync))))
(message "Registering %s... " files)
(mapc #'vc-file-clearprops files)
(vc-call-backend backend 'register files comment)
(dolist (fname files)
(vc-file-setprop fname 'vc-backend backend)
(when-let* ((bname (get-file-buffer fname)))
(with-current-buffer bname
(unless vc-make-backup-files
(setq-local backup-inhibited t))
(when vc-auto-revert-mode
(auto-revert-mode 1))))
(vc-resynch-buffer fname t t))
(message "Registering %s... done" files)))