GNU bug report logs - #27762
26.0.50; ls-lisp: misalignment when dired-directory is a cons

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Wed, 19 Jul 2017 03:23:02 UTC

Severity: minor

Found in version 26.0.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27762 in the body.
You can then email your comments to 27762 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Wed, 19 Jul 2017 03:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 19 Jul 2017 03:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; ls-lisp: misalignment when dired-directory is a cons
Date: Wed, 19 Jul 2017 12:21:58 +0900
There are some misalignment on Dired buffers when using 'ls-lisp'
and 'dired-directory' is a cons.


I)
emacs -Q -l ls-lisp -eval '(setq ls-lisp-use-insert-directory-program nil)'
Eval this form:
(let* ((dir source-directory)
       (default-directory dir)
       (files (mapcar (lambda (f) (concat "src/" f))
	      	       	  (directory-files (expand-file-name "src") nil "\\.*\\.c\\'"))))
(dired (nconc (list dir) files)))
;; Note some lines have an additional space in front;  the space must
;; be added in the size column.

The first patch solves this problem.

II) Now suppose we want to list the same files _but_ we want that
"cyge32.c" appears the first.
emacs -Q -l ls-lisp -eval '(setq ls-lisp-use-insert-directory-program nil)'
Eval this form:

(let* ((dir source-directory)
       (default-directory dir)
       (files (mapcar (lambda (f) (concat "src/" f))
	      	          (cons "cygw32.c"
	      		            (delete "cygw32.c"
				                    (directory-files (expand-file-name "src") nil "\\.*\\.c\\'"))))))
(dired (nconc (list dir) files)))
;; Note how the first file looks misaligned.

--8<-----------------------------cut here---------------start------------->8---
commit b1889776b4fc808036da259b588365e85cf52324
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Wed Jul 19 11:16:13 2017 +0900

    * lisp/dired.el (dired-align-file): Add the spaces in size column.

diff --git a/lisp/dired.el b/lisp/dired.el
index 4fb4fe78f8..f4941e0d91 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1153,7 +1153,14 @@ dired-align-file
 	      (setq file-col (+ spaces file-col))
 	      (if (> file-col other-col)
 		  (setq spaces (- spaces (- file-col other-col))))
-	      (insert-char ?\s spaces)
+              ;; Add the spaces in front of the file size.
+              (when (search-forward-regexp directory-listing-before-filename-regexp nil t)
+                (goto-char (match-beginning 0))
+                ;; If size is in human readable units, then we should skip
+                ;; '.' and letters (units) as well.
+                (search-backward-regexp "[[:space:]]" nil t)
+                (skip-chars-forward "[:space:]")
+	        (insert-char ?\s spaces))
 	      ;; Let's just make really sure we did not mess up.
 	      (unless (save-excursion
 			(eq (dired-move-to-filename) (marker-position file)))


commit 16baaf7df330309be6490b115c513371c0660aef
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Wed Jul 19 11:52:30 2017 +0900

    ls-lisp: Fix dired format when dired-directory is a cons
    
    * lisp/ls-lisp.el (ls-lisp-obtain-formats): New defun extracted from
    ls-lisp-insert-directory.
    * lisp/dired.el (dired-readin-insert): Call it if 'dired-directory' is
    a cons and we are using ls-lisp.
    (ls-lisp-use-insert-directory-program): Move declaration before use
    this var.

diff --git a/lisp/dired.el b/lisp/dired.el
index f4941e0d91..95f438e912 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1035,15 +1035,20 @@ dired-readin
 
 ;; Subroutines of dired-readin
 
+(defvar ls-lisp-use-insert-directory-program)
+(declare-function ls-lisp-obtain-formats "ls-lisp" (alist file-list switches))
 (defun dired-readin-insert ()
   ;; Insert listing for the specified dir (and maybe file list)
   ;; already in dired-directory, assuming a clean buffer.
   (let (dir file-list)
-    (if (consp dired-directory)
+    (cond ((consp dired-directory)
+           (when (and (featurep 'ls-lisp)
+	              (null ls-lisp-use-insert-directory-program))
+             (ls-lisp-obtain-formats nil (cdr dired-directory) nil))
 	(setq dir (car dired-directory)
-	      file-list (cdr dired-directory))
-      (setq dir dired-directory
-	    file-list nil))
+	      file-list (cdr dired-directory)))
+          (t (setq dir dired-directory
+	           file-list nil)))
     (setq dir (expand-file-name dir))
     (if (and (equal "" (file-name-nondirectory dir))
 	     (not file-list))
@@ -1171,7 +1176,6 @@ dired-align-file
 	(set-marker file nil)))))
 
 
-(defvar ls-lisp-use-insert-directory-program)
 
 (defun dired-check-switches (switches short &optional long)
   "Return non-nil if the string SWITCHES matches LONG or SHORT format."
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index b368efbbc9..391afd16bd 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -338,6 +338,46 @@ ls-lisp--insert-directory
 		(insert " available " available)))))))))
 (advice-add 'insert-directory :around #'ls-lisp--insert-directory)
 
+(defun ls-lisp-obtain-formats (alist file-list switches)
+  (let ((file-alist (or alist
+                        (mapcar (lambda (f)
+                                  (nconc (list f) (file-attributes f))) file-list)))
+	(sum 0)
+        (max-uid-len 0)
+	(max-gid-len 0)
+	(max-file-size 0)
+        ;; do all bindings here for speed
+	total-line files elt short file-size attr
+	fuid fgid uid-len gid-len)
+    (dolist (elt file-alist)
+      (setq attr (cdr elt)
+	    fuid (nth 2 attr)
+	    uid-len (if (stringp fuid) (string-width fuid)
+		      (length (format "%d" fuid)))
+	    fgid (nth 3 attr)
+	    gid-len (if (stringp fgid) (string-width fgid)
+		      (length (format "%d" fgid)))
+	    file-size (nth 7 attr))
+      (if (> uid-len max-uid-len)
+	  (setq max-uid-len uid-len))
+      (if (> gid-len max-gid-len)
+	  (setq max-gid-len gid-len))
+      (if (> file-size max-file-size)
+	  (setq max-file-size file-size)))
+    (setq ls-lisp-uid-d-fmt (format " %%-%dd" max-uid-len))
+    (setq ls-lisp-uid-s-fmt (format " %%-%ds" max-uid-len))
+    (setq ls-lisp-gid-d-fmt (format " %%-%dd" max-gid-len))
+    (setq ls-lisp-gid-s-fmt (format " %%-%ds" max-gid-len))
+    (setq ls-lisp-filesize-d-fmt
+	  (format " %%%dd" (length (format "%.0f" max-file-size))))
+    (setq ls-lisp-filesize-f-fmt
+	  (format " %%%d.0f" (length (format "%.0f" max-file-size))))
+    (if (memq ?s switches)
+	(setq ls-lisp-filesize-b-fmt
+	      (format "%%%d.0f "
+		      (length (format "%.0f"
+				      (fceiling
+				       (/ max-file-size 1024.0)))))))))
 (defun ls-lisp-insert-directory
   (file switches time-index wildcard-regexp full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
@@ -381,35 +421,7 @@ ls-lisp-insert-directory
 	  ;; Find the appropriate format for displaying uid, gid, and
 	  ;; file size, by finding the longest strings among all the
 	  ;; files we are about to display.
-	  (dolist (elt file-alist)
-	    (setq attr (cdr elt)
-		  fuid (nth 2 attr)
-		  uid-len (if (stringp fuid) (string-width fuid)
-			    (length (format "%d" fuid)))
-		  fgid (nth 3 attr)
-		  gid-len (if (stringp fgid) (string-width fgid)
-			    (length (format "%d" fgid)))
-		  file-size (nth 7 attr))
-	    (if (> uid-len max-uid-len)
-		(setq max-uid-len uid-len))
-	    (if (> gid-len max-gid-len)
-		(setq max-gid-len gid-len))
-	    (if (> file-size max-file-size)
-		(setq max-file-size file-size)))
-	  (setq ls-lisp-uid-d-fmt (format " %%-%dd" max-uid-len))
-	  (setq ls-lisp-uid-s-fmt (format " %%-%ds" max-uid-len))
-	  (setq ls-lisp-gid-d-fmt (format " %%-%dd" max-gid-len))
-	  (setq ls-lisp-gid-s-fmt (format " %%-%ds" max-gid-len))
-	  (setq ls-lisp-filesize-d-fmt
-		(format " %%%dd" (length (format "%.0f" max-file-size))))
-	  (setq ls-lisp-filesize-f-fmt
-		(format " %%%d.0f" (length (format "%.0f" max-file-size))))
-	  (if (memq ?s switches)
-	      (setq ls-lisp-filesize-b-fmt
-		    (format "%%%d.0f "
-			    (length (format "%.0f"
-					    (fceiling
-					     (/ max-file-size 1024.0)))))))
+	  (ls-lisp-obtain-formats file-alist nil switches)
 	  (setq files file-alist)
 	  (while files			; long (-l) format
 	    (setq elt (car files)

--8<-----------------------------cut here---------------end--------------->8---
The second patch seems to fix this problem.
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-18
Repository revision: be79366410703a788c3c8ce7951e89bc9dfdac88




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Wed, 19 Jul 2017 17:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Wed, 19 Jul 2017 20:04:33 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Wed, 19 Jul 2017 12:21:58 +0900
> 
> 
> There are some misalignment on Dired buffers when using 'ls-lisp'
> and 'dired-directory' is a cons.
> 
> 
> I)
> emacs -Q -l ls-lisp -eval '(setq ls-lisp-use-insert-directory-program nil)'
> Eval this form:
> (let* ((dir source-directory)
>        (default-directory dir)
>        (files (mapcar (lambda (f) (concat "src/" f))
> 	      	       	  (directory-files (expand-file-name "src") nil "\\.*\\.c\\'"))))
> (dired (nconc (list dir) files)))
> ;; Note some lines have an additional space in front;  the space must
> ;; be added in the size column.
> 
> The first patch solves this problem.
> 
> II) Now suppose we want to list the same files _but_ we want that
> "cyge32.c" appears the first.
> emacs -Q -l ls-lisp -eval '(setq ls-lisp-use-insert-directory-program nil)'
> Eval this form:
> 
> (let* ((dir source-directory)
>        (default-directory dir)
>        (files (mapcar (lambda (f) (concat "src/" f))
> 	      	          (cons "cygw32.c"
> 	      		            (delete "cygw32.c"
> 				                    (directory-files (expand-file-name "src") nil "\\.*\\.c\\'"))))))
> (dired (nconc (list dir) files)))
> ;; Note how the first file looks misaligned.

Thanks, but I'd prefer to keep the ls-lisp related stuff confined to
ls-lisp.el.  Is it possible to rewrite the patch such that dired.el
code doesn't need to call ls-lisp functions directly (and thus the
need for (featurep 'ls-lisp) etc. would be avoided)?

Also, what exactly is the source of the differences between ls-lisp
and the 'ls' command, and are you sure the differences aren't specific
to GNU 'ls'?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Thu, 20 Jul 2017 03:46:02 GMT) Full text and rfc822 format available.

Message #11 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Thu, 20 Jul 2017 12:45:22 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

>> II) Now suppose we want to list the same files _but_ we want that
>> "cyge32.c" appears the first.
>> emacs -Q -l ls-lisp -eval '(setq ls-lisp-use-insert-directory-program nil)'
>> Eval this form:
>> 
>> (let* ((dir source-directory)
>>        (default-directory dir)
>>        (files (mapcar (lambda (f) (concat "src/" f))
>> 	      	          (cons "cygw32.c"
>> 	      		            (delete "cygw32.c"
>> 				                    (directory-files (expand-file-name "src") nil "\\.*\\.c\\'"))))))
>> (dired (nconc (list dir) files)))
>> ;; Note how the first file looks misaligned.
>
> Thanks, but I'd prefer to keep the ls-lisp related stuff confined to
> ls-lisp.el.  Is it possible to rewrite the patch such that dired.el
> code doesn't need to call ls-lisp functions directly (and thus the
> need for (featurep 'ls-lisp) etc. would be avoided)?
Thanks.  Yes, that sounds better.

> Also, what exactly is the source of the differences between ls-lisp
> and the 'ls' command, and are you sure the differences aren't specific
> to GNU 'ls'?

I think II) above is not specific of ls-lisp: the same happen with
GNU ls.
 
With emacs -Q:

(let* ((dir (expand-file-name "src" source-directory))
         (default-directory dir))
  (dired (list dir "cygw32.c" "alloc.c" "w32xfns.c" "xdisp.c")) ; Wrong aligment.
  ;; Following just fix the first file, but xdisp.c keeps misaligned.
  (dired-goto-file (expand-file-name "cygw32.c"))
  (forward-line 0)
  (let ((inhibit-read-only t))
    (dired-align-file (point) (point-max))))


Note that when i eval the previous form GNU 'ls' is used, and i see misalignment.
I would expect `dired-align-file' fix this problem, but i doesn't.

*) Since this is not specific of `ls-lisp', one alternative fix could
   be to run `dired-align-file' at the end of `dired-internal-noselect'
   when `dired-directory' is a cons.

**) First, we must fix `dired-lign-file', which is not doing its job
    in the snippet above.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Fri, 21 Jul 2017 04:56:02 GMT) Full text and rfc822 format available.

Message #14 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Fri, 21 Jul 2017 13:55:26 +0900
> With emacs -Q:
>
> (let* ((dir (expand-file-name "src" source-directory))
>          (default-directory dir))
>   (dired (list dir "cygw32.c" "alloc.c" "w32xfns.c" "xdisp.c")) ; Wrong aligment.
>   ;; Following just fix the first file, but xdisp.c keeps misaligned.
>   (dired-goto-file (expand-file-name "cygw32.c"))
>   (forward-line 0)
>   (let ((inhibit-read-only t))
>     (dired-align-file (point) (point-max))))
>
>
> Note that when i eval the previous form GNU 'ls' is used, and i see misalignment.
> I would expect `dired-align-file' fix this problem, but i doesn't.
>
> *) Since this is not specific of `ls-lisp', one alternative fix could
>    be to run `dired-align-file' at the end of `dired-internal-noselect'
>    when `dired-directory' is a cons.
>
> **) First, we must fix `dired-lign-file', which is not doing its job
>     in the snippet above.
Eli, how do you think about following patch?

--8<-----------------------------cut here---------------start------------->8---
commit 458fe93358594cf7338180b6feb54eb37d28ed21
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Fri Jul 21 13:50:56 2017 +0900

    Fix misalignment in Dired when dired-directory is a cons
    
    * lisp/dired.el (dired--need-align-p, dired--align-all-files):
    New defuns.
    (dired-internal-noselect): Call dired--align-all-files when
    dired-directory is a cons (Bug#27762).
    * test/lisp/dired-tests.el (dired-test-bug27762): Test should pass.

diff --git a/lisp/dired.el b/lisp/dired.el
index 9d500a9f52..371af15f79 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -34,6 +34,7 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'subr-x))
 ;; When bootstrapping dired-loaddefs has not been generated.
 (require 'dired-loaddefs nil t)
 
@@ -871,6 +872,46 @@ dired-auto-revert-buffer
   :group 'dired
   :version "23.2")
 
+(defun dired--need-align-p ()
+  "Return non-nil if some file names are misaligned.
+The return value is the target column for the file names."
+  (save-excursion
+    (goto-char (point-min))
+    (dired-goto-next-file)
+    ;; Use point difference instead of `current-column', because
+    ;; the former works when `dired-hide-details-mode' is enabled.
+    (let* ((first (- (point) (point-at-bol)))
+           (target first))
+      (while (and (not (eobp))
+                  (progn
+                    (forward-line)
+                    (dired-move-to-filename)))
+        (when-let* ((col-diff (- (point) (point-at-bol)))
+                    (higher (> col-diff target)))
+          (setq target col-diff)))
+      (and (/= first target) target))))
+
+(defun dired--align-all-files ()
+  "Align all files adding spaces in front of the size column."
+  (let ((target (dired--need-align-p))
+        (regexp directory-listing-before-filename-regexp))
+    (when target
+      (save-excursion
+        (goto-char (point-min))
+        (dired-goto-next-file)
+        (while (dired-move-to-filename)
+          (let ((col-diff (- target (- (point) (point-at-bol))))
+                (inhibit-read-only t)
+                props)
+            (unless (zerop col-diff)
+              (re-search-backward regexp nil t)
+              (goto-char (match-beginning 0))
+              (search-backward-regexp "[[:space:]]" nil t)
+              (setq props (text-properties-at (1- (point))))
+              (skip-chars-forward "[:space:]")
+              (insert (apply #'propertize (make-string col-diff ?\s) props)))
+            (forward-line)))))))
+
 (defun dired-internal-noselect (dir-or-list &optional switches mode)
   ;; If DIR-OR-LIST is a string and there is an existing dired buffer
   ;; for it, just leave buffer as it is (don't even call dired-revert).
@@ -939,6 +980,8 @@ dired-internal-noselect
 	  (if failed (kill-buffer buffer))))
       (goto-char (point-min))
       (dired-initial-position dirname))
+    (when (consp dired-directory)
+      (dired--align-all-files))
     (set-buffer old-buf)
     buffer))
 
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index bd1816172e..d5f999aab6 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -147,7 +147,6 @@
 
 (ert-deftest dired-test-bug27762 ()
   "Test for http://debbugs.gnu.org/27762 ."
-  :expected-result :failed
   (let* ((dir source-directory)
          (default-directory dir)
          (files (mapcar (lambda (f) (concat "src/" f))

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-21
Repository revision: 1d559e384b467b3f74e8b78695f124b561c884d9





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Sat, 29 Jul 2017 08:10:01 GMT) Full text and rfc822 format available.

Message #17 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Sat, 29 Jul 2017 11:09:07 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 27762 <at> debbugs.gnu.org
> Date: Fri, 21 Jul 2017 13:55:26 +0900
> 
> 
> > With emacs -Q:
> >
> > (let* ((dir (expand-file-name "src" source-directory))
> >          (default-directory dir))
> >   (dired (list dir "cygw32.c" "alloc.c" "w32xfns.c" "xdisp.c")) ; Wrong aligment.
> >   ;; Following just fix the first file, but xdisp.c keeps misaligned.
> >   (dired-goto-file (expand-file-name "cygw32.c"))
> >   (forward-line 0)
> >   (let ((inhibit-read-only t))
> >     (dired-align-file (point) (point-max))))
> >
> >
> > Note that when i eval the previous form GNU 'ls' is used, and i see misalignment.
> > I would expect `dired-align-file' fix this problem, but i doesn't.
> >
> > *) Since this is not specific of `ls-lisp', one alternative fix could
> >    be to run `dired-align-file' at the end of `dired-internal-noselect'
> >    when `dired-directory' is a cons.
> >
> > **) First, we must fix `dired-lign-file', which is not doing its job
> >     in the snippet above.
> Eli, how do you think about following patch?

Looks OK, but why this complicated code:

> +        (when-let* ((col-diff (- (point) (point-at-bol)))
> +                    (higher (> col-diff target)))
> +          (setq target col-diff)))
> +      (and (/= first target) target))))

Doesn't current-column do its job in this case?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Tue, 01 Aug 2017 07:02:02 GMT) Full text and rfc822 format available.

Message #20 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Tue, 01 Aug 2017 16:01:17 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

> Looks OK, but why this complicated code:
>
>> +        (when-let* ((col-diff (- (point) (point-at-bol)))
>> +                    (higher (> col-diff target)))
>> +          (setq target col-diff)))
>> +      (and (/= first target) target))))
>
> Doesn't current-column do its job in this case?
That is to work regardless on the `dired-hide-details-mode' value.
If we use `current-column' we are in trouble.
Consider the following:

;; Definition uses `current-column'.
(defun dired--need-align-p ()
  "Return non-nil if some file names are misaligned.
The return value is the target column for the file names."
  (save-excursion
    (goto-char (point-min))
    (dired-goto-next-file)
    ;; Use point difference instead of `current-column', because
    ;; the former works when `dired-hide-details-mode' is enabled.
    (let* ((first (current-column))
           (target first))
      (while (and (not (eobp))
                  (progn
                    (forward-line)
                    (dired-move-to-filename)))
        (when (> (current-column) target)
          (setq target (current-column))))
      (and (/= first target) target))))

;; Eval following form:
(let* ((dir (expand-file-name "src" source-directory))
         (default-directory dir))
    (dired (list dir "alloc.c" "w32xfns.c" "xdisp.c")) ; Wrong aligment.
  ;; Following just fix the first file, but xdisp.c keeps misaligned.
  (dired-goto-file (expand-file-name "cygw32.c"))
  (forward-line 0)
  (let ((inhibit-read-only t))
    (dired-align-file (point) (point-max))))

M-: (dired--need-align-p) RET
=> t
( ; toggle dired-hide-details-mode
M-: (dired--need-align-p) RET
=> nil
( ; Toggle again: the files still are misaligned.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Tue, 01 Aug 2017 13:47:01 GMT) Full text and rfc822 format available.

Message #23 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Tue, 01 Aug 2017 16:46:02 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 27762 <at> debbugs.gnu.org
> Date: Tue, 01 Aug 2017 16:01:17 +0900
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Looks OK, but why this complicated code:
> >
> >> +        (when-let* ((col-diff (- (point) (point-at-bol)))
> >> +                    (higher (> col-diff target)))
> >> +          (setq target col-diff)))
> >> +      (and (/= first target) target))))
> >
> > Doesn't current-column do its job in this case?
> That is to work regardless on the `dired-hide-details-mode' value.
> If we use `current-column' we are in trouble.

Then (a) please mention this issue in a comment before this fragment,
and (b) please don't call the variable "column", because it's
confusing.

Thanks.




Reply sent to Tino Calancha <tino.calancha <at> gmail.com>:
You have taken responsibility. (Tue, 01 Aug 2017 15:09:02 GMT) Full text and rfc822 format available.

Notification sent to Tino Calancha <tino.calancha <at> gmail.com>:
bug acknowledged by developer. (Tue, 01 Aug 2017 15:09:03 GMT) Full text and rfc822 format available.

Message #28 received at 27762-done <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 27762-done <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Wed, 02 Aug 2017 00:08:02 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Cc: 27762 <at> debbugs.gnu.org
>> Date: Tue, 01 Aug 2017 16:01:17 +0900
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > Looks OK, but why this complicated code:
>> >
>> >> +        (when-let* ((col-diff (- (point) (point-at-bol)))
>> >> +                    (higher (> col-diff target)))
>> >> +          (setq target col-diff)))
>> >> +      (and (/= first target) target))))
>> >
>> > Doesn't current-column do its job in this case?
>> That is to work regardless on the `dired-hide-details-mode' value.
>> If we use `current-column' we are in trouble.
>
> Then (a) please mention this issue in a comment before this fragment,
> and (b) please don't call the variable "column", because it's
> confusing.
a) The comment is right before the while loop.
b) Done.
Pushed into master as commit f74164a845eff579635da0a1267514ef9d040ad2




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27762; Package emacs. (Tue, 01 Aug 2017 15:44:01 GMT) Full text and rfc822 format available.

Message #31 received at 27762 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27762 <at> debbugs.gnu.org
Subject: Re: bug#27762: 26.0.50;
 ls-lisp: misalignment when dired-directory is a cons
Date: Tue, 01 Aug 2017 18:43:12 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Wed, 02 Aug 2017 00:08:02 +0900
> 
> > Then (a) please mention this issue in a comment before this fragment,
> > and (b) please don't call the variable "column", because it's
> > confusing.
> a) The comment is right before the while loop.
> b) Done.
> Pushed into master as commit f74164a845eff579635da0a1267514ef9d040ad2

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 30 Aug 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.