diff options
| author | Chong Yidong | 2010-03-26 13:43:01 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-03-26 13:43:01 -0400 |
| commit | c3863713624f7d9e20a2c05aabdd5e62cd8a15e6 (patch) | |
| tree | 1b8c894d6b5d47c656f2a28ff839c41e3f0914cf | |
| parent | eca16aa79a024a7fd5f0c98889773964f089d714 (diff) | |
| download | emacs-c3863713624f7d9e20a2c05aabdd5e62cd8a15e6.tar.gz emacs-c3863713624f7d9e20a2c05aabdd5e62cd8a15e6.zip | |
Document `after-load-functions'.
* loading.texi (Hooks for Loading): Document after-load-functions.
Copyedits.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/loading.texi | 44 | ||||
| -rw-r--r-- | etc/NEWS | 6 |
3 files changed, 34 insertions, 21 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 29c3980a2b5..fd5fe0e5262 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-03-26 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * loading.texi (Hooks for Loading): Document after-load-functions. | ||
| 4 | Copyedits. | ||
| 5 | |||
| 1 | 2010-03-24 Arni Magnusson <arnima@hafro.is> (tiny change) | 6 | 2010-03-24 Arni Magnusson <arnima@hafro.is> (tiny change) |
| 2 | 7 | ||
| 3 | * frames.texi (Cursor Parameters): Fix typo. (Bug#5760) | 8 | * frames.texi (Cursor Parameters): Fix typo. (Bug#5760) |
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 38bc9c4d0e8..ec10c51b236 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi | |||
| @@ -920,8 +920,17 @@ library, to remove functions defined in the library. | |||
| 920 | @cindex loading hooks | 920 | @cindex loading hooks |
| 921 | @cindex hooks for loading | 921 | @cindex hooks for loading |
| 922 | 922 | ||
| 923 | You can ask for code to be executed if and when a particular library is | 923 | You can ask for code to be executed each time Emacs loads a library, |
| 924 | loaded, by calling @code{eval-after-load}. | 924 | by using the variable @code{after-load-functions}: |
| 925 | |||
| 926 | @defvar after-load-functions | ||
| 927 | This abnormal hook is run after loading a file. Each function in the | ||
| 928 | hook is called with a single argument, the absolute filename of the | ||
| 929 | file that was just loaded. | ||
| 930 | @end defvar | ||
| 931 | |||
| 932 | If you want code to be executed when a @emph{particular} library is | ||
| 933 | loaded, use the function @code{eval-after-load}: | ||
| 925 | 934 | ||
| 926 | @defun eval-after-load library form | 935 | @defun eval-after-load library form |
| 927 | This function arranges to evaluate @var{form} at the end of loading | 936 | This function arranges to evaluate @var{form} at the end of loading |
| @@ -930,7 +939,7 @@ the file @var{library}, each time @var{library} is loaded. If | |||
| 930 | Don't forget to quote @var{form}! | 939 | Don't forget to quote @var{form}! |
| 931 | 940 | ||
| 932 | You don't need to give a directory or extension in the file name | 941 | You don't need to give a directory or extension in the file name |
| 933 | @var{library}---normally you just give a bare file name, like this: | 942 | @var{library}. Normally, you just give a bare file name, like this: |
| 934 | 943 | ||
| 935 | @example | 944 | @example |
| 936 | (eval-after-load "edebug" '(def-edebug-spec c-point t)) | 945 | (eval-after-load "edebug" '(def-edebug-spec c-point t)) |
| @@ -955,31 +964,30 @@ An error in @var{form} does not undo the load, but does prevent | |||
| 955 | execution of the rest of @var{form}. | 964 | execution of the rest of @var{form}. |
| 956 | @end defun | 965 | @end defun |
| 957 | 966 | ||
| 958 | In general, well-designed Lisp programs should not use this feature. | 967 | Normally, well-designed Lisp programs should not use |
| 959 | The clean and modular ways to interact with a Lisp library are (1) | 968 | @code{eval-after-load}. If you need to examine and set the variables |
| 960 | examine and set the library's variables (those which are meant for | 969 | defined in another library (those meant for outside use), you can do |
| 961 | outside use), and (2) call the library's functions. If you wish to | 970 | it immediately---there is no need to wait until the library is loaded. |
| 962 | do (1), you can do it immediately---there is no need to wait for when | 971 | If you need to call functions defined by that library, you should load |
| 963 | the library is loaded. To do (2), you must load the library (preferably | 972 | the library, preferably with @code{require} (@pxref{Named Features}). |
| 964 | with @code{require}). | ||
| 965 | 973 | ||
| 966 | But it is OK to use @code{eval-after-load} in your personal | 974 | But it is OK to use @code{eval-after-load} in your personal |
| 967 | customizations if you don't feel they must meet the design standards for | 975 | customizations if you don't feel that they must meet the design |
| 968 | programs meant for wider use. | 976 | standards for programs meant for wider use. |
| 969 | 977 | ||
| 970 | @defvar after-load-alist | 978 | @defvar after-load-alist |
| 971 | This variable, an alist built by @code{eval-after-load}, holds the | 979 | This variable stores an alist built by @code{eval-after-load}, |
| 972 | expressions to evaluate when particular libraries are loaded. Each | 980 | containing the expressions to evaluate when certain libraries are |
| 973 | element looks like this: | 981 | loaded. Each element looks like this: |
| 974 | 982 | ||
| 975 | @example | 983 | @example |
| 976 | (@var{regexp-or-feature} @var{forms}@dots{}) | 984 | (@var{regexp-or-feature} @var{forms}@dots{}) |
| 977 | @end example | 985 | @end example |
| 978 | 986 | ||
| 979 | The key @var{regexp-or-feature} is either a regular expression or a | 987 | The key @var{regexp-or-feature} is either a regular expression or a |
| 980 | symbol, and the value is a list of forms. The forms are evaluated when | 988 | symbol, and the value is a list of forms. The forms are evaluated |
| 981 | the key matches the absolute true name of the file being | 989 | when the key matches the absolute true name or feature name of the |
| 982 | @code{load}ed or the symbol being @code{provide}d. | 990 | library being loaded. |
| 983 | @end defvar | 991 | @end defvar |
| 984 | 992 | ||
| 985 | @ignore | 993 | @ignore |
| @@ -321,7 +321,7 @@ advantage of this feature. | |||
| 321 | *** The log command in vc-annotate can display a single log entry | 321 | *** The log command in vc-annotate can display a single log entry |
| 322 | instead of redisplaying the full log. The RCS, CVS and SCCS VC | 322 | instead of redisplaying the full log. The RCS, CVS and SCCS VC |
| 323 | backends do not support this. | 323 | backends do not support this. |
| 324 | 324 | --- | |
| 325 | *** When a file is not found, VC will not try to check it out of RCS anymore. | 325 | *** When a file is not found, VC will not try to check it out of RCS anymore. |
| 326 | 326 | ||
| 327 | *** Diff and log operations can be used from Dired buffers. | 327 | *** Diff and log operations can be used from Dired buffers. |
| @@ -530,9 +530,9 @@ file name handlers such as Tramp to optimizations. | |||
| 530 | *** make-network-process can now also create `seqpacket' Unix sockets. | 530 | *** make-network-process can now also create `seqpacket' Unix sockets. |
| 531 | 531 | ||
| 532 | ** Loading changes | 532 | ** Loading changes |
| 533 | 533 | --- | |
| 534 | *** eval-next-after-load is obsolete. | 534 | *** eval-next-after-load is obsolete. |
| 535 | 535 | +++ | |
| 536 | *** New hook `after-load-functions' run after loading an Elisp file. | 536 | *** New hook `after-load-functions' run after loading an Elisp file. |
| 537 | 537 | ||
| 538 | ** Byte compilation changes | 538 | ** Byte compilation changes |