aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/vc-dir.el66
-rw-r--r--lisp/vc-hooks.el27
3 files changed, 63 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a0621474873..6b0069b7b04 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12009-09-29 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc-hooks.el (vc-dir-buffers): New var.
4 (vc-state-refresh): New function.
5 (vc-state): Use it.
6 (vc-after-save): Always ask the backend to recompute the new state.
7 Always call vc-dir if necessary, using vc-dir-buffers.
8 * vc-dir.el (vc-dir-prepare-status-buffer, vc-dir-resynch-file):
9 Use vc-dir-buffers.
10 (vc-dir-mode): Use vc-dir-buffers rather than after-save-hook.
11 (vc-dir-prepare-status-buffer, vc-dir-update)
12 (vc-dir-resync-directory-files, vc-dir-resynch-file, vc-dir-mode):
13 Don't call expand-file-name on default-directory.
14
12009-09-29 Juanma Barranquero <lekktu@gmail.com> 152009-09-29 Juanma Barranquero <lekktu@gmail.com>
2 16
3 * speedbar.el (speedbar-item-delete): 17 * speedbar.el (speedbar-item-delete):
diff --git a/lisp/vc-dir.el b/lisp/vc-dir.el
index b20e67b9488..f78ca1806c0 100644
--- a/lisp/vc-dir.el
+++ b/lisp/vc-dir.el
@@ -89,16 +89,16 @@ See `run-hooks'."
89(defun vc-dir-prepare-status-buffer (bname dir backend &optional create-new) 89(defun vc-dir-prepare-status-buffer (bname dir backend &optional create-new)
90 "Find a buffer named BNAME showing DIR, or create a new one." 90 "Find a buffer named BNAME showing DIR, or create a new one."
91 (setq dir (file-name-as-directory (expand-file-name dir))) 91 (setq dir (file-name-as-directory (expand-file-name dir)))
92 (let* 92 (let* ;; Look for another buffer name BNAME visiting the same directory.
93 ;; Look for another buffer name BNAME visiting the same directory. 93 ((buf (save-excursion
94 ((buf (save-excursion 94 (unless create-new
95 (unless create-new 95 (dolist (buffer vc-dir-buffers)
96 (dolist (buffer (buffer-list)) 96 (when (buffer-live-p buffer)
97 (set-buffer buffer) 97 (set-buffer buffer)
98 (when (and (derived-mode-p 'vc-dir-mode) 98 (when (and (derived-mode-p 'vc-dir-mode)
99 (eq vc-dir-backend backend) 99 (eq vc-dir-backend backend)
100 (string= (expand-file-name default-directory) dir)) 100 (string= default-directory dir))
101 (return buffer))))))) 101 (return buffer))))))))
102 (or buf 102 (or buf
103 ;; Create a new buffer named BNAME. 103 ;; Create a new buffer named BNAME.
104 (with-current-buffer (create-file-buffer bname) 104 (with-current-buffer (create-file-buffer bname)
@@ -360,7 +360,7 @@ If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
360 (unless node 360 (unless node
361 (ewoc-enter-last 361 (ewoc-enter-last
362 vc-ewoc (vc-dir-create-fileinfo 362 vc-ewoc (vc-dir-create-fileinfo
363 dotname nil nil nil (expand-file-name default-directory))) 363 dotname nil nil nil default-directory))
364 (setq node (ewoc-nth vc-ewoc 0))) 364 (setq node (ewoc-nth vc-ewoc 0)))
365 365
366 (while (and entry node) 366 (while (and entry node)
@@ -849,7 +849,7 @@ If it is a file, return the corresponding cons for the file itself."
849 ;; Update the entries for all the child files of DIRNAME shown in 849 ;; Update the entries for all the child files of DIRNAME shown in
850 ;; the current *vc-dir* buffer. 850 ;; the current *vc-dir* buffer.
851 (let ((files (vc-dir-find-child-files dirname)) 851 (let ((files (vc-dir-find-child-files dirname))
852 (ddir (expand-file-name default-directory)) 852 (ddir default-directory)
853 fileentries) 853 fileentries)
854 (when files 854 (when files
855 (dolist (crt files) 855 (dolist (crt files)
@@ -860,25 +860,25 @@ If it is a file, return the corresponding cons for the file itself."
860(defun vc-dir-resynch-file (&optional fname) 860(defun vc-dir-resynch-file (&optional fname)
861 "Update the entries for FNAME in any directory buffers that list it." 861 "Update the entries for FNAME in any directory buffers that list it."
862 (let ((file (or fname (expand-file-name buffer-file-name))) 862 (let ((file (or fname (expand-file-name buffer-file-name)))
863 (found-vc-dir-buf nil)) 863 (drop '()))
864 (save-excursion 864 (save-current-buffer
865 (dolist (status-buf (buffer-list)) 865 ;; look for a vc-dir buffer that might show this file.
866 (set-buffer status-buf) 866 (dolist (status-buf vc-dir-buffers)
867 ;; look for a vc-dir buffer that might show this file. 867 (if (not (buffer-live-p status-buf))
868 (when (derived-mode-p 'vc-dir-mode) 868 (push status-buf drop)
869 (setq found-vc-dir-buf t) 869 (set-buffer status-buf)
870 (let ((ddir (expand-file-name default-directory))) 870 (if (not (derived-mode-p 'vc-dir-mode))
871 (when (vc-string-prefix-p ddir file) 871 (push status-buf drop)
872 (if (file-directory-p file) 872 (let ((ddir default-directory))
873 (vc-dir-resync-directory-files file) 873 (when (vc-string-prefix-p ddir file)
874 (let ((state (vc-dir-recompute-file-state file ddir))) 874 (if (file-directory-p file)
875 (vc-dir-update 875 (vc-dir-resync-directory-files file)
876 (list state) 876 (let ((state (vc-dir-recompute-file-state file ddir)))
877 status-buf (eq (cadr state) 'up-to-date))))))))) 877 (vc-dir-update
878 ;; We didn't find any vc-dir buffers, remove the hook, it is 878 (list state)
879 ;; not needed. 879 status-buf (eq (cadr state) 'up-to-date))))))))))
880 (unless found-vc-dir-buf 880 ;; Remove out-of-date entries from vc-dir-buffers.
881 (remove-hook 'after-save-hook 'vc-dir-resynch-file)))) 881 (dolist (b drop) (setq vc-dir-buffers (delq b vc-dir-buffers)))))
882 882
883(defvar use-vc-backend) ;; dynamically bound 883(defvar use-vc-backend) ;; dynamically bound
884 884
@@ -928,8 +928,8 @@ the *vc-dir* buffer.
928 (set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer)) 928 (set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer))
929 (set (make-local-variable 'revert-buffer-function) 929 (set (make-local-variable 'revert-buffer-function)
930 'vc-dir-revert-buffer-function) 930 'vc-dir-revert-buffer-function)
931 (setq list-buffers-directory (expand-file-name default-directory)) 931 (setq list-buffers-directory default-directory)
932 (add-hook 'after-save-hook 'vc-dir-resynch-file) 932 (add-to-list 'vc-dir-buffers (current-buffer))
933 ;; Make sure that if the directory buffer is killed, the update 933 ;; Make sure that if the directory buffer is killed, the update
934 ;; process running in the background is also killed. 934 ;; process running in the background is also killed.
935 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) 935 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 3ce54881aee..125b57e3daa 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -517,12 +517,16 @@ status of this file."
517 ;; FIXME: New (sub)states needed (?): 517 ;; FIXME: New (sub)states needed (?):
518 ;; - `copied' and `moved' (might be handled by `removed' and `added') 518 ;; - `copied' and `moved' (might be handled by `removed' and `added')
519 (or (vc-file-getprop file 'vc-state) 519 (or (vc-file-getprop file 'vc-state)
520 (when (> (length file) 0) 520 (when (> (length file) 0) ;Why?? --Stef
521 (setq backend (or backend (vc-backend file))) 521 (setq backend (or backend (vc-backend file)))
522 (when backend 522 (when backend
523 (vc-file-setprop 523 (vc-state-refresh file backend)))))
524 file 'vc-state 524
525 (vc-call-backend backend 'state-heuristic file)))))) 525(defun vc-state-refresh (file backend)
526 "Quickly recompute the `state' of FILE."
527 (vc-file-setprop
528 file 'vc-state
529 (vc-call-backend backend 'state-heuristic file)))
526 530
527(defsubst vc-up-to-date-p (file) 531(defsubst vc-up-to-date-p (file)
528 "Convenience function that checks whether `vc-state' of FILE is `up-to-date'." 532 "Convenience function that checks whether `vc-state' of FILE is `up-to-date'."
@@ -728,6 +732,8 @@ Before doing that, check if there are any old backups and get rid of them."
728 732
729(declare-function vc-dir-resynch-file "vc-dir" (&optional fname)) 733(declare-function vc-dir-resynch-file "vc-dir" (&optional fname))
730 734
735(defvar vc-dir-buffers nil "List of vc-dir buffers.")
736
731(defun vc-after-save () 737(defun vc-after-save ()
732 "Function to be called by `basic-save-buffer' (in files.el)." 738 "Function to be called by `basic-save-buffer' (in files.el)."
733 ;; If the file in the current buffer is under version control, 739 ;; If the file in the current buffer is under version control,
@@ -743,14 +749,13 @@ Before doing that, check if there are any old backups and get rid of them."
743 ;; to avoid confusion. 749 ;; to avoid confusion.
744 (vc-file-setprop file 'vc-checkout-time nil)) 750 (vc-file-setprop file 'vc-checkout-time nil))
745 t) 751 t)
746 (vc-up-to-date-p file)
747 (eq (vc-checkout-model backend (list file)) 'implicit) 752 (eq (vc-checkout-model backend (list file)) 'implicit)
748 (vc-file-setprop file 'vc-state 'edited) 753 (vc-state-refresh file backend)
749 (vc-mode-line file backend) 754 (vc-mode-line file backend))
750 ;; Try to avoid unnecessary work, a *vc-dir* buffer is 755 ;; Try to avoid unnecessary work, a *vc-dir* buffer is
751 ;; present if and only if this is true. 756 ;; present if this is true.
752 (when (memq 'vc-dir-resynch-file after-save-hook) 757 (when vc-dir-buffers
753 (vc-dir-resynch-file file))))) 758 (vc-dir-resynch-file file))))
754 759
755(defvar vc-menu-entry 760(defvar vc-menu-entry
756 '(menu-item "Version Control" vc-menu-map 761 '(menu-item "Version Control" vc-menu-map