]> git.eshelyaron.com Git - emacs.git/commitdiff
Extend T
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 19 Aug 2023 17:32:09 +0000 (19:32 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sat, 19 Aug 2023 17:32:09 +0000 (19:32 +0200)
* lisp/net/tramp.el (tramp-completion-file-name-handler-alist):
Add `file-directory-p'.
(tramp-completion-handle-file-directory-p): New defun.

lisp/net/tramp.el

index a0092a2d70679e43b3c9f89d4cf2ed87624a9060..30602c353b3d6ec531f084fa0414853f99a4827b 100644 (file)
@@ -1410,6 +1410,7 @@ during direct remote copying with scp.")
 
 (defconst tramp-completion-file-name-handler-alist
   '((expand-file-name . tramp-completion-handle-expand-file-name)
+    (file-directory-p . tramp-completion-handle-file-directory-p)
     (file-exists-p . tramp-completion-handle-file-exists-p)
     (file-name-all-completions
      . tramp-completion-handle-file-name-all-completions)
@@ -2643,6 +2644,29 @@ not in completion mode."
       (concat dir filename))
      (t (tramp-run-real-handler #'expand-file-name (list filename directory))))))
 
+;; This is needed in pcomplete.el.
+(defun tramp-completion-handle-file-directory-p (filename)
+  "Like `file-directory-p' for partial Tramp files."
+  ;; We need special handling only when a method is needed.  Then we
+  ;; regard all files "/method:" or "/[method/" as existent, if
+  ;; "method" is a valid Tramp method.
+  (or (string-equal filename "/")
+      (and ;; Is it a valid method?
+           (not (string-empty-p tramp-postfix-method-format))
+           (string-match
+           (rx
+            (regexp tramp-prefix-regexp)
+            (* (regexp tramp-remote-file-name-spec-regexp)
+               (regexp tramp-postfix-hop-regexp))
+            (group-n 9 (regexp tramp-method-regexp))
+            (? (regexp tramp-postfix-method-regexp))
+             eos)
+            filename)
+          (assoc (match-string 9 filename) tramp-methods)
+          t)
+
+      (tramp-run-real-handler #'file-directory-p (list filename))))
+
 (defun tramp-completion-handle-file-exists-p (filename)
   "Like `file-exists-p' for partial Tramp files."
   ;; We need special handling only when a method is needed.  Then we
@@ -2650,7 +2674,7 @@ not in completion mode."
   ;; "method" is a valid Tramp method.  And we regard all files
   ;; "/method:user@", "/user@" or "/[method/user@" as existent, if
   ;; "user@" is a valid file name completion.  Host completion is
-  ;; performed in the respective backen operation.
+  ;; performed in the respective backend operation.
   (or (and (cond
             ;; Completion styles like `flex' and `substring' check for
             ;; the file name "/".  This does exist.