]> git.eshelyaron.com Git - emacs.git/commitdiff
Make Tramp file name completion more quiet for all backends
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 12 Mar 2023 16:21:57 +0000 (17:21 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 12 Mar 2023 16:21:57 +0000 (17:21 +0100)
* lisp/net/tramp-adb.el (tramp-adb-handle-file-name-all-completions):
* lisp/net/tramp-archive.el
(tramp-archive-handle-file-name-all-completions):
* lisp/net/tramp-crypt.el (tramp-crypt-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):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-name-all-completions):
* lisp/net/tramp-smb.el (tramp-smb-handle-file-name-all-completions):
* lisp/net/tramp-sudoedit.el
(tramp-sudoedit-handle-file-name-all-completions):
Return nil when DIRECTORY is missing.  (Bug#61890)

lisp/net/tramp-adb.el
lisp/net/tramp-archive.el
lisp/net/tramp-crypt.el
lisp/net/tramp-fuse.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp-sudoedit.el

index f8c38859477257663dc1d7a2630f99b34d96a13b..64f45e7958d24294f031162953e76deeef130ebd 100644 (file)
@@ -432,31 +432,32 @@ Emacs dired can't find files."
 
 (defun tramp-adb-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
-  (all-completions
-   filename
-   (with-parsed-tramp-file-name (expand-file-name directory) nil
-     (with-tramp-file-property v localname "file-name-all-completions"
-       (tramp-adb-send-command
-       v (format "%s -a %s | cat"
-                 (tramp-adb-get-ls-command v)
-                 (tramp-shell-quote-argument localname)))
-       (mapcar
-       (lambda (f)
-         (if (file-directory-p (expand-file-name f directory))
-             (file-name-as-directory f)
-           f))
-       (with-current-buffer (tramp-get-buffer v)
-         (delete-dups
-          (append
-           ;; On some file systems like "sdcard", "." and ".." are
-           ;; not included.  We fix this by `delete-dups'.
-           '("." "..")
-           (delq
-            nil
-            (mapcar
-             (lambda (l)
-               (and (not (string-match-p (rx bol (* blank) eol) l)) l))
-             (split-string (buffer-string) "\n")))))))))))
+  (ignore-error file-missing
+    (all-completions
+     filename
+     (with-parsed-tramp-file-name (expand-file-name directory) nil
+       (with-tramp-file-property v localname "file-name-all-completions"
+        (tramp-adb-send-command
+         v (format "%s -a %s | cat"
+                   (tramp-adb-get-ls-command v)
+                   (tramp-shell-quote-argument localname)))
+        (mapcar
+         (lambda (f)
+           (if (file-directory-p (expand-file-name f directory))
+               (file-name-as-directory f)
+             f))
+         (with-current-buffer (tramp-get-buffer v)
+           (delete-dups
+            (append
+             ;; On some file systems like "sdcard", "." and ".." are
+             ;; not included.  We fix this by `delete-dups'.
+             '("." "..")
+             (delq
+              nil
+              (mapcar
+               (lambda (l)
+                 (and (not (string-match-p (rx bol (* blank) eol) l)) l))
+               (split-string (buffer-string) "\n"))))))))))))
 
 (defun tramp-adb-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
index 97adb36c4af5e896b38d309fc161db766ae210c1..c2175612fa8edf40b6b97f49ab35a96261272993 100644 (file)
@@ -650,7 +650,9 @@ offered."
 
 (defun tramp-archive-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for file archives."
-  (file-name-all-completions filename (tramp-archive-gvfs-file-name directory)))
+  (ignore-error file-missing
+    (file-name-all-completions
+     filename (tramp-archive-gvfs-file-name directory))))
 
 (defun tramp-archive-handle-file-readable-p (filename)
   "Like `file-readable-p' for file archives."
index afd3166d161f4bd7492f4b65b988aacfd215a0fb..d0f1f1b8184397f32746880b7977f454409c9c87 100644 (file)
@@ -730,18 +730,19 @@ absolute file names."
 
 (defun tramp-crypt-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
-  (all-completions
-   filename
-   (let* (completion-regexp-list
-         tramp-crypt-enabled
-         (directory (file-name-as-directory directory))
-         (enc-dir (tramp-crypt-encrypt-file-name directory)))
-     (mapcar
-      (lambda (x)
-       (substring
-        (tramp-crypt-decrypt-file-name (concat enc-dir x))
-        (length directory)))
-      (file-name-all-completions "" enc-dir)))))
+  (ignore-error file-missing
+    (all-completions
+     filename
+     (let* (completion-regexp-list
+           tramp-crypt-enabled
+           (directory (file-name-as-directory directory))
+           (enc-dir (tramp-crypt-encrypt-file-name directory)))
+       (mapcar
+       (lambda (x)
+         (substring
+          (tramp-crypt-decrypt-file-name (concat enc-dir x))
+          (length directory)))
+       (file-name-all-completions "" enc-dir))))))
 
 (defun tramp-crypt-handle-file-readable-p (filename)
   "Like `file-readable-p' for Tramp files."
index b846caadc18a9a1c3da4c7cc52ce288a1369176b..8112e564a2c308fd4ff504856fbfcc28c8c99638 100644 (file)
 (defun tramp-fuse-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
   (tramp-fuse-remove-hidden-files
-   (all-completions
-    filename
-    (delete-dups
-     (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)))))))))))
+   (ignore-error file-missing
+     (all-completions
+      filename
+      (delete-dups
+       (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))))))))))))
 
 ;; This function isn't used.
 (defun tramp-fuse-handle-insert-directory
index b9639c1e7f71e9956dd505e8c1a49d6f186c6c77..266724c587fb612c85e0222817e577546af41078 100644 (file)
@@ -1418,16 +1418,19 @@ If FILE-SYSTEM is non-nil, return file system attributes."
 (defun tramp-gvfs-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
   (unless (tramp-compat-string-search "/" filename)
-    (all-completions
-     filename
-     (with-parsed-tramp-file-name (expand-file-name directory) nil
-       (with-tramp-file-property v localname "file-name-all-completions"
-         (let ((result '("./" "../")))
-           ;; Get a list of directories and files.
-          (dolist (item (tramp-gvfs-get-directory-attributes directory) result)
-            (if (string-equal (cdr (assoc "type" item)) "directory")
-                (push (file-name-as-directory (car item)) result)
-              (push (car item) result)))))))))
+    (ignore-error file-missing
+      (all-completions
+       filename
+       (with-parsed-tramp-file-name (expand-file-name directory) nil
+        (with-tramp-file-property v localname "file-name-all-completions"
+           (let ((result '("./" "../")))
+             ;; Get a list of directories and files.
+            (dolist (item
+                     (tramp-gvfs-get-directory-attributes directory)
+                     result)
+              (if (string-equal (cdr (assoc "type" item)) "directory")
+                  (push (file-name-as-directory (car item)) result)
+                (push (car item) result))))))))))
 
 (defun tramp-gvfs-handle-file-notify-add-watch (file-name flags _callback)
   "Like `file-notify-add-watch' for Tramp files."
index 3ae5208154af30853115899578f922529d5bb4e3..a854ff42b0d5b6ef86977d64d89a2223c54cf1d7 100644 (file)
@@ -1767,41 +1767,43 @@ ID-FORMAT valid values are `string' and `integer'."
   (with-parsed-tramp-file-name (expand-file-name directory) nil
     (when (and (not (tramp-compat-string-search "/" filename))
               (tramp-connectable-p v))
-      (all-completions
-       filename
-       (with-tramp-file-property v localname "file-name-all-completions"
-        (let (result)
-          ;; Get a list of directories and files, including reliably
-          ;; tagging the directories with a trailing "/".  Because I
-          ;; rock.  --daniel@danann.net
-          (when (tramp-send-command-and-check
-                 v
-                 (if (tramp-get-remote-perl v)
-                     (progn
-                       (tramp-maybe-send-script
-                        v tramp-perl-file-name-all-completions
-                        "tramp_perl_file_name_all_completions")
-                       (format "tramp_perl_file_name_all_completions %s"
-                               (tramp-shell-quote-argument localname)))
-
-                   (format (concat
-                            "cd %s 2>&1 && %s -a 2>%s"
-                            " | while IFS= read f; do"
-                            " if %s -d \"$f\" 2>%s;"
-                            " then \\echo \"$f/\"; else \\echo \"$f\"; fi;"
-                            " done")
-                           (tramp-shell-quote-argument localname)
-                           (tramp-get-ls-command v)
-                           (tramp-get-remote-null-device v)
-                           (tramp-get-test-command v)
-                           (tramp-get-remote-null-device v))))
-
-            ;; Now grab the output.
-            (with-current-buffer (tramp-get-buffer v)
-              (goto-char (point-max))
-              (while (zerop (forward-line -1))
-                (push (buffer-substring (point) (line-end-position)) result)))
-            result)))))))
+    (unless (tramp-compat-string-search "/" filename)
+      (ignore-error file-missing
+       (all-completions
+        filename
+        (with-tramp-file-property v localname "file-name-all-completions"
+          (let (result)
+            ;; Get a list of directories and files, including
+            ;; reliably tagging the directories with a trailing "/".
+            ;; Because I rock.  --daniel@danann.net
+            (when (tramp-send-command-and-check
+                   v
+                   (if (tramp-get-remote-perl v)
+                       (progn
+                         (tramp-maybe-send-script
+                          v tramp-perl-file-name-all-completions
+                          "tramp_perl_file_name_all_completions")
+                         (format "tramp_perl_file_name_all_completions %s"
+                                 (tramp-shell-quote-argument localname)))
+
+                     (format (concat
+                              "cd %s 2>&1 && %s -a 2>%s"
+                              " | while IFS= read f; do"
+                              " if %s -d \"$f\" 2>%s;"
+                              " then \\echo \"$f/\"; else \\echo \"$f\"; fi;"
+                              " done")
+                             (tramp-shell-quote-argument localname)
+                             (tramp-get-ls-command v)
+                             (tramp-get-remote-null-device v)
+                             (tramp-get-test-command v)
+                             (tramp-get-remote-null-device v))))
+
+              ;; Now grab the output.
+              (with-current-buffer (tramp-get-buffer v)
+                (goto-char (point-max))
+                (while (zerop (forward-line -1))
+                  (push (buffer-substring (point) (line-end-position)) result)))
+              result)))))))))
 
 ;; cp, mv and ln
 
index 2a69465224f158c585bc5dcfcfc61ab2352a7176..1aa4520eeb66a52bbc6371a6a33ed8e0c7339bf8 100644 (file)
@@ -976,18 +976,20 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
 ;; files.
 (defun tramp-smb-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
-  (all-completions
-   filename
-   (with-parsed-tramp-file-name (expand-file-name directory) nil
-     (with-tramp-file-property v localname "file-name-all-completions"
-       (delete-dups
-       (mapcar
-        (lambda (x)
-          (list
-           (if (tramp-compat-string-search "d" (nth 1 x))
-               (file-name-as-directory (nth 0 x))
-             (nth 0 x))))
-        (tramp-smb-get-file-entries directory)))))))
+  (ignore-error file-missing
+    (all-completions
+     filename
+     (when (file-directory-p directory)
+       (with-parsed-tramp-file-name (expand-file-name directory) nil
+        (with-tramp-file-property v localname "file-name-all-completions"
+          (delete-dups
+           (mapcar
+            (lambda (x)
+              (list
+               (if (tramp-compat-string-search "d" (nth 1 x))
+                   (file-name-as-directory (nth 0 x))
+                 (nth 0 x))))
+            (tramp-smb-get-file-entries directory)))))))))
 
 (defun tramp-smb-handle-file-system-info (filename)
   "Like `file-system-info' for Tramp files."
index fa1689d6851ac74cac660b1c44b47a680510b5a0..abb9afc570bc263f4a8373942082b42540e80c24 100644 (file)
@@ -460,26 +460,27 @@ the result will be a local, non-Tramp, file name."
 
 (defun tramp-sudoedit-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
-  (all-completions
-   filename
-   (with-parsed-tramp-file-name (expand-file-name directory) nil
-     (with-tramp-file-property v localname "file-name-all-completions"
-       (tramp-sudoedit-send-command
-       v "ls" "-a1" "--quoting-style=literal" "--show-control-chars"
-       (if (tramp-string-empty-or-nil-p localname)
-           "" (file-name-unquote localname)))
-       (mapcar
-       (lambda (f)
-         (if (ignore-errors (file-directory-p (expand-file-name f directory)))
-             (file-name-as-directory f)
-           f))
-       (delq
-        nil
+  (ignore-error file-missing
+    (all-completions
+     filename
+     (with-parsed-tramp-file-name (expand-file-name directory) nil
+       (with-tramp-file-property v localname "file-name-all-completions"
+        (tramp-sudoedit-send-command
+         v "ls" "-a1" "--quoting-style=literal" "--show-control-chars"
+         (if (tramp-string-empty-or-nil-p localname)
+             "" (file-name-unquote localname)))
         (mapcar
-         (lambda (l) (and (not (string-match-p (rx bol (* blank) eol) l)) l))
-         (split-string
-          (tramp-get-buffer-string (tramp-get-connection-buffer v))
-          "\n" 'omit))))))))
+         (lambda (f)
+           (if (ignore-errors (file-directory-p (expand-file-name f directory)))
+               (file-name-as-directory f)
+             f))
+         (delq
+          nil
+          (mapcar
+           (lambda (l) (and (not (string-match-p (rx bol (* blank) eol) l)) l))
+           (split-string
+            (tramp-get-buffer-string (tramp-get-connection-buffer v))
+            "\n" 'omit)))))))))
 
 (defun tramp-sudoedit-handle-file-readable-p (filename)
   "Like `file-readable-p' for Tramp files."