Commit c1253aad authored by Michael Albinus's avatar Michael Albinus
Browse files

* net/tramp.el (tramp-completion-mode): New defvar. Used in

`tramp-completion-mode' for checking if we are in completion mode.
(tramp-completion-handle-file-name-all-completions): Reorder code
in order to complete for file names only in case there are no
method/user/host completions.  This is necessary for cooperation
with ido.  Reported by Kim F. Storm  <storm@cua.dk>.
parent 7d6596b8
2005-10-17 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-completion-mode): New defvar. Used in
`tramp-completion-mode' for checking if we are in completion mode.
(tramp-completion-handle-file-name-all-completions): Reorder code
in order to complete for file names only in case there are no
method/user/host completions. This is necessary for cooperation
with ido. Reported by Kim F. Storm <storm@cua.dk>.
2005-10-16 Chong Yidong <cyd@stupidchicken.com>
* longlines.el (longlines-search-forward)
......
......@@ -4384,6 +4384,7 @@ necessary anymore."
(defun tramp-completion-mode (file)
"Checks whether method / user name / host name completion is active."
(cond
(tramp-completion-mode t)
((not tramp-unified-filenames) t)
((string-match "^/.*:.*:$" file) nil)
((string-match
......@@ -4434,70 +4435,83 @@ necessary anymore."
(substring
file (length (tramp-completion-handle-file-name-directory file))))
(defvar tramp-completion-mode nil
"If non-nil, we are in file name completion mode.")
;; Method, host name and user name completion.
;; `tramp-completion-dissect-file-name' returns a list of
;; tramp-file-name structures. For all of them we return possible completions.
(defun tramp-completion-handle-file-name-all-completions (filename directory)
"Like `file-name-all-completions' for partial tramp files."
(let*
((fullname (concat directory filename))
;; local files
(result
(if (tramp-completion-mode fullname)
(tramp-run-real-handler
'file-name-all-completions (list filename directory))
(tramp-completion-run-real-handler
'file-name-all-completions (list filename directory))))
;; possible completion structures
(v (tramp-completion-dissect-file-name fullname)))
(while v
(let* ((car (car v))
(multi-method (tramp-file-name-multi-method car))
(method (tramp-file-name-method car))
(user (tramp-file-name-user car))
(host (tramp-file-name-host car))
(localname (tramp-file-name-localname car))
(m (tramp-find-method multi-method method user host))
(tramp-current-user user) ; see `tramp-parse-passwd'
all-user-hosts)
(unless (or multi-method ;; Not handled (yet).
localname) ;; Nothing to complete
(if (or user host)
;; Method dependent user / host combinations
(progn
(mapcar
(lambda (x)
(setq all-user-hosts
(append all-user-hosts
(funcall (nth 0 x) (nth 1 x)))))
(tramp-get-completion-function m))
(setq result (append result
(mapcar
(lambda (x)
(tramp-get-completion-user-host
method user host (nth 0 x) (nth 1 x)))
(delq nil all-user-hosts)))))
;; Possible methods
(setq result
(append result (tramp-get-completion-methods m)))))
(setq v (delq car v))))
;;; unify list, remove nil elements
(let (result1)
(while result
(let ((car (car result)))
(when car (add-to-list 'result1 car))
(setq result (delq car result))))
result1)))
(unwind-protect
;; We need to reset `tramp-completion-mode'.
(progn
(setq tramp-completion-mode t)
(let*
((fullname (concat directory filename))
;; possible completion structures
(v (tramp-completion-dissect-file-name fullname))
result result1)
(while v
(let* ((car (car v))
(multi-method (tramp-file-name-multi-method car))
(method (tramp-file-name-method car))
(user (tramp-file-name-user car))
(host (tramp-file-name-host car))
(localname (tramp-file-name-localname car))
(m (tramp-find-method multi-method method user host))
(tramp-current-user user) ; see `tramp-parse-passwd'
all-user-hosts)
(unless (or multi-method ;; Not handled (yet).
localname) ;; Nothing to complete
(if (or user host)
;; Method dependent user / host combinations
(progn
(mapcar
(lambda (x)
(setq all-user-hosts
(append all-user-hosts
(funcall (nth 0 x) (nth 1 x)))))
(tramp-get-completion-function m))
(setq result (append result
(mapcar
(lambda (x)
(tramp-get-completion-user-host
method user host (nth 0 x) (nth 1 x)))
(delq nil all-user-hosts)))))
;; Possible methods
(setq result
(append result (tramp-get-completion-methods m)))))
(setq v (cdr v))))
;; unify list, remove nil elements
(while result
(let ((car (car result)))
(when car (add-to-list 'result1 car))
(setq result (cdr result))))
;; Complete local parts
(append
result1
(condition-case nil
(if result1
;; "/ssh:" does not need to be expanded as hostname.
(tramp-run-real-handler
'file-name-all-completions (list filename directory))
;; No method/user/host found to be expanded.
(tramp-completion-run-real-handler
'file-name-all-completions (list filename directory)))
(error nil)))))
;; unwindform
(setq tramp-completion-mode nil)))
;; Method, host name and user name completion for a file.
(defun tramp-completion-handle-file-name-completion (filename directory)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment