diff options
| author | Richard M. Stallman | 1994-04-30 01:38:51 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-30 01:38:51 +0000 |
| commit | 78c71a989daf70e8efd0dd64f1bd367e60ada05f (patch) | |
| tree | b8f9f9ab85520149cabbac824fc7ab6ecd76e500 /lispref/loading.texi | |
| parent | f06df5635fed315912ad508adf9d1de5278a1c5f (diff) | |
| download | emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.tar.gz emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.zip | |
entered into RCS
Diffstat (limited to 'lispref/loading.texi')
| -rw-r--r-- | lispref/loading.texi | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/lispref/loading.texi b/lispref/loading.texi index 59d27a0a13e..892473b9baf 100644 --- a/lispref/loading.texi +++ b/lispref/loading.texi | |||
| @@ -21,8 +21,8 @@ in an Emacs buffer. | |||
| 21 | 21 | ||
| 22 | @cindex top-level form | 22 | @cindex top-level form |
| 23 | The loaded file must contain Lisp expressions, either as source code | 23 | The loaded file must contain Lisp expressions, either as source code |
| 24 | or, optionally, as byte-compiled code. Each form in the file is called | 24 | or as byte-compiled code. Each form in the file is called a |
| 25 | a @dfn{top-level form}. There is no special format for the forms in a | 25 | @dfn{top-level form}. There is no special format for the forms in a |
| 26 | loadable file; any form in a file may equally well be typed directly | 26 | loadable file; any form in a file may equally well be typed directly |
| 27 | into a buffer and evaluated there. (Indeed, most code is tested this | 27 | into a buffer and evaluated there. (Indeed, most code is tested this |
| 28 | way.) Most often, the forms are function definitions and variable | 28 | way.) Most often, the forms are function definitions and variable |
| @@ -61,7 +61,7 @@ To find the file, @code{load} first looks for a file named | |||
| 61 | @file{@var{filename}.elc}, that is, for a file whose name is | 61 | @file{@var{filename}.elc}, that is, for a file whose name is |
| 62 | @var{filename} with @samp{.elc} appended. If such a file exists, it is | 62 | @var{filename} with @samp{.elc} appended. If such a file exists, it is |
| 63 | loaded. If there is no file by that name, then @code{load} looks for a | 63 | loaded. If there is no file by that name, then @code{load} looks for a |
| 64 | file names @file{@var{filename}.el}. If that file exists, it is loaded. | 64 | file named @file{@var{filename}.el}. If that file exists, it is loaded. |
| 65 | Finally, if neither of those names is found, @code{load} looks for a | 65 | Finally, if neither of those names is found, @code{load} looks for a |
| 66 | file named @var{filename} with nothing appended, and loads it if it | 66 | file named @var{filename} with nothing appended, and loads it if it |
| 67 | exists. (The @code{load} function is not clever about looking at | 67 | exists. (The @code{load} function is not clever about looking at |
| @@ -92,8 +92,8 @@ non-@code{nil}. | |||
| 92 | 92 | ||
| 93 | @cindex load errors | 93 | @cindex load errors |
| 94 | Any unhandled errors while loading a file terminate loading. If the | 94 | Any unhandled errors while loading a file terminate loading. If the |
| 95 | load was done for the sake of @code{autoload}, certain kinds of | 95 | load was done for the sake of @code{autoload}, any function definitions |
| 96 | top-level forms, those which define functions, are undone. | 96 | made during the loading are undone. |
| 97 | 97 | ||
| 98 | @kindex file-error | 98 | @kindex file-error |
| 99 | If @code{load} can't find the file to load, then normally it signals the | 99 | If @code{load} can't find the file to load, then normally it signals the |
| @@ -166,11 +166,12 @@ followed then by the @file{/user/bil/emacs} directory and then by | |||
| 166 | the @file{/usr/local/lisplib} directory, | 166 | the @file{/usr/local/lisplib} directory, |
| 167 | which are then followed by the standard directories for Lisp code. | 167 | which are then followed by the standard directories for Lisp code. |
| 168 | 168 | ||
| 169 | The command line options @samp{-l} or @samp{-load} specify Lispa library | 169 | The command line options @samp{-l} or @samp{-load} specify a Lisp |
| 170 | to load. Since this file might be in the current directory, Emacs 18 | 170 | library to load as part of Emacs startup. Since this file might be in |
| 171 | temporarily adds the current directory to the front of @code{load-path} | 171 | the current directory, Emacs 18 temporarily adds the current directory |
| 172 | so the file can be found there. Newer Emacs versions also find such | 172 | to the front of @code{load-path} so the file can be found there. Newer |
| 173 | files in the current directory, but without altering @code{load-path}. | 173 | Emacs versions also find such files in the current directory, but |
| 174 | without altering @code{load-path}. | ||
| 174 | @end defopt | 175 | @end defopt |
| 175 | 176 | ||
| 176 | @defvar load-in-progress | 177 | @defvar load-in-progress |
| @@ -202,8 +203,8 @@ for the command @code{update-file-autoloads}, which constructs calls to | |||
| 202 | comments are the most convenient way to make a function autoload, but | 203 | comments are the most convenient way to make a function autoload, but |
| 203 | only for packages installed along with Emacs. | 204 | only for packages installed along with Emacs. |
| 204 | 205 | ||
| 205 | @defun autoload symbol filename &optional docstring interactive type | 206 | @defun autoload function filename &optional docstring interactive type |
| 206 | This function defines the function (or macro) named @var{symbol} so as | 207 | This function defines the function (or macro) named @var{function} so as |
| 207 | to load automatically from @var{filename}. The string @var{filename} | 208 | to load automatically from @var{filename}. The string @var{filename} |
| 208 | specifies the file to load to get the real definition of @var{function}. | 209 | specifies the file to load to get the real definition of @var{function}. |
| 209 | 210 | ||
| @@ -227,9 +228,9 @@ keymap. Various parts of Emacs need to know this information without | |||
| 227 | loading the real definition. | 228 | loading the real definition. |
| 228 | 229 | ||
| 229 | @cindex function cell in autoload | 230 | @cindex function cell in autoload |
| 230 | If @var{symbol} already has a non-void function definition that is not | 231 | If @var{function} already has a non-void function definition that is not |
| 231 | an autoload object, @code{autoload} does nothing and returns @code{nil}. | 232 | an autoload object, @code{autoload} does nothing and returns @code{nil}. |
| 232 | If the function cell of @var{symbol} is void, or is already an autoload | 233 | If the function cell of @var{function} is void, or is already an autoload |
| 233 | object, then it is defined as an autoload object like this: | 234 | object, then it is defined as an autoload object like this: |
| 234 | 235 | ||
| 235 | @example | 236 | @example |
| @@ -278,11 +279,11 @@ autoloads for all files in the current directory. | |||
| 278 | The same magic comment can copy any kind of form into | 279 | The same magic comment can copy any kind of form into |
| 279 | @file{loaddefs.el}. If the form following the magic comment is not a | 280 | @file{loaddefs.el}. If the form following the magic comment is not a |
| 280 | function definition, it is copied verbatim. You can also use a magic | 281 | function definition, it is copied verbatim. You can also use a magic |
| 281 | comment to execute a form at build time executing it when the file | 282 | comment to execute a form at build time @emph{without} executing it when |
| 282 | itself is loaded. To do this, write the form @dfn{on the same line} as | 283 | the file itself is loaded. To do this, write the form @dfn{on the same |
| 283 | the magic comment. Since it is in a comment, it does nothing when you | 284 | line} as the magic comment. Since it is in a comment, it does nothing |
| 284 | load the source file; but @code{update-file-autoloads} copies it to | 285 | when you load the source file; but @code{update-file-autoloads} copies |
| 285 | @file{loaddefs.el}, where it is executed while building Emacs. | 286 | it to @file{loaddefs.el}, where it is executed while building Emacs. |
| 286 | 287 | ||
| 287 | The following example shows how @code{doctor} is prepared for | 288 | The following example shows how @code{doctor} is prepared for |
| 288 | autoloading with a magic comment: | 289 | autoloading with a magic comment: |
| @@ -367,7 +368,9 @@ has been loaded before: | |||
| 367 | @noindent | 368 | @noindent |
| 368 | If the library uses @code{provide} to provide a named feature, you can | 369 | If the library uses @code{provide} to provide a named feature, you can |
| 369 | use @code{featurep} to test whether the library has been loaded. | 370 | use @code{featurep} to test whether the library has been loaded. |
| 371 | @ifinfo | ||
| 370 | @xref{Features}. | 372 | @xref{Features}. |
| 373 | @end ifinfo | ||
| 371 | 374 | ||
| 372 | @node Features | 375 | @node Features |
| 373 | @section Features | 376 | @section Features |
| @@ -391,7 +394,7 @@ hasn't been loaded already. | |||
| 391 | feature name as argument. @code{require} looks in the global variable | 394 | feature name as argument. @code{require} looks in the global variable |
| 392 | @code{features} to see whether the desired feature has been provided | 395 | @code{features} to see whether the desired feature has been provided |
| 393 | already. If not, it loads the feature from the appropriate file. This | 396 | already. If not, it loads the feature from the appropriate file. This |
| 394 | file should call @code{provide} at the top-level to add the feature to | 397 | file should call @code{provide} at the top level to add the feature to |
| 395 | @code{features}; if it fails to do so, @code{require} signals an error. | 398 | @code{features}; if it fails to do so, @code{require} signals an error. |
| 396 | @cindex load error with require | 399 | @cindex load error with require |
| 397 | 400 | ||
| @@ -427,7 +430,7 @@ This adds @code{comint} to the global @code{features} list, so that | |||
| 427 | done. | 430 | done. |
| 428 | 431 | ||
| 429 | @cindex byte-compiling @code{require} | 432 | @cindex byte-compiling @code{require} |
| 430 | When @code{require} is used at top-level in a file, it takes effect | 433 | When @code{require} is used at top level in a file, it takes effect |
| 431 | when you byte-compile that file (@pxref{Byte Compilation}) as well as | 434 | when you byte-compile that file (@pxref{Byte Compilation}) as well as |
| 432 | when you load it. This is in case the required package contains macros | 435 | when you load it. This is in case the required package contains macros |
| 433 | that the byte compiler must know about. | 436 | that the byte compiler must know about. |
| @@ -446,6 +449,12 @@ feature, as in the following example. | |||
| 446 | @end group | 449 | @end group |
| 447 | @end smallexample | 450 | @end smallexample |
| 448 | 451 | ||
| 452 | @noindent | ||
| 453 | The compiler ignores the @code{provide}, then processes the | ||
| 454 | @code{require} by loading the file in question. Loading the file does | ||
| 455 | execute the @code{provide} call, so the subsequent @code{require} call | ||
| 456 | does nothing while loading. | ||
| 457 | |||
| 449 | @defun provide feature | 458 | @defun provide feature |
| 450 | This function announces that @var{feature} is now loaded, or being | 459 | This function announces that @var{feature} is now loaded, or being |
| 451 | loaded, into the current Emacs session. This means that the facilities | 460 | loaded, into the current Emacs session. This means that the facilities |
| @@ -508,10 +517,10 @@ reclaim memory for other Lisp objects. To do this, use the function | |||
| 508 | 517 | ||
| 509 | @deffn Command unload-feature feature | 518 | @deffn Command unload-feature feature |
| 510 | This command unloads the library that provided feature @var{feature}. | 519 | This command unloads the library that provided feature @var{feature}. |
| 511 | It undefines all functions and variables defined with @code{defvar}, | 520 | It undefines all functions, macros, and variables defined in that |
| 512 | @code{defmacro}, @code{defconst}, @code{defsubst} and @code{defalias} by | 521 | library with @code{defconst}, @code{defvar}, @code{defun}, |
| 513 | that library. It then restores any autoloads associated with those | 522 | @code{defmacro}, @code{defsubst} and @code{defalias}. It then restores |
| 514 | symbols. | 523 | any autoloads formerly associated with those symbols. |
| 515 | @end deffn | 524 | @end deffn |
| 516 | 525 | ||
| 517 | The @code{unload-feature} function is written in Lisp; its actions are | 526 | The @code{unload-feature} function is written in Lisp; its actions are |
| @@ -528,7 +537,7 @@ composed of these kinds of objects: | |||
| 528 | 537 | ||
| 529 | @itemize @bullet | 538 | @itemize @bullet |
| 530 | @item | 539 | @item |
| 531 | Symbols, which were defined as functions or variables. | 540 | Symbols that were defined by this library. |
| 532 | @item | 541 | @item |
| 533 | Lists of the form @code{(require . @var{feature})} indicating | 542 | Lists of the form @code{(require . @var{feature})} indicating |
| 534 | features that were required. | 543 | features that were required. |