alphapapa / prism.el

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

whitespace-mode space-mark characters sometimes get highlighted incorrectly #23

Open qookei opened 1 year ago

qookei commented 1 year ago

When using whitespace-mode, with space-mark added to whitespace-style, sometimes the characters marking a space get highlighted in the same color as the proceeding character instead of using the foreground color set by the whitespace-space face.

image

alphapapa commented 1 year ago

I've no idea whether this could be considered a bug in whitespace-mode or prism, or just an inconvenient side effect. whitespace-mode uses overlays to display the whitespace characters, which prism does not interact with in any way. I don't know how prism could be expected to account for programs like whitespace-mode. But if you can find a simple solution, I'm willing to consider it.

What does it look like if you disable prism-comments?

qookei commented 1 year ago

I've no idea how one would go about fixing this or what's truly at fault. Changing prism-comments does not seem to affect this behavior (some space-marks are highlighted regardless of whether it's nil or t).

alphapapa commented 1 year ago

Ok, thanks. Maybe someday we'll find a solution. The only thing I can think of to investigate would be to look at the various overlay properties and see if changing the ones applied to whitespace-mode's overlays made any difference. But that's not something I have the time or interest for looking into myself. :)

BTW, that screenshot looks like the color theme I mentioned in the commentary. Is that where you found it?

qookei commented 1 year ago

I appreciate the quick response BTW. One simple way to fix this would just be removing space-mark from my whitespace-style :^) Originally I set it to differentiate tabs and spaces in indentation but in the end I also made tabs have a slightly different background color (without tabs-mark, since that's somewhat borked in it's own way unrelated to prism).

BTW, that screenshot looks like the color theme I mentioned in the commentary. Is that where you found it?

Yeah it is, I found it looks more pleasant than the default one generated from the modus-vivendi-tinted theme, and I didn't feel like tweaking it when trying prism out originally.

alphapapa commented 1 year ago

Cool. In case it might be helpful, here's some code I use to switch between prism "themes":

(unpackaged/define-chooser ap/prism-theme
  ("doom-vibrant"
   (prism-set-colors :colors '("#C57BDB" "#5cEfFF" "#FCCE7B")))
  ("Shuffle random number of theme faces"
   (prism-set-colors :num 24
     :colors (let* ((faces (list 'font-lock-regexp-grouping-backslash 'font-lock-regexp-grouping-construct
                                 'font-lock-negation-char-face 'font-lock-preprocessor-face
                                 'font-lock-function-name-face 'font-lock-keyword-face
                                 'font-lock-variable-name-face 'font-lock-warning-face
                                 'font-lock-builtin-face 'font-lock-constant-face
                                 'font-lock-string-face 'font-lock-type-face))
                    (colors (->> faces
                                 (--map (face-attribute it :foreground))
                                 (--remove (eq 'unspecified it))
                                 -uniq))
                    (num (max 3 (random (1+ (length colors))))))
               (prism-shuffle (seq-take colors num)))))
  ("Default"
   (prism-set-colors :num 16
     :colors (list 'font-lock-type-face 'font-lock-function-name-face
                   'font-lock-keyword-face 'font-lock-doc-face)))
  ("Bunting"
   (prism-set-colors :num 16
     :local (pcase current-prefix-arg
              ('(16) 'reset)
              (_ current-prefix-arg))
     :desaturations (cl-loop for i from 0 below 16
                             collect (* i 3))
     :lightens (cl-loop for i from 0 below 16
                        collect (* 3 i))
     :colors (list "red" "white" "dodgerblue" "white")))
  ("Keen"
   (prism-set-colors :num 24
     :local (pcase current-prefix-arg
              ('(24) 'reset)
              (_ current-prefix-arg))
     :desaturations (cl-loop for i from 0 below 24
                             collect (* i 2.5))
     :lightens (cl-loop for i from 0 below 24
                        collect (* i 2.5))
     :colors (list "sandy brown" "dodgerblue" "medium sea green")
     :comments-fn
     (lambda (color)
       (prism-blend color (face-attribute 'font-lock-comment-face :foreground) 0.25))
     :strings-fn
     (lambda (color)
       (prism-blend color "white" 0.5))
     :parens-fn
     (lambda (color)
       (prism-blend color (face-attribute 'default :background) 0.25))))
  ("Solarized: rainbow"
   (prism-set-colors :num 24
     :local (pcase current-prefix-arg
              ('(16) 'reset)
              (_ current-prefix-arg))
     :lightens '(5 15 25)
     :colors (mapcar #'doom-color '(red orange yellow green blue cyan violet magenta))
     :comments-fn (lambda (color)
                    (--> color
                         (color-desaturate-name it 50)))
     :strings-fn (lambda (color)
                   (prism-blend color "white" 0.5))))
  ("Solarized: rainbow inverted"
   (prism-set-colors :num 24
     :local (pcase current-prefix-arg
              ('(16) 'reset)
              (_ current-prefix-arg))
     :lightens '(5 15 25)
     :colors (reverse (mapcar #'doom-color '(red orange yellow green blue cyan violet magenta)))
     :comments-fn (lambda (color)
                    (--> color
                         (color-desaturate-name it 50)))
     :strings-fn (lambda (color)
                   (prism-blend color "white" 0.5))))
  ("Manegarm"
   (prism-set-colors :num 16
     :colors (list 'font-lock-type-face 'custom-face-tag
                   'font-lock-builtin-face
                   'font-lock-variable-name-face))))