diff options
| author | Eli Zaretskii | 2023-02-26 19:51:59 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2023-02-26 19:51:59 +0200 |
| commit | dde9d149af3281f7ed3d3b9d8a4fd7caa238d0f9 (patch) | |
| tree | 4a309b3d2b0b83db642880a8bfb76e8100cea5ff | |
| parent | 7c552be89da02270993f0866035abedb8c44f890 (diff) | |
| download | emacs-dde9d149af3281f7ed3d3b9d8a4fd7caa238d0f9.tar.gz emacs-dde9d149af3281f7ed3d3b9d8a4fd7caa238d0f9.zip | |
; Improve documentation of loading *.eln files
* doc/lispref/loading.texi (How Programs Do Loading):
* doc/emacs/building.texi (Lisp Libraries): Some additional
details about what happens with natively-compiled files.
| -rw-r--r-- | doc/emacs/building.texi | 37 | ||||
| -rw-r--r-- | doc/lispref/loading.texi | 25 |
2 files changed, 39 insertions, 23 deletions
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 3f6a418de1a..f82b605598e 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi | |||
| @@ -1556,18 +1556,26 @@ command prompts for a @dfn{library name} rather than a file name; it | |||
| 1556 | searches through each directory in the Emacs Lisp load path, trying to | 1556 | searches through each directory in the Emacs Lisp load path, trying to |
| 1557 | find a file matching that library name. If the library name is | 1557 | find a file matching that library name. If the library name is |
| 1558 | @samp{@var{foo}}, it tries looking for files named | 1558 | @samp{@var{foo}}, it tries looking for files named |
| 1559 | @file{@var{foo}.elc}, @file{@var{foo}.el}, and @file{@var{foo}}. The | 1559 | @file{@var{foo}.elc}, @file{@var{foo}.el}, and @file{@var{foo}}. (If |
| 1560 | default behavior is to load the first file found. This command | 1560 | Emacs was built with native compilation enabled, @code{load-library} |
| 1561 | prefers @file{.elc} files over @file{.el} files because compiled files | 1561 | looks for a @samp{.eln} file that corresponds to @file{@var{foo}.el} |
| 1562 | load and run faster. If it finds that @file{@var{lib}.el} is newer | 1562 | and loads it instead of @file{@var{foo}.elc}.) The default behavior |
| 1563 | than @file{@var{lib}.elc}, it issues a warning, in case someone made | 1563 | is to load the first file found. This command prefers @file{.eln} |
| 1564 | changes to the @file{.el} file and forgot to recompile it, but loads | 1564 | files over @file{.elc} files, and prefers @file{.elc} files over |
| 1565 | the @file{.elc} file anyway. (Due to this behavior, you can save | 1565 | @file{.el} files, because compiled files load and run faster. If it |
| 1566 | unfinished edits to Emacs Lisp source files, and not recompile until | 1566 | finds that @file{@var{lib}.el} is newer than @file{@var{lib}.elc}, it |
| 1567 | your changes are ready for use.) If you set the option | 1567 | issues a warning, in case someone made changes to the @file{.el} file |
| 1568 | @code{load-prefer-newer} to a non-@code{nil} value, however, then | 1568 | and forgot to recompile it, but loads the @file{.elc} file anyway. |
| 1569 | rather than the procedure described above, Emacs loads whichever | 1569 | (Due to this behavior, you can save unfinished edits to Emacs Lisp |
| 1570 | version of the file is newest. | 1570 | source files, and not recompile until your changes are ready for use.) |
| 1571 | If you set the option @code{load-prefer-newer} to a non-@code{nil} | ||
| 1572 | value, however, then rather than the procedure described above, Emacs | ||
| 1573 | loads whichever version of the file is newest. If Emacs was built | ||
| 1574 | with native compilation, and it cannot find the @samp{.eln} file | ||
| 1575 | corresponding to @file{@var{lib}.el}, it will load a | ||
| 1576 | @file{@var{lib}.elc} and start native compilation of | ||
| 1577 | @file{@var{lib}.el} in the background, then load the @samp{.eln} file | ||
| 1578 | when it finishes compilation. | ||
| 1571 | 1579 | ||
| 1572 | Emacs Lisp programs usually load Emacs Lisp files using the | 1580 | Emacs Lisp programs usually load Emacs Lisp files using the |
| 1573 | @code{load} function. This is similar to @code{load-library}, but is | 1581 | @code{load} function. This is similar to @code{load-library}, but is |
| @@ -1604,6 +1612,11 @@ It is customary to put locally installed libraries in the | |||
| 1604 | @code{load-path}, or in some subdirectory of @file{site-lisp}. This | 1612 | @code{load-path}, or in some subdirectory of @file{site-lisp}. This |
| 1605 | way, you don't need to modify the default value of @code{load-path}. | 1613 | way, you don't need to modify the default value of @code{load-path}. |
| 1606 | 1614 | ||
| 1615 | @vindex native-comp-eln-load-path | ||
| 1616 | Similarly to @code{load-path}, the list of directories where Emacs | ||
| 1617 | looks for @file{*.eln} files with natively-compiled Lisp code is | ||
| 1618 | specified by the variable @code{native-comp-eln-load-path}. | ||
| 1619 | |||
| 1607 | @cindex autoload | 1620 | @cindex autoload |
| 1608 | Some commands are @dfn{autoloaded}; when you run them, Emacs | 1621 | Some commands are @dfn{autoloaded}; when you run them, Emacs |
| 1609 | automatically loads the associated library first. For instance, the | 1622 | automatically loads the associated library first. For instance, the |
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index dbbdc767738..5c84ba4b1eb 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi | |||
| @@ -75,17 +75,20 @@ file exists, and Emacs was compiled with native-compilation support | |||
| 75 | (@pxref{Native Compilation}), @code{load} attempts to find a | 75 | (@pxref{Native Compilation}), @code{load} attempts to find a |
| 76 | corresponding @samp{.eln} file, and if found, loads it instead of | 76 | corresponding @samp{.eln} file, and if found, loads it instead of |
| 77 | @file{@var{filename}.elc}. Otherwise, it loads | 77 | @file{@var{filename}.elc}. Otherwise, it loads |
| 78 | @file{@var{filename}.elc}. If there is no file by that name, then | 78 | @file{@var{filename}.elc} (and starts a background native compilation |
| 79 | @code{load} looks for a file named @file{@var{filename}.el}. If that | 79 | to produce the missing @samp{.eln} file, followed by loading that |
| 80 | file exists, it is loaded. If Emacs was compiled with support for | 80 | file). If there is no @file{@var{filename}.elc}, then @code{load} |
| 81 | dynamic modules (@pxref{Dynamic Modules}), @code{load} next looks for | 81 | looks for a file named @file{@var{filename}.el}. If that file exists, |
| 82 | a file named @file{@var{filename}.@var{ext}}, where @var{ext} is a | 82 | it is loaded. If Emacs was compiled with support for dynamic modules |
| 83 | system-dependent file-name extension of shared libraries. Finally, if | 83 | (@pxref{Dynamic Modules}), @code{load} next looks for a file named |
| 84 | neither of those names is found, @code{load} looks for a file named | 84 | @file{@var{filename}.@var{ext}}, where @var{ext} is a system-dependent |
| 85 | @var{filename} with nothing appended, and loads it if it exists. (The | 85 | file-name extension of shared libraries (@samp{.so} on GNU and Unix |
| 86 | @code{load} function is not clever about looking at @var{filename}. | 86 | systems). Finally, if neither of those names is found, @code{load} |
| 87 | In the perverse case of a file named @file{foo.el.el}, evaluation of | 87 | looks for a file named @var{filename} with nothing appended, and loads |
| 88 | @code{(load "foo.el")} will indeed find it.) | 88 | it if it exists. (The @code{load} function is not clever about |
| 89 | looking at @var{filename}. In the perverse case of a file named | ||
| 90 | @file{foo.el.el}, evaluation of @code{(load "foo.el")} will indeed | ||
| 91 | find it.) | ||
| 89 | 92 | ||
| 90 | If Auto Compression mode is enabled, as it is by default, then if | 93 | If Auto Compression mode is enabled, as it is by default, then if |
| 91 | @code{load} can not find a file, it searches for a compressed version | 94 | @code{load} can not find a file, it searches for a compressed version |