emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 025cd2a9c21 2/2: Unify "."" and ".." handling in tramp-*-file-nam


From: Michael Albinus
Subject: master 025cd2a9c21 2/2: Unify "."" and ".." handling in tramp-*-file-name-all-completions
Date: Wed, 22 Nov 2023 07:50:23 -0500 (EST)

branch: master
commit 025cd2a9c213ee6e6f6506f586713c2b476fc053
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Unify ".""  and ".." handling in tramp-*-file-name-all-completions
    
    * lisp/net/tramp-adb.el (tramp-adb-handle-file-name-all-completions):
    * lisp/net/tramp-fuse.el (tramp-fuse-handle-file-name-all-completions):
    * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-name-all-completions):
    Remove special handling of "." an "..".
    
    * lisp/net/tramp.el (tramp-skeleton-file-name-all-completions):
    Handle ".""  and "..".
---
 lisp/net/tramp-adb.el  | 12 ++++--------
 lisp/net/tramp-fuse.el | 13 ++-----------
 lisp/net/tramp-gvfs.el |  2 +-
 lisp/net/tramp.el      | 16 ++++++++++++----
 4 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index acbf5ec01c6..e4d3ba8c74b 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -450,14 +450,10 @@ Emacs dired can't find files."
                (file-name-as-directory f)
              f))
          (with-current-buffer (tramp-get-buffer v)
-           (append
-            ;; On some file systems like "sdcard", "." and ".." are
-            ;; not included.
-            '("." "..")
-            (mapcar
-             (lambda (l)
-               (and (not (string-match-p (rx bol (* blank) eol) l)) l))
-             (split-string (buffer-string) "\n" 'omit))))))))))
+           (mapcar
+            (lambda (l)
+              (and (not (string-match-p (rx bol (* blank) eol) l)) l))
+            (split-string (buffer-string) "\n" 'omit)))))))))
 
 (defun tramp-adb-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el
index 4b04f75ce96..30516ce9ecc 100644
--- a/lisp/net/tramp-fuse.el
+++ b/lisp/net/tramp-fuse.el
@@ -106,17 +106,8 @@
     (tramp-fuse-remove-hidden-files
      (all-completions
       filename
-      (append
-       (file-name-all-completions
-       filename (tramp-fuse-local-file-name directory))
-       ;; Some storage systems do not return "." and "..".
-       (let (result)
-        (dolist (item '(".." ".") result)
-          (when (string-prefix-p filename item)
-            (catch 'match
-              (dolist (elt completion-regexp-list)
-                (unless (string-match-p elt item) (throw 'match nil)))
-              (setq result (cons (concat item "/") result)))))))))))
+      (file-name-all-completions
+       filename (tramp-fuse-local-file-name directory))))))
 
 ;; This function isn't used.
 (defun tramp-fuse-handle-insert-directory
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 573d89c0c51..35778aca6d4 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1469,7 +1469,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
        filename
        (with-parsed-tramp-file-name (expand-file-name directory) nil
         (with-tramp-file-property v localname "file-name-all-completions"
-           (let ((result '("./" "../")))
+           (let (result)
              ;; Get a list of directories and files.
             (dolist (item
                      (tramp-gvfs-get-directory-attributes directory)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a21e6823424..e19b8c78f8c 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2742,19 +2742,27 @@ not in completion mode."
       (tramp-run-real-handler #'file-exists-p (list filename))))
 
 (defmacro tramp-skeleton-file-name-all-completions
-    (_filename _directory &rest body)
+    (filename directory &rest body)
   "Skeleton for `tramp-*-handle-filename-all-completions'.
 BODY is the backend specific code."
   (declare (indent 2) (debug t))
   `(ignore-error file-missing
      (delete-dups (delq nil
        (let* ((case-fold-search read-file-name-completion-ignore-case)
-             (regexp (mapconcat #'identity completion-regexp-list "\\|"))
-             (result ,@body))
+             (result (progn ,@body)))
+        ;; Some storage systems do not return "." and "..".
+        (when (tramp-tramp-file-p ,directory)
+          (dolist (elt '(".." "."))
+            (when (string-prefix-p ,filename elt)
+              (setq result (cons (concat elt "/") result)))))
         (if (consp completion-regexp-list)
             ;; Discriminate over `completion-regexp-list'.
             (mapcar
-             (lambda (x) (and (stringp x) (string-match-p regexp x) x))
+             (lambda (x)
+               (when (stringp x)
+                 (catch 'match
+                   (dolist (elt completion-regexp-list x)
+                     (unless (string-match-p elt x) (throw 'match nil))))))
              result)
           result))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]