aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/loading.texi
diff options
context:
space:
mode:
authorRichard M. Stallman1994-04-30 01:38:51 +0000
committerRichard M. Stallman1994-04-30 01:38:51 +0000
commit78c71a989daf70e8efd0dd64f1bd367e60ada05f (patch)
treeb8f9f9ab85520149cabbac824fc7ab6ecd76e500 /lispref/loading.texi
parentf06df5635fed315912ad508adf9d1de5278a1c5f (diff)
downloademacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.tar.gz
emacs-78c71a989daf70e8efd0dd64f1bd367e60ada05f.zip
entered into RCS
Diffstat (limited to 'lispref/loading.texi')
-rw-r--r--lispref/loading.texi61
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
24or, optionally, as byte-compiled code. Each form in the file is called 24or as byte-compiled code. Each form in the file is called a
25a @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
26loadable file; any form in a file may equally well be typed directly 26loadable file; any form in a file may equally well be typed directly
27into a buffer and evaluated there. (Indeed, most code is tested this 27into a buffer and evaluated there. (Indeed, most code is tested this
28way.) Most often, the forms are function definitions and variable 28way.) 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
63loaded. If there is no file by that name, then @code{load} looks for a 63loaded. If there is no file by that name, then @code{load} looks for a
64file names @file{@var{filename}.el}. If that file exists, it is loaded. 64file named @file{@var{filename}.el}. If that file exists, it is loaded.
65Finally, if neither of those names is found, @code{load} looks for a 65Finally, if neither of those names is found, @code{load} looks for a
66file named @var{filename} with nothing appended, and loads it if it 66file named @var{filename} with nothing appended, and loads it if it
67exists. (The @code{load} function is not clever about looking at 67exists. (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
94Any unhandled errors while loading a file terminate loading. If the 94Any unhandled errors while loading a file terminate loading. If the
95load was done for the sake of @code{autoload}, certain kinds of 95load was done for the sake of @code{autoload}, any function definitions
96top-level forms, those which define functions, are undone. 96made during the loading are undone.
97 97
98@kindex file-error 98@kindex file-error
99If @code{load} can't find the file to load, then normally it signals the 99If @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
166the @file{/usr/local/lisplib} directory, 166the @file{/usr/local/lisplib} directory,
167which are then followed by the standard directories for Lisp code. 167which are then followed by the standard directories for Lisp code.
168 168
169The command line options @samp{-l} or @samp{-load} specify Lispa library 169The command line options @samp{-l} or @samp{-load} specify a Lisp
170to load. Since this file might be in the current directory, Emacs 18 170library to load as part of Emacs startup. Since this file might be in
171temporarily adds the current directory to the front of @code{load-path} 171the current directory, Emacs 18 temporarily adds the current directory
172so the file can be found there. Newer Emacs versions also find such 172to the front of @code{load-path} so the file can be found there. Newer
173files in the current directory, but without altering @code{load-path}. 173Emacs versions also find such files in the current directory, but
174without 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
202comments are the most convenient way to make a function autoload, but 203comments are the most convenient way to make a function autoload, but
203only for packages installed along with Emacs. 204only 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
206This function defines the function (or macro) named @var{symbol} so as 207This function defines the function (or macro) named @var{function} so as
207to load automatically from @var{filename}. The string @var{filename} 208to load automatically from @var{filename}. The string @var{filename}
208specifies the file to load to get the real definition of @var{function}. 209specifies 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
227loading the real definition. 228loading the real definition.
228 229
229@cindex function cell in autoload 230@cindex function cell in autoload
230If @var{symbol} already has a non-void function definition that is not 231If @var{function} already has a non-void function definition that is not
231an autoload object, @code{autoload} does nothing and returns @code{nil}. 232an autoload object, @code{autoload} does nothing and returns @code{nil}.
232If the function cell of @var{symbol} is void, or is already an autoload 233If the function cell of @var{function} is void, or is already an autoload
233object, then it is defined as an autoload object like this: 234object, 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
280function definition, it is copied verbatim. You can also use a magic 281function definition, it is copied verbatim. You can also use a magic
281comment to execute a form at build time executing it when the file 282comment to execute a form at build time @emph{without} executing it when
282itself is loaded. To do this, write the form @dfn{on the same line} as 283the file itself is loaded. To do this, write the form @dfn{on the same
283the magic comment. Since it is in a comment, it does nothing when you 284line} as the magic comment. Since it is in a comment, it does nothing
284load the source file; but @code{update-file-autoloads} copies it to 285when you load the source file; but @code{update-file-autoloads} copies
285@file{loaddefs.el}, where it is executed while building Emacs. 286it 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
288autoloading with a magic comment: 289autoloading with a magic comment:
@@ -367,7 +368,9 @@ has been loaded before:
367@noindent 368@noindent
368If the library uses @code{provide} to provide a named feature, you can 369If the library uses @code{provide} to provide a named feature, you can
369use @code{featurep} to test whether the library has been loaded. 370use @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.
391feature name as argument. @code{require} looks in the global variable 394feature 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
393already. If not, it loads the feature from the appropriate file. This 396already. If not, it loads the feature from the appropriate file. This
394file should call @code{provide} at the top-level to add the feature to 397file 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
427done. 430done.
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
431when you byte-compile that file (@pxref{Byte Compilation}) as well as 434when you byte-compile that file (@pxref{Byte Compilation}) as well as
432when you load it. This is in case the required package contains macros 435when you load it. This is in case the required package contains macros
433that the byte compiler must know about. 436that 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
453The compiler ignores the @code{provide}, then processes the
454@code{require} by loading the file in question. Loading the file does
455execute the @code{provide} call, so the subsequent @code{require} call
456does nothing while loading.
457
449@defun provide feature 458@defun provide feature
450This function announces that @var{feature} is now loaded, or being 459This function announces that @var{feature} is now loaded, or being
451loaded, into the current Emacs session. This means that the facilities 460loaded, 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
510This command unloads the library that provided feature @var{feature}. 519This command unloads the library that provided feature @var{feature}.
511It undefines all functions and variables defined with @code{defvar}, 520It undefines all functions, macros, and variables defined in that
512@code{defmacro}, @code{defconst}, @code{defsubst} and @code{defalias} by 521library with @code{defconst}, @code{defvar}, @code{defun},
513that library. It then restores any autoloads associated with those 522@code{defmacro}, @code{defsubst} and @code{defalias}. It then restores
514symbols. 523any 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
531Symbols, which were defined as functions or variables. 540Symbols that were defined by this library.
532@item 541@item
533Lists of the form @code{(require . @var{feature})} indicating 542Lists of the form @code{(require . @var{feature})} indicating
534features that were required. 543features that were required.