aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-12-05 13:51:09 +0200
committerEli Zaretskii2015-12-05 13:51:09 +0200
commit52781882859ded459b97bcc83c8548d8cb67a30f (patch)
treed02f7cbf909d9cfcea94a8a423a1eede75d588db
parent8ebd0a08f3392e687c12a4491462c1d8caf16e76 (diff)
downloademacs-52781882859ded459b97bcc83c8548d8cb67a30f.tar.gz
emacs-52781882859ded459b97bcc83c8548d8cb67a30f.zip
Initial documentation of dynamic modules
* doc/lispref/loading.texi (Dynamic Modules): New section with initial documentation for dynamic modules. * doc/lispref/elisp.texi (Top): Add "Dynamic Modules" to the detailed menu * etc/NEWS: Fix typos in dynamic modules' entry.
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/loading.texi61
-rw-r--r--etc/NEWS2
3 files changed, 62 insertions, 2 deletions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 2d3548f65ba..dedb0a5e40e 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -602,6 +602,7 @@ Loading
602* Unloading:: How to unload a library that was loaded. 602* Unloading:: How to unload a library that was loaded.
603* Hooks for Loading:: Providing code to be run when 603* Hooks for Loading:: Providing code to be run when
604 particular libraries are loaded. 604 particular libraries are loaded.
605* Dynamic Modules:: Modules provide additional Lisp primitives.
605 606
606Byte Compilation 607Byte Compilation
607 608
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
29way.) Most often, the forms are function definitions and variable 29way.) Most often, the forms are function definitions and variable
30definitions. 30definitions.
31 31
32For on-demand loading of external libraries, @pxref{Dynamic Libraries}. 32 Emacs can also load compiled dynamic modules: shared libraries that
33provide additional functionality for use in Emacs Lisp programs, just
34like a package written in Emacs Lisp would. When a dynamic module is
35loaded, Emacs calls a specially-named initialization function which
36the module needs to implement, and which exposes the additional
37functions and variables to Emacs Lisp programs.
38
39For on-demand loading of external libraries which are known in advance
40to 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
1076it immediately---there is no need to wait until the library is loaded. 1085it immediately---there is no need to wait until the library is loaded.
1077If you need to call functions defined by that library, you should load 1086If you need to call functions defined by that library, you should load
1078the library, preferably with @code{require} (@pxref{Named Features}). 1087the 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
1096additional functionality for use in Emacs Lisp programs, just like a
1097package written in Emacs Lisp would.
1098
1099 Functions that load Emacs Lisp packages can also load dynamic
1100modules. They recognize dynamic modules by looking at their file-name
1101extension, a.k.a.@: ``suffix''. This suffix is platform-dependent.
1102
1103@defvar module-file-suffix
1104This variable holds the system-dependent value of the file-name
1105extension of the module files. Its value is @file{.so} on Posix hosts
1106and @file{.dll} on MS-Windows.
1107@end defvar
1108
1109@findex emacs_module_init
1110@vindex plugin_is_GPL_compatible
1111Every 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
1114export a symbol named @code{plugin_is_GPL_compatible} to indicate that
1115its code is released under the GPL or compatible license; Emacs will
1116refuse to load modules that don't export such a symbol.
1117
1118If a module needs to call Emacs functions, it should do so through the
1119API defined and documented in the header file @file{emacs-module.h}
1120that is part of the Emacs distribution.
1121
1122@cindex user-ptr object
1123Modules can create @code{user-ptr} Lisp objects that embed pointers to
1124C struct's defined by the module. This is useful for keeping around
1125complex data structures created by a module, to be passed back to the
1126module's functions. User-ptr objects can also have associated
1127@dfn{finalizers} -- functions to be run when the object is GC'ed; this
1128is useful for freeing any resources allocated for the underlying data
1129structure, such as memory, open file descriptors, etc.
1130
1131@defun user-ptrp object
1132This function returns @code{t} if its argument is a @code{user-ptr}
1133object.
1134@end defun
1135
1136Loadable modules in Emacs are enabled by using the
1137@kbd{--with-modules} option at configure time.
diff --git a/etc/NEWS b/etc/NEWS
index ca61fc00ac2..ef2dc1220cc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -210,7 +210,7 @@ module's functions. User-ptr objects can also have associated
210"finalizers" -- functions to be run when the object is GC'ed; this is 210"finalizers" -- functions to be run when the object is GC'ed; this is
211useful for freeing any resources allocated for the underlying data 211useful for freeing any resources allocated for the underlying data
212structure, such as memory, open file descriptors, etc. A new 212structure, such as memory, open file descriptors, etc. A new
213predicate `user-ptr-p' returns non-nil if its argument is a `usr-ptr' 213predicate `user-ptrp' returns non-nil if its argument is a `user-ptr'
214object. 214object.
215 215
216Loadable modules in Emacs are an experimental feature, and subject to 216Loadable modules in Emacs are an experimental feature, and subject to