From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67953: 30.0.50; ls-lisp messes up columns Date: Fri, 22 Dec 2023 11:01:18 +0200 Message-ID: <83jzp6fw69.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27642"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67953@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 22 10:02:53 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rGbQj-0006yc-70 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Dec 2023 10:02:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGbQ6-0005r5-9C; Fri, 22 Dec 2023 04:02:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGbPp-0005Z2-Uw for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2023 04:01:58 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGbPp-0002aV-M6 for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2023 04:01:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rGbPt-0001c2-TY for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2023 04:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Dec 2023 09:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67953 X-GNU-PR-Package: emacs Original-Received: via spool by 67953-submit@debbugs.gnu.org id=B67953.17032357056174 (code B ref 67953); Fri, 22 Dec 2023 09:02:01 +0000 Original-Received: (at 67953) by debbugs.gnu.org; 22 Dec 2023 09:01:45 +0000 Original-Received: from localhost ([127.0.0.1]:46036 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGbPc-0001bW-GI for submit@debbugs.gnu.org; Fri, 22 Dec 2023 04:01:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGbPZ-0001bJ-HJ for 67953@debbugs.gnu.org; Fri, 22 Dec 2023 04:01:42 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGbPP-0002XQ-NE; Fri, 22 Dec 2023 04:01:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=i0Tm3XnL2kR68fQqDgwwjT3ChXL/ZVrVjwM+N70GVho=; b=l03+lgfo9pK/+Gbu33mw P8hCBe9d28G0ZsE5m4MStgcU3GkoklXSqPNtd9L8CwOu4vP+UUR08xFzSAFdnUGLfIYOaNRRNFt9b VQcon1BTBmtlx93kczDq7q0YYVUji++iCWufJWlKARIJ7nStfVn/7cCiNKuWfAEhw1MR9Aaexn4vU MpUBuyPObpjAm9TiUypV+zYz30+CyizQ2O1ZH4985w5WlyEGCPnfEgrXKAsx6QeA9YHAp2WXV9Kxo 4IClkYk2F7Iypzr6NVcQJkxLjrpOWkS8SIn5Mq1qhT2tr1O/oZ2hzNFWBtJtWnmI8oTv3VIYopEWt g+ueJxY7hHn6yw==; In-Reply-To: (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276652 Archived-At: > 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" > > 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.