Fix dired-insert-directory wrt remote directories

* lisp/dired.el (dired-insert-directory): Respect remote
directories consequently.
This commit is contained in:
Michael Albinus 2023-06-27 12:46:49 +02:00
parent 3a50773ab0
commit eca7394bdf

View file

@ -1632,6 +1632,7 @@ In other cases, DIR should be a directory name or a directory filename.
If HDR is non-nil, insert a header line with the directory name."
(let ((opoint (point))
(process-environment (copy-sequence process-environment))
(remotep (file-remote-p dir))
end)
(if (and
;; Don't try to invoke `ls' if we are on DOS/Windows where
@ -1641,7 +1642,7 @@ If HDR is non-nil, insert a header line with the directory name."
(null ls-lisp-use-insert-directory-program)))
;; FIXME: Big ugly hack for Eshell's eshell-ls-use-in-dired.
(not (bound-and-true-p eshell-ls-use-in-dired))
(or (file-remote-p dir)
(or remotep
(if (eq dired-use-ls-dired 'unspecified)
;; Check whether "ls --dired" gives exit code 0, and
;; save the answer in `dired-use-ls-dired'.
@ -1656,19 +1657,14 @@ see `dired-use-ls-dired' for more details.")
;; Use -N with --dired, to countermand possible non-default
;; quoting style, in particular via the environment variable
;; QUOTING_STYLE.
(setq switches (concat "--dired -N " switches)))
(unless remotep
(setq switches (concat "--dired -N " switches))))
;; Expand directory wildcards and fill file-list.
(let ((dir-wildcard (insert-directory-wildcard-in-dir-p dir)))
(cond (dir-wildcard
(setq switches (concat "-d " switches))
;; We don't know whether the remote ls supports
;; "--dired", so we cannot add it to the `process-file'
;; call for wildcards.
(when (file-remote-p dir)
(setq switches (string-replace "--dired -N" "" switches)))
(let* ((default-directory (car dir-wildcard))
(script (format "ls %s %s" switches (cdr dir-wildcard)))
(remotep (file-remote-p dir))
(sh (or (and remotep "/bin/sh")
(executable-find shell-file-name)
(executable-find "sh")))