[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On DOS/Windows, unnecessary load of tramp by `file-relative-name'
From: |
David PONCE |
Subject: |
On DOS/Windows, unnecessary load of tramp by `file-relative-name' |
Date: |
Thu, 24 Apr 2003 12:54:05 +0200 (CEST) |
Hi All,
Since the following change to files.el:
2003-03-29 Kai Großjohann <address@hidden>
* files.el (file-relative-name): If FILENAME and DIRECTORY are
on different drives (on DOS/Windows) or use different
handlers, do like `expand-file-name' on FILENAME and return an
absolute name.
From Lars Hansen <address@hidden>.
I noticed that each time `file-relative-name' is called, tramp.el is
auto loaded, even if I don't access to remote files.
After some investigation, I found that `file-relative-name' put a
leading slash on file and directory names before comparing them to
find the relative name. On DOS/Windows, when the name begins with a
drive letter, for example "c:/emacs", `file-relative-name' actually
use this form internally: "/c:/emacs". Unfortunately that form
matches `tramp-file-name-regexp', which causes "tramp.el" to be loaded
when `file-relative-name' then calls `file-name-as-directory'.
To fix that, I propose the following patch to files.el:
Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.653
diff -c -r1.653 files.el
*** lisp/files.el 24 Apr 2003 01:58:40 -0000 1.653
--- lisp/files.el 24 Apr 2003 09:45:22 -0000
***************
*** 2884,2899 ****
default-directory))))
(setq filename (expand-file-name filename))
(let ((hf (find-file-name-handler filename 'file-local-copy))
! (hd (find-file-name-handler directory 'file-local-copy)))
(when (and hf (not (get hf 'file-remote-p))) (setq hf nil))
(when (and hd (not (get hd 'file-remote-p))) (setq hd nil))
(if ;; Conditions for separate trees
(or
;; Test for different drives on DOS/Windows
! (and
! (memq system-type '(ms-dos cygwin windows-nt))
! (not (string-equal (substring filename 0 2)
! (substring directory 0 2))))
;; Test for different remote file handlers
(not (eq hf hd))
;; Test for different remote file system identification
--- 2884,2899 ----
default-directory))))
(setq filename (expand-file-name filename))
(let ((hf (find-file-name-handler filename 'file-local-copy))
! (hd (find-file-name-handler directory 'file-local-copy))
! (test-drive (memq system-type '(ms-dos cygwin windows-nt))))
(when (and hf (not (get hf 'file-remote-p))) (setq hf nil))
(when (and hd (not (get hd 'file-remote-p))) (setq hd nil))
(if ;; Conditions for separate trees
(or
;; Test for different drives on DOS/Windows
! (and test-drive
! (not (string-equal (substring filename 0 2)
! (substring directory 0 2))))
;; Test for different remote file handlers
(not (eq hf hd))
;; Test for different remote file system identification
***************
*** 2909,2917 ****
(string-match re directory)
(substring directory 0 (match-end 0))))))))
filename
! (unless (eq (aref filename 0) ?/)
(setq filename (concat "/" filename)))
! (unless (eq (aref directory 0) ?/)
(setq directory (concat "/" directory)))
(let ((ancestor ".")
(filename-dir (file-name-as-directory filename)))
--- 2909,2922 ----
(string-match re directory)
(substring directory 0 (match-end 0))))))))
filename
! ;; On DOS/Windows, don't prefix filename with / if it starts
! ;; with a drive letter. That prevents unecessary loading of
! ;; "tramp", because "/C:" matches `tramp-file-name-regexp'!
! (unless (or (eq (aref filename 0) ?/)
! (and test-drive (string-match "^[A-Za-z]:" filename)))
(setq filename (concat "/" filename)))
! (unless (or (eq (aref directory 0) ?/)
! (and test-drive (string-match "^[A-Za-z]:" directory)))
(setq directory (concat "/" directory)))
(let ((ancestor ".")
(filename-dir (file-name-as-directory filename)))
Maybe is there a better way to fix that?
What do you think?
Sincerely,
David
In GNU Emacs 21.3.50.1 (i386-mingw-nt4.0.1381)
of 2003-04-24 on EBAT311
configured using `configure --with-gcc (3.2)'
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: ENU
locale-coding-system: iso-latin-1
default-enable-multibyte-characters: t
- On DOS/Windows, unnecessary load of tramp by `file-relative-name',
David PONCE <=