all messages for Emacs-related lists mirrored at yhetil.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: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31  0:45 bug#21383: Static revisions in vc-working-revision Jonathan H
2015-08-31  4:45 ` Stefan Monnier
2015-08-31  8:47   ` Dmitry Gutov
2015-08-31 17:44     ` Stefan Monnier
2015-09-01  2:11       ` Dmitry Gutov
2015-09-01  3:55         ` Stefan Monnier
2015-09-01 12:05           ` Dmitry Gutov
2015-09-01 15:45             ` Stefan Monnier
2015-09-01 15:54               ` Dmitry Gutov
2015-09-01 16:52                 ` Stefan Monnier
2015-09-01 17:23                   ` Dmitry Gutov
2015-09-02  3:50                     ` Stefan Monnier
2015-09-02 10:49                       ` Dmitry Gutov
2015-09-02 22:44                         ` Jonathan H
2015-09-03 12:56                           ` Dmitry Gutov
2015-09-03 16:17                             ` Stefan Monnier
2015-09-03 17:34                               ` Jonathan H
2015-09-03 18:40                                 ` Dmitry Gutov
2015-09-03 20:07                                   ` Stefan Monnier
2015-09-03 22:32                                     ` Dmitry Gutov
2015-09-04 14:36                                       ` Stefan Monnier
2015-09-05  2:30                                         ` Dmitry Gutov
2015-09-03 16:04                         ` Stefan Monnier
2015-09-03 19:24                           ` Dmitry Gutov
2015-09-04  2:20                             ` Stefan Monnier
2015-09-05  3:08                               ` Dmitry Gutov
2015-09-05 15:12                                 ` Stefan Monnier
2015-09-05 20:30                                   ` Dmitry Gutov
2015-09-06 22:29                                     ` Stefan Monnier
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

* 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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.