Subject: bug#72309: propertized-buffer-identification with maximum width

From: Heime <[email-masked]>
Date: Sun, 28 Jul 2024 10:55:31 +0000

Sent with Proton Mail secure email.

On Sunday, July 28th, 2024 at 4:55 PM, Eli Zaretskii <[email-masked]> wrote:

> > Date: Sat, 27 Jul 2024 20:49:05 +0000
> > From: Heime [email-masked]
> > Cc: [email-masked], Eli Zaretskii [email-masked]
> > 
> > On Sunday, July 28th, 2024 at 3:27 AM, Heime via "Bug reports for GNU Emacs, the Swiss army knife of text editors" [email-masked] wrote:
> > 
> > > Sent with Proton Mail secure email.
> > > 
> > > On Sunday, July 28th, 2024 at 2:56 AM, Heime via "Bug reports for GNU Emacs, the Swiss army knife of text editors" [email-masked] wrote:
> > > 
> > > > Sent with Proton Mail secure email.
> > > > 
> > > > On Sunday, July 28th, 2024 at 1:29 AM, Eli Zaretskii [email-masked] wrote:
> > > > 
> > > > > > Date: Sat, 27 Jul 2024 13:08:31 +0000
> > > > > > From: Heime [email-masked]
> > > > > > Cc: [email-masked]
> > > > > > 
> > > > > > On Sunday, July 28th, 2024 at 1:00 AM, Eli Zaretskii [email-masked] wrote:
> > > > > > 
> > > > > > > Yes, but the (WIDTH something) construct is not for truncating long
> > > > > > > names, it's for ensuring the string produced by "something" doesn't
> > > > > > > take too many columns. So you are using this for a wrong purpose. If
> > > > > > > you want to truncate a buffer's name, use truncate-string-to-width
> > > > > > > instead, which is also capable of showing the ellipsis at the end.
> > > > > > 
> > > > > > I do not know how to access the buffer name and apply truncate-string-to-width
> > > > > > when setting mode-line-buffer-identification on propertized-buffer-identification.
> > > > > 
> > > > > Use :eval.
> > > > 
> > > > I have done it without success
> > > > 
> > > > (defun vodil-rtgbfn (wmin)
> > > > (setq-default mode-line-buffer-identification
> > > > (propertized-buffer-identification (format " %%%db " wmin))))
> > > > 
> > > > (vodil-rtgbfn 8)
> > > > 
> > > > (setq-default mode-line-format
> > > > '( "%e" (:eval (truncate-string-to-width mode-line-buffer-identification 13))
> > > > vodil-panelit-bfselec))
> > > 
> > > Have now done, but now the buffer name is not displayed. Why has there
> > > to be so much torture to change the defaults !
> > > 
> > > (defun vodil-tkbfn-ellipses (wmax)
> > > "Get the buffer name truncated to WMAX width with ellipsis."
> > > 
> > > (let* ( (bfname (buffer-name (window-buffer)))
> > > (tkname (if (> (length bfname) wmax)
> > > 
> > > (truncate-string-to-width bfname wmax nil nil "...")
> > > bfname)))
> > > (propertized-buffer-identification (format " %s " tkname))))
> > > 
> > > (defun vodil-tkbfn (wmax)
> > > "Set mode-line-buffer-identification with WMAX maximum width."
> > > 
> > > (setq-default mode-line-buffer-identification
> > > '(:eval (vodil-tkbfn-ellipses wmax))))
> > 
> > What is the big problem of showing how to implement this, buffer name
> > with truncation ellipses using mode-line-buffer-identification ?
> 
> 
> We don't have people here whose job is to write code for others. This
> is a volunteer-based project, where people help you with ideas, but
> the actual job of writing and debugging the code is yours.
> 
> So please take the ideas, read the documentation, and work on the
> implementation you want. If you have questions about the
> implementation, please ask them on help-gnu-emacs, which is where
> user-level help should be sought.

Could there be a bug.  I have tried the various ideas and suggestions
and they did not work as others thought they would.  One implementation
that worked (using (width rest)) got a lot of gripe and was turned down.

Se I am back to where I have started.
 
> > Can there be some additional commands to make this possibility less
> > cumbersome. For instance, an option that gives mode-line-buffer-identification
> > with truncation ellipses.
> 
> No.

And people with small screen, what do they do ?  With all the minor modes displaying
in the modeline, it becomes unusable (meaning that its contents goes beyond the window).