7

I've got (set-face-attribute 'default nil :height 100) in my init.el because I find the default font size a little too large. However, it doesn't get executed when emacs is loaded.

I don't have an init.elc file that's not representative updated version of my init.el, and I know the rest of the my init.el is being executed.

There are no other (set-face-attribute ...) sexps after it that could be overwriting it.

Going back in to my init.el after loading emacs and executing it myself sets the property correctly (i.e. for all buffers (but not new frames), persistently)

Squidly
  • 590
  • 1
  • 6
  • 25
  • Although your `init.el` is not overwriting it, it could still be having no effect. Perhaps `set-face-attribute` is a per-buffer property? (This is all from memory). You could try putting the command in a hook that gets executed later. – alexis Oct 16 '13 at 10:10
  • 2
    The code is correct. Try using only that in your init file and eliminate all other codes and packages. If it works then (i.e., with a blank init except for the `set-face-attribute . . .`), well, then you have a conflict with something else in your other settings. If you have already grepped for other possible `set-face-attribute`, and come up with nothing, and if you have disabled your color themes, you will need to slowly re-enable the rest of your settings until you find the conflict. Also look for frame settings with font specifications, like `default-frame-alist`. – lawlist Oct 16 '13 at 16:01

2 Answers2

5

After some chopping bits out of my config file, I discovered it was due to (add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-12")).

The reason I'd discounted it before was because I ran (set-face-attribute 'default nil :height 100) at the very end of my init file.

The solution is to change the sexp that alters default-frame-alist to be (add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-12") '(height . 100)), and remove the one that alters the face-attribute directly

Squidly
  • 590
  • 1
  • 6
  • 25
  • 1
    1. You should accept your own answer, if it is adequate. 2. Why don't you customize `default-frame-alist` (`M-x customize-option`), instead of fiddling with it using Lisp in your init file? It is a user option for a reason. – Drew Nov 02 '13 at 20:13
  • Because it doesn't seem to be working quite as intended yet. I hadn't come back to edit the answer yet. As for elisp, I prefer it to using customize - I think either option is valid, and I prefer the elisp approach. – Squidly Nov 04 '13 at 11:00
1

This is an old thread, but I had the same problem and managed to fix it. I see that you did as well, but wanted to contribute my solution, as I didn't find it anywhere else.

I just added the following line to my ~/.emacs.d/init.el:

(add-hook 'find-file-hook (lambda () (set-face-attribute 'default nil :height 105)))

And it worked. Props to alexis in the comments on OP for the suggestion.

preskitt91
  • 19
  • 1