From 10b19e8897234fe0d51245bbbe3048c548568a3e Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Thu, 30 Nov 2006 20:50:31 +0000 Subject: [PATCH] =?utf8?q?2006-11-30=20=20Micha=C3=ABl=20Cadilhac=20=20=20(ido-local-file-exists-p):=20New.=20T?= =?utf8?q?ell=20if=20a=20file=20exists=20locally,=20i.e.=20without=20using?= =?utf8?q?=20file=20name=20handlers.=20(ido-read-internal):=20Allow=20mono?= =?utf8?q?=20letter=20host=20names,=20avoiding=20the=20`c:'=20problem=20by?= =?utf8?q?=20testing=20if=20the=20file=20exists=20locally.=20(ido-complete?= =?utf8?q?,=20ido-make-file-list,=20ido-exhibit):=20Ditto.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lisp/ido.el | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index 8844b12f5b7..0e18c4b5fde 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1142,6 +1142,11 @@ so that it doesn't interfere with other minibuffer usage.") (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 @@ If INITIAL is non-nil, it specifies the initial input string." (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 @@ If INITIAL is non-nil, it specifies the initial input string." ((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 @@ If INITIAL is non-nil, it specifies the initial input string." ((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 @@ for first matching file." (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 @@ For details of keybindings, do `\\[describe-function] ido-find-file'." (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) -- 2.39.2