emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: `file-relative-name' for compressed files


From: Emilio Lopes
Subject: Re: `file-relative-name' for compressed files
Date: Sat, 12 Jun 2004 20:21:07 +0200
User-agent: Emacs Gnus

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  <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
                                                        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




reply via email to

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