Next: , Up: Configuring   [Index]


4.2.1 Emacs Initialization

The Emacs =Initialization= File

When Emacs is started, it normally tries to load a Lisp program from an “initialization file”, or “init file” for short. This file, if it exists, specifies how to initialize Emacs for you.

Emacs looks for your ‘init’ file using the filenames (in this order):

If your ‘init’ file defines many functions, consider moving them to a separate (byte-compiled) file that you load in your ‘init’ file.

To prevent loading the ‘init’ file, using the command-line switch ‘-q’. To specify a unique file to load as the ‘init’ file, use the command-line switch ‘-u, --user’.

Use setq-default

Some variables automatically become buffer-local when set with ‘setq’; what you want in the init file is to set the default value, using ‘setq-default’.

Function: setq-default [var value] ...

Set the default value of variable VAR to VALUE. The default value of a variable is seen in buffers that do not have their own values for the variable.

VAR

the variable name, is literal (not evaluated);

VALUE

is an expression: it is evaluated and its value returned.

More generally, you can use multiple variables and values, as in

(setq-default VAR VALUE VAR VALUE...)

Site Startup File

Your site may also have a “site startup file”; this is named ‘site-start.el’, if it exists. Emacs finds this file via the standard search path for Lisp libraries. Emacs loads this library before it loads your ‘init’ file.

To inhibit loading of this library, use the option ‘–no-site-file’.

Default Init File

There can also be a “default init file”, which is the library named ‘default.el’, found via the standard search path for libraries. The Emacs distribution contains no such library; your site may create one for local customizations. If this library exists, it is loaded whenever you start Emacs (except when you specify ‘-q’). But your init file, if any, is loaded first; if it sets ‘inhibit-default-init’ non-‘nil’, then ‘default’ is not loaded.

Location of Init Files

You can place ‘default.el’ and ‘site-start.el’ in any of the directories which Emacs searches for Lisp libraries. The variable ‘load-path’ (*note Lisp Libraries) specifies these directories.

The Early Init File

Most customizations for Emacs should be put in the normal init file. *Note Init File. However, it is sometimes desirable to have customizations that take effect during Emacs startup earlier than the normal init file is processed. Such customizations can be put in the early init file,

This file is loaded before the package system and GUI is initialized, so in it you can customize variables that affect frame appearance as well as the package initialization process, such as


Next: Emacs Directory, Up: Configuring   [Index]