How do you change the Emacs init file to customize the font for new frames?

2.1k Views Asked by At

I want to know, what text do I have to input in the .emacs file so that it uses a especific font (like the clean 5x8) on the new frames, such as with the speedbar. I can modify the speedbar font size and type by using SHIFT-LeftClick but I want it to stay by default.

4

There are 4 best solutions below

0
On BEST ANSWER

There are several choices. Perhaps the easiest is to use Customize to change the default frame font. Choose Customize from the menu, use a regex to find default-frame-alist.

Set the Font property (You may have to add it to the list.) Mine is set as

"-*-*-medium-r-normal--16-*-*-*-*-*-fontset-osaka"

Second choice is to actually set the default-frame-alist in your .emacs.

Here's a hint: set up your current frame the way you like it, then type

(pp (current-frame-configuration))^J

in the *scratch* buffer to find out all the frame parameters.

0
On

Customize option default-frame-alist. End of story.

For font changes, see this page: http://www.emacswiki.org/emacs/SetFonts.

1
On

If you work in non-Debian linux, another way to set up a default font for emacs is to add emacs customisation to the file ~/.Xdefaults (in Debian, any file in /etc/X11/Xresources/ is used; for example, /etc/X11/Xresources/emacs):

emacs*font: 7x14

which may be followed by different other options:

emacs*Background: DarkSlateGray
emacs*Foreground: Wheat
emacs*pointerColor: Orchid
emacs*cursorColor: Orchid
emacs*bitmapIcon: on
emacs.geometry: 100x40

The name of the font above is not explicit, in some situations you may need to specify it explicitly, such as

emacs.font -*-*-medium-r-normal--14-130-75-75-c-70-fontset-startup

The exact name of your preferred font can obtain, as in the above answer, by typing

(pp (current-frame-configuration))^J

in the *scratch* buffer. You would need to reload X.

2
On
(eval-after-load 'speedbar
  (add-to-list 'speedbar-frame-parameters '(font . "5x8")))

or

M-x customize-variable
speedbar-frame-parameters