From 33af1f98b44c426fdef241496515dfa0cf87a0b1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 14 Apr 2021 17:40:57 -0400 Subject: [PATCH] emacs/dired: drop non-standard switches on Windows On Windows (or systems that don't support ls), ls-lisp-use-insert-directory-program will be nil. In these cases, strip out non-standard switches so they don't throw an error and make dired unusuable. Fixes #3939 --- modules/emacs/dired/config.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index a2ef28c08..307dd56e4 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -36,12 +36,14 @@ (setq dired-listing-switches (string-join args " ")) (add-hook! 'dired-mode-hook - (defun +dired-disable-gnu-ls-flags-in-tramp-buffers-h () - "Fix #1703: dired over TRAMP displays a blank screen. + (defun +dired-disable-gnu-ls-flags-maybe-h () + "Remove extraneous switches from `dired-actual-switches' when it's +uncertain that they are supported (e.g. over TRAMP or on Windows). -This is because there's no guarantee the remote system has GNU ls, which is the -only variant that supports --group-directories-first." - (when (file-remote-p default-directory) +Fixes #1703: dired over TRAMP displays a blank screen. +Fixes #3939: unsortable dired entries on Windows." + (when (or (file-remote-p default-directory) + (not (bound-and-true-p ls-lisp-use-insert-directory-program))) (setq-local dired-actual-switches (car args)))))) ;; Don't complain about this command being disabled when we use it