~protesilaos/modus-themes

1

Using rainbow-delimiters colors for highlight-parentheses

Justin Koh <j@ustink.org>
Details
Message ID
<eeb7a78597f7c917d0bfe9483a6177d5e67f58fe.camel@ustink.org>
DKIM signature
missing
Download raw message
Since modus-themes defined some colors for rainbow-delimiters,
I thought to reuse them for highlight-parentheses.

Here is a simple example based on the modus-themes manual
"Note on highlight-parentheses.el"[1].

    (require 'highlight-parentheses)
    
    (defun my-modus-themes-highlight-parentheses ()
      "Update highlight-parentheses with the current Modus theme's colors."
      (modus-themes-with-colors
        ;; Use the rainbow-n colors intended for rainbow-delimiters support.
        ;; Skip rainbow-0 which is black/white.
        (setq highlight-parentheses-colors (list rainbow-1 rainbow-2 rainbow-3
                                                 rainbow-4 rainbow-5 rainbow-6
                                                 rainbow-7 rainbow-8)
              highlight-parentheses-background-colors nil))
      ;; Tell highlight-parentheses the colors changed.
      (highlight-parentheses--color-update))
    
    (add-hook 'modus-themes-after-load-theme-hook
              #'my-modus-themes-highlight-parentheses)
    (add-hook 'prog-mode-hook #'highlight-parentheses-mode)

I didn't replicate the full example with foreground/background options
for the sake of brevity.

I think using highlight-parentheses--color-update is an improvement,
as is separating the updating of colors from activating the mode.

-- 
Justin Koh <j@ustink.org>

[1]
https://protesilaos.com/emacs/modus-themes#h:24bab397-dcb2-421d-aa6e-ec5bd622b913
Details
Message ID
<87bkf0x3l9.fsf@protesilaos.com>
In-Reply-To
<eeb7a78597f7c917d0bfe9483a6177d5e67f58fe.camel@ustink.org> (view parent)
DKIM signature
missing
Download raw message
Hello Justin,

> From: Justin Koh <j@ustink.org>
> Date: Tue, 15 Aug 2023 19:42:27 +0800
>
> Since modus-themes defined some colors for rainbow-delimiters,
> I thought to reuse them for highlight-parentheses.
>
> Here is a simple example based on the modus-themes manual
> "Note on highlight-parentheses.el"[1].

> [... 19 lines elided]

> I didn't replicate the full example with foreground/background options
> for the sake of brevity.
>
> I think using highlight-parentheses--color-update is an improvement,
> as is separating the updating of colors from activating the mode.

Sounds good!  Do you want to prepare a patch with this change?

All the best,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)