From: Po Lu Date: Tue, 9 Apr 2024 07:24:30 +0000 (+0800) Subject: Fix misalignment of entries created by Dired file operations X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2db68cf50af99b5d1909bb247f7c99f65754adbf;p=emacs.git Fix misalignment of entries created by Dired file operations * lisp/dired.el (dired-insert-directory): Insert leading space if absent before calling dired-align-file. (cherry picked from commit 22386c5634ba72d4f7b321524509c1e3549fe4d2) --- diff --git a/lisp/dired.el b/lisp/dired.el index f0113c002a4..28ec187e666 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1740,8 +1740,16 @@ see `dired-use-ls-dired' for more details.") (file-expand-wildcards (cdr dir-wildcard)))) (let ((beg (point))) (insert-directory f switches nil nil) - ;; Re-align fields, if necessary. - (dired-align-file beg (point)))))) + ;; `dired-align-file' doesn't fare well with dired + ;; implementations that don't indent entries by one + ;; column, which in all known implementations is + ;; equivalent to not supporting `--dired'. + (save-excursion + (goto-char beg) + (unless (looking-at " ") + (insert " "))) + ;; Re-align fields, if necessary. + (dired-align-file beg (point)))))) (t (insert-directory dir switches wildcard (not wildcard)))) ;; Quote certain characters, unless ls quoted them for us.