-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Modify mode-line lighter customization #86
base: master
Are you sure you want to change the base?
Conversation
This adds a new customizable variable, `envrc-lighter-function` that sits between `envrc-lighter` and `envrc-STATUS-lighter`. This allows overriding `envrc-lighter` without relying on internal definitions (`envrc--status`). The other benefit of this is that any customization is likely to want to set all three `envrc-STATUS-lighter`, with them being mostly the same, with a small conditional part (as you can see from both `envrc--default-lighter` and my lambda below). While this variable is a `risky-local-variable`, I believe that `envrc-STATUS-lighter` are also risky, because they can also contain `:eval`, no? If `envrc-lighter-function` is not customized, the existing `envrc-STATUS-lighter` variables should continue to work as they have. In future, I think this could be the _only_ `-lighter` customizable variable. I like my minor modes to be pretty minimal, so I use this like ```elisp (setq envrc-lighter-function (lambda (status) `(:propertize "🗁" face ,(pcase status ('on 'envrc-mode-line-on-face) ('error 'envrc-mode-line-error-face) (_ 'envrc-mode-line-none-face))))) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I figured people would just write their custom function and set envrc-lighter
to (:eval (my-lighter-function)
. Part of me thinks there's no point changing custom vars in order to "unwrap" that function, but in practical terms I don't think anyone is going to set the lighter to a constant string, for example, so I'm +1 on this PR. If we're doing that, I'd also happy to just go ahead and remove envrc-lighter
and mark it obsolete, plus remove the various envrc-STATUS-lighter
vars. Would you like to amend the PR to do that too?
P.S. Sorry that CI is a bit broken currently, I still haven't figured out what's wrong with the failing tests. |
Co-authored-by: Steve Purcell <[email protected]>
tl;dr: This is basically just rambling, no real information here other than “I’ll obsolete the oher vars”.
An alternative I meant to mention in the description is just making
I think removing (defun sellout--envrc-lighter (status)
"Return a lighter for the provided envrc STATUS."
`(:propertize "🗁"
face
,(pcase status
('error 'envrc-mode-line-error-face)
('on 'envrc-mode-line-on-face)
(_ 'envrc-mode-line-none-face))))
(use-package envrc
:custom
(envrc-error-lighter (sellout--envrc-lighter 'error))
(envrc-none-lighter (sellout--envrc-lighter 'none))
(envrc-on-lighter (sellout--envrc-lighter 'on))
:hook (after-init . envrc-global-mode)) Which I prefer over (use-package envrc
:custom
(envrc-lighter '(:eval (sellout--envrc-lighter envrc--status)))
:hook (after-init . envrc-global-mode)) because … I guess just because of Another possible benefit of
Yeah, I’m happy to. |
This commits to the new function-based lighter.
Yeah, I guess I'm not super averse to making Regarding |
This adds a new customizable variable,
envrc-lighter-function
that sits betweenenvrc-lighter
andenvrc-STATUS-lighter
. This allows overridingenvrc-lighter
without relying on internal definitions (envrc--status
).The other benefit of this is that any customization is likely to want to set all three
envrc-STATUS-lighter
, with them being mostly the same, with a small conditional part (as you can see from bothenvrc--default-lighter
and my lambda below). While this variable is arisky-local-variable
, I believe thatenvrc-STATUS-lighter
are also risky, because they can also contain:eval
, no?If
envrc-lighter-function
is not customized, the existingenvrc-STATUS-lighter
variables should continue to work as they have.In future, I think this could be the only
-lighter
customizable variable.I like my minor modes to be pretty minimal, so I use this like