Subject: Re: bug#12492: Acknowledgement (24.2.50; Open vc-dir buffer easier and faster)

From: Dmitry Gutov <[email-masked]>
Date: Sun, 23 Sep 2012 03:31:35 +0400

Same patch, with ChangeLog entries.
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-09-22 15:24:26 +0000
+++ lisp/ChangeLog	2012-09-22 23:29:54 +0000
@@ -1,3 +1,11 @@
+2012-09-22  Dmitry Gutov  <[email-masked]>
+
+	* vc/vc-hooks.el (vc-prefix-map): Bind vc-root-dir to "d".
+	(vc-menu-map): Make "VC Dir" menu item call vc-root-dir.
+
+	* vc/vc-dir.el (vc-dir): Don't refresh the buffer.
+	(vc-root-dir): New function.
+
 2012-09-22  Chong Yidong  <[email-masked]>
 
 	* repeat.el (repeat): Doc fix (Bug#12348).

=== modified file 'lisp/vc/vc-dir.el'
--- lisp/vc/vc-dir.el	2012-08-13 21:31:56 +0000
+++ lisp/vc/vc-dir.el	2012-09-22 23:25:15 +0000
@@ -1227,12 +1227,25 @@
     (setq backend (vc-responsible-backend dir)))
   (let (pop-up-windows)		      ; based on cvs-examine; bug#6204
     (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))
-  (if (derived-mode-p 'vc-dir-mode)
-      (vc-dir-refresh)
+  ;; If the mode matches, the buffer was only buried and should be up to date.
+  (unless (derived-mode-p 'vc-dir-mode)
     ;; FIXME: find a better way to pass the backend to `vc-dir-mode'.
     (let ((use-vc-backend backend))
       (vc-dir-mode))))
 
+;;;###autoload
+(defun vc-root-dir ()
+  "Show the VC status of the current buffer's repository.
+If the buffer is not visiting a version controlled file, or if
+the backend does not support function `root', prompt for
+directory.  See `vc-dir' for more details."
+  (interactive)
+  (let* ((backend (vc-backend (buffer-file-name)))
+         (dir (and backend (vc-call-backend backend 'root buffer-file-name))))
+    (if dir
+        (vc-dir dir backend)
+      (call-interactively 'vc-dir))))
+
 (defun vc-default-dir-extra-headers (_backend _dir)
   ;; Be loud by default to remind people to add code to display
   ;; backend specific headers.

=== modified file 'lisp/vc/vc-hooks.el'
--- lisp/vc/vc-hooks.el	2012-07-11 23:13:41 +0000
+++ lisp/vc/vc-hooks.el	2012-09-22 23:25:58 +0000
@@ -923,7 +923,7 @@
     (define-key map "a" 'vc-update-change-log)
     (define-key map "b" 'vc-switch-backend)
     (define-key map "c" 'vc-rollback)
-    (define-key map "d" 'vc-dir)
+    (define-key map "d" 'vc-root-dir)
     (define-key map "g" 'vc-annotate)
     (define-key map "h" 'vc-insert-headers)
     (define-key map "i" 'vc-register)
@@ -1005,9 +1005,9 @@
     (bindings--define-key map [vc-register]
       '(menu-item "Register" vc-register
 		  :help "Register file set into a version control system"))
-    (bindings--define-key map [vc-dir]
-      '(menu-item "VC Dir"  vc-dir
-		  :help "Show the VC status of files in a directory"))
+    (bindings--define-key map [vc-root-dir]
+      '(menu-item "VC Dir"  vc-root-dir
+		  :help "Show the VC status of the repository"))
     map))
 
 (defalias 'vc-menu-map vc-menu-map)