diff options
| author | K. Handa | 2016-01-03 17:53:43 +0900 |
|---|---|---|
| committer | K. Handa | 2016-01-03 17:53:43 +0900 |
| commit | fb6d826c69939c2d016c1b824d4e9bcb53d9e643 (patch) | |
| tree | b9ce862d6cbe25e740203421984df21e4cbadbf4 /doc/lispref/loading.texi | |
| parent | 536f48e9a2251b9e654ea974bd90ff2f40218753 (diff) | |
| parent | 91917dd58ec5278e555b9c693a830749083e8f89 (diff) | |
| download | emacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.tar.gz emacs-fb6d826c69939c2d016c1b824d4e9bcb53d9e643.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'doc/lispref/loading.texi')
| -rw-r--r-- | doc/lispref/loading.texi | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 82de765876e..e01f3161731 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi | |||
| @@ -29,7 +29,15 @@ into a buffer and evaluated there. (Indeed, most code is tested this | |||
| 29 | way.) Most often, the forms are function definitions and variable | 29 | way.) Most often, the forms are function definitions and variable |
| 30 | definitions. | 30 | definitions. |
| 31 | 31 | ||
| 32 | For on-demand loading of external libraries, @pxref{Dynamic Libraries}. | 32 | Emacs can also load compiled dynamic modules: shared libraries that |
| 33 | provide additional functionality for use in Emacs Lisp programs, just | ||
| 34 | like a package written in Emacs Lisp would. When a dynamic module is | ||
| 35 | loaded, Emacs calls a specially-named initialization function which | ||
| 36 | the module needs to implement, and which exposes the additional | ||
| 37 | functions and variables to Emacs Lisp programs. | ||
| 38 | |||
| 39 | For on-demand loading of external libraries which are known in advance | ||
| 40 | to be required by certain Emacs primitives, @pxref{Dynamic Libraries}. | ||
| 33 | 41 | ||
| 34 | @menu | 42 | @menu |
| 35 | * How Programs Do Loading:: The @code{load} function and others. | 43 | * How Programs Do Loading:: The @code{load} function and others. |
| @@ -43,6 +51,7 @@ For on-demand loading of external libraries, @pxref{Dynamic Libraries}. | |||
| 43 | * Unloading:: How to unload a library that was loaded. | 51 | * Unloading:: How to unload a library that was loaded. |
| 44 | * Hooks for Loading:: Providing code to be run when | 52 | * Hooks for Loading:: Providing code to be run when |
| 45 | particular libraries are loaded. | 53 | particular libraries are loaded. |
| 54 | * Dynamic Modules:: Modules provide additional Lisp primitives. | ||
| 46 | @end menu | 55 | @end menu |
| 47 | 56 | ||
| 48 | @node How Programs Do Loading | 57 | @node How Programs Do Loading |
| @@ -1076,3 +1085,53 @@ defined in another library (those meant for outside use), you can do | |||
| 1076 | it immediately---there is no need to wait until the library is loaded. | 1085 | it immediately---there is no need to wait until the library is loaded. |
| 1077 | If you need to call functions defined by that library, you should load | 1086 | If you need to call functions defined by that library, you should load |
| 1078 | the library, preferably with @code{require} (@pxref{Named Features}). | 1087 | the library, preferably with @code{require} (@pxref{Named Features}). |
| 1088 | |||
| 1089 | @node Dynamic Modules | ||
| 1090 | @section Emacs Dynamic Modules | ||
| 1091 | @cindex dynamic modules | ||
| 1092 | |||
| 1093 | @c FIXME: This is intentionally incomplete, as the module integration | ||
| 1094 | @c is not yet finished. To be refined later. | ||
| 1095 | A @dfn{dynamic Emacs module} is a shared library that provides | ||
| 1096 | additional functionality for use in Emacs Lisp programs, just like a | ||
| 1097 | package written in Emacs Lisp would. | ||
| 1098 | |||
| 1099 | Functions that load Emacs Lisp packages can also load dynamic | ||
| 1100 | modules. They recognize dynamic modules by looking at their file-name | ||
| 1101 | extension, a.k.a.@: ``suffix''. This suffix is platform-dependent. | ||
| 1102 | |||
| 1103 | @defvar module-file-suffix | ||
| 1104 | This variable holds the system-dependent value of the file-name | ||
| 1105 | extension of the module files. Its value is @file{.so} on Posix hosts | ||
| 1106 | and @file{.dll} on MS-Windows. | ||
| 1107 | @end defvar | ||
| 1108 | |||
| 1109 | @findex emacs_module_init | ||
| 1110 | @vindex plugin_is_GPL_compatible | ||
| 1111 | Every dynamic module should export a C-callable function named | ||
| 1112 | @code{emacs_module_init}, which Emacs will call as part of the call to | ||
| 1113 | @code{load} or @code{require} which loads the module. It should also | ||
| 1114 | export a symbol named @code{plugin_is_GPL_compatible} to indicate that | ||
| 1115 | its code is released under the GPL or compatible license; Emacs will | ||
| 1116 | refuse to load modules that don't export such a symbol. | ||
| 1117 | |||
| 1118 | If a module needs to call Emacs functions, it should do so through the | ||
| 1119 | API defined and documented in the header file @file{emacs-module.h} | ||
| 1120 | that is part of the Emacs distribution. | ||
| 1121 | |||
| 1122 | @cindex user-ptr object | ||
| 1123 | Modules can create @code{user-ptr} Lisp objects that embed pointers to | ||
| 1124 | C struct's defined by the module. This is useful for keeping around | ||
| 1125 | complex data structures created by a module, to be passed back to the | ||
| 1126 | module's functions. User-ptr objects can also have associated | ||
| 1127 | @dfn{finalizers} -- functions to be run when the object is GC'ed; this | ||
| 1128 | is useful for freeing any resources allocated for the underlying data | ||
| 1129 | structure, such as memory, open file descriptors, etc. | ||
| 1130 | |||
| 1131 | @defun user-ptrp object | ||
| 1132 | This function returns @code{t} if its argument is a @code{user-ptr} | ||
| 1133 | object. | ||
| 1134 | @end defun | ||
| 1135 | |||
| 1136 | Loadable modules in Emacs are enabled by using the | ||
| 1137 | @kbd{--with-modules} option at configure time. | ||