[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

address@hidden: Re: `file-relative-name' for compressed files]

From: Richard Stallman
Subject: address@hidden: Re: `file-relative-name' for compressed files]
Date: Sun, 13 Jun 2004 17:49:04 -0400

------- Start of forwarded message -------
To: address@hidden
Cc: address@hidden
Subject: Re: `file-relative-name' for compressed files
Organization: private
From: Emilio Lopes <address@hidden>
Mail-Followup-To: address@hidden, address@hidden
Date: Sat, 12 Jun 2004 20:21:07 +0200
In-Reply-To: <address@hidden> (Richard Stallman's
 message of "Fri, 11 Jun 2004 21:51:09 -0400")
X-Spam-Status: No, hits=-1.2 required=5.0
X-Spam-Checker-Version: SpamAssassin 2.55 (

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'

> 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

           ;; Test for different remote file system identification
            (let ((re (car (rassq hf file-name-handler-alist))))
                 (string-match re filename)
                 (substring filename 0 (match-end 0)))
                 (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  <address@hidden>

        * 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
      (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
           ;; Test for different drives on DOS/Windows
- --- 2913,2923 ----
          (file-name-as-directory (expand-file-name (or 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
           ;; Test for different drives on DOS/Windows
------- End of forwarded message -------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]