[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `file-relative-name' for compressed files
From: |
Michael Albinus |
Subject: |
Re: `file-relative-name' for compressed files |
Date: |
Sun, 13 Jun 2004 21:51:47 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Emilio Lopes <address@hidden> writes:
> But while working on this I've found another problem:
>
> (file-relative-name "/bar:/a/b/c/foo" "/xyz:/a/b/c/")
> => "../../../../ssh:bar:/a/b/c/foo"
>
> It should return "/bar:/a/b/c/foo".
>
> The problem seems to come from TRAMP. TRAMP comes in because the
> handler for remote files is `tramp-file-name-handler'.
>
> For the example above the expansion of the arguments gives:
>
> (expand-file-name "/bar:/a/b/c/foo")
> => "/ssh:bar:/a/b/c/foo"
>
> (expand-file-name "/xyz:/a/b/c/")
> => "/ssh:xyz:/a/b/c/"
>
> The piece of code bellow from `file-relative-name' compares the
> host name part of the filenames, but it's fooled by TRAMP's method
> specification: because both filenames begin with "/ssh:" (that's
> what matching the names against `re' returns), they seem to reside
> on the same machine and `file-relative-name' returns a relative
> filename.
>
> ;; Test for different remote file system identification
> (and
> hf
> (let ((re (car (rassq hf file-name-handler-alist))))
> (not
> (equal
> (and
> (string-match re filename)
> (substring filename 0 (match-end 0)))
> (and
> (string-match re directory)
> (substring directory 0 (match-end 0)))))))
>
> It seems that TRAMP's `tramp-file-name-regexp-unified' ("\\`/[^/:]+:")
> should be reworked to account for its extended filename syntax.
Instead of trusting that a regexp in file-name-handler-alist matches
the "remote" part of a filename (that's not documented this way), it
would be more clean to ask explicitely for it. Maybe a new function:
(defun file-name-remote-part (filename &optional directory)
"Return FILENAME part describing access to a remote host.
If FILENAME is not absolute, it returns the remote part of DIRECTORY
(default: `default-directory'). Missing defaults in FILENAME are expanded."
Example (with current Tramp syntax):
(file-name-remote-part "/bar:/a/b/c/foo")
=> "/ssh:address@hidden:"
This would simplify the life. An equivalent function returning the
local part could be the counterpart.
Best regards, Michael.
- `file-relative-name' for compressed files, Emilio Lopes, 2004/06/10
- Re: `file-relative-name' for compressed files, Richard Stallman, 2004/06/11
- Re: `file-relative-name' for compressed files, Emilio Lopes, 2004/06/12
- Re: `file-relative-name' for compressed files,
Michael Albinus <=
- Re: `file-relative-name' for compressed files, Richard Stallman, 2004/06/14
- Re: `file-relative-name' for compressed files, Michael Albinus, 2004/06/16
- Re: `file-relative-name' for compressed files, Richard Stallman, 2004/06/17
- Re: `file-relative-name' for compressed files, Kai Grossjohann, 2004/06/22
- Re: `file-relative-name' for compressed files, Richard Stallman, 2004/06/23
- Re: `file-relative-name' for compressed files, Kai Grossjohann, 2004/06/26
- Re: `file-relative-name' for compressed files, Emilio Lopes, 2004/06/27
- Re: `file-relative-name' for compressed files, Kai Grossjohann, 2004/06/27
- Re: `file-relative-name' for compressed files, Stefan, 2004/06/28
- Re: `file-relative-name' for compressed files, Richard Stallman, 2004/06/28