aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2005-10-19 22:21:18 +0000
committerKim F. Storm2005-10-19 22:21:18 +0000
commitc577a4d245a287c9ec6b2add58cfc18a0a4c14d4 (patch)
tree96ff287991e01a22fdf72cd28885536a0474b9d9
parente50165ec102505693cd792eae49d3464bd782e2e (diff)
downloademacs-c577a4d245a287c9ec6b2add58cfc18a0a4c14d4.tar.gz
emacs-c577a4d245a287c9ec6b2add58cfc18a0a4c14d4.zip
(ido-is-tramp-root): Simplify regexp matching tramp root.
(ido-set-current-directory): Don't add / after final @. (ido-file-name-all-completions-1): Adapt to fixed tramp completion. Explicitly handle ange-ftp completion oddities. (ido-make-file-list): Don't rotate list at tramp root to avoid triggering tramp file handler for expand-file-name via get-file-buffer.
-rw-r--r--lisp/ido.el72
1 files changed, 40 insertions, 32 deletions
diff --git a/lisp/ido.el b/lisp/ido.el
index b234795d3be..cc4eab4bb4d 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1084,9 +1084,9 @@ it doesn't interfere with other minibuffer usage.")
1084 (setq truncate-lines t))))) 1084 (setq truncate-lines t)))))
1085 1085
1086(defun ido-is-tramp-root (&optional dir) 1086(defun ido-is-tramp-root (&optional dir)
1087 (setq dir (or dir ido-current-directory))
1088 (and ido-enable-tramp-completion 1087 (and ido-enable-tramp-completion
1089 (string-match "\\`/[^/][^/]+:\\([^/:@]+@\\)?\\'" dir))) 1088 (string-match "\\`/[^/]+[@:]\\'"
1089 (or dir ido-current-directory))))
1090 1090
1091(defun ido-is-root-directory (&optional dir) 1091(defun ido-is-root-directory (&optional dir)
1092 (setq dir (or dir ido-current-directory)) 1092 (setq dir (or dir ido-current-directory))
@@ -1507,11 +1507,16 @@ With ARG, turn ido speed-up on if arg is positive, off otherwise."
1507 1507
1508(defun ido-set-current-directory (dir &optional subdir no-merge) 1508(defun ido-set-current-directory (dir &optional subdir no-merge)
1509 ;; Set ido's current directory to DIR or DIR/SUBDIR 1509 ;; Set ido's current directory to DIR or DIR/SUBDIR
1510 (setq dir (ido-final-slash dir t)) 1510 (unless (and ido-enable-tramp-completion
1511 (string-match "\\`/[^/]*@\\'" dir))
1512 (setq dir (ido-final-slash dir t)))
1511 (setq ido-use-merged-list nil 1513 (setq ido-use-merged-list nil
1512 ido-try-merged-list (not no-merge)) 1514 ido-try-merged-list (not no-merge))
1513 (if subdir 1515 (when subdir
1514 (setq dir (ido-final-slash (concat dir subdir) t))) 1516 (setq dir (concat dir subdir))
1517 (unless (and ido-enable-tramp-completion
1518 (string-match "\\`/[^/]*@\\'" dir))
1519 (setq dir (ido-final-slash dir t))))
1515 (if (equal dir ido-current-directory) 1520 (if (equal dir ido-current-directory)
1516 nil 1521 nil
1517 (ido-trace "cd" dir) 1522 (ido-trace "cd" dir)
@@ -3102,27 +3107,29 @@ for first matching file."
3102 ((ido-nonreadable-directory-p dir) '()) 3107 ((ido-nonreadable-directory-p dir) '())
3103 ;; do not check (ido-directory-too-big-p dir) here. 3108 ;; do not check (ido-directory-too-big-p dir) here.
3104 ;; Caller must have done that if necessary. 3109 ;; Caller must have done that if necessary.
3110
3105 ((and ido-enable-tramp-completion 3111 ((and ido-enable-tramp-completion
3106 (string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir)) 3112 (or (fboundp 'tramp-completion-mode)
3107 3113 (require 'tramp nil t))
3108 ;; Trick tramp's file-name-all-completions handler to DTRT, as it 3114 (string-match "\\`/[^/]+[:@]\\'" dir))
3109 ;; has some pretty obscure requirements. This seems to work... 3115 ;; Strip method:user@host: part of tramp completions.
3110 ;; /ftp: => (f-n-a-c "/ftp:" "") 3116 ;; Tramp completions do not include leading slash.
3111 ;; /ftp:kfs: => (f-n-a-c "" "/ftp:kfs:") 3117 (let ((len (1- (length dir)))
3112 ;; /ftp:kfs@ => (f-n-a-c "ftp:kfs@" "/") 3118 (compl
3113 ;; /ftp:kfs@kfs: => (f-n-a-c "" "/ftp:kfs@kfs:") 3119 (or (file-name-all-completions "" dir)
3114 ;; Currently no attempt is made to handle multi: stuff. 3120 ;; work around bug in ange-ftp.
3115 3121 ;; /ftp:user@host: => nil
3116 (let* ((prefix (match-string 1 dir)) 3122 ;; /ftp:user@host:./ => ok
3117 (user-flag (match-beginning 2)) 3123 (and
3118 (len (and prefix (length prefix))) 3124 (not (string= "/ftp:" dir))
3119 compl) 3125 (tramp-tramp-file-p dir)
3120 (if user-flag 3126 (fboundp 'tramp-ftp-file-name-p)
3121 (setq dir (substring dir 1))) 3127 (funcall 'tramp-ftp-file-name-p dir)
3122 (require 'tramp nil t) 3128 (string-match ":\\'" dir)
3123 (ido-trace "tramp complete" dir) 3129 (file-name-all-completions "" (concat dir "./"))))))
3124 (setq compl (file-name-all-completions dir (if user-flag "/" ""))) 3130 (if (and compl
3125 (if (> len 0) 3131 (> (length (car compl)) len)
3132 (string= (substring (car compl) 0 len) (substring dir 1)))
3126 (mapcar (lambda (c) (substring c len)) compl) 3133 (mapcar (lambda (c) (substring c len)) compl)
3127 compl))) 3134 compl)))
3128 (t 3135 (t
@@ -3193,13 +3200,14 @@ for first matching file."
3193 (if ido-file-extensions-order 3200 (if ido-file-extensions-order
3194 #'ido-file-extension-lessp 3201 #'ido-file-extension-lessp
3195 #'ido-file-lessp))) 3202 #'ido-file-lessp)))
3196 (let ((default-directory ido-current-directory)) 3203 (unless (ido-is-tramp-root ido-current-directory)
3197 (ido-to-end ;; move ftp hosts and visited files to end 3204 (let ((default-directory ido-current-directory))
3198 (delq nil (mapcar 3205 (ido-to-end ;; move ftp hosts and visited files to end
3199 (lambda (x) (if (or (string-match "..:\\'" x) 3206 (delq nil (mapcar
3200 (and (not (ido-final-slash x)) 3207 (lambda (x) (if (or (string-match "..:\\'" x)
3201 (get-file-buffer x))) x)) 3208 (and (not (ido-final-slash x))
3202 ido-temp-list)))) 3209 (get-file-buffer x))) x))
3210 ido-temp-list)))))
3203 (ido-to-end ;; move . files to end 3211 (ido-to-end ;; move . files to end
3204 (delq nil (mapcar 3212 (delq nil (mapcar
3205 (lambda (x) (if (string-equal (substring x 0 1) ".") x)) 3213 (lambda (x) (if (string-equal (substring x 0 1) ".") x))