diff options
| author | Luc Teirlinck | 2006-02-28 03:01:57 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2006-02-28 03:01:57 +0000 |
| commit | fcaedd23eb5b8752cbd2083918c18a9436eee70a (patch) | |
| tree | a7aaad557c1543165c20c13f2a898205ff72db31 | |
| parent | 2534ef94426f71e51fe4ad37f02afb86fa5e552b (diff) | |
| download | emacs-fcaedd23eb5b8752cbd2083918c18a9436eee70a.tar.gz emacs-fcaedd23eb5b8752cbd2083918c18a9436eee70a.zip | |
(Loading): Include new node "Load Suffixes" in menu.
(How Programs Do Loading): Discuss the effects of Auto Compression
mode on `load'.
(Load Suffixes): New node.
(Library Search): Delete description of `load-suffixes': it was
moved to "Load Suffixes".
(Autoload, Named Features): Mention `load-suffixes'.
| -rw-r--r-- | lispref/loading.texi | 96 |
1 files changed, 76 insertions, 20 deletions
diff --git a/lispref/loading.texi b/lispref/loading.texi index b78fb92ad82..e12d44c71de 100644 --- a/lispref/loading.texi +++ b/lispref/loading.texi | |||
| @@ -36,6 +36,7 @@ containing Lisp code. | |||
| 36 | 36 | ||
| 37 | @menu | 37 | @menu |
| 38 | * How Programs Do Loading:: The @code{load} function and others. | 38 | * How Programs Do Loading:: The @code{load} function and others. |
| 39 | * Load Suffixes:: Details about the suffixes that @code{load} tries. | ||
| 39 | * Library Search:: Finding a library to load. | 40 | * Library Search:: Finding a library to load. |
| 40 | * Loading Non-ASCII:: Non-@acronym{ASCII} characters in Emacs Lisp files. | 41 | * Loading Non-ASCII:: Non-@acronym{ASCII} characters in Emacs Lisp files. |
| 41 | * Autoload:: Setting up a function to autoload. | 42 | * Autoload:: Setting up a function to autoload. |
| @@ -72,17 +73,27 @@ exists. (The @code{load} function is not clever about looking at | |||
| 72 | @var{filename}. In the perverse case of a file named @file{foo.el.el}, | 73 | @var{filename}. In the perverse case of a file named @file{foo.el.el}, |
| 73 | evaluation of @code{(load "foo.el")} will indeed find it.) | 74 | evaluation of @code{(load "foo.el")} will indeed find it.) |
| 74 | 75 | ||
| 75 | If the optional argument @var{nosuffix} is non-@code{nil}, then the | 76 | If Auto Compression mode is enabled, as it is by default, then |
| 76 | suffixes @samp{.elc} and @samp{.el} are not tried. In this case, you | 77 | if @code{load} can not find a file, it searches for a compressed |
| 77 | must specify the precise file name you want. By specifying the precise | 78 | version of the file before trying other file names. It decompresses |
| 78 | file name and using @code{t} for @var{nosuffix}, you can prevent | 79 | and loads it if it exists. It looks for compressed versions by |
| 79 | perverse file names such as @file{foo.el.el} from being tried. | 80 | appending the suffixes in @code{jka-compr-load-suffixes} to the file |
| 81 | name. The value of this variable must be a list of strings. Its | ||
| 82 | standard value is @code{(".gz")}. | ||
| 83 | |||
| 84 | If the optional argument @var{nosuffix} is non-@code{nil}, then | ||
| 85 | @code{load} does not try the suffixes @samp{.elc} and @samp{.el}. In | ||
| 86 | this case, you must specify the precise file name you want, except | ||
| 87 | that, if Auto Compression mode is enabled, @code{load} will still use | ||
| 88 | @code{jka-compr-load-suffixes} to find compressed versions. By | ||
| 89 | specifying the precise file name and using @code{t} for | ||
| 90 | @var{nosuffix}, you can prevent perverse file names such as | ||
| 91 | @file{foo.el.el} from being tried. | ||
| 80 | 92 | ||
| 81 | If the optional argument @var{must-suffix} is non-@code{nil}, then | 93 | If the optional argument @var{must-suffix} is non-@code{nil}, then |
| 82 | @code{load} insists that the file name used must end in either | 94 | @code{load} insists that the file name used must end in either |
| 83 | @samp{.el} or @samp{.elc}, unless it contains an explicit directory | 95 | @samp{.el} or @samp{.elc} (possibly extended with a compression |
| 84 | name. If @var{filename} does not contain an explicit directory name, | 96 | suffix), unless it contains an explicit directory name. |
| 85 | and does not end in a suffix, then @code{load} insists on adding one. | ||
| 86 | 97 | ||
| 87 | If @var{filename} is a relative file name, such as @file{foo} or | 98 | If @var{filename} is a relative file name, such as @file{foo} or |
| 88 | @file{baz/foo.bar}, @code{load} searches for the file using the variable | 99 | @file{baz/foo.bar}, @code{load} searches for the file using the variable |
| @@ -127,8 +138,10 @@ See below. | |||
| 127 | @deffn Command load-file filename | 138 | @deffn Command load-file filename |
| 128 | This command loads the file @var{filename}. If @var{filename} is a | 139 | This command loads the file @var{filename}. If @var{filename} is a |
| 129 | relative file name, then the current default directory is assumed. | 140 | relative file name, then the current default directory is assumed. |
| 130 | @code{load-path} is not used, and suffixes are not appended. Use this | 141 | This command does not use @code{load-path}, and does not append |
| 131 | command if you wish to specify precisely the file name to load. | 142 | suffixes. However, it does look for compressed versions (if Auto |
| 143 | Compression Mode is enabled). Use this command if you wish to specify | ||
| 144 | precisely the file name to load. | ||
| 132 | @end deffn | 145 | @end deffn |
| 133 | 146 | ||
| 134 | @deffn Command load-library library | 147 | @deffn Command load-library library |
| @@ -158,6 +171,53 @@ feature: to pass the function as the @var{read-function} argument to | |||
| 158 | For information about how @code{load} is used in building Emacs, see | 171 | For information about how @code{load} is used in building Emacs, see |
| 159 | @ref{Building Emacs}. | 172 | @ref{Building Emacs}. |
| 160 | 173 | ||
| 174 | @node Load Suffixes | ||
| 175 | @section Load Suffixes | ||
| 176 | We now describe some technical details about the exact suffixes that | ||
| 177 | @code{load} tries. | ||
| 178 | |||
| 179 | @defvar load-suffixes | ||
| 180 | This is a list of suffixes indicating (compiled or source) Emacs Lisp | ||
| 181 | files. It should not include the empty string. @code{load} uses | ||
| 182 | these suffixes in order when it appends Lisp suffixes to the specified | ||
| 183 | file name. The standard value is @code{(".elc" "el")} which produces | ||
| 184 | the behavior described in the previous section. | ||
| 185 | @end defvar | ||
| 186 | |||
| 187 | @defvar load-file-rep-suffixes | ||
| 188 | This is a list of suffixes that indicate representations of the same | ||
| 189 | file. This list should normally start with the empty string. | ||
| 190 | When @code{load} searches for a file it appends the suffixes in this | ||
| 191 | list, in order, to the file name, before searching for another file. | ||
| 192 | |||
| 193 | Enabling Auto Compression mode appends the suffixes in | ||
| 194 | @code{jka-compr-load-suffixes} to this list and disabling Auto | ||
| 195 | Compression mode removes them again. The standard value of | ||
| 196 | @code{load-file-rep-suffixes} if Auto Compression mode is disabled is | ||
| 197 | @code{("")}. Given that the standard value of | ||
| 198 | @code{jka-compr-load-suffixes} is @code{(".gz")}, the standard value | ||
| 199 | of @code{load-file-rep-suffixes} if Auto Compression mode is enabled | ||
| 200 | is @code{("" ".gz")}. | ||
| 201 | @end defvar | ||
| 202 | |||
| 203 | @defun get-load-suffixes | ||
| 204 | This function returns the list of all suffixes that @code{load} should | ||
| 205 | try, in order, when its @var{must-suffix} argument is non-@code{nil}. | ||
| 206 | This takes both @code{load-suffixes} and @code{load-file-rep-suffixes} | ||
| 207 | into account. If @code{load-suffixes}, @code{jka-compr-load-suffixes} | ||
| 208 | and @code{load-file-rep-suffixes} all have their standard values, this | ||
| 209 | function returns @code{(".elc" "elc.gz" ".el" ".el.gz")} if Auto | ||
| 210 | Compression mode is enabled and @code{(".elc" ".el")} if Auto | ||
| 211 | Compression mode is disabled. | ||
| 212 | @end defun | ||
| 213 | |||
| 214 | To summarize, if both its @var{nosuffix} and @var{must-suffix} | ||
| 215 | arguments are @code{nil}, @code{load} first tries the suffixes in the | ||
| 216 | return value of @code{get-load-suffixes} and then those in | ||
| 217 | @code{load-file-rep-suffixes}. If @var{nosuffix} is non-@code{nil}, | ||
| 218 | it only tries the latter and is @var{must-suffix} is non-@code{nil}, | ||
| 219 | only the former. | ||
| 220 | |||
| 161 | @node Library Search | 221 | @node Library Search |
| 162 | @section Library Search | 222 | @section Library Search |
| 163 | 223 | ||
| @@ -288,13 +348,6 @@ interactively, the argument @var{interactive-call} is @code{t}, and this | |||
| 288 | tells @code{locate-library} to display the file name in the echo area. | 348 | tells @code{locate-library} to display the file name in the echo area. |
| 289 | @end deffn | 349 | @end deffn |
| 290 | 350 | ||
| 291 | @defvar load-suffixes | ||
| 292 | This variable is a list of suffixes (strings) that @code{load} should | ||
| 293 | try adding to the specified file name. The default value is | ||
| 294 | @code{(".elc" ".elc.gz" ".el" ".el.gz" ".gz")}. There is no need to | ||
| 295 | include the null suffix. | ||
| 296 | @end defvar | ||
| 297 | |||
| 298 | @node Loading Non-ASCII | 351 | @node Loading Non-ASCII |
| 299 | @section Loading Non-@acronym{ASCII} Characters | 352 | @section Loading Non-@acronym{ASCII} Characters |
| 300 | 353 | ||
| @@ -362,7 +415,8 @@ specifies the file to load to get the real definition of @var{function}. | |||
| 362 | If @var{filename} does not contain either a directory name, or the | 415 | If @var{filename} does not contain either a directory name, or the |
| 363 | suffix @code{.el} or @code{.elc}, then @code{autoload} insists on adding | 416 | suffix @code{.el} or @code{.elc}, then @code{autoload} insists on adding |
| 364 | one of these suffixes, and it will not load from a file whose name is | 417 | one of these suffixes, and it will not load from a file whose name is |
| 365 | just @var{filename} with no added suffix. | 418 | just @var{filename} with no added suffix. (The variable |
| 419 | @code{load-suffixes} specifies the exact required suffixes.) | ||
| 366 | 420 | ||
| 367 | The argument @var{docstring} is the documentation string for the | 421 | The argument @var{docstring} is the documentation string for the |
| 368 | function. Specifying the documentation string in the call to | 422 | function. Specifying the documentation string in the call to |
| @@ -699,8 +753,10 @@ If the feature is not present, then @code{require} loads @var{filename} | |||
| 699 | with @code{load}. If @var{filename} is not supplied, then the name of | 753 | with @code{load}. If @var{filename} is not supplied, then the name of |
| 700 | the symbol @var{feature} is used as the base file name to load. | 754 | the symbol @var{feature} is used as the base file name to load. |
| 701 | However, in this case, @code{require} insists on finding @var{feature} | 755 | However, in this case, @code{require} insists on finding @var{feature} |
| 702 | with an added suffix; a file whose name is just @var{feature} won't be | 756 | with an added @samp{el} or @samp{.elc} suffix (possibly extended with |
| 703 | used. | 757 | a compression suffix); a file whose name is just @var{feature} won't |
| 758 | be used. (The variable @code{load-suffixes} specifies the exact | ||
| 759 | required Lisp suffixes.) | ||
| 704 | 760 | ||
| 705 | If @var{noerror} is non-@code{nil}, that suppresses errors from actual | 761 | If @var{noerror} is non-@code{nil}, that suppresses errors from actual |
| 706 | loading of the file. In that case, @code{require} returns @code{nil} | 762 | loading of the file. In that case, @code{require} returns @code{nil} |