GNU bug report logs - #67953
30.0.50; ls-lisp messes up columns

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Thu, 21 Dec 2023 14:37:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

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 67953 in the body.
You can then email your comments to 67953 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#67953; Package emacs. (Thu, 21 Dec 2023 14:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 21 Dec 2023 14:37:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; ls-lisp messes up columns
Date: Thu, 21 Dec 2023 09:35:55 -0500
Package: Emacs
Version: 30.0.50


After loading `ls-lisp`, I notice that with (setq
ls-lisp-use-insert-directory-program t) I get the nice:

    C-x d /u*/s* RET  ==>

      /:
      wildcard u*/s*/
      drwxr-xr-x   2 root root 20480 10 déc 11:24 usr/sbin/
      drwxr-xr-x 404 root root 16384  2 déc 15:05 usr/share/
      drwxr-xr-x   4 root root  4096 22 fév  2023 usr/src/

But with (setq ls-lisp-use-insert-directory-program nil) I get:

    C-x d /u*/s* RET  ==>

      /:
      wildcard u*/s*
      drwxr-xr-x  2 root root 20480 12-10 11:24 usr/sbin
      drwxr-xr-x404 root root 16384 12-02 15:05 usr/share
       drwxr-xr-x  4 root root 4096 2023-02-22  usr/src

Notice the weird extra space in front of the last line and the missing
space between "x" and "404" in the penultimate line.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67953; Package emacs. (Fri, 22 Dec 2023 09:02:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 67953 <at> debbugs.gnu.org
Subject: Re: bug#67953: 30.0.50; ls-lisp messes up columns
Date: Fri, 22 Dec 2023 11:01:18 +0200
> Date: Thu, 21 Dec 2023 09:35:55 -0500
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Package: Emacs
> Version: 30.0.50
> 
> 
> After loading `ls-lisp`, I notice that with (setq
> ls-lisp-use-insert-directory-program t) I get the nice:
> 
>     C-x d /u*/s* RET  ==>
> 
>       /:
>       wildcard u*/s*/
>       drwxr-xr-x   2 root root 20480 10 déc 11:24 usr/sbin/
>       drwxr-xr-x 404 root root 16384  2 déc 15:05 usr/share/
>       drwxr-xr-x   4 root root  4096 22 fév  2023 usr/src/
> 
> But with (setq ls-lisp-use-insert-directory-program nil) I get:
> 
>     C-x d /u*/s* RET  ==>
> 
>       /:
>       wildcard u*/s*
>       drwxr-xr-x  2 root root 20480 12-10 11:24 usr/sbin
>       drwxr-xr-x404 root root 16384 12-02 15:05 usr/share
>        drwxr-xr-x  4 root root 4096 2023-02-22  usr/src
> 
> Notice the weird extra space in front of the last line and the missing
> space between "x" and "404" in the penultimate line.

It's a bug in dired-align-file (it sounds like it was never tested
with a version of 'ls' that doesn't support the --dired switch).  Its
algorithm breaks down if the entry of a file does not start with
spaces.  --dired guarantees that, but ls-lisp doesn't, and I wonder
what other versions of 'ls' do.

The simple kludge below, which simply prevents it from realigning the
first column of data, seems to fix it here.  WDYT?

diff --git a/lisp/dired.el b/lisp/dired.el
index cc548ba..3838368 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1572,14 +1572,16 @@ dired-align-file
 		 ;; the beginning or the end of the next field, depending on
 		 ;; whether this field is left or right aligned).
 		 (align-pt-offset
-		  (save-excursion
-		    (goto-char other)
-		    (move-to-column curcol)
-		    (when (looking-at
-			   (concat
-			    (if (eq (char-before) ?\s) " *" "[^ ]* *")
-			    (if num-align "[0-9][^ ]*")))
-		      (- (match-end 0) (match-beginning 0)))))
+                  (if (zerop curcol)
+                      0
+		    (save-excursion
+		      (goto-char other)
+		      (move-to-column curcol)
+		      (when (looking-at
+			     (concat
+			      (if (eq (char-before) ?\s) " *" "[^ ]* *")
+			      (if num-align "[0-9][^ ]*")))
+		        (- (match-end 0) (match-beginning 0))))))
 		 ;; Now, the number of spaces to insert is align-pt-offset
 		 ;; minus the distance to the equivalent point on the
 		 ;; current line.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67953; Package emacs. (Fri, 22 Dec 2023 15:32:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 67953 <at> debbugs.gnu.org
Subject: Re: bug#67953: 30.0.50; ls-lisp messes up columns
Date: Fri, 22 Dec 2023 10:31:07 -0500
> The simple kludge below, which simply prevents it from realigning the
> first column of data, seems to fix it here.  WDYT?

Looks OK to me.  I'd recommend we add a comment about this (zerop
curcol) test explaining why the other branch mishandles this
case (or mentioning that we don't know why).


        Stefan


> diff --git a/lisp/dired.el b/lisp/dired.el
> index cc548ba..3838368 100644
> --- a/lisp/dired.el
> +++ b/lisp/dired.el
> @@ -1572,14 +1572,16 @@ dired-align-file
>  		 ;; the beginning or the end of the next field, depending on
>  		 ;; whether this field is left or right aligned).
>  		 (align-pt-offset
> -		  (save-excursion
> -		    (goto-char other)
> -		    (move-to-column curcol)
> -		    (when (looking-at
> -			   (concat
> -			    (if (eq (char-before) ?\s) " *" "[^ ]* *")
> -			    (if num-align "[0-9][^ ]*")))
> -		      (- (match-end 0) (match-beginning 0)))))
> +                  (if (zerop curcol)
> +                      0
> +		    (save-excursion
> +		      (goto-char other)
> +		      (move-to-column curcol)
> +		      (when (looking-at
> +			     (concat
> +			      (if (eq (char-before) ?\s) " *" "[^ ]* *")
> +			      (if num-align "[0-9][^ ]*")))
> +		        (- (match-end 0) (match-beginning 0))))))
>  		 ;; Now, the number of spaces to insert is align-pt-offset
>  		 ;; minus the distance to the equivalent point on the
>  		 ;; current line.





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 23 Dec 2023 11:06:01 GMT) Full text and rfc822 format available.

Notification sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
bug acknowledged by developer. (Sat, 23 Dec 2023 11:06:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 67953-done <at> debbugs.gnu.org
Subject: Re: bug#67953: 30.0.50; ls-lisp messes up columns
Date: Sat, 23 Dec 2023 13:05:20 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: 67953 <at> debbugs.gnu.org
> Date: Fri, 22 Dec 2023 10:31:07 -0500
> 
> > The simple kludge below, which simply prevents it from realigning the
> > first column of data, seems to fix it here.  WDYT?
> 
> Looks OK to me.  I'd recommend we add a comment about this (zerop
> curcol) test explaining why the other branch mishandles this
> case (or mentioning that we don't know why).

Done.  I decided to install this on master, since this is a very old
problem (I can see it in Emacs 26), and the situations where it rears
its ugly head are quite rare.

Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 20 Jan 2024 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 207 days ago.

Previous Next


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