------- Start of forwarded message ------- To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: `file-relative-name' for compressed files Organization: private From: Emilio Lopes <[EMAIL PROTECTED]> Mail-Followup-To: [EMAIL PROTECTED], [EMAIL PROTECTED] Date: Sat, 12 Jun 2004 20:21:07 +0200 In-Reply-To: <[EMAIL PROTECTED]> (Richard Stallman's message of "Fri, 11 Jun 2004 21:51:09 -0400") X-Spam-Status: No, hits=-1.2 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,PATCH_CONTEXT_DIFF, RCVD_IN_ORBS,REFERENCES,REPLY_WITH_QUOTES,SATISFACTION, USER_AGENT version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
Richard Stallman writes: > I think this is a cleaner fix, and it seems to work. Indeed. I'm not satisfied with having to mention `jka-compr-handler' explicitly. > Do you see any problem with it? Unfortunately it has problems with remote *compressed* files: (file-relative-name "/bar:/a/b/c/foo.gz" "/bar:/a/b/c/") => "/ssh:bar:/a/b/c/foo.gz" 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. I'm including here a reworked version of my fix for the problem I reported on my previous message: 2004-06-12 Emilio C. Lopes <[EMAIL PROTECTED]> * files.el (file-relative-name): Ignore `jka-compr-handler' when determining the handler of FILENAME. *** lisp/files.el.~1.702.~ Sat Jun 12 19:57:01 2004 - --- lisp/files.el Sat Jun 12 19:57:57 2004 *************** *** 2913,2920 **** (file-name-as-directory (expand-file-name (or directory default-directory)))) (setq filename (expand-file-name filename)) ! (let ((hf (find-file-name-handler filename 'file-remote-p)) ! (hd (find-file-name-handler directory 'file-remote-p))) (if ;; Conditions for separate trees (or ;; Test for different drives on DOS/Windows - --- 2913,2923 ---- (file-name-as-directory (expand-file-name (or directory default-directory)))) (setq filename (expand-file-name filename)) ! (let* ((inhibit-file-name-handlers ! (cons 'jka-compr-handler inhibit-file-name-handlers)) ! (inhibit-file-name-operation 'file-remote-p) ! (hf (find-file-name-handler filename 'file-remote-p)) ! (hd (find-file-name-handler directory 'file-remote-p))) (if ;; Conditions for separate trees (or ;; Test for different drives on DOS/Windows ------- End of forwarded message ------- _______________________________________________ Tramp-devel mailing list [EMAIL PROTECTED] http://lists.nongnu.org/mailman/listinfo/tramp-devel