0

I've a few set-face-attribute statements inside eval-after-load blocks inside my zenburn theme configuration. These are working fine when I startup emacs using emacsclient. But, when I create a new frame using C-x 5 2, the statements inside eval-after-load are not applied for the new frame.

My theme config for reference. As a workaround, I create new frames using emacsclient command on the terminal. But I'd not like to do this. Is there any way I fix this problem?

Install zenburn-theme and golden-ratio-scroll-screen and open emacs -Q and run the below steps to reproduce the problem:

(package-initialize)
(require 'zenburn-theme)
(require 'golden-ratio-scroll-screen)
(load-theme 'zenburn t)
(set-face-attribute 'golden-ratio-scroll-highlight-line-face nil
                         :background nil :foreground nil)

Now open any file, and run golden-ratio-scroll-screen-up or golden-ratio-scroll-screen-down and observe the face of the current line as it moves up/down. Now enter C-x 5 2 to create a new frame and run golden-ratio-scroll-screen-up and now you can see that the face settings you applied previously are gone and it has reverted back to its default face settings.

My emacs environment:

Emacs version: GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin17.6.0, NS appkit-1561.40 Version 10.13.5 (Build 17F77))
 of 2018-06-21, built using commit 5583e6460c38c5d613e732934b066421349a5259.

./configure options:
  --disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs/HEAD-5583e64_1/share/info/emacs --prefix=/usr/local/Cellar/emacs/HEAD-5583e64_1 --with-gnutls --without-x --with-xml2 --with-dbus --with-imagemagick --with-modules --with-rsvg --without-pop --with-ns --disable-ns-self-contained

Features:
  RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS
  • 1
    Can you please provide a simple, step-by-step recipe to repro the behavior, starting from emacs -Q (no init file)? – Drew Jun 28 '18 at 14:49
  • Your link to your code is a 404, but in any case please do as Drew requests and include the code which reproduces the problem in the question text. – phils Jun 29 '18 at 5:08
  • @Drew Added steps to reproduce the problem and fixed the link to my zenburn config. – Chakravarthy Raghunandan Jun 29 '18 at 6:29
  • Not sure I understand the question, still. But yes, if a library has already been loaded into your Emacs session then no, it will not be reloaded by eval-after-load. Are you expecting that it will be reloaded? Your code comment speaks of a bug, but I don't see what bug you mean. If you think you've found a bug, please report it, with M-x report-emacs-bug. – Drew Jun 29 '18 at 14:14
1

I'm going to take a guess. Now I don't know why set-face-attributes wouldn't work across all frames, but try:

(custom-theme-set-faces
     'zenburn
     '(face-settings ((t (:inherit 'default)))))

This is assuming zenburn is the official name of the theme (1). What this does is explicitly tells emacs that these settings are part of the zenburn's theme. If that doesn't work I suggest you follow Drew's suggestion and try to create a step-by-step recreation of loading the theme adding the bit of code and seeing if it recreates the problem. By the way your github returns a 404 for me.

  1. You can find the official name by just doing M-x load-theme and let tab or auto complete show you the available themes.

Edit: Using your example I can repeat the problem. However if I do:

(package-initialize)
(require 'zenburn-theme)
(require 'golden-ratio-scroll-screen)
(load-theme 'zenburn t)
(custom-theme-set-faces
 'zenburn
 '(golden-ratio-scroll-highlight-line-face
   ((t ((:background nil :foreground nil))))))
(global-set-key (kbd "C-v") 'golden-ratio-scroll-screen-up)

It does not show a little highlight thing when you scroll down/make a new frame. I believe this should work with your current defun setup. I'm not sure why it doesn't (your init.el looks really nice and organized by the way), either way let me know at least if your results in a new emacs -Q matches mine. Switching themes is such a pain...

Edit: From the comments below:

 (set-face-foreground 'golden-ratio-scroll-highlight-line-face nil) 
 (set-face-background 'golden-ratio-scroll-highlight-line-face nil)

And here are the rest of the functions in case you want to change other faces with different attributes. Reading the source of that function I believe the main problem was the nil funny enough, changing your original answer to

 (set-face-attribute 'golden-ratio-scroll-highlight-line-face nil
                     :background 'unspecified :foreground 'unspecified)

Works as well.

  • Yes, zenburn is the official name of the theme. I fixed the github link, please check now. I've added steps to reproduce the problem. – Chakravarthy Raghunandan Jun 29 '18 at 6:18
  • I'd tried custom-theme-set-faces for zenburn before setting with set-face-attribute. I think the problem with custom-theme-set-faces is that we can only change the faces which are present in zenburn theme config and other face changes will not be applied. – Chakravarthy Raghunandan Jun 29 '18 at 6:28
  • @Chakravarthy Raghunandan edited my answer let me know if it helps. – Greth Jun 29 '18 at 12:22
  • Using custom-theme-set-faces is not making any difference for golden-ratio-scroll-highlight-line-face, when running emacs normally or in emacsclient – Chakravarthy Raghunandan Jun 30 '18 at 6:42
  • Not an ideal solution, but does (set-face-foreground 'golden-ratio-scroll-highlight-line-face nil) (set-face-background 'golden-ratio-scroll-highlight-line-face nil) Work? – Greth Jun 30 '18 at 10:35

Your Answer

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

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