From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Rogers Newsgroups: gmane.emacs.bugs Subject: bug#7350: 24.0.50; make vc-deduce-backend smarter Date: Sun, 7 Nov 2010 16:41:08 -0500 Message-ID: <19671.7412.608640.593137@rgr.rgrjr.com> References: <19669.54304.980911.220632@rgr.rgrjr.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289168033 6328 80.91.229.12 (7 Nov 2010 22:13:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 7 Nov 2010 22:13:53 +0000 (UTC) Cc: 7350@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 07 23:13:48 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PFDUh-0000SP-Jt for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Nov 2010 23:13:47 +0100 Original-Received: from localhost ([127.0.0.1]:34180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFDUg-00009r-TJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Nov 2010 17:13:46 -0500 Original-Received: from [140.186.70.92] (port=36151 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFDUd-00009g-2v for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2010 17:13:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFDUb-0005BN-Ql for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2010 17:13:43 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFDUb-0005BA-LU for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2010 17:13:41 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PFDBa-00065f-7m; Sun, 07 Nov 2010 16:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Bob Rogers Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Nov 2010 21:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7350 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7350-submit@debbugs.gnu.org id=B7350.128916683423405 (code B ref 7350); Sun, 07 Nov 2010 21:54:02 +0000 Original-Received: (at 7350) by debbugs.gnu.org; 7 Nov 2010 21:53:54 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFDBR-00065S-TW for submit@debbugs.gnu.org; Sun, 07 Nov 2010 16:53:54 -0500 Original-Received: from rgrjr.com ([216.146.47.5]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFCug-0005z0-6M for 7350@debbugs.gnu.org; Sun, 07 Nov 2010 16:36:35 -0500 Original-Received: from rgrjr.dyndns.org (c-66-30-196-77.hsd1.ma.comcast.net [66.30.196.77]) by rgrjr.com (Postfix on CentOS) with ESMTP id CABD0160109 for <7350@debbugs.gnu.org>; Sun, 7 Nov 2010 21:41:09 +0000 (UTC) Original-Received: (qmail 3421 invoked by uid 89); 7 Nov 2010 21:41:09 -0000 Original-Received: from unknown (HELO rgr.rgrjr.com) (192.168.57.1) by home with SMTP; 7 Nov 2010 21:41:09 -0000 Original-Received: by rgr.rgrjr.com (Postfix, from userid 500) id EFE73A4E03; Sun, 7 Nov 2010 16:41:08 -0500 (EST) In-Reply-To: X-Mailer: VM 7.19 under Emacs 24.0.50.1 X-Mailman-Approved-At: Sun, 07 Nov 2010 16:53:52 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 07 Nov 2010 16:54:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41428 Archived-At: From: Stefan Monnier Date: Sun, 07 Nov 2010 15:03:16 -0500 > I notice that vc-root-diff only works if the current buffer is > visiting a version-controlled file, and in certain other buffer modes. > In particular, it works in dired-mode, where it uses the > default-directory, but not in shell-mode, which is not one of the > explicit special cases. Could you give an example use-case where you'd want vc-deduce-backend to be run in a shell-mode buffer? Stefan I have gotten into the habit of using a shell buffer to disambiguate which repo I want to use for general VC commands like vc-root-diff and vc-dir. Since I bind "shell" to f8, it is often faster to type "f8 C-x v d RET" than to supply an explicit pathname to vc-dir. (I'm often in the right shell buffer already, having just typed "make test".) Since vc-root-diff doesn't take a pathname arg, I have to do something explicit to get into the right tree anyway. So it makes sense to me that vc-root-diff should work like vc-dir in a non-VC buffer. There is already an exception for dired-mode; why not generalize? In fact, this is something of a regression from Emacs 22.x, where "C-u C-x v = . RET RET RET" would do the equivalent of (vc-version-diff (expand-file-name ".") nil nil) which is nearly vc-root-diff, regardless of buffer mode. This no longer works in the brave new world of filesets, so I had to revise my shorthand command to turn "." into a fileset. I was hoping that vc-root-diff (which I only stumbled over recently) would serve as a replacement, but it doesn't quite match my workflow because of this insistence on being in a VC buffer. As an aside, I often think that VC doesn't have a good enough notion of "current file set;" there are other times when it doesn't seem to DTRT. (Except for the change in vc-diff mentioned in the previous paragraph, I can't recall any examples off the top of my head). But so far I haven't had any ideas. In short, I don't have a killer use case -- I could just keep on using my own command for this -- but on the other hand, I don't see the need for limiting commands like vc-root-diff in this way. If you think that this is the wrong place to make this change, then the alternative patch below makes the same change to vc-root-diff directly. (And I'll let you know if I find any better use cases. ;-) -- Bob ------------------------------------------------------------------------ diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 665dafb..5c7fa81 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1682,7 +1682,9 @@ saving the buffer." ;; that's not what we want here, we want the diff for the VC root dir. (call-interactively 'vc-version-diff) (when buffer-file-name (vc-buffer-sync not-urgent)) - (let ((backend (vc-deduce-backend)) + (let ((backend (or (vc-deduce-backend) + (and default-directory + (vc-responsible-backend default-directory)))) rootdir working-revision) (unless backend (error "Buffer is not version controlled"))