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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 25 Nov 2023 22:02:38 +0200

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sat, 25 Nov 2023 19:51:55 +0200
> 
> > Thanks, installed on the master branch, and closing the bug.
> 
> There is a problem with this specific configuration
> when ellipsis is a vector:
> 
>   (progn
>     (or standard-display-table (setq standard-display-table (make-display-table)))
>     (let* ((face (lsh (face-id 'escape-glyph) 22))
>            (dots (+ face ?…)))
>       (set-char-table-extra-slot standard-display-table 4 (vector dots))))
> 
> that fails with
> 
>   Debugger entered--Lisp error: (wrong-type-argument characterp 88088614)
>     concat([88088614])
>     (if glyphs (concat glyphs) "...")
>     (string-width (if glyphs (concat glyphs) "..."))
>     dired--get-ellipsis-length()
>     ...
> 

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.