Mercurial > emacs
comparison lisp/vc.el @ 41395:0abfca935c80
(with-vc-properties): Don't bind `filename' locally.
(with-vc-file, edit-vc-file): Use `make-symbol' for local bindings to
avoid name clashes. Fix `lisp-indent-function' property for both.
author | André Spiegel <spiegel@gnu.org> |
---|---|
date | Fri, 23 Nov 2001 10:11:29 +0000 |
parents | cb1ebde1c4c9 |
children | 678f91af978a |
comparison
equal
deleted
inserted
replaced
41394:6c7b3a4baa00 | 41395:0abfca935c80 |
---|---|
4 | 4 |
5 ;; Author: FSF (see below for full credits) | 5 ;; Author: FSF (see below for full credits) |
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
7 ;; Keywords: tools | 7 ;; Keywords: tools |
8 | 8 |
9 ;; $Id: vc.el,v 1.319 2001/11/12 23:01:17 sds Exp $ | 9 ;; $Id: vc.el,v 1.320 2001/11/15 10:31:17 spiegel Exp $ |
10 | 10 |
11 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
12 | 12 |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | 13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
14 ;; it under the terms of the GNU General Public License as published by | 14 ;; it under the terms of the GNU General Public License as published by |
724 (defmacro with-vc-properties (file form settings) | 724 (defmacro with-vc-properties (file form settings) |
725 "Execute FORM, then maybe set per-file properties for FILE. | 725 "Execute FORM, then maybe set per-file properties for FILE. |
726 SETTINGS is an association list of property/value pairs. After | 726 SETTINGS is an association list of property/value pairs. After |
727 executing FORM, set those properties from SETTINGS that have not yet | 727 executing FORM, set those properties from SETTINGS that have not yet |
728 been updated to their corresponding values." | 728 been updated to their corresponding values." |
729 `(let ((vc-touched-properties (list t)) | 729 `(let ((vc-touched-properties (list t))) |
730 (filename ,file)) | |
731 ,form | 730 ,form |
732 (mapcar (lambda (setting) | 731 (mapcar (lambda (setting) |
733 (let ((property (car setting))) | 732 (let ((property (car setting))) |
734 (unless (memq property vc-touched-properties) | 733 (unless (memq property vc-touched-properties) |
735 (put (intern filename vc-file-prop-obarray) | 734 (put (intern ,file vc-file-prop-obarray) |
736 property (cdr setting))))) | 735 property (cdr setting))))) |
737 ,settings))) | 736 ,settings))) |
738 | 737 |
739 ;; Random helper functions | 738 ;; Random helper functions |
740 | 739 |
749 "Check out a writable copy of FILE if necessary, then execute BODY. | 748 "Check out a writable copy of FILE if necessary, then execute BODY. |
750 Check in FILE with COMMENT (a string) after BODY has been executed. | 749 Check in FILE with COMMENT (a string) after BODY has been executed. |
751 FILE is passed through `expand-file-name'; BODY executed within | 750 FILE is passed through `expand-file-name'; BODY executed within |
752 `save-excursion'. If FILE is not under version control, or locked by | 751 `save-excursion'. If FILE is not under version control, or locked by |
753 somebody else, signal error." | 752 somebody else, signal error." |
754 `(let ((file (expand-file-name ,file))) | 753 (let ((filevar (make-symbol "file"))) |
755 (or (vc-backend file) | 754 `(let ((,filevar (expand-file-name ,file))) |
756 (error (format "File not under version control: `%s'" file))) | 755 (or (vc-backend ,filevar) |
757 (unless (vc-editable-p file) | 756 (error (format "File not under version control: `%s'" file))) |
758 (let ((state (vc-state file))) | 757 (unless (vc-editable-p ,filevar) |
759 (if (stringp state) (error (format "`%s' is locking `%s'" state file)) | 758 (let ((state (vc-state ,filevar))) |
760 (vc-checkout file t)))) | 759 (if (stringp state) |
761 (save-excursion | 760 (error (format "`%s' is locking `%s'" state ,filevar)) |
762 ,@body) | 761 (vc-checkout ,filevar t)))) |
763 (vc-checkin file nil ,comment))) | 762 (save-excursion |
764 (put 'with-vc-file 'indent-function 1) | 763 ,@body) |
764 (vc-checkin ,filevar nil ,comment)))) | |
765 | |
766 (put 'with-vc-file 'lisp-indent-function 2) | |
765 | 767 |
766 ;;;###autoload | 768 ;;;###autoload |
767 (defmacro edit-vc-file (file comment &rest body) | 769 (defmacro edit-vc-file (file comment &rest body) |
768 "Edit FILE under version control, executing body. | 770 "Edit FILE under version control, executing body. |
769 Checkin with COMMENT after executing BODY. | 771 Checkin with COMMENT after executing BODY. |
770 This macro uses `with-vc-file', passing args to it. | 772 This macro uses `with-vc-file', passing args to it. |
771 However, before executing BODY, find FILE, and after BODY, save buffer." | 773 However, before executing BODY, find FILE, and after BODY, save buffer." |
772 `(with-vc-file | 774 (let ((filevar (make-symbol "file"))) |
773 ,file ,comment | 775 `(let ((,filevar (expand-file-name ,file))) |
774 (set-buffer (find-file-noselect ,file)) | 776 (with-vc-file |
775 ,@body | 777 ,filevar ,comment |
776 (save-buffer))) | 778 (set-buffer (find-file-noselect ,filevar)) |
777 (put 'edit-vc-file 'indent-function 1) | 779 ,@body |
780 (save-buffer))))) | |
781 | |
782 (put 'edit-vc-file 'lisp-indent-function 2) | |
778 | 783 |
779 (defun vc-ensure-vc-buffer () | 784 (defun vc-ensure-vc-buffer () |
780 "Make sure that the current buffer visits a version-controlled file." | 785 "Make sure that the current buffer visits a version-controlled file." |
781 (if vc-dired-mode | 786 (if vc-dired-mode |
782 (set-buffer (find-file-noselect (dired-get-filename))) | 787 (set-buffer (find-file-noselect (dired-get-filename))) |