[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: eliding in mode-line-format
From: |
Yuri Khan |
Subject: |
Re: eliding in mode-line-format |
Date: |
Fri, 1 Oct 2021 21:23:08 +0700 |
On Fri, 1 Oct 2021 at 21:02, Manuel Giraud <manuel@ledu-giraud.fr> wrote:
> I'd like to have some kind eliding feature in the mode line.
>
> As a usage example, I'd like to be able to have "a buffer with a really
> long and meaning full name" that I'm able to track down (with icomplete
> for instance) but I want its "%b" mode line representation to be
> truncated to say n characters ("a buffer with…" for instance).
$ emacs -Q
(setq-default mode-line-buffer-identification
'(-15 (:eval (propertized-buffer-identification "%b"))))
Now you have buffer names truncated to 15 characters.
(See documentation on mode-line-format, also see the default value of
mode-line-format and all the parts it gets built from.)
Instead of using a list with a negative number at the front, you might
prefer defining a function to ellipsize a string. You then get to
choose an ellipsis character and whether to truncate from the start,
end or middle.