Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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

wants to merge 2 commits into from

Conversation

c-alpha
Copy link
Contributor

@c-alpha c-alpha commented Dec 14, 2018

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

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

  • powerline-minor-mode-filter-mode which can be set to either include (white-list mode), or exclude (black-list mode);
  • powerline-minor-mode-filter-regexp-list is a list of regular expressions which is used to filter the minor mode indicators according to the filter mode determined by powerline-minor-mode-filter-mode.

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
Copy link
Contributor Author

c-alpha commented Dec 14, 2018

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

@c-alpha
Copy link
Contributor Author

c-alpha commented Dec 14, 2018

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

@c-alpha
Copy link
Contributor Author

c-alpha commented Jan 22, 2019

@milkypostman ?

@milkypostman
Copy link
Owner

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

@c-alpha
Copy link
Contributor Author

c-alpha commented Jan 23, 2019

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
Copy link
Owner

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
Copy link
Contributor Author

c-alpha commented Feb 2, 2021

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
Copy link
Contributor Author

c-alpha commented Feb 2, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants