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.

Full log


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.




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

Previous Next


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