Mercurial > emacs
comparison lisp/net/tramp.el @ 108033:1545dcb1c3b7
Fix Bug#5840.
* icomplete.el (icomplete-completions): Use `non-essential'.
* net/tramp.el (tramp-connectable-p): New defun.
(tramp-handle-expand-file-name)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-handle-file-name-completion): Use it.
author | Michael Albinus <albinus@detlef> |
---|---|
date | Wed, 21 Apr 2010 21:48:42 +0200 |
parents | 12062a99ca8d |
children | 6469bf1a3a10 |
comparison
equal
deleted
inserted
replaced
108032:9e4618c4ed12 | 108033:1545dcb1c3b7 |
---|---|
4223 (setq dir (or dir default-directory "/")) | 4223 (setq dir (or dir default-directory "/")) |
4224 ;; Unless NAME is absolute, concat DIR and NAME. | 4224 ;; Unless NAME is absolute, concat DIR and NAME. |
4225 (unless (file-name-absolute-p name) | 4225 (unless (file-name-absolute-p name) |
4226 (setq name (concat (file-name-as-directory dir) name))) | 4226 (setq name (concat (file-name-as-directory dir) name))) |
4227 ;; If NAME is not a Tramp file, run the real handler. | 4227 ;; If NAME is not a Tramp file, run the real handler. |
4228 (if (not (tramp-tramp-file-p name)) | 4228 (if (not (tramp-connectable-p name)) |
4229 (tramp-run-real-handler 'expand-file-name (list name nil)) | 4229 (tramp-run-real-handler 'expand-file-name (list name nil)) |
4230 ;; Dissect NAME. | 4230 ;; Dissect NAME. |
4231 (with-parsed-tramp-file-name name nil | 4231 (with-parsed-tramp-file-name name nil |
4232 (unless (tramp-run-real-handler 'file-name-absolute-p (list localname)) | 4232 (unless (tramp-run-real-handler 'file-name-absolute-p (list localname)) |
4233 (setq localname (concat "~/" localname))) | 4233 (setq localname (concat "~/" localname))) |
5645 last-input-event) ?\?) | 5645 last-input-event) ?\?) |
5646 (equal | 5646 (equal |
5647 (funcall (symbol-function 'event-to-character) | 5647 (funcall (symbol-function 'event-to-character) |
5648 last-input-event) ?\ ))))))) | 5648 last-input-event) ?\ ))))))) |
5649 | 5649 |
5650 (defun tramp-connectable-p (filename) | |
5651 "Check, whether it is possible to connect the remote host w/o side-effects. | |
5652 This is true, if either the remote host is already connected, or if we are | |
5653 not in completion mode." | |
5654 (and (tramp-tramp-file-p filename) | |
5655 (with-parsed-tramp-file-name filename nil | |
5656 (or (get-buffer (tramp-buffer-name v)) | |
5657 (not (tramp-completion-mode-p)))))) | |
5658 | |
5650 ;; Method, host name and user name completion. | 5659 ;; Method, host name and user name completion. |
5651 ;; `tramp-completion-dissect-file-name' returns a list of | 5660 ;; `tramp-completion-dissect-file-name' returns a list of |
5652 ;; tramp-file-name structures. For all of them we return possible completions. | 5661 ;; tramp-file-name structures. For all of them we return possible completions. |
5653 ;;;###autoload | 5662 ;;;###autoload |
5654 (defun tramp-completion-handle-file-name-all-completions (filename directory) | 5663 (defun tramp-completion-handle-file-name-all-completions (filename directory) |
5708 | 5717 |
5709 ;; Complete local parts. | 5718 ;; Complete local parts. |
5710 (append | 5719 (append |
5711 result1 | 5720 result1 |
5712 (condition-case nil | 5721 (condition-case nil |
5713 (tramp-completion-run-real-handler | 5722 (when (tramp-connectable-p fullname) |
5714 'file-name-all-completions (list filename directory)) | 5723 (tramp-completion-run-real-handler |
5724 'file-name-all-completions (list filename directory))) | |
5715 (error nil))))) | 5725 (error nil))))) |
5716 | 5726 |
5717 ;; Method, host name and user name completion for a file. | 5727 ;; Method, host name and user name completion for a file. |
5718 ;;;###autoload | 5728 ;;;###autoload |
5719 (defun tramp-completion-handle-file-name-completion | 5729 (defun tramp-completion-handle-file-name-completion |
5720 (filename directory &optional predicate) | 5730 (filename directory &optional predicate) |
5721 "Like `file-name-completion' for Tramp files." | 5731 "Like `file-name-completion' for Tramp files." |
5722 (try-completion | 5732 (try-completion |
5723 filename | 5733 filename |
5724 (mapcar 'list (file-name-all-completions filename directory)) | 5734 (mapcar 'list (file-name-all-completions filename directory)) |
5725 (when predicate | 5735 (when (and predicate |
5736 (tramp-connectable-p (expand-file-name filename directory))) | |
5726 (lambda (x) (funcall predicate (expand-file-name (car x) directory)))))) | 5737 (lambda (x) (funcall predicate (expand-file-name (car x) directory)))))) |
5727 | 5738 |
5728 ;; I misuse a little bit the tramp-file-name structure in order to handle | 5739 ;; I misuse a little bit the tramp-file-name structure in order to handle |
5729 ;; completion possibilities for partial methods / user names / host names. | 5740 ;; completion possibilities for partial methods / user names / host names. |
5730 ;; Return value is a list of tramp-file-name structures according to possible | 5741 ;; Return value is a list of tramp-file-name structures according to possible |