diff options
author | Dan Nicolaescu <dann@ics.uci.edu> | 2008-03-22 20:32:10 +0000 |
---|---|---|
committer | Dan Nicolaescu <dann@ics.uci.edu> | 2008-03-22 20:32:10 +0000 |
commit | e9e065e5b3af82c66716a1a3e82eea75f58d3c5e (patch) | |
tree | fdbeb75ce7ca8a1d2876ff1a05e2f833115be642 /lisp/vc.el | |
parent | 935f7c5a64fd4fddb602e8483050c230c9c6bbc3 (diff) | |
download | emacs-e9e065e5b3af82c66716a1a3e82eea75f58d3c5e.tar.gz |
(vc-status-prepare-status-buffer): New function.
(vc-status): Use it.
Diffstat (limited to 'lisp/vc.el')
-rw-r--r-- | lisp/vc.el | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 81d45870e64..c50b72f7d3f 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -2685,13 +2685,29 @@ With prefix arg READ-SWITCHES, specify a value to override ;; Must be in sync with vc-status-printer. (forward-char 25)) +(defun vc-status-prepare-status-buffer (dir &optional create-new) + "Find a *vc-status* buffer showing DIR, or create a new one." + (setq dir (expand-file-name dir)) + (let ((bname "*vc-status*")) + ;; Look for another *vc-status* buffer visiting the same directory. + (save-excursion + (unless create-new + (dolist (buffer (buffer-list)) + (set-buffer buffer) + (when (and (eq major-mode 'vc-status-mode) + (string= default-directory dir)) + (return buffer))))) + ;; Create a new *vc-status* buffer. + (with-current-buffer (create-file-buffer bname) + (cd dir) + (vc-setup-buffer (current-buffer)) + (current-buffer)))) + ;;;###autoload (defun vc-status (dir) "Show the VC status for DIR." (interactive "DVC status for directory: ") - (vc-setup-buffer "*vc-status*") - (switch-to-buffer "*vc-status*") - (cd dir) + (switch-to-buffer (vc-status-prepare-status-buffer dir)) (vc-status-mode)) (defvar vc-status-menu-map |