help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Operation of format-mode-line


From: Yuri Khan
Subject: Re: Operation of format-mode-line
Date: Thu, 25 Jul 2024 19:50:54 +0700

On Thu, 25 Jul 2024 at 19:39, Heime <heimeborgia@protonmail.com> wrote:

> > The text properties are all generated by
> > propertized-buffer-identification, so if you leave that intact and
> > only change "%12b" to "%20b", all the rest should be as it was before.
>
> You really need to assist me with the code.  Have been working on modifying
> the width as seen in vodil-width.
>
> (defun vodil-width (new-width)
>   "Update the width of the buffer name in the mode line to NEW-WIDTH."
>
>   (let* ( (current-format
>               (format-mode-line mode-line-buffer-identification))
>           (new-format
>               (replace-regexp-in-string "%[0-9]+b"
>                 (format "%%%db" new-width) current-format)))
>
>     (setq mode-line-buffer-identification new-format)))

You are making it much more difficult for yourself. Just put the
following into your init file:

    (setq mode-line-buffer-identification
      (propertized-buffer-identification "%20b"))

If you insist on having a function that accepts the new width as a number:

    (defun my-set-mode-line-buffer-identification-width (new-width)
      (setq mode-line-buffer-identification
        (propertized-buffer-identification
          (format "%%%db" new-width))))

…but you really should not need this unless you are frequently
switching between very large and very small monitors.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]