Commit 4fe2e5ed authored by Eric S. Raymond's avatar Eric S. Raymond

Merege two functions in preparation for removing dired.

parent e6244c1b
...@@ -567,10 +567,7 @@ editing!" ...@@ -567,10 +567,7 @@ editing!"
(when buffer (when buffer
(with-current-buffer buffer (with-current-buffer buffer
(vc-resynch-window file keep noquery))))) (vc-resynch-window file keep noquery)))))
(vc-directory-resynch-file file) (vc-directory-resynch-file file))
(when (memq 'vc-dir-mark-buffer-changed after-save-hook)
(let ((buffer (get-file-buffer file)))
(vc-dir-mark-buffer-changed file))))
;; Command closures ;; Command closures
...@@ -850,20 +847,6 @@ This code, like dired, assumes UNIX -l format." ...@@ -850,20 +847,6 @@ This code, like dired, assumes UNIX -l format."
(push buffer result))))) (push buffer result)))))
(nreverse result))) (nreverse result)))
(defun vc-directory-resynch-file (file)
"Update the entries for FILE in any VC Dired buffers that list it."
;;FIXME This needs to be implemented so it works for vc-dir
(let ((buffers (vc-dired-buffers-for-dir (file-name-directory file))))
(when buffers
(mapcar (lambda (buffer)
(with-current-buffer buffer
(when (dired-goto-file file)
;; bind vc-dired-terse-mode to nil so that
;; files won't vanish when they are checked in
(let ((vc-dired-terse-mode nil))
(dired-do-redisplay 1)))))
buffers))))
;;;###autoload ;;;###autoload
(defun vc-directory (dir read-switches) (defun vc-directory (dir read-switches)
"Create a buffer in VC Dired Mode for directory DIR. "Create a buffer in VC Dired Mode for directory DIR.
...@@ -1559,32 +1542,45 @@ that share the same state." ...@@ -1559,32 +1542,45 @@ that share the same state."
(setq crt (ewoc-next vc-ewoc crt))))) (setq crt (ewoc-next vc-ewoc crt)))))
result)) result))
(defun vc-dir-mark-buffer-changed (&optional fname) (defun vc-directory-resynch-file (&optional fname)
(let* ((file (or fname (expand-file-name buffer-file-name))) "Update the entries for FILE in any directory buffers that list it."
(found-vc-dir-buf nil)) (let ((file (or fname (expand-file-name buffer-file-name))))
(save-excursion ;; The VC-Dired case
(dolist (status-buf (buffer-list)) (let ((buffers (vc-dired-buffers-for-dir (file-name-directory file))))
(set-buffer status-buf) (when buffers
;; look for a vc-dir buffer that might show this file. (mapc (lambda (buffer)
(when (eq major-mode 'vc-dir-mode) (with-current-buffer buffer
(setq found-vc-dir-buf t) (when (dired-goto-file file)
(let ((ddir (expand-file-name default-directory))) ;; bind vc-dired-terse-mode to nil so that
;; This test is cvs-string-prefix-p ;; files won't vanish when they are checked in
(when (eq t (compare-strings file nil (length ddir) ddir nil nil)) (let ((vc-dired-terse-mode nil))
(let* (dired-do-redisplay 1)))))
((file-short (substring file (length ddir))) buffers)))
(state ;; The vc-dir case
(funcall (vc-client-object->file-to-state vc-client-mode) (let ((found-vc-dir-buf nil))
file)) (save-excursion
(extra (dolist (status-buf (buffer-list))
(funcall (vc-client-object->file-to-extra vc-client-mode) (set-buffer status-buf)
file)) ;; look for a vc-dir buffer that might show this file.
(entry (when (eq major-mode 'vc-dir-mode)
(list file-short state extra))) (setq found-vc-dir-buf t)
(vc-dir-update (list entry) status-buf)))))) (let ((ddir (expand-file-name default-directory)))
;; We didn't find any vc-dir buffers, remove the hook, it is ;; This test is cvs-string-prefix-p
;; not needed. (when (eq t (compare-strings file nil (length ddir) ddir nil nil))
(unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-mark-buffer-changed))))) (let*
((file-short (substring file (length ddir)))
(state
(funcall (vc-client-object->file-to-state vc-client-mode)
file))
(extra
(funcall (vc-client-object->file-to-extra vc-client-mode)
file))
(entry
(list file-short state extra)))
(vc-dir-update (list entry) status-buf))))))
;; We didn't find any vc-dir buffers, remove the hook, it is
;; not needed.
(unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-directory-resynch-file))))))
(defun vc-dir-mode (client-object) (defun vc-dir-mode (client-object)
"Major mode for showing the VC status for a directory. "Major mode for showing the VC status for a directory.
...@@ -1619,7 +1615,7 @@ U - if the cursor is on a file: unmark all the files with the same VC state ...@@ -1619,7 +1615,7 @@ U - if the cursor is on a file: unmark all the files with the same VC state
(set (make-local-variable 'vc-ewoc) (set (make-local-variable 'vc-ewoc)
(ewoc-create (vc-client-object->file-to-info client-object) (ewoc-create (vc-client-object->file-to-info client-object)
(vc-client-object->headers client-object))) (vc-client-object->headers client-object)))
(add-hook 'after-save-hook 'vc-dir-mark-buffer-changed) (add-hook 'after-save-hook 'vc-directory-resynch-file)
;; Make sure that if the VC status buffer is killed, the update ;; Make sure that if the VC status buffer is killed, the update
;; process running in the background is also killed. ;; process running in the background is also killed.
(add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
......
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