This section explains the steps involved in building the Emacs executable. You don't have to know this material to build and install Emacs, since the makefiles do all these things automatically. This information is pertinent to Emacs maintenance.
Compilation of the C source files in the src directory produces an executable file called temacs, also called a bare impure Emacs. It contains the Emacs Lisp interpreter and I/O routines, but not the editing commands.
The command ‘temacs -l loadup’ uses temacs to create the real runnable Emacs executable. These arguments direct temacs to evaluate the Lisp files specified in the file loadup.el. These files set up the normal Emacs editing environment, resulting in an Emacs that is still impure but no longer bare.
It takes a substantial time to load the standard Lisp files. Luckily, you don't have to do this each time you run Emacs; temacs can dump out an executable program called emacs that has these files preloaded. emacs starts more quickly because it does not need to load the files. This is the Emacs executable that is normally installed.
To create emacs, use the command ‘temacs -batch -l loadup
dump’. The purpose of ‘-batch’ here is to prevent temacs
from trying to initialize any of its data on the terminal; this ensures
that the tables of terminal information are empty in the dumped Emacs.
The argument ‘dump’ tells loadup.el to dump a new executable
named emacs. The variable
preloaded-file-list stores a
list of the Lisp files that were dumped with the emacs executable.
Some operating systems don't support dumping. On those systems, you must start Emacs with the ‘temacs -l loadup’ command each time you use it. This takes a substantial time, but since you need to start Emacs once a day at most—or once a week if you never log out—the extra time is not too severe a problem.
You can specify additional files to preload by writing a library named site-load.el that loads them. You may need to add a definition
#define SITELOAD_PURESIZE_EXTRA n
to make n added bytes of pure space to hold the additional files. (Try adding increments of 20000 until it is big enough.) However, the advantage of preloading additional files decreases as machines get faster. On modern machines, it is usually not advisable.
After loadup.el reads site-load.el, it finds the
documentation strings for primitive and preloaded functions (and
variables) in the file etc/DOC where they are stored, by
Snarf-documentation (see Accessing Documentation).
You can specify other Lisp expressions to execute just before dumping by putting them in a library named site-init.el. This file is executed after the documentation strings are found.
If you want to preload function or variable definitions, there are three ways you can do this and make their documentation strings accessible when you subsequently run Emacs:
byte-compile-dynamic-docstringsas a local variable in each of these files, and load them with either site-load.el or site-init.el. (This method has the drawback that the documentation strings take up space in Emacs all the time.)
It is not advisable to put anything in site-load.el or site-init.el that would alter any of the features that users expect in an ordinary unmodified Emacs. If you feel you must override normal features for your site, do it with default.el, so that users can override your changes if they wish. See Startup Summary.
In a package that can be preloaded, it is sometimes useful to
specify a computation to be done when Emacs subsequently starts up.
For this, use
This evaluates the body forms, either immediately if running in an Emacs that has already started up, or later when Emacs does start up. Since the value of the body forms is not necessarily available when the
eval-at-startupform is run, that form always returns
If you want to use this function in an Emacs that was already dumped, you must run Emacs with ‘-batch’.