summaryrefslogtreecommitdiff
path: root/lisp/vc-hooks.el
diff options
context:
space:
mode:
authorAndré Spiegel <spiegel@gnu.org>2000-10-04 09:50:21 +0000
committerAndré Spiegel <spiegel@gnu.org>2000-10-04 09:50:21 +0000
commitd445a9756a2b10ac488561ba1ce16397101e5548 (patch)
tree19b741b83fcd78e6cbf8f85130cee3ffd2854f17 /lisp/vc-hooks.el
parentffda04606120aabbb51a2f14a655ce7fc03e7063 (diff)
downloademacs-d445a9756a2b10ac488561ba1ce16397101e5548.tar.gz
(vc-before-save, vc-default-make-version-backups,
vc-version-backup-file-name): New functions.
Diffstat (limited to 'lisp/vc-hooks.el')
-rw-r--r--lisp/vc-hooks.el24
1 files changed, 23 insertions, 1 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index c8277ec95cd..8e662efefba 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -5,7 +5,7 @@
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
-;; $Id: vc-hooks.el,v 1.120 2000/09/21 13:15:26 spiegel Exp $
+;; $Id: vc-hooks.el,v 1.121 2000/10/02 12:02:37 spiegel Exp $
;; This file is part of GNU Emacs.
@@ -459,6 +459,28 @@ to do that, use this command a second time with no argument."
(toggle-read-only)))
(define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
+(defun vc-default-make-version-backups (backend file)
+ "Return non-nil if unmodified repository versions should
+be backed up locally. The default is to switch off this feature."
+ nil)
+
+(defun vc-version-backup-file-name (file &optional rev)
+ "Return a backup file name for REV or the current version of FILE."
+ (concat file ".~" (or rev (vc-workfile-version file)) "~"))
+
+(defun vc-before-save ()
+ "Function to be called by `basic-save-buffer' (in files.el)."
+ ;; If the file on disk is still in sync with the repository,
+ ;; and version backups should be made, copy the file to
+ ;; another name. This enables local diffs and local reverting.
+ (let ((file (buffer-file-name)))
+ (and (vc-backend file)
+ (vc-up-to-date-p file)
+ (eq (vc-checkout-model file) 'implicit)
+ (vc-call make-version-backups file)
+ (copy-file file (vc-version-backup-file-name file)
+ 'ok-if-already-exists 'keep-date))))
+
(defun vc-after-save ()
"Function to be called by `basic-save-buffer' (in files.el)."
;; If the file in the current buffer is under version control,