diff options
| author | Michael Albinus | 2023-08-19 19:32:09 +0200 |
|---|---|---|
| committer | Michael Albinus | 2023-08-19 19:32:09 +0200 |
| commit | 9ecd6553adedb447a60da9dcc3efe5158f796155 (patch) | |
| tree | 0440905116745d3388a5003d29ba02bdb5eb866b | |
| parent | cd3f163005ef9e5ad73fb8609e8199d86b9ce865 (diff) | |
| download | emacs-9ecd6553adedb447a60da9dcc3efe5158f796155.tar.gz emacs-9ecd6553adedb447a60da9dcc3efe5158f796155.zip | |
Extend T
* lisp/net/tramp.el (tramp-completion-file-name-handler-alist):
Add `file-directory-p'.
(tramp-completion-handle-file-directory-p): New defun.
| -rw-r--r-- | lisp/net/tramp.el | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a0092a2d706..30602c353b3 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -1410,6 +1410,7 @@ during direct remote copying with scp.") | |||
| 1410 | 1410 | ||
| 1411 | (defconst tramp-completion-file-name-handler-alist | 1411 | (defconst tramp-completion-file-name-handler-alist |
| 1412 | '((expand-file-name . tramp-completion-handle-expand-file-name) | 1412 | '((expand-file-name . tramp-completion-handle-expand-file-name) |
| 1413 | (file-directory-p . tramp-completion-handle-file-directory-p) | ||
| 1413 | (file-exists-p . tramp-completion-handle-file-exists-p) | 1414 | (file-exists-p . tramp-completion-handle-file-exists-p) |
| 1414 | (file-name-all-completions | 1415 | (file-name-all-completions |
| 1415 | . tramp-completion-handle-file-name-all-completions) | 1416 | . tramp-completion-handle-file-name-all-completions) |
| @@ -2643,6 +2644,29 @@ not in completion mode." | |||
| 2643 | (concat dir filename)) | 2644 | (concat dir filename)) |
| 2644 | (t (tramp-run-real-handler #'expand-file-name (list filename directory)))))) | 2645 | (t (tramp-run-real-handler #'expand-file-name (list filename directory)))))) |
| 2645 | 2646 | ||
| 2647 | ;; This is needed in pcomplete.el. | ||
| 2648 | (defun tramp-completion-handle-file-directory-p (filename) | ||
| 2649 | "Like `file-directory-p' for partial Tramp files." | ||
| 2650 | ;; We need special handling only when a method is needed. Then we | ||
| 2651 | ;; regard all files "/method:" or "/[method/" as existent, if | ||
| 2652 | ;; "method" is a valid Tramp method. | ||
| 2653 | (or (string-equal filename "/") | ||
| 2654 | (and ;; Is it a valid method? | ||
| 2655 | (not (string-empty-p tramp-postfix-method-format)) | ||
| 2656 | (string-match | ||
| 2657 | (rx | ||
| 2658 | (regexp tramp-prefix-regexp) | ||
| 2659 | (* (regexp tramp-remote-file-name-spec-regexp) | ||
| 2660 | (regexp tramp-postfix-hop-regexp)) | ||
| 2661 | (group-n 9 (regexp tramp-method-regexp)) | ||
| 2662 | (? (regexp tramp-postfix-method-regexp)) | ||
| 2663 | eos) | ||
| 2664 | filename) | ||
| 2665 | (assoc (match-string 9 filename) tramp-methods) | ||
| 2666 | t) | ||
| 2667 | |||
| 2668 | (tramp-run-real-handler #'file-directory-p (list filename)))) | ||
| 2669 | |||
| 2646 | (defun tramp-completion-handle-file-exists-p (filename) | 2670 | (defun tramp-completion-handle-file-exists-p (filename) |
| 2647 | "Like `file-exists-p' for partial Tramp files." | 2671 | "Like `file-exists-p' for partial Tramp files." |
| 2648 | ;; We need special handling only when a method is needed. Then we | 2672 | ;; We need special handling only when a method is needed. Then we |
| @@ -2650,7 +2674,7 @@ not in completion mode." | |||
| 2650 | ;; "method" is a valid Tramp method. And we regard all files | 2674 | ;; "method" is a valid Tramp method. And we regard all files |
| 2651 | ;; "/method:user@", "/user@" or "/[method/user@" as existent, if | 2675 | ;; "/method:user@", "/user@" or "/[method/user@" as existent, if |
| 2652 | ;; "user@" is a valid file name completion. Host completion is | 2676 | ;; "user@" is a valid file name completion. Host completion is |
| 2653 | ;; performed in the respective backen operation. | 2677 | ;; performed in the respective backend operation. |
| 2654 | (or (and (cond | 2678 | (or (and (cond |
| 2655 | ;; Completion styles like `flex' and `substring' check for | 2679 | ;; Completion styles like `flex' and `substring' check for |
| 2656 | ;; the file name "/". This does exist. | 2680 | ;; the file name "/". This does exist. |