From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David PONCE Newsgroups: gmane.emacs.devel Subject: On DOS/Windows, unnecessary load of tramp by `file-relative-name' Date: Thu, 24 Apr 2003 12:54:05 +0200 (CEST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <21141901.1051181645426.JavaMail.www@wwinf0602> Reply-To: david.ponce@wanadoo.fr NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1051182500 25579 80.91.224.249 (24 Apr 2003 11:08:20 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 24 Apr 2003 11:08:20 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Apr 24 13:08:18 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 198eaQ-0006eP-00 for ; Thu, 24 Apr 2003 13:08:18 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 198egc-0002IC-00 for ; Thu, 24 Apr 2003 13:14:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 198eXJ-0000SM-01 for emacs-devel@quimby.gnus.org; Thu, 24 Apr 2003 07:05:05 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 198eVq-0000KB-00 for emacs-devel@gnu.org; Thu, 24 Apr 2003 07:03:34 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 198eTI-0008C5-00 for emacs-devel@gnu.org; Thu, 24 Apr 2003 07:00:59 -0400 Original-Received: from smtp1.wanadoo.fr ([193.252.22.25] helo=mwinf0603.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 198eMk-0007QP-00 for emacs-devel@gnu.org; Thu, 24 Apr 2003 06:54:11 -0400 Original-Received: from wwinf0602 (wwinf0602 [172.22.137.29]) by mwinf0603.wanadoo.fr (SMTP Server) with ESMTP id 6B9982400242 for ; Thu, 24 Apr 2003 12:54:05 +0200 (CEST) Original-To: emacs-devel X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13421 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13421 Hi All, Since the following change to files.el: 2003-03-29 Kai Gro=DFjohann * 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 . 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/lisp/files.el,v retrieving revision 1.653 diff -c -r1.653 files.el *** lisp/files.el=0924 Apr 2003 01:58:40 -0000=091.653 --- lisp/files.el=0924 Apr 2003 09:45:22 -0000 *************** *** 2884,2899 **** =09=09=09=09=09=09=09default-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 =09 (or =09 ;; Test for different drives on DOS/Windows ! =09 (and ! =09 (memq system-type '(ms-dos cygwin windows-nt)) ! =09 (not (string-equal (substring filename 0 2) ! =09=09=09 (substring directory 0 2)))) =09 ;; Test for different remote file handlers =09 (not (eq hf hd)) =09 ;; Test for different remote file system identification --- 2884,2899 ---- =09=09=09=09=09=09=09default-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 =09 (or =09 ;; Test for different drives on DOS/Windows ! =09 (and test-drive ! (not (string-equal (substring filename 0 2) ! (substring directory 0 2)))) =09 ;; Test for different remote file handlers =09 (not (eq hf hd)) =09 ;; Test for different remote file system identification *************** *** 2909,2917 **** =09=09 (string-match re directory) =09=09 (substring directory 0 (match-end 0)))))))) =09 filename ! (unless (eq (aref filename 0) ?/) =09 (setq filename (concat "/" filename))) ! (unless (eq (aref directory 0) ?/) =09 (setq directory (concat "/" directory))) (let ((ancestor ".") =09 (filename-dir (file-name-as-directory filename))) --- 2909,2922 ---- =09=09 (string-match re directory) =09=09 (substring directory 0 (match-end 0)))))))) =09 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))= ) =09 (setq filename (concat "/" filename))) ! (unless (or (eq (aref directory 0) ?/) ! (and test-drive (string-match "^[A-Za-z]:" directory)= )) =09 (setq directory (concat "/" directory))) (let ((ancestor ".") =09 (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