From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: support VC operations from dired Date: Sun, 20 Sep 2009 14:22:12 -0700 (PDT) Message-ID: <200909202122.n8KLMCIb028441@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253481945 30184 80.91.229.12 (20 Sep 2009 21:25:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Sep 2009 21:25:45 +0000 (UTC) Cc: emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 20 23:25:37 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MpTub-0006mO-FT for ged-emacs-devel@m.gmane.org; Sun, 20 Sep 2009 23:25:37 +0200 Original-Received: from localhost ([127.0.0.1]:43939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpTua-0002qA-Hb for ged-emacs-devel@m.gmane.org; Sun, 20 Sep 2009 17:25:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MpTuV-0002pm-RC for emacs-devel@gnu.org; Sun, 20 Sep 2009 17:25:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MpTuQ-0002p3-8i for emacs-devel@gnu.org; Sun, 20 Sep 2009 17:25:30 -0400 Original-Received: from [199.232.76.173] (port=49353 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpTuQ-0002p0-2V for emacs-devel@gnu.org; Sun, 20 Sep 2009 17:25:26 -0400 Original-Received: from sallyv2.ics.uci.edu ([128.195.1.120]:64864) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MpTuM-0002IS-T0; Sun, 20 Sep 2009 17:25:23 -0400 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by sallyv2.ics.uci.edu (8.13.8+Sun/8.13.8) with ESMTP id n8KLMDvn000906; Sun, 20 Sep 2009 14:22:13 -0700 (PDT) Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id n8KLMCIb028441; Sun, 20 Sep 2009 14:22:12 -0700 (PDT) Original-Lines: 50 X-ICS-MailScanner-Information: Please contact the ISP for more information X-ICS-MailScanner-ID: n8KLMDvn000906 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.44, required 5, autolearn=disabled, ALL_TRUSTED -1.44) X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115486 Archived-At: Here's a minimal patch (minimally tested too) to support diff and log from dired buffers. State changing operations seems to be more complicated to support, so an error is thrown (and this makes use of the vc-deduce-fileset's previously unused argument OBSERVER). I don't have much interest in working on this further, but if people find it useful, please check it in. Index: vc.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v retrieving revision 1.729 diff -u -3 -p -u -p -r1.729 vc.el --- vc.el 14 Sep 2009 04:38:56 -0000 1.729 +++ vc.el 20 Sep 2009 20:20:56 -0000 @@ -913,6 +913,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) @@ -943,6 +947,11 @@ current buffer." (list buffer-file-name)))) (t (error "No fileset is available here."))))) + +(defun vc-dired-deduce-fileset () + (list (vc-responsible-backend default-directory) + (dired-map-over-marks (dired-get-filename) nil))) + (defun vc-ensure-vc-buffer () "Make sure that the current buffer visits a version-controlled file." (cond @@ -1598,7 +1607,7 @@ saving the buffer." (if historic (call-interactively 'vc-version-diff) (when buffer-file-name (vc-buffer-sync not-urgent)) - (vc-diff-internal t (vc-deduce-fileset) nil nil (interactive-p)))) + (vc-diff-internal t (vc-deduce-fileset t) nil nil (interactive-p)))) ;;;###autoload (defun vc-root-diff (historic &optional not-urgent)