This chapter describes the events involved in starting up Emacs, and the various facilities that you can use to change the way Emacs starts.
The Emacs Start-Up Procedure describes the Emacs start-up procedure. Emacs Initialisation Files describes how to use initialisation files to customise EMACS. Emacs Environment Files describes how to save customisations in environment files.
This section describes in detail what happens when Emacs is initially started and re-started after an ESC-x pause-emacs command. The steps that are executed when returning to a paused Emacs are specifically noted.
This section describes in detail what happens when Emacs is initially started.
The following steps are executed in order:
The resulting name is then used as the name of a file to execute as a series of MLisp expressions. When the file has been completely executed, the function package-name-com is called.
For example, a package called dired will have a file called dired.mlp that contains an MLisp function called dired-com.
An initialisation file is an MLisp program which is executed whenever you start Emacs. Emacs looks for an initialisation file using the file name emacs_path:emacsinit.ml or the MLisp program EMACSINIT.
An initialisation file can ask you questions and do things, as well as just setting up commands for later use.
The example shows a sample initialisation file.
Example: Sample EMACSINIT.ML
; ; Setup EMACS in the windows UI style ; (default-emacs-init "windows,windows-extended,ere-searching") ; ; Set up some variables ; (setq scroll-step 1) (setq visible-bell 1) (setq silently-kill-processes 1) (setq checkpoint-frequency 500) (setq unlink-checkpoint-files 1) (setq default-case-fold-search 1) (setq default-comment-column 41) ; ; Make some functions automatically load a library or package ; (autoload "add-tag" "tags") (autoload "goto-tag" "tags") (autoload "email" "email") ; ; Associate some commands with file specifications ; (auto-execute "lisp-mode" "*.ml") (auto-execute "text-mode" "*.tex") (auto-execute "c-mode" "*.c") ; ; Some re-wired key bindings ; (bind-to-key "goto-percent" "\^Xg") (bind-to-key "add-tag" "\[F2]") (bind-to-key "goto-tag" "\^XL") (bind-to-key "visit-function" "\^XP")
On current computer hardware it is not usually worth bothering with the Emacs Environment feature.
Consider using the Emacs Environment feature if:
It may be more efficient to save your customisations, extensions and small amounts of data in an Emacs environment file. Emacs can be started up using an environment file faster than it can when reading in initialisation files.
However, environment files tend to be much larger than initialisation files because they contain all the volatile information needed to re-start an Emacs editing session.
Emacs saves the following information in environment files:
Subprocesses stored in an environment file are re-started when the Emacs environment is restored. The input, output and termination procedures and buffers are also restored. Note, however, that recreated subprocesses execute with the default directory of the new Emacs process. Symbols and logical names defined in the saved process are not restored.
Scheduled procedures saved in an environment file are delivered at the specified time. If that time has already expired, they are delivered immediately.
You use the ESC-x save-environment command to save the current environment in an Emacs environment file. save-environment asks for the name of the file you want to create and will supply a default file type of ".EMACS_ENVIRONMENT" if no file type is specified.
Use the /RESTORE qualifier on the Emacs command line to cause Emacs to restore an environment file.
You cannot restore an environment file that was saved by a previous version of Emacs. Emacs will not be able to restore an environment file if the VMS shared libraries that Emacs uses have changed significantly since the environment was saved (this often happens when VMS is upgraded).
If Emacs detects an attempt to restore an incompatible environment, an error message is displayed and the editing session is aborted. If this happens to you, you must rebuild your environment file.