Subject: allow VC operations from dired
From: Dan Nicolaescu <[email-masked]>
To: bug-gnu-emacs <[email-masked]>
Date: Thu, 8 Oct 2009 13:19:59 -0700 (PDT)

This patch allows VC operations to be run from dired.
State changing VC operations are not supported. 
(only the various variations of log and diff)

OK to check in?

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -r1.732 vc.el
--- vc.el	3 Oct 2009 18:29:26 -0000	1.732
+++ vc.el	8 Oct 2009 20:17:08 -0000
@@ -634,7 +634,8 @@
 (require 'vc-dispatcher)
 
 (eval-when-compile
-  (require 'cl))
+  (require 'cl)
+  (require 'dired))
 
 (unless (assoc 'vc-parent-buffer minor-mode-alist)
   (setq minor-mode-alist
@@ -889,6 +903,10 @@ current buffer."
     (cond
      ((derived-mode-p 'vc-dir-mode)
       (vc-dir-deduce-fileset state-model-only-files))
+     ((derived-mode-p 'dired-mode)
+      (if observer
+	  (vc-dired-deduce-fileset)
+	(error "State changing VC operations not supported in `dired-mode'")))
      ((setq backend (vc-backend buffer-file-name))
       (if state-model-only-files
 	(list backend (list buffer-file-name)
@@ -921,4 +939,9 @@
 
+
+(defun vc-dired-deduce-fileset ()
+  (list (vc-responsible-backend default-directory)
+	(dired-map-over-marks (dired-get-filename nil t) nil)))
+
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
   (cond
@@ -1590,6 +1613,7 @@ saving the buffer."
     (when buffer-file-name (vc-buffer-sync not-urgent))
     (let ((backend
 	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 		 (vc-mode (vc-backend buffer-file-name))))
 	  rootdir working-revision)
       (unless backend
@@ -1881,6 +1905,7 @@ If WORKING-REVISION is non-nil, leave th
   (interactive)
   (let ((backend
 	 (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+	       ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 	       (vc-mode (vc-backend buffer-file-name))))
 	rootdir working-revision)
     (unless backend