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 "..".
This commit is contained in:
Michael Albinus 2023-11-22 13:50:06 +01:00
parent 04aa76bb92
commit 025cd2a9c2
4 changed files with 19 additions and 24 deletions

View file

@ -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."

View file

@ -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

View file

@ -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)

View file

@ -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))))))