Mercurial > emacs
comparison lisp/ido.el @ 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 | 9843dfd8d011 |
children | 3043e9ec901c f1d13e615070 |
comparison
equal
deleted
inserted
replaced
74336:c94145f8e712 | 74337:ee9b338cccea |
---|---|
1139 (if b | 1139 (if b |
1140 (if ido-trace-enable | 1140 (if ido-trace-enable |
1141 (kill-buffer b) | 1141 (kill-buffer b) |
1142 (pop-to-buffer b t t) | 1142 (pop-to-buffer b t t) |
1143 (setq truncate-lines t))))) | 1143 (setq truncate-lines t))))) |
1144 | |
1145 (defun ido-local-file-exists-p (file) | |
1146 "Tell if FILE exists locally." | |
1147 (let (file-name-handler-alist) | |
1148 (file-exists-p file))) | |
1144 | 1149 |
1145 (defun ido-unc-hosts (&optional query) | 1150 (defun ido-unc-hosts (&optional query) |
1146 "Return list of UNC host names." | 1151 "Return list of UNC host names." |
1147 (let ((hosts | 1152 (let ((hosts |
1148 (cond | 1153 (cond |
2066 ;; root-dir of a certain drive (Windows or MS-DOS). | 2071 ;; root-dir of a certain drive (Windows or MS-DOS). |
2067 (or (ido-is-root-directory) | 2072 (or (ido-is-root-directory) |
2068 (ido-set-current-directory (file-name-directory (substring ido-current-directory 0 -1)))) | 2073 (ido-set-current-directory (file-name-directory (substring ido-current-directory 0 -1)))) |
2069 (setq ido-set-default-item t)) | 2074 (setq ido-set-default-item t)) |
2070 | 2075 |
2071 ((and (string-match (if ido-enable-tramp-completion "..[:@]\\'" "..:\\'") ido-selected) | 2076 ((and (string-match (if ido-enable-tramp-completion ".[:@]\\'" ".:\\'") ido-selected) |
2072 (ido-is-root-directory)) ;; Ange-ftp or Tramp | 2077 (ido-is-root-directory) ;; Ange-ftp or Tramp |
2078 (not (ido-local-file-exists-p ido-selected))) | |
2073 (ido-set-current-directory ido-current-directory ido-selected) | 2079 (ido-set-current-directory ido-current-directory ido-selected) |
2074 (ido-trace "tramp prefix" ido-selected) | 2080 (ido-trace "tramp prefix" ido-selected) |
2075 (if (ido-is-slow-ftp-host) | 2081 (if (ido-is-slow-ftp-host) |
2076 (setq ido-exit 'fallback | 2082 (setq ido-exit 'fallback |
2077 done t) | 2083 done t) |
2078 (setq ido-set-default-item t))) | 2084 (setq ido-set-default-item t))) |
2079 | 2085 |
2080 ((or (string-match "[/\\][^/\\]" ido-selected) | 2086 ((or (string-match "[/\\][^/\\]" ido-selected) |
2081 (and (memq system-type '(windows-nt ms-dos)) | 2087 (and (memq system-type '(windows-nt ms-dos)) |
2082 (string-match "\\`.:" ido-selected))) | 2088 (string-match "\\`[a-zA-Z]:" ido-selected))) |
2083 (ido-set-current-directory (file-name-directory ido-selected)) | 2089 (ido-set-current-directory (file-name-directory ido-selected)) |
2084 (setq ido-set-default-item t)) | 2090 (setq ido-set-default-item t)) |
2085 | 2091 |
2086 ((string-match "\\`~" ido-selected) | 2092 ((string-match "\\`~" ido-selected) |
2087 (ido-set-current-home ido-selected)) | 2093 (ido-set-current-home ido-selected)) |
2426 (call-interactively (setq this-command ido-cannot-complete-command)))) | 2432 (call-interactively (setq this-command ido-cannot-complete-command)))) |
2427 | 2433 |
2428 ((and (= 1 (length ido-matches)) | 2434 ((and (= 1 (length ido-matches)) |
2429 (not (and ido-enable-tramp-completion | 2435 (not (and ido-enable-tramp-completion |
2430 (string-equal ido-current-directory "/") | 2436 (string-equal ido-current-directory "/") |
2431 (string-match "..[@:]\\'" (ido-name (car ido-matches)))))) | 2437 (string-match ".[@:]\\'" (ido-name (car ido-matches))))) |
2438 (not (ido-local-file-exists-p (ido-name (car ido-matches))))) | |
2432 ;; only one choice, so select it. | 2439 ;; only one choice, so select it. |
2433 (if (not ido-confirm-unique-completion) | 2440 (if (not ido-confirm-unique-completion) |
2434 (exit-minibuffer) | 2441 (exit-minibuffer) |
2435 (setq ido-rescan (not ido-enable-prefix)) | 2442 (setq ido-rescan (not ido-enable-prefix)) |
2436 (delete-region (minibuffer-prompt-end) (point)) | 2443 (delete-region (minibuffer-prompt-end) (point)) |
3436 #'ido-file-lessp))) | 3443 #'ido-file-lessp))) |
3437 (unless (ido-is-tramp-root ido-current-directory) | 3444 (unless (ido-is-tramp-root ido-current-directory) |
3438 (let ((default-directory ido-current-directory)) | 3445 (let ((default-directory ido-current-directory)) |
3439 (ido-to-end ;; move ftp hosts and visited files to end | 3446 (ido-to-end ;; move ftp hosts and visited files to end |
3440 (delq nil (mapcar | 3447 (delq nil (mapcar |
3441 (lambda (x) (if (or (string-match "..:\\'" x) | 3448 (lambda (x) (if (or (and (string-match ".:\\'" x) |
3449 (not (ido-local-file-exists-p x))) | |
3442 (and (not (ido-final-slash x)) | 3450 (and (not (ido-final-slash x)) |
3443 (get-file-buffer x))) x)) | 3451 (let (file-name-handler-alist) |
3452 (get-file-buffer x)))) x)) | |
3444 ido-temp-list))))) | 3453 ido-temp-list))))) |
3445 (ido-to-end ;; move . files to end | 3454 (ido-to-end ;; move . files to end |
3446 (delq nil (mapcar | 3455 (delq nil (mapcar |
3447 (lambda (x) (if (string-equal (substring x 0 1) ".") x)) | 3456 (lambda (x) (if (string-equal (substring x 0 1) ".") x)) |
3448 ido-temp-list))) | 3457 ido-temp-list))) |
4152 (ido-is-root-directory))) | 4161 (ido-is-root-directory))) |
4153 (ido-set-current-directory "//") | 4162 (ido-set-current-directory "//") |
4154 (setq refresh t)) | 4163 (setq refresh t)) |
4155 )) | 4164 )) |
4156 | 4165 |
4157 ((and (string-match (if ido-enable-tramp-completion "..[:@]\\'" "..:\\'") contents) | 4166 ((and (string-match (if ido-enable-tramp-completion ".[:@]\\'" ".:\\'") contents) |
4158 (ido-is-root-directory)) ;; Ange-ftp or tramp | 4167 (ido-is-root-directory) ;; Ange-ftp or tramp |
4168 (not (ido-local-file-exists-p contents))) | |
4159 (ido-set-current-directory ido-current-directory contents) | 4169 (ido-set-current-directory ido-current-directory contents) |
4160 (when (ido-is-slow-ftp-host) | 4170 (when (ido-is-slow-ftp-host) |
4161 (setq ido-exit 'fallback) | 4171 (setq ido-exit 'fallback) |
4162 (exit-minibuffer)) | 4172 (exit-minibuffer)) |
4163 (setq refresh t)) | 4173 (setq refresh t)) |