[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27762: 26.0.50; ls-lisp: misalignment when dired-directory is a cons
From: |
Tino Calancha |
Subject: |
bug#27762: 26.0.50; ls-lisp: misalignment when dired-directory is a cons |
Date: |
Tue, 01 Aug 2017 16:01:17 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
Eli Zaretskii <eliz@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.
- bug#27762: 26.0.50; ls-lisp: misalignment when dired-directory is a cons,
Tino Calancha <=