40.1.1 Summary: Sequence of Actions at Startup
When Emacs is started up, it performs the following operations (see normal-top-level
in startup.el
):
- It adds subdirectories to
load-path
, by running the file namedsubdirs.el
in each directory in the list. Normally, this file adds the directoryβs subdirectories to the list, and those are scanned in their turn. The filessubdirs.el
are normally generated automatically when Emacs is installed. - It loads any
leim-list.el
that it finds in theload-path
directories. This file is intended for registering input methods. The search is only for any personalleim-list.el
files that you may have created; it skips the directories containing the standard Emacs libraries (these should contain only a singleleim-list.el
file, which is compiled into the Emacs executable). - It sets the variable
before-init-time
to the value ofcurrent-time
(see Time of Day). It also setsafter-init-time
tonil
, which signals to Lisp programs that Emacs is being initialized. - It sets the language environment and the terminal coding system, if requested by environment variables such as
LANG
. - It does some basic parsing of the command-line arguments.
- It loads your early init file (see Early Init File in The GNU Emacs Manual). This is not done if the options β
-q
β, β-Q
β, or β--batch
β were specified. If the β-u
β option was specified, Emacs looks for the init file in that userβs home directory instead. - It calls the function
package-activate-all
to activate any optional Emacs Lisp package that has been installed. See Packaging Basics. However, Emacs doesnβt activate the packages whenpackage-enable-at-startup
isnil
or when itβs started with one of the options β-q
β, β-Q
β, or β--batch
β. To activate the packages in the latter case,package-activate-all
should be called explicitly (e.g., via the β--funcall
β option). - If not running in batch mode, it initializes the window system that the variable
initial-window-system
specifies (see initial-window-system). The initialization function,window-system-initialization
, is a generic function (see Generic Functions) whose actual implementation is different for each supported window system. If the value ofinitial-window-system
iswindowsystem
, then the appropriate implementation of the initialization function is defined in the fileterm/windowsystem-win.el
. This file should have been compiled into the Emacs executable when it was built. - It runs the normal hook
before-init-hook
. - If appropriate, it creates a graphical frame. As part of creating the graphical frame, it initializes the window system specified by
initial-frame-alist
anddefault-frame-alist
(see Initial Parameters) for the graphical frame, by calling thewindow-system-initialization
function for that window system. This is not done in batch (noninteractive) or daemon mode. - It initializes the initial frameβs faces, and sets up the menu bar and tool bar if needed. If graphical frames are supported, it sets up the tool bar even if the current frame is not a graphical one, since a graphical frame may be created later on.
- It use
custom-reevaluate-setting
to re-initialize the members of the listcustom-delayed-init-variables
. These are any pre-loaded user options whose default value depends on the run-time, rather than build-time, context. See custom-initialize-delay. - It loads the library
site-start
, if it exists. This is not done if the options β-Q
β or β--no-site-file
β were specified. - It loads your init file (see Init File). This is not done if the options β
-q
β, β-Q
β, or β--batch
β were specified. If the β-u
β option was specified, Emacs looks for the init file in that userβs home directory instead. - It loads the library
default
, if it exists. This is not done ifinhibit-default-init
is non-nil
, nor if the options β-q
β, β-Q
β, or β--batch
β were specified. - It loads your abbrevs from the file specified by
abbrev-file-name
, if that file exists and can be read (see abbrev-file-name). This is not done if the option β--batch
β was specified. - It sets the variable
after-init-time
to the value ofcurrent-time
. This variable was set tonil
earlier; setting it to the current time signals that the initialization phase is over, and, together withbefore-init-time
, provides the measurement of how long it took. - It runs the normal hook
after-init-hook
. - If the buffer
*scratch*
exists and is still in Fundamental mode (as it should be by default), it sets its major mode according toinitial-major-mode
. - If started on a text terminal, it loads the terminal-specific Lisp library (see Terminal-Specific), and runs the hook
tty-setup-hook
. This is not done in--batch
mode, nor ifterm-file-prefix
isnil
. - It displays the initial echo area message, unless you have suppressed that with
inhibit-startup-echo-area-message
. - It processes any command-line options that were not handled earlier.
- It now exits if the option
--batch
was specified. - If the
*scratch*
buffer exists and is empty, it inserts(substitute-command-keys initial-scratch-message)
into that buffer. - If
initial-buffer-choice
is a string, it visits the file (or directory) with that name. If it is a function, it calls the function with no arguments and selects the buffer that it returns. If one file is given as a command line argument, that file is visited and its buffer displayed alongsideinitial-buffer-choice
. If more than one file is given, all of the files are visited and the*Buffer List*
buffer is displayed alongsideinitial-buffer-choice
. - It runs
emacs-startup-hook
. - It calls
frame-notice-user-settings
, which modifies the parameters of the selected frame according to whatever the init files specify. - It runs
window-setup-hook
. The only difference between this hook andemacs-startup-hook
is that this one runs after the previously mentioned modifications to the frame parameters. - It displays the startup screen, which is a special buffer that contains information about copyleft and basic Emacs usage. This is not done if
inhibit-startup-screen
orinitial-buffer-choice
are non-nil
, or if the β--no-splash
β or β-Q
β command-line options were specified. - If a daemon was requested, it calls
server-start
. (On POSIX systems, if a background daemon was requested, it then detaches from the controlling terminal.) See Emacs Server in The GNU Emacs Manual. - If started by the X session manager, it calls
emacs-session-restore
passing it as argument the ID of the previous session. See Session Management.
The following options affect some aspects of the startup sequence.
user option
inhibit-startup-screenβ
This variable, if non-nil
, inhibits the startup screen. In that case, Emacs typically displays the *scratch*
buffer; but see initial-buffer-choice
, below.
Do not set this variable in the init file of a new user, or in a way that affects more than one user, as that would prevent new users from receiving information about copyleft and basic Emacs usage.
inhibit-startup-message
and inhibit-splash-screen
are aliases for this variable.
user option
initial-buffer-choiceβ
If non-nil
, this variable is a string that specifies a file or directory for Emacs to display after starting up, instead of the startup screen. If its value is a function, Emacs calls that function which must return a buffer which is then displayed. If its value is t
, Emacs displays the *scratch*
buffer.
user option
inhibit-startup-echo-area-messageβ
This variable controls the display of the startup echo area message. You can suppress the startup echo area message by adding text with this form to your init file:
(setq inhibit-startup-echo-area-message
"your-login-name")
Emacs explicitly checks for an expression as shown above in your init file; your login name must appear in the expression as a Lisp string constant. You can also use the Customize interface. Other methods of setting inhibit-startup-echo-area-message
to the same value do not inhibit the startup message. This way, you can easily inhibit the message for yourself if you wish, but thoughtless copying of your init file will not inhibit the message for someone else.
user option
initial-scratch-messageβ
This variable, if non-nil
, should be a string, which is treated as documentation to be inserted into the *scratch*
buffer when Emacs starts up. If it is nil
, the *scratch*
buffer is empty.
The following command-line options affect some aspects of the startup sequence. See Initial Options in The GNU Emacs Manual.
--no-splash
β
Do not display a splash screen.
--batch
β
Run without an interactive terminal. See Batch Mode.
--daemon
β
--bg-daemon
β
--fg-daemon
β
Do not initialize any display; just start a server. (A βbackground" daemon automatically runs in the background.)
--no-init-file
β
-q
β
Do not load either the init file, or the default
library.
--no-site-file
β
Do not load the site-start
library.
--quick
β
-Q
β
Equivalent to β-q --no-site-file --no-splash
β.