aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/loading.texi
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-20 17:43:57 +0000
committerRichard M. Stallman1998-04-20 17:43:57 +0000
commit969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch)
tree5d7d0399caf410b5c4849aa9d43352b18f68d4c9 /lispref/loading.texi
parentb933f645ac70a31659f364cabf7da730d27eb244 (diff)
downloademacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz
emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip
*** empty log message ***
Diffstat (limited to 'lispref/loading.texi')
-rw-r--r--lispref/loading.texi78
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
88means you should consider recompiling @file{foo.el}. @xref{Byte 88means you should consider recompiling @file{foo.el}. @xref{Byte
89Compilation}. 89Compilation}.
90 90
91When loading a source file (not compiled), @code{load} performs
92character set translation just as Emacs would do when visiting the file.
93@xref{Coding Systems}.
94
91Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear 95Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear
92in the echo area during loading unless @var{nomessage} is 96in the echo area during loading unless @var{nomessage} is
93non-@code{nil}. 97non-@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,
171which are then followed by the standard directories for Lisp code. 175which are then followed by the standard directories for Lisp code.
172 176
173The command line options @samp{-l} or @samp{-load} specify a Lisp
174library to load as part of Emacs startup. Since this file might be in
175the current directory, Emacs 18 temporarily adds the current directory
176to the front of @code{load-path} so the file can be found there. Newer
177Emacs versions also find such files in the current directory, but
178without altering @code{load-path}.
179
180Dumping Emacs uses a special value of @code{load-path}. If the value of 177Dumping 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
182same special value), the dumped Emacs switches to the ordinary 179same special value), the dumped Emacs switches to the ordinary
@@ -233,7 +230,7 @@ Normally, the variable's value is @code{nil}, which means those
233functions should use @code{read}. 230functions 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
239This command finds the precise file name for library @var{library}. It 236This 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
266source before the real definition. @code{autoload} is the low-level 263source before the real definition. @code{autoload} is the low-level
267primitive for autoloading; any Lisp program can call @code{autoload} at 264primitive for autoloading; any Lisp program can call @code{autoload} at
268any time. Magic comments do nothing on their own; they serve as a guide 265any time. Magic comments are the most convenient way to make a function
269for the command @code{update-file-autoloads}, which constructs calls to 266autoload, for packages installed along with Emacs. They do nothing on
270@code{autoload} and arranges to execute them when Emacs is built. Magic 267their own, but they serve as a guide for the command
271comments are the most convenient way to make a function autoload, but 268@code{update-file-autoloads}, which constructs calls to @code{autoload}
272only for packages installed along with Emacs. 269and 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
275This function defines the function (or macro) named @var{function} so as 272This function defines the function (or macro) named @var{function} so as
@@ -287,10 +284,10 @@ in the function definition itself. Specifying the documentation string
287in the call to @code{autoload} makes it possible to look at the 284in the call to @code{autoload} makes it possible to look at the
288documentation without loading the function's real definition. 285documentation without loading the function's real definition.
289 286
290If @var{interactive} is non-@code{nil}, then the function can be called 287If @var{interactive} is non-@code{nil}, that says @var{function} can be
291interactively. This lets completion in @kbd{M-x} work without loading 288called interactively. This lets completion in @kbd{M-x} work without
292the function's real definition. The complete interactive specification 289loading its real definition. The complete interactive specification is
293is not given here; it's not needed unless the user actually calls 290not 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
295definition. 292definition.
296 293
@@ -365,8 +362,9 @@ function definition, it is copied verbatim. You can also use a magic
365comment to execute a form at build time @emph{without} executing it when 362comment to execute a form at build time @emph{without} executing it when
366the file itself is loaded. To do this, write the form @emph{on the same 363the file itself is loaded. To do this, write the form @emph{on the same
367line} as the magic comment. Since it is in a comment, it does nothing 364line} as the magic comment. Since it is in a comment, it does nothing
368when you load the source file; but @code{update-file-autoloads} copies 365when you load the source file; but @kbd{M-x update-file-autoloads}
369it to @file{loaddefs.el}, where it is executed while building Emacs. 366copies it to @file{loaddefs.el}, where it is executed while building
367Emacs.
370 368
371 The following example shows how @code{doctor} is prepared for 369 The following example shows how @code{doctor} is prepared for
372autoloading with a magic comment: 370autoloading 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
404example, after you have rewritten and reinstalled a function definition 402example, after you have rewritten and reinstalled a function definition
405by editing it in a buffer, you may wish to return to the original 403by editing it in a buffer, you may wish to return to the original
406version; you can do this by reloading the file it came from. 404version; 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
411that you intend to save and reinstall, you need to byte-compile the new 409that you intend to save and reinstall, you need to byte-compile the new
412version; otherwise Emacs will load the older, byte-compiled file instead 410version; otherwise Emacs will load the older, byte-compiled file instead
413of your newer, non-compiled file! If that happens, the message 411of your newer, non-compiled file! If that happens, the message
414displayed when loading the file says, ``(compiled; source is newer'', to 412displayed when loading the file includes, @samp{(compiled; source is
415remind you to recompile. 413newer)}, 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
418file might be loaded more than once. For example, think about whether 416file 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
445has been loaded before: 443has 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
457If the library uses @code{provide} to provide a named feature, you can 454If the library uses @code{provide} to provide a named feature, you can
458use @code{featurep} to test whether the library has been loaded. 455use @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},
493the definition for @code{run-prolog} includes the following code: 488the 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
505The expression @code{(require 'comint)} loads the file @file{comint.el} 500The expression @code{(require 'comint)} loads the file @file{comint.el}
506if it has not yet been loaded. This ensures that @code{make-comint} is 501if it has not yet been loaded. This ensures that @code{make-comint} is
507defined. 502defined. Features are normally named after the files that provide them,
503so that @code{require} need not be given the file name.
508 504
509The @file{comint.el} file contains the following top-level expression: 505The @file{comint.el} file contains the following top-level expression:
510 506
@@ -541,7 +537,7 @@ feature, as in the following example.
541The compiler ignores the @code{provide}, then processes the 537The 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
543execute the @code{provide} call, so the subsequent @code{require} call 539execute the @code{provide} call, so the subsequent @code{require} call
544does nothing while loading. 540does nothing when the file is loaded.
545 541
546@defun provide feature 542@defun provide feature
547This function announces that @var{feature} is now loaded, or being 543This 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
591This function returns @code{t} if @var{feature} has been provided in the 587This function returns @code{t} if @var{feature} has been provided in the
592current Emacs session (i.e., @var{feature} is a member of 588current 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
613This command unloads the library that provided feature @var{feature}. 609This command unloads the library that provided feature @var{feature}.
614It undefines all functions, macros, and variables defined in that 610It undefines all functions, macros, and variables defined in that
615library with @code{defconst}, @code{defvar}, @code{defun}, 611library 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}.
617any autoloads formerly associated with those symbols. (Loading 613It then restores any autoloads formerly associated with those symbols.
618saves these in the @code{autoload} property of the symbol.) 614(Loading saves these in the @code{autoload} property of the symbol.)
619 615
620Ordinarily, @code{unload-feature} refuses to unload a library on which 616Ordinarily, @code{unload-feature} refuses to unload a library on which
621other loaded libraries depend. (A library @var{a} depends on library 617other 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
686the library is loaded. To do (2), you must load the library (preferably 682the library is loaded. To do (2), you must load the library (preferably
687with @code{require}). 683with @code{require}).
688 684
689But it is ok to use @code{eval-after-load} in your personal customizations 685But it is OK to use @code{eval-after-load} in your personal
690if you don't feel they must meet the design standards of programs to be 686customizations if you don't feel they must meet the design standards for
691released. 687programs meant for wider use.
692 688
693@defvar after-load-alist 689@defvar after-load-alist
694An alist of expressions to evaluate if and when particular libraries are 690An alist of expressions to evaluate if and when particular libraries are