You can ask for code to be executed each time Emacs loads a library,
by using the variable
This abnormal hook is run after loading a file. Each function in the hook is called with a single argument, the absolute filename of the file that was just loaded.
If you want code to be executed when a particular library is
loaded, use the function
This function arranges to evaluate form at the end of loading the file library, each time library is loaded. If library is already loaded, it evaluates form right away. Don't forget to quote form!
You don't need to give a directory or extension in the file name library. Normally, you just give a bare file name, like this:(eval-after-load "edebug" '(def-edebug-spec c-point t))
To restrict which files can trigger the evaluation, include a directory or an extension or both in library. Only a file whose absolute true name (i.e., the name with all symbolic links chased out) matches all the given name components will match. In the following example, my_inst.elc or my_inst.elc.gz in some directory
..../foo/barwill trigger the evaluation, but not my_inst.el:(eval-after-load "foo/bar/my_inst.elc" ...)
library can also be a feature (i.e. a symbol), in which case form is evaluated when
An error in form does not undo the load, but does prevent execution of the rest of form.
Normally, well-designed Lisp programs should not use
eval-after-load. If you need to examine and set the variables
defined in another library (those meant for outside use), you can do
it immediately—there is no need to wait until the library is loaded.
If you need to call functions defined by that library, you should load
the library, preferably with
require (see Named Features).
But it is OK to use
eval-after-load in your personal
customizations if you don't feel that they must meet the design
standards for programs meant for wider use.
This variable stores an alist built by
eval-after-load, containing the expressions to evaluate when certain libraries are loaded. Each element looks like this:(regexp-or-feature forms...)
The key regexp-or-feature is either a regular expression or a symbol, and the value is a list of forms. The forms are evaluated when the key matches the absolute true name or feature name of the library being loaded.