Commit 709822e8 authored by André Spiegel's avatar André Spiegel
Browse files

(with-vc-file, edit-vc-file): New macros.

parent fbddb98d
......@@ -5,7 +5,7 @@
;; Author: Eric S. Raymond <>
;; Maintainer: Andre Spiegel <>
;; $Id: vc.el,v 1.237 1998/09/10 21:50:05 fx Exp fx $
;; $Id: vc.el,v 1.238 1998/10/30 19:11:08 fx Exp spiegel $
;; This file is part of GNU Emacs.
......@@ -494,6 +494,39 @@ If nil, VC itself computes this value when it is first needed."
;; CVS
;;; Two macros for elisp programming
(defmacro with-vc-file (file comment &rest body)
"Execute BODY, checking out a writable copy of FILE first if necessary.
After BODY has been executed, check-in FILE with COMMENT (a string).
FILE is passed through `expand-file-name'; BODY executed within
`save-excursion'. If FILE is not under version control, or locked by
somebody else, signal error."
`(let ((file (expand-file-name ,file)))
(or (vc-registered file)
(error (format "File not under version control: `%s'" file)))
(let ((locking-user (vc-locking-user file)))
(cond ((and (not locking-user)
(eq (vc-checkout-model file) 'manual))
(vc-checkout file t))
((and (stringp locking-user)
(not (string= locking-user (vc-user-login-name))))
(error (format "`%s' is locking `%s'" locking-user file)))))
(vc-checkin file nil ,comment)))
(defmacro edit-vc-file (file comment &rest body)
"Edit FILE under version control, executing BODY. Checkin with COMMENT.
This macro uses `with-vc-file', passing args to it.
However, before executing BODY, find FILE, and after BODY, save buffer."
,file ,comment
(find-file ,file)
(defun vc-ensure-vc-buffer ()
;; Make sure that the current buffer visits a version-controlled file.
(if vc-dired-mode
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment