[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: file-relative-name and remote files
From: |
Lars Hansen |
Subject: |
Re: file-relative-name and remote files |
Date: |
Mon, 24 Feb 2003 22:24:37 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2.1) Gecko/20021130 |
> file-relative-name assumes that filename and directory is part of the
> same tree except when we are on a DOS/Windows system and the first two
> chars in the expanded file names (the drive) are not equal. This
> approach does not work with remote files. With remote files filename
> and directory may reside in different trees.
Could someone please supply an example, so we can see if that is really
true? I have doubts about it. A remote file name in Emacs is simply
an absolute file name whose first component is special. Ordinary relative
names ought to work for them.
Any file can be written as a name relative to any directory using the
".." construct, as long as
both are residing in the same directory tree. The problem is when they
reside in different trees.
But file-relative-name needs to know when this is so. Try
(file-relative-name "/dir/file" "/scp:address@hidden:/dir1/")
You need to replace "address@hidden" with a valid user and
server name,
since the expand-file-name call is handeled by Tramp. The above example
ought to return "/dir/file" since filename is on the local machine and
directory on the remote,
but in fact it returns "../../dir/file". This makes no sense.
Likewise
(file-relative-name "/scp:address@hidden:/dir1/file" "/dir/")
ought to return "/scp:address@hidden:dir1/file" but it does return
"../scp:address@hidden:/dir1/file".
It is possible that it might be preferable to return FILENAME unchanged
in the case where it and DIRECTORY are on different hosts.
If so, there is no need for a new file operation.
You can use file-remote-p to see if either one is remote.
Then you can see if the names have the same first component.
I don't understand the issue about a new file operation. I think we can keep
file-relative-name as a lisp function and implement it along the lines
proposed by
Stefan Monnier. We just need to decide that it is ok to settle for the
rules for
file handler invoking syntax I outlined earlier:
1. File names don't have a file-handler invoking syntax that is special
in the directory part and the base part at the same time.
2. Files not residing in the local directory tree have a file-handler
invoking syntax that is special in the directory part of the file name.
- file-relative-name and remote files, Lars Hansen, 2003/02/23
- Re: file-relative-name and remote files,
Lars Hansen <=
- Re: file-relative-name and remote files, Stefan Monnier, 2003/02/24
- Re: file-relative-name and remote files, Richard Stallman, 2003/02/25
- Re: file-relative-name and remote files, Kai Großjohann, 2003/02/27
- Re: file-relative-name and remote files, Kai Großjohann, 2003/02/27
- Re: file-relative-name and remote files, Andreas Schwab, 2003/02/27