GNU bug report logs - #77361
[PATCH] New user option to hide minor mode lighters

Previous Next

Package: emacs;

Reported by: Pengji Zhang <me <at> pengjiz.com>

Date: Sat, 29 Mar 2025 11:09:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #28 received at 77361 <at> debbugs.gnu.org (full text, mbox):

From: Pengji Zhang <me <at> pengjiz.com>
To: Jonas Bernoulli <jonas <at> bernoul.li>
Cc: 77361 <at> debbugs.gnu.org
Subject: Re: bug#77361: [PATCH] New user option to hide minor mode lighters
Date: Sat, 19 Apr 2025 12:30:42 +0800
[Message part 1 (text/plain, inline)]
(Cc'ing the bug tracker thread in case others would like to chime in.)

Hello Jonas,

Jonas Bernoulli <jonas <at> bernoul.li> writes:

> Pengji Zhang <me <at> pengjiz.com> writes:
>
>> - 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.
>
> As the author of minions I am going to stick with that, but even then
> the addition of `mode-line-minor-modes' is beneficial.  Minions can
> now just modify this trivial element instead of the much more complex
> `mode-line-modes', which lead to a lot of duplication (or alternatively
> fragile patching of the built-in value).

Thanks! Good to know it is useful to minions as well.

> Unfortunately one still has to modify `mode-line-modes' to remove the
> parens around the modes.  IMO these are just unnecessary noise if one
> uses minions or the new mode-line-collapse-minor-modes.
>
>   Messages …
>
> is good enough for me, I can see how one might want parens if showing
> enabled minor-modes directly in the mode-line
>
>   (Messages foobar schalala other modes here)
>
> So I would like to suggest the addition of something like:
>
> (defcustom mode-line-modes-delimiters '("(" . ")")
>   "Strings placed near the edges of `mode-line-modes'."
>   :type '(choice (const :tag "No delimiters")
>                  (cons (string :tag "Opening string")
>                        (string :tag "Closing string")))
>   :group 'mode-line
>   :version "31.1")
>
> used like so
>
>  (defvar mode-line-modes
> ...
> -         "("
> +         '(:eval (car mode-line-modes-delimiters))
> ...
> -         ")"
> +         '(:eval (cdr mode-line-modes-delimiters))

Just my two cents -- I do think that it is good to make the delimiters
customizable.

> Additionally you might want to consider making the menu string
> customizable instead of using
>
> (if (char-displayable-p ?…) " …" " ...")

That makes sense. Please find the attached patch.

>      Cheers,
>      Jonas

Regards,
Pengji

[0001-Make-lighter-customizable-for-collapsed-minor-modes-.patch (text/x-patch, inline)]
From 656f03f48b2af0afab1e20ea3f13b2a007bc2bb8 Mon Sep 17 00:00:00 2001
From: Pengji Zhang <me <at> pengjiz.com>
Date: Sat, 19 Apr 2025 12:04:36 +0800
Subject: [PATCH] Make lighter customizable for collapsed minor modes
 (bug#77361)

* lisp/bindings.el (mode-line-collapsed-minor-modes-lighter):
New option for the collapsed lighter of minor modes.
(mode-line-collapse-minor-modes): Mention that the collapsed
lighter could be customized.
(mode-line--minor-modes): Use the new option.
* etc/NEWS: Announce the new option.
---
 etc/NEWS         |  5 +++++
 lisp/bindings.el | 14 ++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 98f8e703013..ac06b214499 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -334,6 +334,11 @@ single button.  The value could also be a list to specify minor mode
 lighters to hide or show.  The default value is nil, which retains the
 previous behavior of showing all minor mode lighters.
 
+---
+*** New user option 'mode-line-collapsed-minor-modes-lighter'.
+The value should be a string to speficify the mode line lighter for
+collapsed minor modes.
+
 ** Tab Bars and Tab Lines
 
 ---
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 2d6e1579e10..9be467a421e 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -431,7 +431,8 @@ bindings--sort-menu-keymap
 
 (defcustom mode-line-collapse-minor-modes nil
   "Minor modes for which mode line lighters are hidden.
-Hidden lighters are collapsed into one.
+Hidden lighters are collapsed into one, which is customizable via option
+`mode-line-collapsed-minor-modes-lighter'.
 
 The value could be a list (MODES ...) which means to collapse lighters
 only for MODES, or a list (not MODES ...) which means to collapse all
@@ -445,6 +446,15 @@ mode-line-collapse-minor-modes
   :group 'mode-line
   :version "31.1")
 
+(defcustom mode-line-collapsed-minor-modes-lighter
+  (if (char-displayable-p ?…) " …" " ...")
+  "Lighter for collapsed minor modes.
+This is effective only when `mode-line-collapse-minor-modes' is non-nil."
+  :type 'string
+  :initialize #'custom-initialize-delay
+  :group 'mode-line
+  :version "31.1")
+
 (defvar mode-line-minor-modes '(:eval (mode-line--minor-modes))
   "Mode line construct for minor mode lighters.")
 ;;;###autoload
@@ -541,7 +551,7 @@ mode-line--minor-modes
                       :parent mode-line-minor-mode-keymap
                       "<mode-line> <down-mouse-1>" menu
                       "<mode-line> <mouse-2>" #'describe-mode)))
-              `(:propertize ,(if (char-displayable-p ?…) " …" " ...")
+              `(:propertize mode-line-collapsed-minor-modes-lighter
                             mouse-face mode-line-highlight
                             help-echo "Hidden minor modes\n\
 mouse-1: Display hidden minor modes\n\
-- 
2.49.0


This bug report was last modified 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.