unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Using different default-directory and relative paths in VC, Was: Re: bug#21383
Date: Mon, 7 Sep 2015 23:55:24 +0300	[thread overview]
Message-ID: <55EDF9BC.3000605@yandex.ru> (raw)
In-Reply-To: <jwvzj0zmbkw.fsf-monnier+emacsbugs@gnu.org>

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 <FILE>), 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."




       reply	other threads:[~2015-09-07 20:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAAW2-ZfFt-D9VX_xU1Sp2tCL_59LreL3wCen0-Snia7H8mmrpA@mail.gmail.com>
     [not found] ` <jwvpp24t6cq.fsf-monnier+emacsbugs@gnu.org>
     [not found]   ` <55E41499.5030501@yandex.ru>
     [not found]     ` <jwvio7ve4o4.fsf-monnier+emacsbugs@gnu.org>
     [not found]       ` <55E5094A.3010108@yandex.ru>
     [not found]         ` <jwvmvx6sso7.fsf-monnier+emacsbugs@gnu.org>
     [not found]           ` <55E59487.1050804@yandex.ru>
     [not found]             ` <jwvtwreqh6n.fsf-monnier+emacsbugs@gnu.org>
     [not found]               ` <55E5CA42.1080005@yandex.ru>
     [not found]                 ` <jwv1teiqdz2.fsf-monnier+emacsbugs@gnu.org>
     [not found]                   ` <55E5DF1A.9010902@yandex.ru>
     [not found]                     ` <jwv4mjdqyad.fsf-monnier+emacsbugs@gnu.org>
     [not found]                       ` <55E6D426.10105@yandex.ru>
     [not found]                         ` <jwvegifmr7x.fsf-monnier+emacsbugs@gnu.org>
     [not found]                           ` <55E89E83.6000501@yandex.ru>
     [not found]                             ` <jwvmvx3j5ir.fsf-monnier+emacsbugs@gnu.org>
     [not found]                               ` <55EA5CB0.9070007@yandex.ru>
     [not found]                                 ` <jwvlhckhpnc.fsf-monnier+emacsbugs@gnu.org>
     [not found]                                   ` <55EB50D7.2030103@yandex.ru>
     [not found]                                     ` <jwvzj0zmbkw.fsf-monnier+emacsbugs@gnu.org>
2015-09-07 20:55                                       ` Dmitry Gutov [this message]
2015-09-07 22:33                                         ` Using different default-directory and relative paths in VC, Was: Re: bug#21383 Stefan Monnier
2015-09-07 23:29                                           ` Dmitry Gutov
2015-09-07 23:34                                             ` Dmitry Gutov
2015-09-08  1:31                                             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55EDF9BC.3000605@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).