From eca7394bdf2f57632238b2cf66c996b43cca2aef Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 27 Jun 2023 12:46:49 +0200 Subject: [PATCH] Fix dired-insert-directory wrt remote directories * lisp/dired.el (dired-insert-directory): Respect remote directories consequently. --- lisp/dired.el | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index 914d0a0e783..b4cfaa1842f 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -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"))) -- 2.39.2