- (if (and ido-enable-tramp-completion
- (string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir))
-
- ;; Trick tramp's file-name-all-completions handler to DTRT, as it
- ;; has some pretty obscure requirements. This seems to work...
- ;; /ftp: => (f-n-a-c "/ftp:" "")
- ;; /ftp:kfs: => (f-n-a-c "" "/ftp:kfs:")
- ;; /ftp:kfs@ => (f-n-a-c "ftp:kfs@" "/")
- ;; /ftp:kfs@kfs: => (f-n-a-c "" "/ftp:kfs@kfs:")
- ;; Currently no attempt is made to handle multi: stuff.
-
- (let* ((prefix (match-string 1 dir))
- (user-flag (match-beginning 2))
- (len (and prefix (length prefix)))
- compl)
- (if user-flag
- (setq dir (substring dir 1)))
- (require 'tramp nil t)
- (ido-trace "tramp complete" dir)
- (setq compl (file-name-all-completions dir (if user-flag "/" "")))
- (if (> len 0)
- (mapcar (lambda (c) (substring c len)) compl)
- compl))
- (file-name-all-completions "" dir)))
+ (cond
+ ((ido-nonreadable-directory-p dir) '())
+ ((and ido-enable-tramp-completion
+ (string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir))
+
+ ;; Trick tramp's file-name-all-completions handler to DTRT, as it
+ ;; has some pretty obscure requirements. This seems to work...
+ ;; /ftp: => (f-n-a-c "/ftp:" "")
+ ;; /ftp:kfs: => (f-n-a-c "" "/ftp:kfs:")
+ ;; /ftp:kfs@ => (f-n-a-c "ftp:kfs@" "/")
+ ;; /ftp:kfs@kfs: => (f-n-a-c "" "/ftp:kfs@kfs:")
+ ;; Currently no attempt is made to handle multi: stuff.
+
+ (let* ((prefix (match-string 1 dir))
+ (user-flag (match-beginning 2))
+ (len (and prefix (length prefix)))
+ compl)
+ (if user-flag
+ (setq dir (substring dir 1)))
+ (require 'tramp nil t)
+ (ido-trace "tramp complete" dir)
+ (setq compl (file-name-all-completions dir (if user-flag "/" "")))
+ (if (> len 0)
+ (mapcar (lambda (c) (substring c len)) compl)
+ compl)))
+ (t
+ (file-name-all-completions "" dir))))