From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Using different default-directory and relative paths in VC, Was: Re: bug#21383 Date: Mon, 7 Sep 2015 23:55:24 +0300 Message-ID: <55EDF9BC.3000605@yandex.ru> References: <55E41499.5030501@yandex.ru> <55E5094A.3010108@yandex.ru> <55E59487.1050804@yandex.ru> <55E5CA42.1080005@yandex.ru> <55E5DF1A.9010902@yandex.ru> <55E6D426.10105@yandex.ru> <55E89E83.6000501@yandex.ru> <55EA5CB0.9070007@yandex.ru> <55EB50D7.2030103@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1441659356 6938 80.91.229.3 (7 Sep 2015 20:55:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Sep 2015 20:55:56 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 07 22:55:48 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZZ3S4-0003uB-EJ for ged-emacs-devel@m.gmane.org; Mon, 07 Sep 2015 22:55:44 +0200 Original-Received: from localhost ([::1]:58747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ3S4-0004VN-2N for ged-emacs-devel@m.gmane.org; Mon, 07 Sep 2015 16:55:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ3Rx-0004VB-86 for emacs-devel@gnu.org; Mon, 07 Sep 2015 16:55:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ3Rt-0000G2-7y for emacs-devel@gnu.org; Mon, 07 Sep 2015 16:55:37 -0400 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:36829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ3Rs-0000Dl-Us for emacs-devel@gnu.org; Mon, 07 Sep 2015 16:55:33 -0400 Original-Received: by wicgb1 with SMTP id gb1so56574145wic.1 for ; Mon, 07 Sep 2015 13:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=NdThj7hVHW5Yx5gtNLhrUXB0wzVeQIQWGIrurKX1Eko=; b=B5eThlGmgBEIV54P78TgNPo1J/ydmmAcfsaaM1FSWXM3xs9+neHKiOZj0Zqfdpfs0a qLNqXGJd56YqD2KmP6InS0CExjRIeZBAF6ca0MifVGUJZda9Cf/rSxVpGLxHZgyxZcDr nvvdHL76JAs0QiU33jstHp03v6i5ytzl5x/lJ/8+IPxF/aAqlhSeX0Z8IuaZtyV2L0yM fprW2DjhINC6SvgF2eLRcnZY+T7mXpmfSYybx5r1C3a0qgWLQ4yS5q0wjXpg4qoa70T/ xvuIcWFSmd6FFXdiuaOQ6ZTX6YdUSyI+DZksOtrPuHgqbAxM43sJNpsZc1YbswekJO64 tq8A== X-Received: by 10.180.186.98 with SMTP id fj2mr8444382wic.58.1441659331696; Mon, 07 Sep 2015 13:55:31 -0700 (PDT) Original-Received: from [10.9.0.103] (nat.webazilla.com. [78.140.128.228]) by smtp.googlemail.com with ESMTPSA id lq9sm1218352wjb.35.2015.09.07.13.55.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 13:55:31 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Thunderbird/40.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:189677 Archived-At: On 09/07/2015 01:29 AM, Stefan Monnier wrote: >> Does vc-status get a relative file name as input? > > Currently, I don't think so. But that could be changed if needed. Hopefully not. >> b) how are you going to enforce it?. > > By checking all callers? That's an odd thing to do for an API. What if diff-hl calls vc-state with an absolute path? Will it get a slap on the wrist? >> (*) If we try to eliminate this duplication of info, we introduce >> duplication of effort inside VC. Seems to be pointless complexity. > > Clearly it's easy to get back the absolute file name with just > (expand-file-name ), and I don't see where we'd obviously get > duplication of efforts. So I'm not sure why you think it'd add complexity. I was thinking that due to assuming that default-directory will have to be bound to the root. But indeed, simply using the parent directory of the file in question should work well enough. Although when a command is passed a list of files, determining their common parent will require more effort. > What I do see as a problem is that it would require a careful > study&adjustment of the whole VC code. I'm not sure if the result would > be more complex or simpler, admittedly. I think it'd be about the same, > just with cleaner semantics. Something like the below might work, but it'll need to be done in every command, and some of them take a list of files; other ones take a directory and a set of files too. And we'll have to be on the lookout for commands that output relative paths when passed relative paths as input (like 'find' does). Note that if FILE is a relative name, (file-name-directory file) returns an unsuitable value. diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 3e6d2a9..e273c6d 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -475,10 +475,12 @@ status of this file. Otherwise, the value returned is one of: ;; FIXME: New (sub)states needed (?): ;; - `copied' and `moved' (might be handled by `removed' and `added') (or (vc-file-getprop file 'vc-state) - (when (> (length file) 0) ;Why?? --Stef - (setq backend (or backend (vc-responsible-backend file))) - (when backend - (vc-state-refresh file backend))))) + (let ((default-directory (file-name-directory file)) + (file (file-relative-name file))) + (when (> (length file) 0) ;Why?? --Stef + (setq backend (or backend (vc-responsible-backend file))) + (when backend + (vc-state-refresh file backend)))))) (defun vc-state-refresh (file backend) "Quickly recompute the `state' of FILE."