--- ../emacs/lisp/ls-lisp.el 2021-06-06 23:11:38.317648694 +0200 +++ ./ls-lisp.el 2021-07-16 16:54:51.413276991 +0200 @@ -682,24 +682,27 @@ (ding) (sit-for 2)))) ; to show user the message! (if (memq ?F switches) ; classify switch (setq file-alist (mapcar 'ls-lisp-classify file-alist))) - (if ls-lisp-dirs-first - ;; Re-sort directories first, without otherwise changing the - ;; ordering, and reverse whole list. cadr of each element of - ;; `file-alist' is t for directory, string (name linked to) for - ;; symbolic link, or nil. - (let (el dirs files) - (while file-alist - (if (or (eq (cadr (setq el (car file-alist))) t) ; directory - (and (stringp (cadr el)) - (file-directory-p (cadr el)))) ; symlink to a directory - (setq dirs (cons el dirs)) - (setq files (cons el files))) - (setq file-alist (cdr file-alist))) - (setq file-alist - (if (memq ?U switches) ; unsorted order is reversed - (nconc dirs files) - (nconc files dirs) - )))) + (let ((dirs-first (or ls-lisp-dirs-first + (string-match "groupdirectoriesfirst" (concat + switches))))) + (if dirs-first + ;; Re-sort directories first, without otherwise changing the + ;; ordering, and reverse whole list. cadr of each element of + ;; `file-alist' is t for directory, string (name linked to) for + ;; symbolic link, or nil. + (let (el dirs files) + (while file-alist + (if (or (eq (cadr (setq el (car file-alist))) t) ; directory + (and (stringp (cadr el)) + (file-directory-p (cadr el)))) ; symlink to a directory + (setq dirs (cons el dirs)) + (setq files (cons el files))) + (setq file-alist (cdr file-alist))) + (setq file-alist + (if (memq ?U switches) ; unsorted order is reversed + (nconc dirs files) + (nconc files dirs) + ))))) ;; Finally reverse file alist if necessary. ;; (eq below MUST compare `(not (memq ...))' to force comparison of ;; t or nil, rather than list tails!)