Subject: bug#67161: 30.0.50; [PATCH] Add option `dired-filename-display-length'

From: Eli Zaretskii <[email-masked]>
Date: Sun, 26 Nov 2023 07:59:29 +0200

> From: Liu Hui <[email-masked]>
> Date: Sun, 26 Nov 2023 10:56:52 +0800
> Cc: Juri Linkov <[email-masked]>, [email-masked]
> 
> Eli Zaretskii <[email-masked]> 于2023年11月26日周日 04:02写道：
> 
> > Does the below fix the problem, and is the Dired display after the
> > change correct when file names are truncated?
> >
> > diff --git a/lisp/dired.el b/lisp/dired.el
> > index 23a6fc0..096d6a8 100644
> > --- a/lisp/dired.el
> > +++ b/lisp/dired.el
> > @@ -2021,8 +2021,12 @@ dired--get-ellipsis-length
> >    (let* ((dt (or (window-display-table)
> >                   buffer-display-table
> >                   standard-display-table))
> > -         (glyphs (and dt (display-table-slot dt 'selective-display))))
> > -    (string-width (if glyphs (concat glyphs) "..."))))
> > +         (glyphs (and dt (display-table-slot dt 'selective-display)))
> > +         (vlen (length glyphs))
> > +         (char-glyphs (make-vector vlen nil)))
> > +    (dotimes (i vlen)
> > +      (aset char-glyphs i (glyph-char (aref glyphs i))))
> > +    (string-width (if glyphs (concat char-glyphs) "..."))))
> >
> >  (defun dired--get-filename-display-length ()
> >    "Return maximum display length of filename.
> 
> Thanks Eli! I wasn't aware of the face of glyph and I confirm the
> dired display is correct with your fix.

Thanks for testing.

However, I'm beginning to think that this is a subtle misfeature in
'concat': it should support vector of glyphs with faces, and should
preserve the face information (my patch simply discards faces, which
could perhaps affect string-width result).

So I think we should perhaps extend 'concat' to support vectors of
glyphs with faces.  Stefan, WDYT?