"Stephen J. Turnbull" <stephen(a)xemacs.org> writes:
>>>>> "Kai" == Kai Großjohann
<kai.grossjohann(a)gmx.net> writes:
Kai> It seems I misunderstood. I thought you were only talking
Kai> about the ".." interpretation. But it turns out you're
Kai> talking about the interpretation of "~" for remote files.
What I'm interested in is the semantics of remote file name expansion,
in particular, the _error_ semantics if the remote system is not
accessible.
It seems I didn't propose to change that :-)
Kai> What should be the result of
"/x/../me@home.net:/a/b"?
Kai> Maybe you're proposing that it should return
Kai> "/:/me@home.net:/a/b".
I'm not proposing that, although I think it's very reasonable to
suppose that /a/.. is / on localhost. What I'm worried about is
_unreasonable_ alternatives, interactions among file handlers and the
like, and operations that don't succeed. (Examples below.)
I see. I should be thinking more about the failing cases, perhaps.
I'm also worried about the fact that this means that file
handler
regexps that are written to be anchored at / are not.
Don't be worried. I'm doing changes in expand-file-name in order to
allow the regexes to stay anchored.
Kai> But what I meant by saying it's a file operation is
that
Kai> expand-file-name looks to see if its arg matches a regexp
Kai> from file-name-handler-alist. This does not necessarily
Kai> imply any disk access. It just implies that file handlers
Kai> can provide their own implementation of expand-file-name.
OK.
>> I suppose it's reasonable to interpret that you should look up
>> the user name on the remote system, but it's equally reasonable
>> to interpret that as an attempt to access the path
Kai> Which path?
The path being expanded.
I lost you there, it seems. Ah, maybe you mean that accessing the
file "/user@host:~/foo" could mean to access a directory named "~" in
the home directory on the remote host.
But Ange-FTP has been expanding ~ for many years now.
Kai> Okay. Here's another one; maybe this example
convinces you.
Kai> It does not use "~" at all.
No example that _succeeds_ is going to convince me. I can see that
the semantics proposed here on success are useful. What bothers me is
coming up with reasonable semantics on _failure_, which is going to be
fairly common (eg, if you're attempting to access Al Jazeera assets
this week).
Well. expand-file-name is only called when the file is accessed,
mostly. So how does "/jrl@host:~/foo" differ from
"/jrl@host:/home/jrl/foo" here? Both will fail if the remote host is
offline.
Kai> This means that people who wish to use EFS to access
another
Kai> host which just happens to provide an AFS filesystem, and
Kai> said people would like to access that, then they need to use
Kai> "/user@host:/../some/file".
Yuck! Who thought of that?
I don't know :-) But Emacs' expand-file-name has code to keep "/.."
at the beginning of the name because "/.." "is a super-root on
certain file systems".
But ... either EFS handles this purely textually, or you should
never hang on to the result of (expand-file-name
"/user@host:/../some/file") (because if AFS happens to be offline
when you expand-file-name, and EFS checks whether it's there, and
it's not, and the next handler reduces /user@host:/../ to /, you'll
never be able to get access without reinitializing the app).
I was kinda hoping that some kind of error would happen when AFS was
unavailable.
I don't know anything about it, but if it was NFS, then the NFS
client (ie, the host I'm accessing via EFS) would wait forever for
the NFS server (where the file actually resides) comes back online.
The user gets impatient and hits C-g.
Kai> IMHO, expand-file-name on "/a/../something"
should be the
Kai> same as expand-file-name on "/something".
Well, how about "/luser@parasite:/../user@host:/../foo"?
That should invoke the file handler for "/luser@parasite:" and let
that handle the rest. That file handler will have to decide how to
deal with "/..", but presumably it would do the same thing that Emacs
does on Unix...
And how about if that is written
(expand-file-name "/user@host:/../foo" "/luser@parasite:/..")
Same thing.
or
(concat "/luser@parasite:/.." "/user@host:/../foo")
concat is not a good way to do filename expansion: if you do (concat
"~/" "foo"), the result is different from (expand-file-name
"foo"
"~/").
But you knew that...
Presumably that is how you're going to get paths of the form
you're
talking about.
Kai> You were also talking about interactivity. It's not quite
Kai> clear to me what that means. Why is it important whether
Kai> expand-file-name is invoked after the user hits TAB in the
Kai> C-x C-f prompt or at some other time?
Because when it fails (and if it attempts to access remote hosts, it
_will_ fail, sooner rather than later), in the interactive case
there's someone who can (for almost all values of "Emacs user" :-)
pass a reverse Turing test to repair things. In the non-interactive
case (eg, init.el) bad things can happen before something intelligent
can intervene.
Just let the handler signal an error. Signaling errors is something
that happens often in Emacs, I guess there are useful mechanisms to
deal with it :-)
I guess what I really want most is restrictions and/or finer control
on what expand-file-name handlers can do. But I still have some
questions about the semantics of the feature you're proposing.
As you say, I'm going for consistency. At the moment, we have
(testing with XEmacs 21.4.6):
(expand-file-name "/tmp/../kai@localhost:~/../foo") => "/foo"
(expand-file-name "/kai@localhost:~/../foo") =>
"/kai@localhost:/home/foo"
With my suggestion, both return the same value (the second one).
I agree that it's kinda nice that expand-file-name doesn't have to
access the disk for local files, so it's sad that it has to access
"the disk" for remote files. But expand-file-name has been doing this
for many years now (since ange-ftp), so practically speaking, there
does not seem to be a problem with this.
--
A preposition is not a good thing to end a sentence with.