bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4677: allow VC operations from dired


From: Dan Nicolaescu
Subject: bug#4677: allow VC operations from dired
Date: Sun, 11 Oct 2009 19:46:24 -0700 (PDT)

Juri Linkov <address@hidden> writes:

  > > 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)
  > 
  > Thanks, it works right except in one case: when called outside of
  > a repository controlled directory, it traverses all subdirectories
  > trying to find a repository (I think traversing subdirectories
  > makes no sense in this case) and later fails with:
  > 
  >   Wrong type argument: stringp, nil

Thanks.  Here's an updated patch.

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -u -p -r1.732 vc.el
--- vc.el       3 Oct 2009 18:29:26 -0000       1.732
+++ vc.el       12 Oct 2009 02:41:06 -0000
@@ -634,7 +631,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 +906,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 +942,11 @@
 
+
+(defun vc-dired-deduce-fileset ()
+  (let ((backend (vc-backend default-directory)))
+    (unless backend (error "Directory not under VC"))
+    (list backend
+       (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 +1618,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 +1913,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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]