milkypostman / powerline

emacs powerline
Other
793 stars 118 forks source link

Add the ability to selectively show or hide minor mode indicators #159

Open c-alpha opened 5 years ago

c-alpha commented 5 years ago

I think this PR would probably be suitable to address #64.

I have added two new config variables to control the new behaviour:

The default behaviour is to show all minor modes, i.e. no change to the current behaviour.

In white-list mode, only minor mode indicators matching one of the regular expressions are shown. In black-list mode, all minor mode indicators matching one of the regular expressions are hidden.

Example: to hide all minor modes, you could use this:

(setq powerline-minor-mode-filter-mode 'include)
(setq powerline-minor-mode-filter-regexp-list '("^$"))
c-alpha commented 5 years ago

Just realised that the white-list mode implementation is still a little bit aggressive. ;-) Let me fix that...

c-alpha commented 5 years ago

From my side, this PR would be ready to merge. @milkypostman, any thoughts?

c-alpha commented 5 years ago

@milkypostman ?

milkypostman commented 5 years ago

aren't there already separate packages that do this like diminish?

c-alpha commented 5 years ago

aren't there already separate packages that do this like diminish?

Thanks for your consideration! I tried a couple of them (incl. diminish), but couldn't get any of them to work.

Also, when you read the descriptions of mode-line and minor-mode-hiding packages, compatibility with one or the other package is being mentioned. I guess it will depend on how the mode-line package generates the minor mode indicators. If and when it retrieves the information from a variable which a minor-mode-hiding package has previously modified, then the modes will he shown/hidden as intended. If and when it however retrieves the information from a variable which has not (or not yet) been modified by a minor-mode-hiding package, then there will be no showing/hiding effect. So ultimately it seems to depend on which variables and which hooks each package uses, whether each combination works or not.

That was my motivation for making this PR.

milkypostman commented 5 years ago

i'm still considering this. i'd like to understand better why the other packages don't work. they should work just fine with this package unless we're not adhering to some standard.

c-alpha commented 3 years ago

It's been a while...

Some further thoughts: I opted to not use diminish or delight, because I didn't want to keep adding new hiding code when changing my config, but want regular expression matching to hide all but a select, few minor modes. I found rich-minority, which has the white-/black-listing functionality with regular expressions I am looking for, but it does not modify minor-mode-alist, and hence has no effect when used in conjunction with powerline.

c-alpha commented 3 years ago

Update: I have (locally) modified my code to patch powerline-minor-modes so that it uses the minor mode list provided by rich-minority, if and when that package is installed and loaded. With this, and this init code:

(require 'powerline)
(powerline-default-theme)

(setq rm-blacklist nil)
(setq rm-whitelist (format "^ \\(%s\\)$" (mapconcat #'identity
                            '("Narrow" "Ov.*")
                            "\\|")))
(rich-minority-mode 1)

it will have the desired effect (white-/black-listing of minor modes with regular expressions ). If rich-minority is not installed, or (rich-minority-mode 1) is omitted from the init code, the behaviour is the same as before (all minor mode lighters are unconditionally shown).

Maybe making it an integration feature with another, optional package, makes it more palatable?