0

One issue with themes in Emacs is that they tend not to set the org-hide face properly so that leading stars in headings become visible. I have written a function to set the org-hide foreground to the default background when a theme is enabled, but it is not exactly working. It works if I invoke it manually but not when invoked in a hook called when a new theme is enabled. Here is what I have:

  (defun ded:set-org-hide ()
    "Make sure that both the background and foreground colors of the org-hide face
      matches the background of the default face."
    (interactive)
    (message "ded:set-org-hide")
    (set-face-attribute 'org-hide nil
                        :foreground
                        (face-attribute 'default :background nil t)))
  (add-hook 'after-enable-theme-hook #'ded:set-org-hide)

I know it is getting invoked because I see the message, but it does not set the org-hide face for some reason.

Any ideas?

2
  • 1
    Does it do what you expect when you call the function directly? If so, then perhaps the theme code is overriding what it does.
    – Drew
    Commented Jun 30, 2023 at 13:00
  • Yes, it works perfectly when called directly. Commented Jul 1, 2023 at 8:36

1 Answer 1

0

I found a work-around for this that I want to post just in case someone else runs across this. For some reason, the function works fine if called after a slight delay after enabling a new theme, so I just wrapped the above function in a timer delay:

   (defun ded:delay-org-hide ()
     (run-at-time 1 nil #'ded:set-org-hide))

Then, call this delayed version in the hook:

(add-hook 'after-enable-theme-hook #'ded:delay-org-hide)

Now, all is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.