DevelopmentCool2449 / colorful-mode

🎨Preview any color in your buffer
GNU General Public License v3.0
60 stars 5 forks source link

Suggestion #2

Open bjd-pfq opened 6 months ago

bjd-pfq commented 6 months ago

If your program can be adapted to handle CSS user-defined colors, then I'm willing to try it out. E.g.: top of css:

@define_color  base_color  #ff0000;   /* red */
@define_color  highlight_color  aquamarine;
. . .
. . .
foo {
   border-color: 1px solid @highlight_color;          <-- here, @highlight_color would get a red background
}
.bar {
   background: @base_color;                           <-- here, @base_color would get an aquamarine background
}
DevelopmentCool2449 commented 6 months ago

Hi, this sound interesting, i think i found a way for implement it, the only thing that i see is that it would only allow highlighting, i will see if it's possible implement the rest of features to this.

bjd-pfq commented 6 months ago

It would be fun to do implement I suppose. Prob. needs some lookup-table. Can said table be kept relatively small? It depends on how many discrete colors are used in a large corporate website. Maybe not even that many -- designers like to keep those things simple, because it's the most pleasing to the eye.

Your implementation must also recognize all the other ways to specify colors and alpha, like rainbow.el does, incl. hsl, rgb(a), etc.

And I'd make three character color-codes optional, like #fab et al. Raibow.el now colors all kinds of strings that I might have (like a comment in a bash script that reads "#defined at line thus and so' get its first 4 chars #def colored whereas it shouldn't). So options for minimal length, and also for omitting words like yellowstone, etc.

Btw., I have never looked at rainbow.el, so I wouldn't know how that is currently implemented. Maybe it works by regexing an entire buffer's visual part of its buffer after every edit?

Also, you prob. have heard of the new spectecular treesitter code coloring technique with emacs 29 and above. I have currently just built emacs 29 esp. because of that new feature, though haven't experimented with it yet. Might there be stuff in there that could be put to use for colored color-names or color-refs too?

DevelopmentCool2449 commented 5 months ago

Sorry for the late reply,

And I'd make three character color-codes optional, like #fab et al. Raibow.el now colors all kinds of strings that I might have (like a comment in a bash script that reads "#defined at line thus and so' get its first 4 chars #def colored whereas it shouldn't). So options for minimal length, and also for omitting words like yellowstone, etc.

colorful allows omitting color keywords (see: colorful-exclude-colors), by default it omit #def (for #define) and it should work for all the colors keywords that colorful detects.

Also, you prob. have heard of the new spectecular treesitter code coloring technique with emacs 29 and above. I have currently just built emacs 29 esp. because of that new feature, though haven't experimented with it yet. Might there be stuff in there that could be put to use for colored color-names or color-refs too?

Can you provide more information about that?

bjd-pfq commented 5 months ago

https://www.masteringemacs.org/article/how-to-get-started-tree-sitter