]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix misalignment of entries created by Dired file operations
authorPo Lu <luangruo@yahoo.com>
Tue, 9 Apr 2024 07:24:30 +0000 (15:24 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 10 Apr 2024 20:29:56 +0000 (22:29 +0200)
* lisp/dired.el (dired-insert-directory): Insert leading space
if absent before calling dired-align-file.

(cherry picked from commit 22386c5634ba72d4f7b321524509c1e3549fe4d2)

lisp/dired.el

index f0113c002a438a1c20556ed63bf739d33b5d1c8e..28ec187e6664045712d4b092c2e1027f651a866d 100644 (file)
@@ -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.