2

I'm trying to set the faces of highlight-indent-guides automatically whenever a new theme is loaded by making small adjustments to the background color of the default face. I have everything working here, but I've been forced to resort to the following horrible hack:

(defun imalison:set-highlight-indent-guides-faces-load-theme (&rest args)
  (if (face-background 'default)
      (imalison:set-highlight-indent-guides-faces)
    (run-at-time "1 sec" nil 'imalison:set-highlight-indent-guides-faces-load-theme)))

(advice-add 'load-theme
            :after 'imalison:set-highlight-indent-guides-faces-load-theme)

The reason the timer is needed is because (face-background 'default) is nil immediately after the call to load-theme, even though it is properly set a few seconds later. As I mention in the issue that I filed against highlight-indent-guides, I suspect that load-theme might rely on a callback somewhere when setting face values, which would explain why the face is not set when the function returns. Does anyone who is more familiar with emacs' theme system know what is going on here? Is there a reason there is no after-load-theme hook?

  • Not sure what the problem is, but I believe the proper way of modifying a theme face is using custom-theme-set-faces rather than changing the face directly with set-face-background. – Ernest A Dec 30 '16 at 9:10
  • This only seems to happen when I start emacs in daemon without a frame. If I start emacs normally, everything is fine. – imalison Jan 16 '17 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.