GNU Info

Info Node: (elisp)Hooks for Loading

(elisp)Hooks for Loading


Prev: Unloading Up: Loading
Enter node , (file) or (file)node

Hooks for Loading
=================

   You can ask for code to be executed if and when a particular library
is loaded, by calling `eval-after-load'.

 - Function: eval-after-load library form
     This function arranges to evaluate FORM at the end of loading the
     library LIBRARY, if and when LIBRARY is loaded.  If LIBRARY is
     already loaded, it evaluates FORM right away.

     The library name LIBRARY must exactly match the argument of
     `load'.  To get the proper results when an installed library is
     found by searching `load-path', you should not include any
     directory names in LIBRARY.

     An error in FORM does not undo the load, but does prevent
     execution of the rest of FORM.

   In general, well-designed Lisp programs should not use this feature.
The clean and modular ways to interact with a Lisp library are (1)
examine and set the library's variables (those which are meant for
outside use), and (2) call the library's functions.  If you wish to do
(1), you can do it immediately--there is no need to wait for when the
library is loaded.  To do (2), you must load the library (preferably
with `require').

   But it is OK to use `eval-after-load' in your personal
customizations if you don't feel they must meet the design standards for
programs meant for wider use.

 - Variable: after-load-alist
     This variable holds an alist of expressions to evaluate if and when
     particular libraries are loaded.  Each element looks like this:

          (FILENAME FORMS...)

     The function `load' checks `after-load-alist' in order to
     implement `eval-after-load'.


automatically generated by info2www version 1.2.2.9