aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel1998-11-04 15:09:38 +0000
committerAndré Spiegel1998-11-04 15:09:38 +0000
commit709822e81357375f7184b719e949fbc63cbb5def (patch)
treeb0796ca586108dc01199424604a461c52d3822a9
parentfbddb98df162de9a860d332a9afcc633dd77d9af (diff)
downloademacs-709822e81357375f7184b719e949fbc63cbb5def.tar.gz
emacs-709822e81357375f7184b719e949fbc63cbb5def.zip
(with-vc-file, edit-vc-file): New macros.
-rw-r--r--lisp/vc.el35
1 files changed, 34 insertions, 1 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index e41dfd95b4d..4600defef4b 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -5,7 +5,7 @@
5;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 5;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
6;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de> 6;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
7 7
8;; $Id: vc.el,v 1.237 1998/09/10 21:50:05 fx Exp fx $ 8;; $Id: vc.el,v 1.238 1998/10/30 19:11:08 fx Exp spiegel $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -494,6 +494,39 @@ If nil, VC itself computes this value when it is first needed."
494 ;; CVS 494 ;; CVS
495 t)) 495 t))
496 496
497;;; Two macros for elisp programming
498;;;###autoload
499(defmacro with-vc-file (file comment &rest body)
500 "Execute BODY, checking out a writable copy of FILE first if necessary.
501After BODY has been executed, check-in FILE with COMMENT (a string).
502FILE is passed through `expand-file-name'; BODY executed within
503`save-excursion'. If FILE is not under version control, or locked by
504somebody else, signal error."
505 `(let ((file (expand-file-name ,file)))
506 (or (vc-registered file)
507 (error (format "File not under version control: `%s'" file)))
508 (let ((locking-user (vc-locking-user file)))
509 (cond ((and (not locking-user)
510 (eq (vc-checkout-model file) 'manual))
511 (vc-checkout file t))
512 ((and (stringp locking-user)
513 (not (string= locking-user (vc-user-login-name))))
514 (error (format "`%s' is locking `%s'" locking-user file)))))
515 (save-excursion
516 ,@body)
517 (vc-checkin file nil ,comment)))
518
519;;;###autoload
520(defmacro edit-vc-file (file comment &rest body)
521 "Edit FILE under version control, executing BODY. Checkin with COMMENT.
522This macro uses `with-vc-file', passing args to it.
523However, before executing BODY, find FILE, and after BODY, save buffer."
524 `(with-vc-file
525 ,file ,comment
526 (find-file ,file)
527 ,@body
528 (save-buffer)))
529
497(defun vc-ensure-vc-buffer () 530(defun vc-ensure-vc-buffer ()
498 ;; Make sure that the current buffer visits a version-controlled file. 531 ;; Make sure that the current buffer visits a version-controlled file.
499 (if vc-dired-mode 532 (if vc-dired-mode