From bc35ff325b150d01e6858358e625dcdb6374fb37 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 2 Feb 2011 18:21:52 +0200 Subject: [PATCH] Fix Dired on DOS/Windows. dired.el (dired-insert-directory): Don't invoke `ls' when ls-lisp.el is used to emulate it. --- lisp/ChangeLog | 5 +++++ lisp/dired.el | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 627c61deaeb..219aef943de 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-02-02 Eli Zaretskii + + * dired.el (dired-insert-directory): Don't invoke `ls' when + ls-lisp.el is used to emulate it. + 2011-02-01 Julien Danjou * color.el (color-gradient): Add a color-gradient function. diff --git a/lisp/dired.el b/lisp/dired.el index 3cc490f12c7..3a76398e956 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1052,6 +1052,8 @@ BEG..END is the line where the file info is located." (set-marker file nil))))) +(defvar ls-lisp-use-insert-directory-program) + (defun dired-insert-directory (dir switches &optional file-list wildcard hdr) "Insert a directory listing of DIR, Dired style. Use SWITCHES to make the listings. @@ -1063,14 +1065,20 @@ If HDR is non-nil, insert a header line with the directory name." (let ((opoint (point)) (process-environment (copy-sequence process-environment)) end) - (if (or (if (eq dired-use-ls-dired 'unspecified) - ;; Check whether "ls --dired" gives exit code 0, and - ;; save the answer in `dired-use-ls-dired'. - (setq dired-use-ls-dired - (eq (call-process insert-directory-program nil nil nil "--dired") - 0)) - dired-use-ls-dired) - (file-remote-p dir)) + (if (and + ;; Don't try to invoke `ls' if we are on DOS/Windows where + ;; ls-lisp emulation is used, except if they want to use `ls' + ;; as indicated by `ls-lisp-use-insert-directory-program'. + (not (and (featurep 'ls-lisp) + (null ls-lisp-use-insert-directory-program))) + (or (if (eq dired-use-ls-dired 'unspecified) + ;; Check whether "ls --dired" gives exit code 0, and + ;; save the answer in `dired-use-ls-dired'. + (setq dired-use-ls-dired + (eq (call-process insert-directory-program nil nil nil "--dired") + 0)) + dired-use-ls-dired) + (file-remote-p dir))) (setq switches (concat "--dired " switches))) ;; We used to specify the C locale here, to force English month names; ;; but this should not be necessary any more, -- 2.39.5