diff options
| author | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
| commit | 969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch) | |
| tree | 5d7d0399caf410b5c4849aa9d43352b18f68d4c9 /lispref/loading.texi | |
| parent | b933f645ac70a31659f364cabf7da730d27eb244 (diff) | |
| download | emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip | |
*** empty log message ***
Diffstat (limited to 'lispref/loading.texi')
| -rw-r--r-- | lispref/loading.texi | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/lispref/loading.texi b/lispref/loading.texi index e3a72b3e318..44eac1cbe44 100644 --- a/lispref/loading.texi +++ b/lispref/loading.texi | |||
| @@ -88,6 +88,10 @@ If you get a warning that @file{foo.elc} is older than @file{foo.el}, it | |||
| 88 | means you should consider recompiling @file{foo.el}. @xref{Byte | 88 | means you should consider recompiling @file{foo.el}. @xref{Byte |
| 89 | Compilation}. | 89 | Compilation}. |
| 90 | 90 | ||
| 91 | When loading a source file (not compiled), @code{load} performs | ||
| 92 | character set translation just as Emacs would do when visiting the file. | ||
| 93 | @xref{Coding Systems}. | ||
| 94 | |||
| 91 | Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear | 95 | Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear |
| 92 | in the echo area during loading unless @var{nomessage} is | 96 | in the echo area during loading unless @var{nomessage} is |
| 93 | non-@code{nil}. | 97 | non-@code{nil}. |
| @@ -170,13 +174,6 @@ followed then by the @file{/user/bil/emacs} directory, the | |||
| 170 | @file{/usr/local/lisplib} directory, and the @file{~/emacs} directory, | 174 | @file{/usr/local/lisplib} directory, and the @file{~/emacs} directory, |
| 171 | which are then followed by the standard directories for Lisp code. | 175 | which are then followed by the standard directories for Lisp code. |
| 172 | 176 | ||
| 173 | The command line options @samp{-l} or @samp{-load} specify a Lisp | ||
| 174 | library to load as part of Emacs startup. Since this file might be in | ||
| 175 | the current directory, Emacs 18 temporarily adds the current directory | ||
| 176 | to the front of @code{load-path} so the file can be found there. Newer | ||
| 177 | Emacs versions also find such files in the current directory, but | ||
| 178 | without altering @code{load-path}. | ||
| 179 | |||
| 180 | Dumping Emacs uses a special value of @code{load-path}. If the value of | 177 | Dumping Emacs uses a special value of @code{load-path}. If the value of |
| 181 | @code{load-path} at the end of dumping is unchanged (that is, still the | 178 | @code{load-path} at the end of dumping is unchanged (that is, still the |
| 182 | same special value), the dumped Emacs switches to the ordinary | 179 | same special value), the dumped Emacs switches to the ordinary |
| @@ -233,7 +230,7 @@ Normally, the variable's value is @code{nil}, which means those | |||
| 233 | functions should use @code{read}. | 230 | functions should use @code{read}. |
| 234 | @end defvar | 231 | @end defvar |
| 235 | 232 | ||
| 236 | To learn how @code{load} is used to build Emacs, see @ref{Building Emacs}. | 233 | For how @code{load} is used to build Emacs, see @ref{Building Emacs}. |
| 237 | 234 | ||
| 238 | @deffn Command locate-library library &optional nosuffix path interactive-call | 235 | @deffn Command locate-library library &optional nosuffix path interactive-call |
| 239 | This command finds the precise file name for library @var{library}. It | 236 | This command finds the precise file name for library @var{library}. It |
| @@ -265,11 +262,11 @@ as if it had been loaded all along. | |||
| 265 | @code{autoload}, and by writing a special ``magic'' comment in the | 262 | @code{autoload}, and by writing a special ``magic'' comment in the |
| 266 | source before the real definition. @code{autoload} is the low-level | 263 | source before the real definition. @code{autoload} is the low-level |
| 267 | primitive for autoloading; any Lisp program can call @code{autoload} at | 264 | primitive for autoloading; any Lisp program can call @code{autoload} at |
| 268 | any time. Magic comments do nothing on their own; they serve as a guide | 265 | any time. Magic comments are the most convenient way to make a function |
| 269 | for the command @code{update-file-autoloads}, which constructs calls to | 266 | autoload, for packages installed along with Emacs. They do nothing on |
| 270 | @code{autoload} and arranges to execute them when Emacs is built. Magic | 267 | their own, but they serve as a guide for the command |
| 271 | comments are the most convenient way to make a function autoload, but | 268 | @code{update-file-autoloads}, which constructs calls to @code{autoload} |
| 272 | only for packages installed along with Emacs. | 269 | and arranges to execute them when Emacs is built. |
| 273 | 270 | ||
| 274 | @defun autoload function filename &optional docstring interactive type | 271 | @defun autoload function filename &optional docstring interactive type |
| 275 | This function defines the function (or macro) named @var{function} so as | 272 | This function defines the function (or macro) named @var{function} so as |
| @@ -287,10 +284,10 @@ in the function definition itself. Specifying the documentation string | |||
| 287 | in the call to @code{autoload} makes it possible to look at the | 284 | in the call to @code{autoload} makes it possible to look at the |
| 288 | documentation without loading the function's real definition. | 285 | documentation without loading the function's real definition. |
| 289 | 286 | ||
| 290 | If @var{interactive} is non-@code{nil}, then the function can be called | 287 | If @var{interactive} is non-@code{nil}, that says @var{function} can be |
| 291 | interactively. This lets completion in @kbd{M-x} work without loading | 288 | called interactively. This lets completion in @kbd{M-x} work without |
| 292 | the function's real definition. The complete interactive specification | 289 | loading its real definition. The complete interactive specification is |
| 293 | is not given here; it's not needed unless the user actually calls | 290 | not given here; it's not needed unless the user actually calls |
| 294 | @var{function}, and when that happens, it's time to load the real | 291 | @var{function}, and when that happens, it's time to load the real |
| 295 | definition. | 292 | definition. |
| 296 | 293 | ||
| @@ -365,8 +362,9 @@ function definition, it is copied verbatim. You can also use a magic | |||
| 365 | comment to execute a form at build time @emph{without} executing it when | 362 | comment to execute a form at build time @emph{without} executing it when |
| 366 | the file itself is loaded. To do this, write the form @emph{on the same | 363 | the file itself is loaded. To do this, write the form @emph{on the same |
| 367 | line} as the magic comment. Since it is in a comment, it does nothing | 364 | line} as the magic comment. Since it is in a comment, it does nothing |
| 368 | when you load the source file; but @code{update-file-autoloads} copies | 365 | when you load the source file; but @kbd{M-x update-file-autoloads} |
| 369 | it to @file{loaddefs.el}, where it is executed while building Emacs. | 366 | copies it to @file{loaddefs.el}, where it is executed while building |
| 367 | Emacs. | ||
| 370 | 368 | ||
| 371 | The following example shows how @code{doctor} is prepared for | 369 | The following example shows how @code{doctor} is prepared for |
| 372 | autoloading with a magic comment: | 370 | autoloading with a magic comment: |
| @@ -400,7 +398,7 @@ documentation string in the @file{etc/DOC} file. @xref{Building Emacs}. | |||
| 400 | @section Repeated Loading | 398 | @section Repeated Loading |
| 401 | @cindex repeated loading | 399 | @cindex repeated loading |
| 402 | 400 | ||
| 403 | You may load one file more than once in an Emacs session. For | 401 | You can load one file more than once in an Emacs session. For |
| 404 | example, after you have rewritten and reinstalled a function definition | 402 | example, after you have rewritten and reinstalled a function definition |
| 405 | by editing it in a buffer, you may wish to return to the original | 403 | by editing it in a buffer, you may wish to return to the original |
| 406 | version; you can do this by reloading the file it came from. | 404 | version; you can do this by reloading the file it came from. |
| @@ -411,8 +409,8 @@ rather than a non-compiled file of similar name. If you rewrite a file | |||
| 411 | that you intend to save and reinstall, you need to byte-compile the new | 409 | that you intend to save and reinstall, you need to byte-compile the new |
| 412 | version; otherwise Emacs will load the older, byte-compiled file instead | 410 | version; otherwise Emacs will load the older, byte-compiled file instead |
| 413 | of your newer, non-compiled file! If that happens, the message | 411 | of your newer, non-compiled file! If that happens, the message |
| 414 | displayed when loading the file says, ``(compiled; source is newer'', to | 412 | displayed when loading the file includes, @samp{(compiled; source is |
| 415 | remind you to recompile. | 413 | newer)}, to remind you to recompile it. |
| 416 | 414 | ||
| 417 | When writing the forms in a Lisp library file, keep in mind that the | 415 | When writing the forms in a Lisp library file, keep in mind that the |
| 418 | file might be loaded more than once. For example, think about whether | 416 | file might be loaded more than once. For example, think about whether |
| @@ -445,17 +443,17 @@ already been loaded. Here's one way to test, in a library, whether it | |||
| 445 | has been loaded before: | 443 | has been loaded before: |
| 446 | 444 | ||
| 447 | @example | 445 | @example |
| 448 | (defvar foo-was-loaded) | 446 | (defvar foo-was-loaded nil) |
| 449 | 447 | ||
| 450 | (if (not (boundp 'foo-was-loaded)) | 448 | (unless foo-was-loaded |
| 451 | @var{execute-first-time-only}) | 449 | @var{execute-first-time-only} |
| 452 | 450 | (setq foo-was-loaded t)) | |
| 453 | (setq foo-was-loaded t) | ||
| 454 | @end example | 451 | @end example |
| 455 | 452 | ||
| 456 | @noindent | 453 | @noindent |
| 457 | If the library uses @code{provide} to provide a named feature, you can | 454 | If the library uses @code{provide} to provide a named feature, you can |
| 458 | use @code{featurep} to test whether the library has been loaded. | 455 | use @code{featurep} earlier in the file to test whether the |
| 456 | @code{provide} call has been executed before. | ||
| 459 | @ifinfo | 457 | @ifinfo |
| 460 | @xref{Named Features}. | 458 | @xref{Named Features}. |
| 461 | @end ifinfo | 459 | @end ifinfo |
| @@ -486,9 +484,6 @@ file should call @code{provide} at the top level to add the feature to | |||
| 486 | @code{features}; if it fails to do so, @code{require} signals an error. | 484 | @code{features}; if it fails to do so, @code{require} signals an error. |
| 487 | @cindex load error with require | 485 | @cindex load error with require |
| 488 | 486 | ||
| 489 | Features are normally named after the files that provide them, so that | ||
| 490 | @code{require} need not be given the file name. | ||
| 491 | |||
| 492 | For example, in @file{emacs/lisp/prolog.el}, | 487 | For example, in @file{emacs/lisp/prolog.el}, |
| 493 | the definition for @code{run-prolog} includes the following code: | 488 | the definition for @code{run-prolog} includes the following code: |
| 494 | 489 | ||
| @@ -504,7 +499,8 @@ the definition for @code{run-prolog} includes the following code: | |||
| 504 | @noindent | 499 | @noindent |
| 505 | The expression @code{(require 'comint)} loads the file @file{comint.el} | 500 | The expression @code{(require 'comint)} loads the file @file{comint.el} |
| 506 | if it has not yet been loaded. This ensures that @code{make-comint} is | 501 | if it has not yet been loaded. This ensures that @code{make-comint} is |
| 507 | defined. | 502 | defined. Features are normally named after the files that provide them, |
| 503 | so that @code{require} need not be given the file name. | ||
| 508 | 504 | ||
| 509 | The @file{comint.el} file contains the following top-level expression: | 505 | The @file{comint.el} file contains the following top-level expression: |
| 510 | 506 | ||
| @@ -541,7 +537,7 @@ feature, as in the following example. | |||
| 541 | The compiler ignores the @code{provide}, then processes the | 537 | The compiler ignores the @code{provide}, then processes the |
| 542 | @code{require} by loading the file in question. Loading the file does | 538 | @code{require} by loading the file in question. Loading the file does |
| 543 | execute the @code{provide} call, so the subsequent @code{require} call | 539 | execute the @code{provide} call, so the subsequent @code{require} call |
| 544 | does nothing while loading. | 540 | does nothing when the file is loaded. |
| 545 | 541 | ||
| 546 | @defun provide feature | 542 | @defun provide feature |
| 547 | This function announces that @var{feature} is now loaded, or being | 543 | This function announces that @var{feature} is now loaded, or being |
| @@ -589,7 +585,7 @@ provided}. | |||
| 589 | 585 | ||
| 590 | @defun featurep feature | 586 | @defun featurep feature |
| 591 | This function returns @code{t} if @var{feature} has been provided in the | 587 | This function returns @code{t} if @var{feature} has been provided in the |
| 592 | current Emacs session (i.e., @var{feature} is a member of | 588 | current Emacs session (i.e., if @var{feature} is a member of |
| 593 | @code{features}.) | 589 | @code{features}.) |
| 594 | @end defun | 590 | @end defun |
| 595 | 591 | ||
| @@ -612,10 +608,10 @@ reclaim memory for other Lisp objects. To do this, use the function | |||
| 612 | @deffn Command unload-feature feature &optional force | 608 | @deffn Command unload-feature feature &optional force |
| 613 | This command unloads the library that provided feature @var{feature}. | 609 | This command unloads the library that provided feature @var{feature}. |
| 614 | It undefines all functions, macros, and variables defined in that | 610 | It undefines all functions, macros, and variables defined in that |
| 615 | library with @code{defconst}, @code{defvar}, @code{defun}, | 611 | library with @code{defun}, @code{defalias}, @code{defsubst}, |
| 616 | @code{defmacro}, @code{defsubst} and @code{defalias}. It then restores | 612 | @code{defmacro}, @code{defconst}, @code{defvar}, and @code{defcustom}. |
| 617 | any autoloads formerly associated with those symbols. (Loading | 613 | It then restores any autoloads formerly associated with those symbols. |
| 618 | saves these in the @code{autoload} property of the symbol.) | 614 | (Loading saves these in the @code{autoload} property of the symbol.) |
| 619 | 615 | ||
| 620 | Ordinarily, @code{unload-feature} refuses to unload a library on which | 616 | Ordinarily, @code{unload-feature} refuses to unload a library on which |
| 621 | other loaded libraries depend. (A library @var{a} depends on library | 617 | other loaded libraries depend. (A library @var{a} depends on library |
| @@ -686,9 +682,9 @@ do (1), you can do it immediately---there is no need to wait for when | |||
| 686 | the library is loaded. To do (2), you must load the library (preferably | 682 | the library is loaded. To do (2), you must load the library (preferably |
| 687 | with @code{require}). | 683 | with @code{require}). |
| 688 | 684 | ||
| 689 | But it is ok to use @code{eval-after-load} in your personal customizations | 685 | But it is OK to use @code{eval-after-load} in your personal |
| 690 | if you don't feel they must meet the design standards of programs to be | 686 | customizations if you don't feel they must meet the design standards for |
| 691 | released. | 687 | programs meant for wider use. |
| 692 | 688 | ||
| 693 | @defvar after-load-alist | 689 | @defvar after-load-alist |
| 694 | An alist of expressions to evaluate if and when particular libraries are | 690 | An alist of expressions to evaluate if and when particular libraries are |