4

I just upgraded Emacs to 25.1.1 (via the Arch Linux package manager pacman).

Now I can't set the font size in my .emacs anymore.

I am able to adjust it via C-x C-+ and C-x C--, and I can also use M-x customize to set the default font height to 83 instead of 103. This works for my current session in all buffers, then.

But when I save the generated config code (attached below) in my .emacs and restart, the settings are ignored and Emacs starts with the default font size instead. I am confused as to where to start searching for the cause of the problem, since it works if I adjust it in each session, but does not work when restarting Emacs.

There is no error message and nothing of help in the *Messages* buffer.

Where can I start looking for the problem?

I must add that I have no idea about how Emacs-Lisp works and can only copy-paste things into my config file. It's a very confusing language for me.

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 83 :width normal :foundry "PfEd" :family "DejaVu Sans Mono"))))
 '(tabbar-button ((t (:inherit tabbar-default :foreground "dark red"))))
 '(tabbar-button-highlight ((t (:inherit tabbar-default))))
 '(tabbar-default ((t (:inherit variable-pitch :background "#959A79" :foreground "black" :weight bold))))
 '(tabbar-highlight ((t (:underline t))))
 '(tabbar-selected ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-separator ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-unselected ((t (:inherit tabbar-default)))))
Scott Weldon
  • 2,695
  • 1
  • 17
  • 31
  • I had the same problem. To solve this I put this in my `.emacs` :- `(set-frame-font "PragmataPro 13")`. Put the font-name followed by the font-size in the quotes. Thats it. – Chakravarthy Raghunandan Sep 19 '16 at 16:59
  • How did you set the faces? Did you add those lines to the `.emacs` file or you just set it with `customize-faces` and clicked _Apply and Save_? – caisah Sep 19 '16 at 18:21
  • caisah: I used `customize` and let it add it to my `.emacs` automatically – Alexander Engelhardt Sep 19 '16 at 18:35
  • Chakravarthy: Thank you! The command `set-frame-font` worked. I had to find a super long string for my desired font via `xfontsel` in Linux, according to here: https://www.emacswiki.org/emacs/SetFonts – Alexander Engelhardt Sep 19 '16 at 18:43
  • Chakravarthy: Okay, update: It does not work if I open a new frame with `C-x 5 2`. The new frame will have the old font that I don't want... – Alexander Engelhardt Sep 21 '16 at 13:59

2 Answers2

6

This is most likely an instance of Emacs bug#25228 - custom-set-faces from init file ~/.emacs ignored. Basically Emacs is applying gconf settings which override your customization (Emacs versions prior to 25.1 apparently had some bug which prevented the settings from applying at all). To disable gconf updates, add this your .emacs:

(define-key special-event-map [config-changed-event] #'ignore)
npostavs
  • 9,033
  • 1
  • 21
  • 53
0

You can use this command to increase the font size,

(set-face-attribute 'default nil :height 165)

It works for me on Mac - Emacs 25.1.50

Madhavan
  • 1,957
  • 12
  • 28
  • For me, unfortunately, it doesn't work. If I try to enter the command via M-x set-face-attribute, it can't even be found. The only one that I can call is set-face-font. This one would work within a session, but also not within a startup file – Alexander Engelhardt Sep 19 '16 at 17:55
  • It is not a command, it's a function. You can't call it via `M-x` - you have to evaluate the entire elisp expression. Press `M-:` to bring up a dialogue for evaluating short expressions, or paste it into an elisp buffer and evaluate it using `M-x eval-last-sexp`. – JCC Sep 20 '16 at 19:33
  • Oh! It works with `M-:`, but not if I put this line in my (otherwise empty) `.emacs`. Do you know why that would make a difference? – Alexander Engelhardt Sep 23 '16 at 08:15
  • 1
    This may be another instance of [Emacs bug#25228 - custom-set-faces from init file ~/.emacs ignored](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25228) – npostavs Dec 19 '16 at 13:48
  • @MadhavanKumar The bug affects GNU Emacs running on a GNOME desktop, so Macs won't be affected, so while the `set-face-attribute` command in your init file works for you, it won't work on affected systems. – Teemu Leisti May 04 '18 at 12:33