Subject: bug#77361: [PATCH] New user option to hide minor mode lighters, [PATCH] New user option to hide minor mode lighters

From: Daniel Mendler <[email-masked]>
Date: Sat, 05 Apr 2025 13:45:10 +0200

Hello Pengji!

Pengji Zhang <[email-masked]> writes:
> The attached patch adds a new user option to hide some minor mode
> lighters on the mode line (by collapsing them into a menu), which is to
> shorten the mode line and prioritize important information when many
> minor modes are on.
>
> There exist a few packages that solve the problem. To name a few:
>
> - diminish[1] and delight[2]. Both offer a way to change the minor mode
>   lighters by modifying 'minor-mode-alist'. To hide a minor mode
>   lighter, one may change it to nil.
>
> - minions[3], which partially inspired this patch. It replaces minor
>   mode lighters by a menu to toggle all minor modes.
>
> This patch is different from those solutions in two aspects:
>
> - Unlike diminish or delight, one can still see the lighters by clicking
>   the button, instead of hiding them permanently. Besides, this patch is
>   compatible with those two packages.
>
> - Unlike minions, this patch focuses on *lighters* for *enabled* minor
>   modes. The menu contains only lighters, making it a more space
>   efficient replacement for lighters on mode line, instead of a way to
>   manage minor modes like minions.
>
> So I hope this patch is still useful given the existing similar
> solutions.
>
> Please let me know what you think. Thanks!

This is a good idea. I've used both minions and diminish and it is nice
to have this functionality ootb. I have some concerns however regarding
the frequent mode line recomputation during redisplay. Do you see a
possibility to cache the computed minor mode menu and collapsed lighter?
In any case, the computation should be as efficient as possible. For
profiling I suggest to enable your new user option and then scroll
repeatedly in order to force redisplays and mode line recomputations. If
certain mode line functions appear prominently in the profile they are
candidates for optimization, in order to reduce redisplay latency.

Daniel