726 |
SETTINGS is an association list of property/value pairs. After |
SETTINGS is an association list of property/value pairs. After |
727 |
executing FORM, set those properties from SETTINGS that have not yet |
executing FORM, set those properties from SETTINGS that have not yet |
728 |
been updated to their corresponding values." |
been updated to their corresponding values." |
729 |
`(let ((vc-touched-properties (list t)) |
`(let ((vc-touched-properties (list t))) |
|
(filename ,file)) |
|
730 |
,form |
,form |
731 |
(mapcar (lambda (setting) |
(mapcar (lambda (setting) |
732 |
(let ((property (car setting))) |
(let ((property (car setting))) |
733 |
(unless (memq property vc-touched-properties) |
(unless (memq property vc-touched-properties) |
734 |
(put (intern filename vc-file-prop-obarray) |
(put (intern ,file vc-file-prop-obarray) |
735 |
property (cdr setting))))) |
property (cdr setting))))) |
736 |
,settings))) |
,settings))) |
737 |
|
|
750 |
FILE is passed through `expand-file-name'; BODY executed within |
FILE is passed through `expand-file-name'; BODY executed within |
751 |
`save-excursion'. If FILE is not under version control, or locked by |
`save-excursion'. If FILE is not under version control, or locked by |
752 |
somebody else, signal error." |
somebody else, signal error." |
753 |
`(let ((file (expand-file-name ,file))) |
(let ((filevar (make-symbol "file"))) |
754 |
(or (vc-backend file) |
`(let ((,filevar (expand-file-name ,file))) |
755 |
(error (format "File not under version control: `%s'" file))) |
(or (vc-backend ,filevar) |
756 |
(unless (vc-editable-p file) |
(error (format "File not under version control: `%s'" file))) |
757 |
(let ((state (vc-state file))) |
(unless (vc-editable-p ,filevar) |
758 |
(if (stringp state) (error (format "`%s' is locking `%s'" state file)) |
(let ((state (vc-state ,filevar))) |
759 |
(vc-checkout file t)))) |
(if (stringp state) |
760 |
(save-excursion |
(error (format "`%s' is locking `%s'" state ,filevar)) |
761 |
,@body) |
(vc-checkout ,filevar t)))) |
762 |
(vc-checkin file nil ,comment))) |
(save-excursion |
763 |
(put 'with-vc-file 'indent-function 1) |
,@body) |
764 |
|
(vc-checkin ,filevar nil ,comment)))) |
765 |
|
|
766 |
|
(put 'with-vc-file 'lisp-indent-function 2) |
767 |
|
|
768 |
;;;###autoload |
;;;###autoload |
769 |
(defmacro edit-vc-file (file comment &rest body) |
(defmacro edit-vc-file (file comment &rest body) |
771 |
Checkin with COMMENT after executing BODY. |
Checkin with COMMENT after executing BODY. |
772 |
This macro uses `with-vc-file', passing args to it. |
This macro uses `with-vc-file', passing args to it. |
773 |
However, before executing BODY, find FILE, and after BODY, save buffer." |
However, before executing BODY, find FILE, and after BODY, save buffer." |
774 |
`(with-vc-file |
(let ((filevar (make-symbol "file"))) |
775 |
,file ,comment |
`(let ((,filevar (expand-file-name ,file))) |
776 |
(set-buffer (find-file-noselect ,file)) |
(with-vc-file |
777 |
,@body |
,filevar ,comment |
778 |
(save-buffer))) |
(set-buffer (find-file-noselect ,filevar)) |
779 |
(put 'edit-vc-file 'indent-function 1) |
,@body |
780 |
|
(save-buffer))))) |
781 |
|
|
782 |
|
(put 'edit-vc-file 'lisp-indent-function 2) |
783 |
|
|
784 |
(defun vc-ensure-vc-buffer () |
(defun vc-ensure-vc-buffer () |
785 |
"Make sure that the current buffer visits a version-controlled file." |
"Make sure that the current buffer visits a version-controlled file." |