Next: , Previous: , Up: Advanced customization   [Index]

7.19 DIY Custom hl-todo colors

The hl-todo package provides the user option hl-todo-keyword-faces: it specifies a pair of keyword and corresponding color value. The Modus themes configure that option in the interest of legibility. While this works for our purposes, users may still prefer to apply their custom values, in which case the following approach is necessary:

(defun my-modus-themes-hl-todo-faces (&rest _)
  (setq hl-todo-keyword-faces '(("TODO" . "#ff0000")
                                ("HACK" . "#ffff00")
                                ("XXX" . "#00ffff")
                                ("NOTE" . "#ff00ff"))))

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

Using a hook at the post-load-theme phase.

Or include a let form, if needed:

(defun my-modus-themes-hl-todo-faces (&rest _)
  (let ((red "#ff0000")
        (blue "#0000ff"))
    (setq hl-todo-keyword-faces `(("TODO" . ,blue)
                                  ("HACK" . ,red)
                                  ("XXX" . ,red)
                                  ("NOTE" . ,blue)))))

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

Using a hook at the post-load-theme phase.

Normally, we do not touch user options, though this is an exception: otherwise the defaults are not always legible.

Reload the theme for changes to take effect.