aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-05-08 17:41:16 +0000
committerStefan Monnier2003-05-08 17:41:16 +0000
commitb4e4e3a832bfe537d4db0a78bf95e17959f0c760 (patch)
tree8e9419ec0b73cdccd6dff983b5e0ccf3807a2b71
parent0c9b7dd84e7a8f5f58641616cd5914fffe1e022b (diff)
downloademacs-b4e4e3a832bfe537d4db0a78bf95e17959f0c760.tar.gz
emacs-b4e4e3a832bfe537d4db0a78bf95e17959f0c760.zip
(with-vc-properties, with-vc-file, edit-vc-file):
Add `declare's for debugging and indentation. (vc-do-command): Use `remq'. (vc-buffer-context): Remove unused var `curbuf'. (vc-next-action-dired): Remove unused var `dired-dir'. (vc-switches): New fun. (vc-diff-switches-list): Use it. (vc-dired-hook): Remove unused var `cvs-dir'. (vc-dired-purge): Remove unused var `subdir'. (vc-cancel-version): Remove unused var `config'. (vc-rename-master): Use dolist iso mapcar. (vc-rename-file): Remove redundant tests. Clear the properties of the old file name. (vc-annotate): Pass the complete filename to `annotate-command'. (vc-annotate-lines): Remove unused var `overlay'.
-rw-r--r--lisp/vc.el175
1 files changed, 83 insertions, 92 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index 504ca762996..c0d94a683ae 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -6,7 +6,7 @@
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.349 2003/02/05 23:13:21 lektu Exp $ 9;; $Id: vc.el,v 1.350 2003/02/19 18:56:38 spiegel Exp $
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12 12
@@ -751,6 +751,7 @@ as used by RCS and CVS."
751SETTINGS is an association list of property/value pairs. After 751SETTINGS is an association list of property/value pairs. After
752executing FORM, set those properties from SETTINGS that have not yet 752executing FORM, set those properties from SETTINGS that have not yet
753been updated to their corresponding values." 753been updated to their corresponding values."
754 (declare (debug t))
754 `(let ((vc-touched-properties (list t))) 755 `(let ((vc-touched-properties (list t)))
755 ,form 756 ,form
756 (mapcar (lambda (setting) 757 (mapcar (lambda (setting)
@@ -775,6 +776,7 @@ Check in FILE with COMMENT (a string) after BODY has been executed.
775FILE is passed through `expand-file-name'; BODY executed within 776FILE is passed through `expand-file-name'; BODY executed within
776`save-excursion'. If FILE is not under version control, or locked by 777`save-excursion'. If FILE is not under version control, or locked by
777somebody else, signal error." 778somebody else, signal error."
779 (declare (debug t) (indent 2))
778 (let ((filevar (make-symbol "file"))) 780 (let ((filevar (make-symbol "file")))
779 `(let ((,filevar (expand-file-name ,file))) 781 `(let ((,filevar (expand-file-name ,file)))
780 (or (vc-backend ,filevar) 782 (or (vc-backend ,filevar)
@@ -788,14 +790,13 @@ somebody else, signal error."
788 ,@body) 790 ,@body)
789 (vc-checkin ,filevar nil ,comment)))) 791 (vc-checkin ,filevar nil ,comment))))
790 792
791(put 'with-vc-file 'lisp-indent-function 2)
792
793;;;###autoload 793;;;###autoload
794(defmacro edit-vc-file (file comment &rest body) 794(defmacro edit-vc-file (file comment &rest body)
795 "Edit FILE under version control, executing body. 795 "Edit FILE under version control, executing body.
796Checkin with COMMENT after executing BODY. 796Checkin with COMMENT after executing BODY.
797This macro uses `with-vc-file', passing args to it. 797This macro uses `with-vc-file', passing args to it.
798However, before executing BODY, find FILE, and after BODY, save buffer." 798However, before executing BODY, find FILE, and after BODY, save buffer."
799 (declare (debug t) (indent 2))
799 (let ((filevar (make-symbol "file"))) 800 (let ((filevar (make-symbol "file")))
800 `(let ((,filevar (expand-file-name ,file))) 801 `(let ((,filevar (expand-file-name ,file)))
801 (with-vc-file 802 (with-vc-file
@@ -804,8 +805,6 @@ However, before executing BODY, find FILE, and after BODY, save buffer."
804 ,@body 805 ,@body
805 (save-buffer))))) 806 (save-buffer)))))
806 807
807(put 'edit-vc-file 'lisp-indent-function 2)
808
809(defun vc-ensure-vc-buffer () 808(defun vc-ensure-vc-buffer ()
810 "Make sure that the current buffer visits a version-controlled file." 809 "Make sure that the current buffer visits a version-controlled file."
811 (if vc-dired-mode 810 (if vc-dired-mode
@@ -874,6 +873,7 @@ Else, add CODE to the process' sentinel."
874Each function is called inside the buffer in which the command was run 873Each function is called inside the buffer in which the command was run
875and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.") 874and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.")
876 875
876(defvar w32-quote-process-args)
877;;;###autoload 877;;;###autoload
878(defun vc-do-command (buffer okstatus command file &rest flags) 878(defun vc-do-command (buffer okstatus command file &rest flags)
879 "Execute a VC command, notifying user and checking for errors. 879 "Execute a VC command, notifying user and checking for errors.
@@ -895,10 +895,9 @@ that is inserted into the command line before the filename."
895 (string= (buffer-name) buffer)) 895 (string= (buffer-name) buffer))
896 (eq buffer (current-buffer))) 896 (eq buffer (current-buffer)))
897 (vc-setup-buffer buffer)) 897 (vc-setup-buffer buffer))
898 (let ((squeezed nil) 898 (let ((squeezed (remq nil flags))
899 (inhibit-read-only t) 899 (inhibit-read-only t)
900 (status 0)) 900 (status 0))
901 (setq squeezed (delq nil (copy-sequence flags)))
902 (when file 901 (when file
903 ;; FIXME: file-relative-name can return a bogus result because 902 ;; FIXME: file-relative-name can return a bogus result because
904 ;; it doesn't look at the actual file-system to see if symlinks 903 ;; it doesn't look at the actual file-system to see if symlinks
@@ -986,27 +985,26 @@ Used by `vc-restore-buffer-context' to later restore the context."
986 (mark-active nil) 985 (mark-active nil)
987 ;; We may want to reparse the compilation buffer after revert 986 ;; We may want to reparse the compilation buffer after revert
988 (reparse (and (boundp 'compilation-error-list) ;compile loaded 987 (reparse (and (boundp 'compilation-error-list) ;compile loaded
989 (let ((curbuf (current-buffer))) 988 ;; Construct a list; each elt is nil or a buffer
990 ;; Construct a list; each elt is nil or a buffer 989 ;; iff that buffer is a compilation output buffer
991 ;; iff that buffer is a compilation output buffer 990 ;; that contains markers into the current buffer.
992 ;; that contains markers into the current buffer. 991 (save-current-buffer
993 (save-excursion 992 (mapcar (lambda (buffer)
994 (mapcar (lambda (buffer) 993 (set-buffer buffer)
995 (set-buffer buffer) 994 (let ((errors (or
996 (let ((errors (or 995 compilation-old-error-list
997 compilation-old-error-list 996 compilation-error-list))
998 compilation-error-list)) 997 (buffer-error-marked-p nil))
999 (buffer-error-marked-p nil)) 998 (while (and (consp errors)
1000 (while (and (consp errors) 999 (not buffer-error-marked-p))
1001 (not buffer-error-marked-p)) 1000 (and (markerp (cdr (car errors)))
1002 (and (markerp (cdr (car errors))) 1001 (eq buffer
1003 (eq buffer 1002 (marker-buffer
1004 (marker-buffer 1003 (cdr (car errors))))
1005 (cdr (car errors)))) 1004 (setq buffer-error-marked-p t))
1006 (setq buffer-error-marked-p t)) 1005 (setq errors (cdr errors)))
1007 (setq errors (cdr errors))) 1006 (if buffer-error-marked-p buffer)))
1008 (if buffer-error-marked-p buffer))) 1007 (buffer-list))))))
1009 (buffer-list)))))))
1010 (list point-context mark-context reparse))) 1008 (list point-context mark-context reparse)))
1011 1009
1012(defun vc-restore-buffer-context (context) 1010(defun vc-restore-buffer-context (context)
@@ -1232,8 +1230,7 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
1232(defun vc-next-action-dired (file rev comment) 1230(defun vc-next-action-dired (file rev comment)
1233 "Call `vc-next-action-on-file' on all the marked files. 1231 "Call `vc-next-action-on-file' on all the marked files.
1234Ignores FILE and REV, but passes on COMMENT." 1232Ignores FILE and REV, but passes on COMMENT."
1235 (let ((dired-buffer (current-buffer)) 1233 (let ((dired-buffer (current-buffer)))
1236 (dired-dir default-directory))
1237 (dired-map-over-marks 1234 (dired-map-over-marks
1238 (let ((file (dired-get-filename))) 1235 (let ((file (dired-get-filename)))
1239 (message "Processing %s..." file) 1236 (message "Processing %s..." file)
@@ -1855,29 +1852,31 @@ actually call the backend, but performs a local diff."
1855 (coding-system-for-read (vc-coding-system-for-diff file))) 1852 (coding-system-for-read (vc-coding-system-for-diff file)))
1856 (if (and file-rel1 file-rel2) 1853 (if (and file-rel1 file-rel2)
1857 (apply 'vc-do-command "*vc-diff*" 1 "diff" nil 1854 (apply 'vc-do-command "*vc-diff*" 1 "diff" nil
1858 (append (if (listp diff-switches) 1855 (append (vc-switches nil 'diff)
1859 diff-switches 1856 (list (file-relative-name file-rel1)
1860 (list diff-switches)) 1857 (file-relative-name file-rel2))))
1861 (if (listp vc-diff-switches)
1862 vc-diff-switches
1863 (list vc-diff-switches))
1864 (list (file-relative-name file-rel1)
1865 (file-relative-name file-rel2))))
1866 (vc-call diff file rel1 rel2)))) 1858 (vc-call diff file rel1 rel2))))
1867 1859
1868(defmacro vc-diff-switches-list (backend) 1860
1869 "Return the list of switches to use for executing diff under BACKEND." 1861(defun vc-switches (backend op)
1870 `(append 1862 (let ((switches
1871 (if (listp diff-switches) diff-switches (list diff-switches)) 1863 (or (if backend
1872 (if (listp vc-diff-switches) vc-diff-switches (list vc-diff-switches)) 1864 (let ((sym (vc-make-backend-sym
1873 (let* ((backend-switches-symbol 1865 backend (intern (concat (symbol-name op)
1874 (intern (concat "vc-" (downcase (symbol-name ,backend)) 1866 "-switches")))))
1875 "-diff-switches"))) 1867 (if (boundp sym) (symbol-value sym))))
1876 (backend-switches 1868 (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
1877 (if (boundp backend-switches-symbol) 1869 (if (boundp sym) (symbol-value sym)))
1878 (eval backend-switches-symbol) 1870 (cond
1879 nil))) 1871 ((eq op 'diff) diff-switches)))))
1880 (if (listp backend-switches) backend-switches (list backend-switches))))) 1872 (if (stringp switches) (list switches)
1873 ;; If not a list, return nil.
1874 ;; This is so we can set vc-diff-switches to t to override
1875 ;; any switches in diff-switches.
1876 (if (listp switches) switches))))
1877
1878(defun vc-diff-switches-list (backend) (vc-switches backend 'diff))
1879;; (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff))
1881 1880
1882(defun vc-default-diff-tree (backend dir rel1 rel2) 1881(defun vc-default-diff-tree (backend dir rel1 rel2)
1883 "List differences for all registered files at and below DIR. 1882 "List differences for all registered files at and below DIR.
@@ -2192,7 +2191,7 @@ This code, like dired, assumes UNIX -l format."
2192 "Reformat the listing according to version control. 2191 "Reformat the listing according to version control.
2193Called by dired after any portion of a vc-dired buffer has been read in." 2192Called by dired after any portion of a vc-dired buffer has been read in."
2194 (message "Getting version information... ") 2193 (message "Getting version information... ")
2195 (let (subdir filename (buffer-read-only nil) cvs-dir) 2194 (let (subdir filename (buffer-read-only nil))
2196 (goto-char (point-min)) 2195 (goto-char (point-min))
2197 (while (not (eobp)) 2196 (while (not (eobp))
2198 (cond 2197 (cond
@@ -2251,23 +2250,22 @@ Called by dired after any portion of a vc-dired buffer has been read in."
2251 2250
2252(defun vc-dired-purge () 2251(defun vc-dired-purge ()
2253 "Remove empty subdirs." 2252 "Remove empty subdirs."
2254 (let (subdir) 2253 (goto-char (point-min))
2255 (goto-char (point-min)) 2254 (while (dired-get-subdir)
2256 (while (setq subdir (dired-get-subdir)) 2255 (forward-line 2)
2257 (forward-line 2) 2256 (if (dired-get-filename nil t)
2258 (if (dired-get-filename nil t) 2257 (if (not (dired-next-subdir 1 t))
2259 (if (not (dired-next-subdir 1 t)) 2258 (goto-char (point-max)))
2260 (goto-char (point-max))) 2259 (forward-line -2)
2261 (forward-line -2) 2260 (if (not (string= (dired-current-directory) default-directory))
2262 (if (not (string= (dired-current-directory) default-directory)) 2261 (dired-do-kill-lines t "")
2263 (dired-do-kill-lines t "") 2262 ;; We cannot remove the top level directory.
2264 ;; We cannot remove the top level directory. 2263 ;; Just make it look a little nicer.
2265 ;; Just make it look a little nicer. 2264 (forward-line 1)
2266 (forward-line 1) 2265 (kill-line)
2267 (kill-line) 2266 (if (not (dired-next-subdir 1 t))
2268 (if (not (dired-next-subdir 1 t)) 2267 (goto-char (point-max))))))
2269 (goto-char (point-max)))))) 2268 (goto-char (point-min)))
2270 (goto-char (point-min))))
2271 2269
2272(defun vc-dired-buffers-for-dir (dir) 2270(defun vc-dired-buffers-for-dir (dir)
2273 "Return a list of all vc-dired buffers that currently display DIR." 2271 "Return a list of all vc-dired buffers that currently display DIR."
@@ -2565,8 +2563,7 @@ A prefix argument NOREVERT means do not revert the buffer afterwards."
2565 (vc-ensure-vc-buffer) 2563 (vc-ensure-vc-buffer)
2566 (let* ((file (buffer-file-name)) 2564 (let* ((file (buffer-file-name))
2567 (backend (vc-backend file)) 2565 (backend (vc-backend file))
2568 (target (vc-workfile-version file)) 2566 (target (vc-workfile-version file)))
2569 (config (current-window-configuration)) done)
2570 (cond 2567 (cond
2571 ((not (vc-find-backend-function backend 'cancel-version)) 2568 ((not (vc-find-backend-function backend 'cancel-version))
2572 (error "Sorry, canceling versions is not supported under %s" backend)) 2569 (error "Sorry, canceling versions is not supported under %s" backend))
@@ -2681,7 +2678,8 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
2681 ;; here and not in vc-revert-file because we don't want to 2678 ;; here and not in vc-revert-file because we don't want to
2682 ;; delete that copy -- it is still useful for OLD-BACKEND. 2679 ;; delete that copy -- it is still useful for OLD-BACKEND.
2683 (if unmodified-file 2680 (if unmodified-file
2684 (copy-file unmodified-file file 'ok-if-already-exists) 2681 (copy-file unmodified-file file
2682 'ok-if-already-exists 'keep-date)
2685 (if (y-or-n-p "Get base version from master? ") 2683 (if (y-or-n-p "Get base version from master? ")
2686 (vc-revert-file file)))) 2684 (vc-revert-file file))))
2687 (vc-call-backend new-backend 'receive-file file rev)) 2685 (vc-call-backend new-backend 'receive-file file rev))
@@ -2726,18 +2724,14 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
2726 oldmaster 2724 oldmaster
2727 (catch 'found 2725 (catch 'found
2728 ;; If possible, keep the master file in the same directory. 2726 ;; If possible, keep the master file in the same directory.
2729 (mapcar (lambda (f) 2727 (dolist (f masters)
2730 (if (and f (string= (file-name-directory (expand-file-name f)) 2728 (if (and f (string= (file-name-directory (expand-file-name f)) dir))
2731 dir)) 2729 (throw 'found f)))
2732 (throw 'found f)))
2733 masters)
2734 ;; If not, just use the first possible place. 2730 ;; If not, just use the first possible place.
2735 (mapcar (lambda (f) 2731 (dolist (f masters)
2736 (and f 2732 (and f (or (not (setq dir (file-name-directory f)))
2737 (or (not (setq dir (file-name-directory f))) 2733 (file-directory-p dir))
2738 (file-directory-p dir)) 2734 (throw 'found f)))
2739 (throw 'found f)))
2740 masters)
2741 (error "New file lacks a version control directory"))))) 2735 (error "New file lacks a version control directory")))))
2742 2736
2743;;;###autoload 2737;;;###autoload
@@ -2746,7 +2740,7 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
2746 (interactive "fVC rename file: \nFRename to: ") 2740 (interactive "fVC rename file: \nFRename to: ")
2747 (let ((oldbuf (get-file-buffer old)) 2741 (let ((oldbuf (get-file-buffer old))
2748 (backend (vc-backend old))) 2742 (backend (vc-backend old)))
2749 (unless (or (null backend) (vc-find-backend-function backend 'rename-file)) 2743 (unless (vc-find-backend-function backend 'rename-file)
2750 (error "Renaming files under %s is not supported in VC" backend)) 2744 (error "Renaming files under %s is not supported in VC" backend))
2751 (if (and oldbuf (buffer-modified-p oldbuf)) 2745 (if (and oldbuf (buffer-modified-p oldbuf))
2752 (error "Please save files before moving them")) 2746 (error "Please save files before moving them"))
@@ -2754,10 +2748,8 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
2754 (error "Already editing new file name")) 2748 (error "Already editing new file name"))
2755 (if (file-exists-p new) 2749 (if (file-exists-p new)
2756 (error "New file already exists")) 2750 (error "New file already exists"))
2757 (when backend 2751 (vc-call-backend backend 'rename-file old new)
2758 (if (and backend (not (vc-up-to-date-p old))) 2752 (vc-file-clearprops old)
2759 (error "Please check in files before moving them"))
2760 (vc-call-backend backend 'rename-file old new))
2761 ;; Move the actual file (unless the backend did it already) 2753 ;; Move the actual file (unless the backend did it already)
2762 (if (or (not backend) (file-exists-p old)) 2754 (if (or (not backend) (file-exists-p old))
2763 (rename-file old new)) 2755 (rename-file old new))
@@ -3056,14 +3048,14 @@ colors. `vc-annotate-background' specifies the background color."
3056 (float (string-to-number 3048 (float (string-to-number
3057 (read-string "Annotate span days: (default 20) " 3049 (read-string "Annotate span days: (default 20) "
3058 nil nil "20"))))) 3050 nil nil "20")))))
3059 (setq vc-annotate-backend (vc-backend (buffer-file-name))) 3051 (setq vc-annotate-backend (vc-backend buffer-file-name))
3060 (message "Annotating...") 3052 (message "Annotating...")
3061 (if (not (vc-find-backend-function vc-annotate-backend 'annotate-command)) 3053 (if (not (vc-find-backend-function vc-annotate-backend 'annotate-command))
3062 (error "Sorry, annotating is not implemented for %s" 3054 (error "Sorry, annotating is not implemented for %s"
3063 vc-annotate-backend)) 3055 vc-annotate-backend))
3064 (with-output-to-temp-buffer temp-buffer-name 3056 (with-output-to-temp-buffer temp-buffer-name
3065 (vc-call-backend vc-annotate-backend 'annotate-command 3057 (vc-call-backend vc-annotate-backend 'annotate-command
3066 (file-name-nondirectory (buffer-file-name)) 3058 buffer-file-name
3067 (get-buffer temp-buffer-name) 3059 (get-buffer temp-buffer-name)
3068 vc-annotate-version)) 3060 vc-annotate-version))
3069 ;; Don't use the temp-buffer-name until the buffer is created 3061 ;; Don't use the temp-buffer-name until the buffer is created
@@ -3151,8 +3143,7 @@ The annotations are relative to the current time, unless overridden by OFFSET."
3151 (set-face-background tmp-face 3143 (set-face-background tmp-face
3152 vc-annotate-background)) 3144 vc-annotate-background))
3153 tmp-face))) ; Return the face 3145 tmp-face))) ; Return the face
3154 (point (point)) 3146 (point (point)))
3155 overlay)
3156 (forward-line 1) 3147 (forward-line 1)
3157 (put-text-property point (point) 'face face))) 3148 (put-text-property point (point) 'face face)))
3158 ;; Pretend to font-lock there were no matches. 3149 ;; Pretend to font-lock there were no matches.