nihao123456ftw · 2022-04-09 16:18
I am trying to use the rainbow-blocks package but when i enable the mode, it overrides the default font lock stylings, taking over the whole buffer.
​
Im trying to convert this:
https://preview.redd.it/4o6z5qvd3js81.png?width=923&format=png&auto=webp&s=966c8a96a89d46ec49a8ec5c89e63b9d2744f55f
into this:
​
https://preview.redd.it/mieciq2f3js81.png?width=923&format=png&auto=webp&s=8ae746c1c4cf10f87c46d29c9896834d6e0a3f5e
​
This happens when i call (rainbow-blocks-propertize-region (point-min) (point-max)), but as soon as i do anything like type or move the point or scroll, the properties of the first image disappear and the rainbow-blocks takes over the whole buffer, so all the saturated colours disappear, which i dont want. I want it to look like the second image all the time. This doesn't happen when i set jit-lock-mode to nil, but then of course i dont have jit-lock. What should i do?
Alan_Shutko · 2022-04-09 16:45
Looks like a long-running request, and someone has written a different package that might fit for you:
https://github.com/istib/rainbow-blocks/issues/6
nihao123456ftw · 2022-04-09 17:38
thanks for bringing this to my attention. Unfortunately it doesn't solve my problem. It looks like that package is for weaving in different attributes, but not for leaving the same attribute alone (e.g package A highlights the foreground and prism highlights the background. Prism would override the foreground if the color is set.).
arthurno1 · 2022-04-09 20:25
> What should i do?
Don't user rainbow-blocks.
What you ask for is not possible. Rainbow-blocks have different syntax highlighting rules than how normal font-lock works. Since rainbow blocks works at nesting level, but font-lock works with classes of words, rainbow blocks can, and probably will, use more colors than ordinary font lock, and it has to override font-lock colors to achieve what it does..Hope that explains to you what happens and why they are mutualy exclusive.
nihao123456ftw · 2022-04-11 14:45
I think i have found a solution. Rainbow-delimiters is a similar package to rainbow-blocks, while trying to optimise code I looked and found that rainbow-delimiters seems to acknowledge more font-lock-mode internals than rainbow blocks does (i was unaware of font-lock-fillin-text-property, i was looking instead at the put-text-property function in prepend mode which is not exactly what i wanted). So i simply inserted a bit more code into rainbow-delimiters logic to achieve the same effect as rainbow-blocks using the same face definitions as rainbow-blocks.