From: David PONCE <david.ponce@wanadoo.fr>
Subject: On DOS/Windows, unnecessary load of tramp by `file-relative-name'
Date: Thu, 24 Apr 2003 12:54:05 +0200 (CEST) [thread overview]
Message-ID: <21141901.1051181645426.JavaMail.www@wwinf0602> (raw)
Hi All,
Since the following change to files.el:
2003-03-29 Kai Großjohann <kai.grossjohann@gmx.net>
* 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 <larsh@math.ku.dk>.
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
next reply other threads:[~2003-04-24 10:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-24 10:54 David PONCE [this message]
2003-04-24 14:12 ` On DOS/Windows, unnecessary load of tramp by `file-relative-name' Kai Großjohann
2003-04-29 21:38 ` Stefan Monnier
2003-04-30 8:21 ` Kai Großjohann
-- strict thread matches above, loose matches on Subject: below --
2003-04-24 14:44 David PONCE
2003-04-25 13:23 ` Kai Großjohann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21141901.1051181645426.JavaMail.www@wwinf0602 \
--to=david.ponce@wanadoo.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.