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 support for :darken color modifier #101

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add support for :darken color modifier #101

wants to merge 5 commits into from

Conversation

belak
Copy link
Member

@belak belak commented Jul 15, 2019

No description provided.

@kurnevsky
Copy link
Contributor

Why don't use color-darken-name in the color package? Also is it possible to make a generic transformer? I use color-saturate-name as well.

@belak
Copy link
Member Author

belak commented Jul 15, 2019

I didn't realize color-darken-name worked properly - when I looked before I thought it assumed #ffff0000ffff format, but it looks like it would work with the usual hex codes. Good feedback.

@kurnevsky
Copy link
Contributor

kurnevsky commented Jul 15, 2019

Also take a note that color package won't work in the terminal before some tty initialization which happens after init file is loaded. I had to use tty-setup-hook to make it convert colors properly: https://github.com/kurnevsky/dotfiles/blob/c8a350540e99b8fec67dfc92bf59030fb51d7701/.emacs.d/init.el#L263-L266

@belak
Copy link
Member Author

belak commented Jul 15, 2019

I've played with it a bit to make this more generic (and provide :darken, :lighten, and :saturate), but it's pretty ugly. I'd be open to tips here.

@belak
Copy link
Member Author

belak commented Jul 16, 2019

In my implementation, I simply only call the color functions for strings starting with #. This makes it only operate on html colors which should be good enough. I don't see anything in the color module which is run after tty init - everything I can see is simple conversions, so I'm not really sure what you're running into.

@kurnevsky
Copy link
Contributor

Try to add this into your init.el:

(require 'color)
(print (color-darken-name "#121212" 0.5))

And execute emacs --no-window-system. It'll print #000000000000.

@belak
Copy link
Member Author

belak commented Jul 16, 2019

Wow, that's really annoying. It tries to determine how that color will display in the current frame. The odd thing is that it handles colors like "white" and "black" properly, but can't understand hex codes until there's a frame available. This is actually an issue with (color-values #121212) which seems to be emacs internal.

It's looking like we can't use these color functions for converting unless we want to force waiting until frame-init.

@kurnevsky
Copy link
Contributor

kurnevsky commented Jul 16, 2019

color-***-name functions use color-***-hsl internally which should be working during init.el loading. So we can use color-rgb-to-hsl + hsl functions. The only thing that should be done manually is color string parsing.

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.

3 participants