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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 14 Nov 2023 15:26:38 +0200

> From: Liu Hui <[email-masked]>
> Date: Tue, 14 Nov 2023 17:52:58 +0800
> 
> The attached patch implements the feature of controlling the display
> length of filename in dired buffers.
> 
> When setting this option to `window', the long filename is shortened
> by hiding the middle part to ensure that the whole line needs not to
> be wrapped. The option can also be set to an integer, meaning the
> maximum display length of filename. For users who turn on line
> truncation, this feature can display the end part including the file
> extension, which I think is convenient.

Thanks.

> +(defcustom dired-filename-hiding-ellipsis "…"

We shouldn't use non-ASCII characters by default, without checking
they can be displayed.

> +    (let ((ell-len (string-width dired-filename-hiding-ellipsis))
> +          maxlen filename-col)
> +      (while (< (point) end)
> +        (ignore-errors
> +	  (if (not (dired-move-to-filename))

Did you consider using truncate-string-to-width here?