comparison lisp/vc-hooks.el @ 32127:1543b0fc904b

(vc-before-save, vc-default-make-version-backups, vc-version-backup-file-name): New functions.
author André Spiegel <spiegel@gnu.org>
date Wed, 04 Oct 2000 09:50:21 +0000
parents d1ab0499dc86
children a771b5a6fa69
comparison
equal deleted inserted replaced
32126:3aab429d3c8a 32127:1543b0fc904b
3 ;; Copyright (C) 1992,93,94,95,96,98,99,2000 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992,93,94,95,96,98,99,2000 Free Software Foundation, Inc.
4 4
5 ;; Author: FSF (see vc.el for full credits) 5 ;; Author: FSF (see vc.el for full credits)
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> 6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
7 7
8 ;; $Id: vc-hooks.el,v 1.120 2000/09/21 13:15:26 spiegel Exp $ 8 ;; $Id: vc-hooks.el,v 1.121 2000/10/02 12:02:37 spiegel Exp $
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
456 ;; use boundp because vc.el might not be loaded 456 ;; use boundp because vc.el might not be loaded
457 (vc-backend (buffer-file-name))) 457 (vc-backend (buffer-file-name)))
458 (vc-next-action verbose) 458 (vc-next-action verbose)
459 (toggle-read-only))) 459 (toggle-read-only)))
460 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) 460 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
461
462 (defun vc-default-make-version-backups (backend file)
463 "Return non-nil if unmodified repository versions should
464 be backed up locally. The default is to switch off this feature."
465 nil)
466
467 (defun vc-version-backup-file-name (file &optional rev)
468 "Return a backup file name for REV or the current version of FILE."
469 (concat file ".~" (or rev (vc-workfile-version file)) "~"))
470
471 (defun vc-before-save ()
472 "Function to be called by `basic-save-buffer' (in files.el)."
473 ;; If the file on disk is still in sync with the repository,
474 ;; and version backups should be made, copy the file to
475 ;; another name. This enables local diffs and local reverting.
476 (let ((file (buffer-file-name)))
477 (and (vc-backend file)
478 (vc-up-to-date-p file)
479 (eq (vc-checkout-model file) 'implicit)
480 (vc-call make-version-backups file)
481 (copy-file file (vc-version-backup-file-name file)
482 'ok-if-already-exists 'keep-date))))
461 483
462 (defun vc-after-save () 484 (defun vc-after-save ()
463 "Function to be called by `basic-save-buffer' (in files.el)." 485 "Function to be called by `basic-save-buffer' (in files.el)."
464 ;; If the file in the current buffer is under version control, 486 ;; If the file in the current buffer is under version control,
465 ;; up-to-date, and locking is not used for the file, set 487 ;; up-to-date, and locking is not used for the file, set