alphapapa / prism.el

Disperse Lisp forms (and other languages) into a spectrum of colors by depth
GNU General Public License v3.0
282 stars 4 forks source link

Samples of Modus themes with prism.el #8

Open protesilaos opened 3 years ago

protesilaos commented 3 years ago

Hello again! This is in response to this reddit thread.

I have been experimenting with various styles and settled on what I feel is a good starting point. Screenshots below. I only have Elisp code here, so this has influenced my decision. Here is the configuration I used:

(use-package prism
  :straight (:host github :repo "alphapapa/prism.el" :branch "master")
  :config
  (setq prism-comments nil) ; non-nil distorts colours

  (prism-set-colors
    :desaturations '(0) ; may lower the contrast ratio
    :lightens '(0) ; same
    :colors (list ; NOTE: I plan to add a "with-color-variables"
             (modus-themes-color 'fg-main)
             (modus-themes-color 'blue-faint)
             (modus-themes-color 'magenta)
             (modus-themes-color 'magenta-alt-other)
             (modus-themes-color 'cyan-alt-other)
             (modus-themes-color 'fg-special-cold)
             (modus-themes-color 'blue-alt)
             (modus-themes-color 'magenta-faint)
             (modus-themes-color 'cyan)
             (modus-themes-color 'fg-main)
             (modus-themes-color 'green-faint)
             (modus-themes-color 'red-alt-faint)
             (modus-themes-color 'blue-alt-faint)
             (modus-themes-color 'fg-special-warm)
             (modus-themes-color 'cyan-alt)
             (modus-themes-color 'blue))))

Screenshots

The sequence is the default theme followed by its prism-styled variant. Note that I do have some options for the themes turned on as I think they work well in this case (just some bold and italics).

Click to enlarge.

Modus Operandi

modus-operandi-default-1

modus-operandi-prism-1

modus-operandi-default-2

modus-operandi-prism-2

modus-operandi-default-3

modus-operandi-prism-3

Modus Vivendi

modus-vivendi-default-1

modus-vivendi-prism-1

modus-vivendi-default-2

modus-vivendi-prism-2

modus-vivendi-default-3

modus-vivendi-prism-3

Your thoughts?

What do you think? If something is amiss, how would you like to review it?

My plan is to first come up with some elegant way for users to get colours from the themes and then I would like to add a section in the manual for users who would like to set up prism.el with the themes.

alphapapa commented 3 years ago

Hi Prot,

Thank you for putting this together. The colors you chose look readable and distinctive. I think it enhances the readability of the code without being overwhelming (though I'm sure many users will always prefer minimal coloring).

The macro sounds like a nice idea. I was disappointed when the solarized-theme package broke its solarized-with-color-variables macro a while back, which broke many customizations in my Emacs config, so I recently moved to doom-themes's implementation of doom-solarized-dark, so I can use the doom-color function. But a macro would be more convenient at times.

My plan is to first come up with some elegant way for users to get colours from the themes and then I would like to add a section in the manual for users who would like to set up prism.el with the themes.

Yes, that sounds like a good idea. I don't know if there would be a good way to integrate them directly in either package's code, so documentation may be the best approach. However, if you think of any enhancements to, e.g. prism-set-colors or prism-randomize-colors that would work well with Modus themes, let me know.

Thanks very much. You're always very thorough in your work, and I'm happy to see you give consideration to integration with prism.

protesilaos commented 3 years ago

Thank you for putting this together.

You are welcome!

The colors you chose look readable and distinctive. I think it enhances the readability of the code without being overwhelming (though I'm sure many users will always prefer minimal coloring).

I added prism.el to my Emacs init file. Will push the changes tomorrow. My use-case for it is to help me read unfamiliar code.

I still want to explore more stylistic choices, such as with fewer colours, with more intense colours, and so on. Then I can define some presets. Would be nice to add them to the themes' manual. Will also share them with you just to be sure I am offering users the right advice.

The macro sounds like a nice idea. I was disappointed when the solarized-theme package broke its solarized-with-color-variables macro a while back, which broke many customizations in my Emacs config, so I recently moved to doom-themes's implementation of doom-solarized-dark, so I can use the doom-color function. But a macro would be more convenient at times.

I remember reading about this a while ago. I am not familiar with the internals though it does not feel right to break things in such a popular package.

My plan is to first come up with some elegant way for users to get colours > from the themes and then I would like to add a section in the manual for > users who would like to set up prism.el with the themes.

Yes, that sounds like a good idea. I don't know if there would be a good way to integrate them directly in either package's code, so documentation may be the best approach.

Given that prism.el is meant to be highly configurable, it is better not to try to anticipate user preferences at the theme level.

However, if you think of any enhancements to, e.g. prism-set-colors or prism-randomize-colors that would work well with Modus themes, let me know.

I will need some more time with prism.el. Those permutations will require further testing to ensure we get things right.

Thanks very much. You're always very thorough in your work, and I'm happy to see you give consideration to integration with prism.

You are welcome! More to follow once I spend some more time with the package.

protesilaos commented 3 years ago

Hello again! First off, we now have modus-themes-with-colors and there is currently progress being made on introducing overrides. Anyhow, I have reviewed my approach to prism.el. I was not entirely happy with what I shared before. It was a little bit contrary to the spirit of this package, in that it would visually blend distinct levels of depth.

So I have settled on these presets for the time being and I plan to include them in the manual:

(use-package prism
  :straight (:host github :repo "alphapapa/prism.el" :branch "master")
  :after modus-themes
  :config
  (setq prism-comments nil) ; non-nil distorts colours
  (setq prism-num-faces 8)

  ;; ;; for 4 colours (the closest to the default)
  ;; (prism-set-colors
  ;;   :desaturations '(0) ; may lower the contrast ratio
  ;;   :lightens '(0)      ; same
  ;;   :colors (modus-themes-with-colors
  ;;             `(,fg-main
  ;;               ,cyan-alt-other
  ;;               ,magenta-alt-other
  ;;               ,magenta)))
  ;;
  ;; ;; for 16 colours
  ;; (prism-set-colors
  ;;   :desaturations '(0) ; may lower the contrast ratio
  ;;   :lightens '(0)      ; same
  ;;   :colors (modus-themes-with-colors
  ;;             `(,fg-main
  ;;               ,magenta
  ;;               ,cyan-alt-other
  ;;               ,magenta-alt-other
  ;;               ,blue
  ;;               ,magenta-alt
  ;;               ,cyan-alt
  ;;               ,red-alt-other
  ;;               ,green
  ;;               ,fg-main
  ;;               ,cyan
  ;;               ,yellow
  ;;               ,blue-alt
  ;;               ,red-alt
  ;;               ,green-alt-other
  ;;               ,fg-special-warm)))

  ;; for 8 colours
  (prism-set-colors
    :desaturations '(0) ; may lower the contrast ratio
    :lightens '(0)      ; same
    :colors (modus-themes-with-colors
              `(,fg-special-cold
                ,magenta
                ,magenta-alt-other
                ,cyan-alt-other
                ,fg-main
                ,blue-alt
                ,red-alt-other
                ,cyan))))

By the way, is the form '(0) correct or am I doing some mistake here? Those features are fine, but I am not sure whether the resulting values satisfy the WCAG AAA accessibility criterion, so I prefer to play it safe. Though I will include a demo of how to apply lightening and desaturarion.

Screenshots

prism-num-faces 16

Screenshot from 2020-12-30 09-21-33

Screenshot from 2020-12-30 09-21-42

prism-num-faces 8

Screenshot from 2020-12-30 09-23-42

Screenshot from 2020-12-30 09-23-46

prism-num-faces 4

Screenshot from 2020-12-30 09-22-28

Screenshot from 2020-12-30 09-22-35

Closing thoughts

Once I update the manual I will post an update here so that you may close the issue. Thanks again for your time and contributions!

protesilaos commented 3 years ago

Hello Adam! Just to inform you that I have added prism.el to the themes' manual: https://protesilaos.com/modus-themes/#h:a94272e0-99da-4149-9e80-11a7e67a2cf2. Feel welcome to close this issue and/or report anything that is incorrect.

P.S. just recently added the modus-themes-with-colors macro and another option to override colours.

alphapapa commented 3 years ago

Hi again Prot,

Thanks for your patience. I didn't mean to overlook your messages for so long.

Those look great! I'm very happy to see Prism mentioned in the manual with example code. Thank you very much.

One thing I notice in those screenshots is that, in the 4-color version, at a certain depth, it seems that the colors stop repeating, and everything deeper is white/black. Assuming that the user would prefer the 4 colors to continue cycling to deeper levels, you could do that by setting Prism to use N colors (I'd generally recommend at least 16), and setting the desaturations and lightens to 0, so the colors wouldn't be modified as they continue cycling.

You did a really great job, especially on the 8- and 16-color versions. The contrast is excellent and the code is so readable!

Now I need to add some of these screenshots to Prism's docs...

protesilaos commented 3 years ago

Thanks for your patience. I didn't mean to overlook your messages for so long.

You are welcome! No worries: this is a volunteer effort, plus we have to account for the prevailing conditions. I hope you are doing well.

Those look great! I'm very happy to see Prism mentioned in the manual with example code. Thank you very much.

One thing I notice in those screenshots is that, in the 4-color version, at a certain depth, it seems that the colors stop repeating, and everything deeper is white/black. Assuming that the user would prefer the 4 colors to continue cycling to deeper levels, you could do that by setting Prism to use N colors (I'd generally recommend at least 16), and setting the desaturations and lightens to 0, so the colors wouldn't be modified as they continue cycling.

You did a really great job, especially on the 8- and 16-color versions. The contrast is excellent and the code is so readable!

You are right. That may be because the main foreground (black/white) is one of the four colours and the code at that point just happens to use that? Not sure right now. I had not observed any problem at the time, but I will check again.

Thank you!

-- Protesilaos Stavrou https://protesilaos.com

bestlem commented 1 year ago

Note that this example does not work for modus themes version 4 as things like cyan-alt-other has been renamed

protesilaos commented 1 year ago

@bestlem Indeed! In the manual I have the updated versions: https://protesilaos.com/emacs/modus-themes#h:a94272e0-99da-4149-9e80-11a7e67a2cf2

alphapapa commented 8 months ago

FWIW, by default, without doing anything special for modus-themes, modus-operandi looks like this, which I find quite readable, as the colors are subtle and retain good contrast:

Screenshot_20231220_090802

protesilaos commented 8 months ago

From: Adam Porter @.***> Date: Wed, 20 Dec 2023 07:10:06 -0800

FWIW, by default, without doing anything special for modus-themes, modus-operandi looks like this, which I find quite readable, as the colors are subtle and retain good contrast:

Screenshot_20231220_090802

Yes, this looks good!

Was it always like this? I have the impression is used to be more faint? Or maybe I did something wrong during my testing... If so, apologies!

-- Protesilaos Stavrou https://protesilaos.com

alphapapa commented 8 months ago

For me, by default, it's looked that way as long as I can remember. I don't think you did anything wrong. :)

protesilaos commented 8 months ago

From: Adam Porter @.***> Date: Wed, 20 Dec 2023 09:20:59 -0800

For me, by default, it's looked that way as long as I can remember. I don't think you did anything wrong. :)

Oh, then I must have missed something... In the manual, I have code blocks that mention this:

(prism-set-colors
  :desaturations '(0) ; do not change---may lower the contrast ratio
  :lightens '(0)      ; same
  ...)

Maybe we should just removed those two keywords? Or do it like this?

(prism-set-colors
  :desaturations (cl-loop for i from 0 below 16 collect (* i 2.5))
  :lightens (cl-loop for i from 0 below 16 collect (* i 2.5))
  ...)

I am not good enough with the cl-loop to know how to tweak this. I guess the number in 'below 16' must be equal to 'prism-num-faces'?

Alternatively, you can send a patch or pull request and I am happy to incorporate it.

-- Protesilaos Stavrou https://protesilaos.com

alphapapa commented 8 months ago

Well, I went through those examples in the manual again, and each one seems good on its own. The default, without evaluating any of those examples, is subtle, reserved, and readable, which I think is a good default. Then each of those examples adds additional colors and increases the number of unique faces, which reduces repetition at deeper levels, and increases the number of unique hues--whether the user prefers the subtle, reserved default or one of these example forms with more hues and faces is a matter of preference, I think. And it's probably best to start with the default than to risk the "angry fruit salad" effect for a user who perceives it that way.

So I'd suggest just making a few small additions to this section of the manual:

  1. Mention that the default set of faces (i.e. without having called prism-set-colors) is subtle and reserved and likely to be preferred by most users.
  2. Explain that the example forms add more hues and faces, which increases uniqueness at depth, but may seem excessive to some users.
  3. Provide a form to reset to the default, so that if the users try the other forms and don't like them, they can easily get back to the default.

What do you think? Thanks.

hapst3r commented 7 months ago

Hej guys,

I really appreciate the attempt to have prism use modus themes colors. However, I run into problems with the configuration that @protesilaos suggests in the manual. When I activate prism-mode, I can no more use modus-themes-toggle, the Messages-buffer says that color-name-to-rgb received the wrong argument type stringp, nil. When prism-mode has not been activated, I don't run into this problem.

In my current configuration, modus-themes is loaded before prism.

This is the configuration for both packages.

(use-package prism
  :demand t
  :requires modus-themes
  :custom
  (prism-colors
   (prism-set-colors
     :desaturations '(0.0) ; do not change---may lower the contrast ratio
     :lightens '(0.0)      ; same
     :colors (modus-themes-with-colors
               (list fg-main
                     magenta
                     cyan-cooler
                     magenta-cooler
                     blue
                     magenta-warmer
                     cyan-warmer
                     red-cooler
                     green
                     fg-main
                     cyan
                     yellow
                     blue-warmer
                     red-warmer
                     green-cooler
                     yellow-faint))))
  (prism-num-faces 16)
  (prism-parens t))

(use-package modus-themes
  :demand t
  :custom
  (modus-themes-to-toggle '(modus-operandi modus-vivendi))
  :bind
  ("<f5>" . modus-themes-toggle))

Sorry to bomb this thread, but when the implementation of a modus-theme "bridge" to prism is in discussion, I think it fits the bill.

Have a good day, fellows!

alphapapa commented 7 months ago

@hapst3r Hello. Thanks for the report. A couple of suggestions:

  1. As mentioned earlier in the discussion on this issue, try omitting the special setup code and just use prism's defaults.
  2. If that causes the same error, then it's likely a matter of something unexpected being present in the way you have configured some faces. So try to reproduce the problem in a clean configuration, e.g. using https://github.com/alphapapa/with-emacs.sh If it still happens, please provide the backtrace of the error, and file it in a new bug report.
protesilaos commented 7 months ago

From: Adam Porter @.***> Date: Mon, 15 Jan 2024 11:34:08 -0800

@hapst3r Hello. Thanks for the report. A couple of suggestions:

  1. As mentioned earlier in the discussion on this issue, try omitting the special setup code and just use prism's defaults.

  2. If that causes the same error, then it's likely a matter of something unexpected being present in the way you have configured some faces. So try to reproduce the problem in a clean configuration, e.g. using https://github.com/alphapapa/with-emacs.sh If it still happens, please provide the backtrace of the error, and file it in a new bug report.

Yes, please use the defaults. What I wrote in the manual was a very long time ago and I have not tested it with the newest version of both packages. Adam showed that prism looks fine out-of-the-box and I agree with that assessment. I need to update the manual, but I try to avoid typing these days. It is on my TODO list.

-- Protesilaos Stavrou https://protesilaos.com

hapst3r commented 7 months ago

@hapst3r Hello. Thanks for the report. A couple of suggestions:

1. As mentioned earlier in the discussion on this issue, try omitting the special setup code and just use `prism`'s defaults.

2. If that causes the same error, then it's likely a matter of something unexpected being present in the way you have configured some faces.  So try to reproduce the problem in a clean configuration, e.g. using https://github.com/alphapapa/with-emacs.sh  If it still happens, please provide the backtrace of the error, and file it in a new bug report.

Hej @alphapapa, thanks for the reply. Using the defaults, this problem does not occur. However, I really prefer the (much) higher contrast provided by the modus color scheme and would love to be able to use those instead of the default ones. I guess I would then have to insert the values of bg-main etc. manually to achieve this, right?

Yes, please use the defaults. What I wrote in the manual was a very long time ago and I have not tested it with the newest version of both packages. Adam showed that prism looks fine out-of-the-box and I agree with that assessment. I need to update the manual, but I try to avoid typing these days. It is on my TODO list. -- Protesilaos Stavrou https://protesilaos.com

Hej @protesilaos thanks for the headsup. I hope all is well and you will soon be able to type as you were used to!