~protesilaos/modus-themes

5 3

[BUG] loading modus themes overrides user settings for hl-todo

Vincent Foley <vincent@era.co>
Details
Message ID
<871qwh1r88.fsf@era.co>
DKIM signature
missing
Download raw message
I have the follow hl-todo configuration in my init.el file:

    (use-package hl-todo
      :ensure t
      :custom
      (hl-todo-keyword-faces '(("TODO" . "#ff0000")
                               ("HACK" . "#ff0000")
                               ("XXX" . "#ff0000")
                               ("PERF" . "#ff0000")
                               ("NB" . "#ff0000")
                               ("NOTE" . "#ff0000")))
      :config
      (global-hl-todo-mode 1))

When I use the command `M-x modus-themes-toggle`, my color settings are
overridden by modus. I believe this happens in modus-themes.el at line
7470.

Extra information:

  - GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33,
    cairo version 1.17.6) of 2022-05-14
  - M-x modus-themes-version: 2.4.0-dev
Details
Message ID
<87k0a91lka.fsf@protesilaos.com>
In-Reply-To
<871qwh1r88.fsf@era.co> (view parent)
DKIM signature
missing
Download raw message
Hello Vincent!

> From: Vincent Foley <vincent@era.co>
> Date: Wed, 25 May 2022 12:58:46 -0400
>
> I have the follow hl-todo configuration in my init.el file:
>
> [... 11 lines elided]
>
> When I use the command `M-x modus-themes-toggle`, my color settings are
> overridden by modus. I believe this happens in modus-themes.el at line
> 7470.

Please try this:

    (defun my-modus-themes-hl-todo-faces ()
      (setq hl-todo-keyword-faces '(("TODO" . "#ff0000")
                                    ("HACK" . "#ff0000")
                                    ("XXX" . "#ff0000")
                                    ("PERF" . "#ff0000")
                                    ("NB" . "#ff0000")
                                    ("NOTE" . "#ff0000"))))

    (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-hl-todo-faces)

Does it work for you?

* * *

We normally don't configure user options, but we have to do it for
hl-todo-keyword-faces because (i) it is about colours which to the
end-user look like any other face and (ii) the colours used by default
are not always legible enough.

-- 
Protesilaos Stavrou
https://protesilaos.com
Vincent Foley <vincent@era.co>
Details
Message ID
<87wne9yvvj.fsf@era.co>
In-Reply-To
<87k0a91lka.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
> Does it work for you?

This is how I made it work:

    (use-package hl-todo
      :ensure t
      :after modus-themes
      :config
      (defun vfb/hl-todo-colors ()
        (interactive)
        (setq hl-todo-keyword-faces '(("TODO" . "#ff0000")
                                      ("HACK" . "#ff0000")
                                      ("XXX" . "#ff0000")
                                      ("PERF" . "#ff0000")
                                      ("NB" . "#ff0000")
                                      ("NOTE" . "#ff0000"))))
      (add-hook 'modus-themes-after-load-theme-hook #'vfb/hl-todo-colors)
      (vfb/hl-todo-colors)
      (global-hl-todo-mode 1))

Not the prettiest, but it works.

Thanks for the help,

Vincent.
Details
Message ID
<8735gwsyvo.fsf@protesilaos.com>
In-Reply-To
<87wne9yvvj.fsf@era.co> (view parent)
DKIM signature
missing
Download raw message
> From: Vincent Foley <vincent@era.co>
> Date: Wed, 25 May 2022 20:33:02 -0400
>
>> Does it work for you?
>
> This is how I made it work:
>
> [... 16 lines elided]
>
> Not the prettiest, but it works.

I see.  I cannot think of a cleaner way to reconcile these competing
priorities: (i) let the theme provide reasonable defaults and (ii) allow
the user to customise/override them.  If you have any ideas, please let
me know.

> Thanks for the help,

You are welcome!

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<m1y1yo245t.fsf@christiantietze.de>
In-Reply-To
<87wne9yvvj.fsf@era.co> (view parent)
DKIM signature
missing
Download raw message
FWIW, I have similar functions and overrides that use the
`modus-themes-after-load-theme-hook'. It's not that bad in sum.

-- Christian
Details
Message ID
<87czg0v6wg.fsf@protesilaos.com>
In-Reply-To
<m1y1yo245t.fsf@christiantietze.de> (view parent)
DKIM signature
missing
Download raw message
> From: Christian Tietze <me@christiantietze.de>
> Date: Thu, 26 May 2022 08:34:22 +0200
>
> FWIW, I have similar functions and overrides that use the
> `modus-themes-after-load-theme-hook'. It's not that bad in sum.

Thanks for sharing!

This one is a tricky case because we normally do not interfere with user
options or other variables for that matter.  We mostly deal with faces.

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