changeset 74337:ee9b338cccea

2006-11-30 Micha¸«³l Cadilhac <michael.cadilhac@lrde.org> (ido-local-file-exists-p): New. Tell if a file exists locally, i.e. without using file name handlers. (ido-read-internal): Allow mono letter host names, avoiding the `c:' problem by testing if the file exists locally. (ido-complete, ido-make-file-list, ido-exhibit): Ditto.
author Kim F. Storm <storm@cua.dk>
date Thu, 30 Nov 2006 20:50:31 +0000
parents c94145f8e712
children 71dce30419e5
files lisp/ido.el
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ido.el	Thu Nov 30 20:50:07 2006 +0000
+++ b/lisp/ido.el	Thu Nov 30 20:50:31 2006 +0000
@@ -1142,6 +1142,11 @@
 	  (pop-to-buffer b t t)
 	  (setq truncate-lines t)))))
 
+(defun ido-local-file-exists-p (file)
+  "Tell if FILE exists locally."
+  (let (file-name-handler-alist)
+    (file-exists-p file)))
+
 (defun ido-unc-hosts (&optional query)
   "Return list of UNC host names."
   (let ((hosts
@@ -2068,8 +2073,9 @@
 	      (ido-set-current-directory (file-name-directory (substring ido-current-directory 0 -1))))
 	  (setq ido-set-default-item t))
 
-	 ((and (string-match (if ido-enable-tramp-completion "..[:@]\\'" "..:\\'") ido-selected)
-	       (ido-is-root-directory)) ;; Ange-ftp or Tramp
+	 ((and (string-match (if ido-enable-tramp-completion ".[:@]\\'" ".:\\'") ido-selected)
+	       (ido-is-root-directory) ;; Ange-ftp or Tramp
+	       (not (ido-local-file-exists-p ido-selected)))
 	  (ido-set-current-directory ido-current-directory ido-selected)
 	  (ido-trace "tramp prefix" ido-selected)
 	  (if (ido-is-slow-ftp-host)
@@ -2079,7 +2085,7 @@
 
 	 ((or (string-match "[/\\][^/\\]" ido-selected)
 	      (and (memq system-type '(windows-nt ms-dos))
-		   (string-match "\\`.:" ido-selected)))
+		   (string-match "\\`[a-zA-Z]:" ido-selected)))
 	  (ido-set-current-directory (file-name-directory ido-selected))
 	  (setq ido-set-default-item t))
 
@@ -2428,7 +2434,8 @@
      ((and (= 1 (length ido-matches))
 	   (not (and ido-enable-tramp-completion
 		     (string-equal ido-current-directory "/")
-		     (string-match "..[@:]\\'" (ido-name (car ido-matches))))))
+		     (string-match ".[@:]\\'" (ido-name (car ido-matches)))))
+		     (not (ido-local-file-exists-p (ido-name (car ido-matches)))))
       ;; only one choice, so select it.
       (if (not ido-confirm-unique-completion)
 	  (exit-minibuffer)
@@ -3438,9 +3445,11 @@
       (let ((default-directory ido-current-directory))
 	(ido-to-end ;; move ftp hosts and visited files to end
 	 (delq nil (mapcar
-		    (lambda (x) (if (or (string-match "..:\\'" x)
+		    (lambda (x) (if (or (and (string-match ".:\\'" x)
+					     (not (ido-local-file-exists-p x)))
 					(and (not (ido-final-slash x))
-					     (get-file-buffer x))) x))
+					     (let (file-name-handler-alist)
+					       (get-file-buffer x)))) x))
 		    ido-temp-list)))))
     (ido-to-end  ;; move . files to end
      (delq nil (mapcar
@@ -4154,8 +4163,9 @@
 	    (setq refresh t))
 	  ))
 
-	 ((and (string-match (if ido-enable-tramp-completion "..[:@]\\'" "..:\\'") contents)
-	       (ido-is-root-directory)) ;; Ange-ftp or tramp
+	 ((and (string-match (if ido-enable-tramp-completion ".[:@]\\'" ".:\\'") contents)
+	       (ido-is-root-directory) ;; Ange-ftp or tramp
+	       (not (ido-local-file-exists-p contents)))
 	  (ido-set-current-directory ido-current-directory contents)
 	  (when (ido-is-slow-ftp-host)
 	    (setq ido-exit 'fallback)