Next: , Up: Starting Up

39.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):

  1. It adds subdirectories to load-path, by running the file named subdirs.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 files subdirs.el are normally generated automatically when Emacs is installed.
  2. If the library leim-list.el exists, Emacs loads it. This optional library is intended for registering input methods; Emacs looks for it in load-path (see Library Search), skipping those directories containing the standard Emacs libraries (since leim-list.el should not exist in those directories).

  3. It sets the variable before-init-time to the value of current-time (see Time of Day). It also sets after-init-time to nil, which signals to Lisp programs that Emacs is being initialized.
  4. It sets the language environment and the terminal coding system, if requested by environment variables such as LANG.
  5. It does some basic parsing of the command-line arguments.

  6. 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 for each supported window system is specified by window-system-initialization-alist. If the value of initial-window-system is windowsystem, then the appropriate initialization function is defined in the file term/windowsystem-win.el. This file should have been compiled into the Emacs executable when it was built.
  7. It runs the normal hook before-init-hook.
  8. If appropriate, it creates a graphical frame. This is not done if the options ‘--batch’ or ‘--daemon’ were specified.
  9. 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.
  10. It use custom-reevaluate-setting to re-initialize the members of the list custom-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.
  11. It loads the library site-start, if it exists. This is not done if the options ‘-Q’ or ‘--no-site-file’ were specified.
  12. 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.
  13. It loads the library default, if it exists. This is not done if inhibit-default-init is non-nil, nor if the options ‘-q’, ‘-Q’, or ‘--batch’ were specified.
  14. 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.
  15. If package-enable-at-startup is non-nil, it calls the function package-initialize to activate any optional Emacs Lisp package that has been installed. See Packaging Basics.

  16. It sets the variable after-init-time to the value of current-time. This variable was set to nil earlier; setting it to the current time signals that the initialization phase is over, and, together with before-init-time, provides the measurement of how long it took.
  17. It runs the normal hook after-init-hook.
  18. If the buffer *scratch* exists and is still in Fundamental mode (as it should be by default), it sets its major mode according to initial-major-mode.
  19. If started on a text terminal, it loads the terminal-specific Lisp library, which is specified by the variable term-file-prefix (see Terminal-Specific). This is not done in --batch mode, nor if term-file-prefix is nil.
  20. It displays the initial echo area message, unless you have suppressed that with inhibit-startup-echo-area-message.
  21. It processes any command-line options that were not handled earlier.
  22. It now exits if the option --batch was specified.
  23. If initial-buffer-choice is a string, it visits the file with that name. If the *scratch* buffer exists and is empty, it inserts initial-scratch-message into that buffer.
  24. It runs emacs-startup-hook and then term-setup-hook.
  25. It calls frame-notice-user-settings, which modifies the parameters of the selected frame according to whatever the init files specify.
  26. It runs window-setup-hook. See Window Systems.
  27. 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 or initial-buffer-choice are non-nil, or if the ‘--no-splash’ or ‘-Q’ command-line options were specified.
  28. If the option --daemon was specified, it calls server-start and detaches from the controlling terminal. See Emacs Server.
  29. 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.

— 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 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.

--no-splash
Do not display a splash screen.
--batch
Run without an interactive terminal. See Batch Mode.
--daemon
Do not initialize any display; just start a server 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’.